-
Notifications
You must be signed in to change notification settings - Fork 289
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
step exporter generates incorrect geometry #697
Comments
I should mention that I'm viewing the step file with freecad, and just to make sure that it's not a bug in freecad, I also uploaded the step to https://www.emachineshop.com/free-online-step-file-viewer/ which agrees with freecad's render. |
Could this be a bug in opencascade's fuzzy boolean operations? I have trouble understanding how that could only apply to step file exports though. |
STL export uses meshes, which is a very different process than STEP export. There could be invalid geometry at the locations that the STL exporter smooths over. Have you checked the STL to make sure it doesn't have any errors? Can you produce a minimum working example so that we can test? |
I have reproduced the problem widget = \
cq.Workplane("XY")\
.rect(5,5)\
.extrude(0.5)
oddly_shaped_holes = \
cq.Workplane("XY")\
.move(0,1.2)\
.lineTo(-0.5,1.2)\
.lineTo(-0.5,1.5)\
.lineTo(-1.5,1.5)\
.lineTo(-1.5,0)\
.mirrorX()\
.mirrorY()\
.extrude(2)\
.edges("|Z")\
.fillet(0.13)
bunch_of_cylinders = \
cq.Workplane("XY")\
.rarray(1,3,4,2)\
.eachpoint(
lambda loc: cq.Workplane("XY")\
.circle(0.15)\
.extrude(2)\
.val()\
.located(loc))
widget = widget.cut(oddly_shaped_holes)
widget = widget.cut(bunch_of_cylinders)
cq.exporters.export(widget, f'widget.stl')
cq.exporters.export(widget, f'widget.step') Everything is looks ok in cq-editor stl looks ok in https://www.viewstl.com/#! But in www.emachineshop.com viewer something strange happens with holes |
Ha! Thanks! Even before I had a chance to distill it! 👍 |
If you change If you change |
@greyltc Please try the same trick on your original model. Will it fix the problem there too? |
Yep, it does. It's like the fuzzy boolean operation feature (see my comment above) is somehow lost in the step export pathway. |
I thought that BREP means all the history of unions, intersections, etc is lost after each operation and only the resulting trimmed surfaces with common edges and vertexes remain. How is it possible that after successfully cutting the holes (as can be seen in cq-viewer or in STL models), STEP export result depends on how exactly the solid was made? |
OCCT stores that edge as something along the lines of a "trimmed circle". It looks like OOCT is inverting which side of it is trimmed when converting it to a STEP. Edit: that sounds more confident than I intended. This is just my best guess. |
It seems to be STEP related - if I export in the brep format the issue is not there. |
Possibly related: https://tracker.dev.opencascade.org/view.php?id=32132 |
Two step files attached, one made with CQ-editor export and OCP/OCCT 7.4, the other with 7.5.1. I can see the error in 7.5.1, but not in 7.4. STEP files renamed to TXT files because github... 😑 Made with @fedorkotov's code as written here. |
Looks like that OCCT issue hasn't been triaged yet, and the last comment was the middle of Feb. It looks to me like it's related to this issue. |
To anyone else who is also being bothered by this bug, I have a workaround: from OCP.BRepTools import BRepTools
BRepTools.Write_s(widget.toOCC(), "good_geometry.brep") I then get bugfree .brep files which I can manually import with the appimage version of FreeCAD and reexport as step files that are also bugless (since the problem doesn't exist in occt 7.4). |
Also |
Upstream bug report: https://tracker.dev.opencascade.org/view.php?id=32264 |
Great, thanks for reporting! They do like draw.exe scripts. |
The opencascade devs have quickly come up with a fix for this issue. Edit: Actully, looks like they've decided to roll this fix into a 7.5.2 release. |
This is with cadquery commit gf0308ce and opencascade 7.5.0:
widget.stl
contains the geometry I expect and the region of interest here looks like this:but
widget.step
looks like this:I made that crescent shape (as shown in the .stl) by using
widget = widget.cut(bunch_of_cylinders)
to cut a bunch of cylinders out of a thin sheet. Many of the resulting voids in the thin sheet step file (not shown here) are correct, but some, like this one, have somehow managed to invert the boolean operation I asked for and instead of subtracting the cutting tool from the stock, the step file shows the cutting tool shape (a cylinder) added to the stock part.Is this a bug in opencascade, not cadquery? Is the step file exporter known to be broken? Are there workarounds/tricks I can play to make step files in a more reliable way?
The text was updated successfully, but these errors were encountered: