-
Notifications
You must be signed in to change notification settings - Fork 302
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
exportSvg doesn't hide edges that are partially visible #593
Comments
To add more info doing Union on the solids works as expected
|
This seems to do the trick for me: from cadquery import cq, Compound
nl = list()
nl.append(cq.Workplane("XY").box(.1, 2, .1, centered=(True, True, True)).val())
nl.append(cq.Workplane("XY").box(2, 1, 1, centered=(True, True, True)).val())
comp = Compound.makeCompound(nl).fuse()
cq.Workplane(comp).exportSvg("boxes.svg") |
You want to have internal edges, I assume. Another bool op needs to be used. I think one from here: #449 |
I will try #449 , but I now understand that an edge crossing a solid through one of their faces (not holes) is not a natural occurence, so maybe this is not actually an issue / worth solving. |
I'll leave the issue open. It might be good to at leas mention this in the docs. |
I have a similar problem. This code generates glitched svg images: import cadquery as cq
from cadquery.cq import Workplane as WP
def rod(wp):
return WP(wp).circle(1).extrude(8)
fig = WP('XY').box(5, 5, 5).add(rod('XY')).add(rod('XZ'))
show_object(fig)
cq.exporters.export(fig, 'figure.svg', opt={
'projectionDir': (0.3, -0.2, 0.1),
'showHidden': False
}) CQ-editor VS svg-export: And if I use fig = WP('XY').box(5, 5, 5).union(rod('XY')).union(rod('XZ')) Does it really make sense to have different behaviors for add and union? Is it for performance purpose?
Feel free to use those code / images in the docs if necessary. |
I can see why a user would think they are related methods, but internally they are pretty much unrelated. If you look at the source you can see they do completely different things. It would be very rare you use add. |
The solution is to implement #449 and use it before SVG export. The HLR algo does not know what to do with interfering but unrelated solids. It is arguably a very weird use case. |
This code generates two boxes, one of them crossing the other one. When exporting to SVG with
exportSvg
, edges that start in a visible area and then intersect the other object are rendered incorrectly.If they go behind the other object, they are rendered correctly.
Incorrect
from cadquery import cq, Compound
nl = list()
nl.append(cq.Workplane("XY").box(.1, 2, .1, centered=(True, True, True)).val())
nl.append(cq.Workplane("XY").box(2, 1, 1, centered=(True, True, True)).val())
comp = Compound.makeCompound(nl)
cq.Workplane(comp).exportSvg("boxes.svg")
Correct
from cadquery import cq, Compound
nl = list()
nl.append(cq.Workplane("XY").box(.1, 2, .1, centered=(True , True, True)).translate((0,0,-1)).val())
nl.append(cq.Workplane("XY").box(2, 1, 1, centered=(True, True, True)).val())
comp = Compound.makeCompound(nl)
cq.Workplane(comp).exportSvg("boxes2.svg")
Cadquery 2.0 - Python 3.7 - Windows,
The text was updated successfully, but these errors were encountered: