Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate projection from export_svg #75

Closed
gumyr opened this issue Dec 6, 2022 · 7 comments
Closed

Separate projection from export_svg #75

gumyr opened this issue Dec 6, 2022 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@gumyr
Copy link
Owner

gumyr commented Dec 6, 2022

When exporting to SVG a projection is done of the Shape to create a set of visible and hidden Edges. These generated Edges are written to the SVG file. As such the projection is a general operation not specific to SVG. In addition, separation would potentially allow more control - when color is added to Shape objects (and potentially stroke width & stroke style to Edge/Wires) these attributes could be used directly when writing to SVG (or DXF?).

export_svg would then expect planar Edges/Wires and be able to translate them to the XY plane for writing.

@gumyr gumyr added the enhancement New feature or request label Dec 6, 2022
@jrmobley
Copy link
Contributor

You can assign this to me.

@jrmobley
Copy link
Contributor

Making progress. Separated the projection into a Drawing class and rebuilt the SVG export to export true circles and Bézier paths. Also has multi-layer support similar to the latest CQ DXF exporter. Plenty of little details still to work out, and then refactoring DXF into the system.

A projected drawing on an enclosure:
dev-drawing

And a planar section of the matching PCB.
dev-section

@Paul8043
Copy link

Paul8043 commented May 4, 2023

@jrmobley
This is a very good decision. The projection should be separated from the exporter. So, projection is an optional step before the exporter has been called. This helps a lot for applications that want to pack a 2D-objects into a SVG-file. My typical workflow is to design a 3D-model and then make a section() on a certain plane and the result should go into a 2D-SVG-file. This is exactly what is needed for my router. The SVG-file will directly drive this router without any cam-application in between. The color-encoding (see cut-type-encoding) determines what the router should perform. My focus here is the 2D-SVG-exporter, it should preserve the shapes, e.g. circles should be encoded as circles, and not as polylines. And it is important that polylines are closed, this will enable some very comfortable functions inside the router (helix-mode). And, also very important, the SVG-exporter must do its job without any internal re-scalings, the measures must be preserved in any case. I would like to discuss some details with you, just to make sure that the 2D-SVG-exporter becomes an interface that is universal enough to accomplish such requirements. Maybe we can make close cooperation. Let me know, if this fits to your plans and activities.

@jrmobley
Copy link
Contributor

jrmobley commented May 5, 2023

@Paul8043
Hello. This work got awkwardly spread between two issues, and I forgot to reference this issue in the PR.

@gumyr merged in that work, and I think he has done some fiddling with it as well, so I'm not sure about the exact status of the code.

In any case, I'm willing to keep working on it to make sure it can do what you need, if it can't already.

@gumyr
Copy link
Owner Author

gumyr commented May 5, 2023

I've only done a little non-functional work on the code to start to get it to pass pylint. It will need unit testing, examples and documentation as well so there is a fair amount still to do.

@Paul8043
Copy link

Paul8043 commented May 9, 2023

I still need a few days to port a cadquery-project to build123d. Coding with build123d makes fun. I like the architecture of build123d, especially the algebra-mode. Great work, thanks for this contribution. Let me know, when the projection-free SVG-exporter will be available.

@gumyr
Copy link
Owner Author

gumyr commented Aug 20, 2023

Done with commit 76c4f2e

@gumyr gumyr closed this as completed Aug 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants