-
This is a question that belongs to issue #75 and PR #190 . I have seen that @jrmobley has contributed a lot of code in this area. I am trying to get my first 2D-export running. I could not find any working example and the new exporters are not yet included in the online documentation. I hope you can give me some start-up aid. This is a very simple example, based on the example 2 (plate with a hole). I take the section at z=0 and would expect to see inside the svg-file a rectangle and a circle. And I have tried to use defaults where ever possible. My m2d.edges() should go the default-layer which is named "". But the code does not run. Let me know what is wrong or missing.
|
Beta Was this translation helpful? Give feedback.
Replies: 14 comments 48 replies
-
I think you've summed up the situation well. Getting the exports to work (and documented) is one of the last things I'd like to finish before creating the first release. You're example seems like a good place to start; let me see if I can get it to work. Cheers, |
Beta Was this translation helpful? Give feedback.
-
It looks like commit 12504c6 broke the connection between the @gumyr was cleaning up some pylint issues, so we need to figure out how to make pylint happy but still have the correct values for the enumeration. Beyond that, call |
Beta Was this translation helpful? Give feedback.
-
I can't remember why I introduced the change that broke it but I've restored the LineType ENUM and the above example runs now with the following change: # svg.add_shape(m2d.edges(), "")
for edge in m2d.edges():
svg.add_shape(edge, "") Getting unittests for this new exporter code needs to be complete before the release can be done. |
Beta Was this translation helpful? Give feedback.
-
I just want to give you more practical example. It is a real part from one of my models. Here the model is built bottom-up. It starts wirth line-segments. The line-segments are put into closed polylines. Each polyline represents a wire. And with the polylines some faces are created, and with them the final 3D-model is extruded. I have given this example, because making a
|
Beta Was this translation helpful? Give feedback.
-
Example-1:
|
Beta Was this translation helpful? Give feedback.
-
Example-2: Any ideas why we have got only 2 wires instead of 3? The 3 polylines, verified with
|
Beta Was this translation helpful? Give feedback.
-
Progress Report: |
Beta Was this translation helpful? Give feedback.
-
Let us go back to example-1: closed-wire-simple closed-wire-complex Be aware that the wire-direction is only needed inside the call of To make this simpler, imagine that a wire looks like a pearl necklace where the pearls are labelled with single letters. The necklace might have an arbitrary shape, but the whole thing lives in the XY-plane. Your view-point is the top of the Z-axis and then you look downwards. Then you stretch the necklace to a circle and then you can immediately recognize the direction (CC or CCW). This is sketched below: The next thing is how to convert a closed wire to a svg-path-list? This is sketched here: alternatives for open wire We can apply occam's razor: We should not the make the solution more complicated than necessary. The svg-file can be made router-compliant with only little code modifications. I hope @jrmobley can confirm this. I personally do not see any need to introduce a direction-property for a wire. I tend to select the simplest solution, and this solution makes already a great contribution. One thing is left over: |
Beta Was this translation helpful? Give feedback.
-
This whole discussion is very interesting but not what I originally expected. Normally CNC Routers would operate from g-code which has been developed over the last 60 or so years to exactly this purpose. Running a CNC Router off standard SVG is interesting but I wonder if it's a sufficiently capable solution. Within build123d and OpenCascade Edge and Wire direction is defined by the topology of the objects, not by any external constraints like spindle rotations. What is the line between drawing and CAM? |
Beta Was this translation helpful? Give feedback.
-
I don't understand what this statement means. Are you referring to the order within ShapeLists as these are generally undefined unless sorted in some way. |
Beta Was this translation helpful? Give feedback.
-
Congratulations, great job. The code is already integrated and available to me. It works as expected, the cut-type coloring works perfectly and also the reversal of the wire direction. Again, thank you very much. |
Beta Was this translation helpful? Give feedback.
-
Would it be possible to extend e.g. line_type and fill_type optionally with RGBA ? I am really impressed with how the new ExportSVG works by the way! |
Beta Was this translation helpful? Give feedback.
-
Sorry, been away from this for a while. Good to hear that you are digging the exporter. Yes, I can add an RGBA option to the SVG colors. |
Beta Was this translation helpful? Give feedback.
-
@jrmobley Glad to have you back. To add the alpha to colors is a good idea. I would prefer the format rgb(255,255,255,0.5). Unfortunately my router accepts only colors without alpha. Is the old format (rgb(255,255,255) without alpha) still provided? Or is there another way how this can be customized? |
Beta Was this translation helpful? Give feedback.
What you're looking for here is a Compound/assembly. This is a collection of objects that aren't fused together - like this: