sketchucation logo sketchucation
    • Login
    1. Home
    2. utessel
    3. Posts
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    U
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 7
    • Groups 1

    Posts

    Recent Best Controversial
    • Find Intersections

      Hi!

      I'm thinking about a script to generate lots of edges for my gcode exporter:
      I have some ideas how this can be done.

      For one idea I want an efficient way to find the positions where faces intersect with my lines: One of the problems: The faces might be in groups or components.

      So one idea is to use the "intersect face with model" thing: With that I would get a polygon on a face, then I could intersect that with my line to and find the intersection points there.
      First problem is that I did't found how to create these polygons with the API.
      The second problem is the question: Is this efficient? It might, because I plan to "shoot" a lot of these edges through my model and I could use the polygon on that face for several edges. But I don't need all the points on that polygon that might be created by the model.

      So any tipps how to do this?

      Thanks!

      Uli

      posted in Plugins
      U
      utessel
    • RE: [Plugin] Another g-code export

      For the "how to find the way through a labyrinth of edges":
      The attribute idea might work, but a bit better (also for the example) is to use two distinct attributes: Entry and Exit.

      Any other idea how to tell the script which edge to use next at a "multi-edge" vertex?

      posted in Plugins
      U
      utessel
    • RE: [Plugin] Another g-code export

      @thomthom said:

      Suggestion has been made that the project could be extended to GCode eventually to provide a complete package for fabbing and such. https://github.com/SketchUp/sketchup-stl/issues/40

      Hmm, in fact my export code is one step towards that already.
      I can imagine it can also be useful for 3D Printer. I still don't have one, but the time will come ๐Ÿ˜‰ Adding a printing head to my milling machine?
      What is missing to use the generated files on Machines like Mendel? Or is this completely nonsense?

      Anyway:
      What really is missing are scripts that generate these paths now:
      For example, generate paths "on" faces, typically all in the same Z-Position.
      This is not too complex, a bit more is to make them loop-free and to connect one layer with the next.

      But for this I had an idea, as I had the problem already:
      Imagine you have a line from top down to a circle, and then further down.
      Sketchup will connect the circle and the line. Now what path do you want?
      At that vertex of the connection I have four edges. Continue straight is not useful here as you will miss the circle.
      Now my idea: An attribute that tells (stores) the expected direction!
      If two edges are marked with the same "walk this way" value, then the path is clear.
      For my example: The edge from top to circle gets an "A", and the right edge here (of the circle) also gets an "A". The left edge (other side, still on the circle) gets a "B", and the line going down also get the "B". Now the path is well defined and doesn't have problems with interesections. Ok, to select the two edges on a circle is tricky, but it was just an example.

      If now someone could tell me how to select and edge within a group (within a group...), then I (aehm, the script of course) could show directly where a problem with the current date exists.
      When the path is generated by a script it is obviously easy to set attributes like this.

      Ah, and another thing I'm thinking about:
      Imagine you have a script that fills a face with lines: But where to start? Where to continue from one layer to the next? One idea is: You draw a line to start the path and where you want to go down. Then you select the face(s!) together with that line, right click and say "fill..." (or so). Now that script has a starting point, and can ask some questions (only material XY, distance from line to line, etc.) and then it fills the face with lines.
      This doesn't work well with groups (and the lines should be in their own group), so the idea is not finished yet.

      Maybe someone has different ideas how to solve these problems (Continue-here on crosses, filling faces with lines)?

      Thanks,

      Uli

      posted in Plugins
      U
      utessel
    • RE: [Plugin] Another g-code export

      Cool, thanks...

      Learned a lot:
      .freeze has something to do make a string really constant I expect. Will read ruby docu for that.
      The filename you give to the extension is the the one that is loaded (or not, when disabled): To use the subfolder is required so that the script is not loaded automatically! This was one thing I didn't undertand how this should work. Might have been to obvious? In the end, very simple but effective solution ๐Ÿ˜‰

      In combination with .rbz files the typical user doesn't need to know anything about scripts anymore: Just select the downloaded file and install, and disable if you don't want it. Nice improvement! (Ok, no real uninstall yet...)
      Of course I will do this to my scripts!

      posted in Plugins
      U
      utessel
    • RE: [Plugin] Another g-code export

      @thomthom said:

      I have a feeling I might have completely failed that answer...

      Partially ...
      Because you had one answer on your page ๐Ÿ˜‰
      The "Hello World example that โ€œplays niceโ€" is already a good start: I didn't know about modules (in ruby)!
      At least, this is a change that is so easy to follow and improves the scripts already.

      I like the way plugins can installed now and like to have a checkbox to disable them:
      But the script itself has to support this: There is this "SketchupExtension" thing: How would your "hello world" example look with that? Register was easy, but disable did not work. At least not immediately, so I didn't spend time on it.

      posted in Plugins
      U
      utessel
    • RE: [Plugin] Another g-code export

      Hi!

      Thanks for your hints:
      If these are all things that I've made "bad", then I'm happy.

      I'm a software developer, but ruby is not my primary environment (which is C++ in embedded environments): In fact, I just tried to find out how to get the things working. After all, it wasn't that hard, and I really like the object-model that I can access with ruby. And Ruby really is a funny language and simple to use:
      The G-Code Exporter was written while I was waiting for "pycam" working on an exported STL file from Sketchup...

      I hope the gcode-export code is better than the attribute code: At least it is using a class, but you can see my learning curve when you read it from end upwards to the beginning: The first lines (=at the end of the file) were written without knowing how to declare anything, and later I just copied them from one script to the next. They did (and do) their job... The attribute thing was just a quick hack to make it usable.
      It better should use a input box for example.

      The capital letter thing is a thing I didn't know at all. Thanks for that. In the end, I still don't know ruby at all: I had to search google how to write a while loop ๐Ÿ˜‰
      Global variables are bad, you are right. I hope the @xxx variables are members of the class?

      So we come to a question:
      What is the best initialization and "let a instance of class do the work" example that I should follow? For example, this extension thing seems to be the way to go, but it did not work as I expected.

      At least for the G-Code Exporter I expect to continue to work on it the next time a bit more, so all hints are welcome. In fact, I'm not a G-Code expert at all, but I got it that far to get my work done.

      For the question about working on open source projects: If I would have time... But I will have a look at it.

      And yes, I posted it here to get comments: About the code, what it is doing and how it could be improved.

      Thank you for that,

      Uli

      posted in Plugins
      U
      utessel
    • [Plugin] Another g-code export

      Hi!

      Long time without using Sketchup I came back to use it with my milling machine.
      It works well on my linuxcnc installation with Wine. Very cool.

      To make it even more useful (at least for myself), I've written two more (simple?) scripts.

      You can download them (and my older scripts) here:
      http://uli-tessel.de/suruby.htm
      As always, the license is GPL.

      The main work is this one: path2gcode.rb

      How can it be used:
      You design your model as normal. Then you add lines to the 3D Space around your design where the milling cutter should run (The old outliner.rb script might help a bit here)
      Then you place a line upwards to a Z-Position you want to place the milling head before going down. The whole path (or line) should not contain a loop: Exactly one start point and one end point.

      The second script gcodeattrib.rb allows to add attributes to edges and groups: the values of these attributes are written to the g-code file. This allows at least to store a F Command to the file. It is likely you will edit this script to add the commands you need. But this should be easy.

      It would be interesting to read back existing G-Code files and store the paths in the model. At least for very simple files this should be possible: Simple = only using G00 and G01 commands for milling, no loop and variable instructions etc.

      I have not tried it yet, but it should also be possible to use my SVG script, so there is another path from Inkscape to Milling: You design your 2D idea, and then you can give the paths a Z-Value and control and edit the order and direction of the milling path, all within Sketchup: Should give a nice way to engrave 2D Images on a 3D surface.

      Hope this is useful for others, too!

      posted in Plugins
      U
      utessel
    • 1 / 1