-
-
Notifications
You must be signed in to change notification settings - Fork 92
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 Missing Surfaces? #745
Comments
Nice box - an electronics case I assume. The problem is almost certainly that although it looks like a valid shape it isn't. It's possible for the OCCT CAD kernel to create invalid shapes like this without warning as described in the docs here: can't get there from here. To debug the problem I'd suggest combining intermediate steps with a Box and visually checking if all of the surfaces are correct. Alternatively, you could export intermediate versions to STEP and check if the problem occurs to isolate what part of the code is causing the invalid shape. |
Thanks for the comment. I knew about potentially invalid shapes, but I thought this one was fine since ocp_vscode shows the part fine. Also, |
As you've found Sometimes the STL exporter will still work with invalid objects as you've found which can be a good way to just get the part out if all you want to do is print it. Good luck with your project. |
What does |
|
I did find out 1 more detail that may be part of the problem. If I remove |
The problem is within OCCT - the boss is not being fused into the shell successfully probably due to some small floating point issue. I was able to get the fuse to work by extruding the offset version of very top surface Although not specific to this problem, you might find it convenient to design in "units" and scale the entire model at the end Although I'd like these problems to be fixed, OCCT issues are outside the scope of build123d unless a work-around can be found. In this case all the work arounds I've tried failed. |
Interestingly, just using regular dimensions and then scaling with from OCP.Interface import Interface_Static
Interface_Static.SetCVal_s("write.step.unit", 'INCH') Your idea of starting on the top surface and extruding "inward" (plus the extra thickness of the top) makes sense to ensure overlapping geometry, though in some cases this may not be possible. I wonder if there could be some solution in extending the extrusion in the opposite direction a little bit. However, doing this fully automatically is probably very difficult and riddled with corner cases. Maybe a small improvement would be to allow extruding a different amount in each direction. shell += cad.extrude(outer, 0.50 * IN, dir2=-1e-8 * IN) where that |
I also still have a hard time understanding why ocp_vscode displays it "correctly" even when FreeCAD does not. My understanding is that both of them using Open CASCADE? |
Looking at the STEP file that has an issue and the alternative (where I just used In the problematic one, it interestingly has some B_SPLINEs, which shouldn't be needed. Note that some of the points end with
Would it be possible to have some global flag to round all values to within some user defined tolerance? If the values were rounded to to 6 (or even 10 digits here) then this would likely go away? |
Sorry for the barrage of comments. But was is interesting is that even when I "force" there to be good clearance, it still doesn't work here. shell += cad.extrude(outer, 0.50 * IN)
# change the line above to one of these:
shell += cad.extrude(outer.located(cad.Pos(Z=0.25 * IN)), 0.50 * IN)
shell += cad.extrude(cad.Pos(Z=0.25 * IN) * outer, 0.50 * IN)
# try using glue and/or tol in the fuse method
shell = shell.fuse(cad.extrude(outer, 0.50 * IN), glue=True, tol=0.01 * IN) In this case, |
Although I can't say for sure what the problem is as it's within the OCCT code base, my guess is that a floating point difference is causing OCCT to interpret a planar surface as a non-planar surface which breaks the logic of fusing the extrusion to the shell. As you mention, it isn't feasible to start extruding in both directions generally as build123d must handle arbitrary shapes. The viewer uses a different system to display object than the OCCT STEP file generator so one shouldn't assume that the results are going to be exactly the same. Unfortunately, this S/W (all S/W?) has bugs and sometimes the only thing to do is avoid them. |
Ya, the issue is even more fundamental than I realized. I spent a bit of time going down the path of investigating the fusing operation, but actually even just the "boss" extruded box itself does not work. from build123d import IN
import build123d as cad
from ocp_vscode import show_object
# base part shell
shell_thickness = 1 / 16 * IN
sketch = cad.Sketch() + [
cad.Pos(Z=0.00 * IN) * cad.Rectangle(6.0 * IN, 4.0 * IN),
cad.Pos(Z=1.00 * IN) * cad.Rectangle(5.0 * IN, 3.0 * IN),
]
solid = cad.loft(sketch, ruled=True)
bottom = solid.faces().sort_by()[0]
shell = cad.offset(solid, amount=-shell_thickness, openings=bottom)
# create a a boss on the inside surface
face = shell.faces().sort_by()[-2]
outer = cad.offset(-face, amount=-0.25 * IN)
# tried this too, since we know there is only 1 face in the sketch, but also fails:
# outer = cad.offset(-face, amount=-0.25 * IN).faces()[0]
box = cad.extrude(outer, -0.50 * IN)
# this works though, so the issue gets introduced in the offset operation
# box = cad.extrude(face, -0.50 * IN)
# save the box extrusion only
# box = box.clean() # does not help
print(box.is_valid())
print(box.is_manifold)
show_object(box)
cad.export_step(box, 'issue_745_2.step')
cad.export_stl(box, 'issue_745_2.stl') Saving just this boss extrusion, which should just be a simple shape, fails to open correctly in FreeCAD. It only shows two of the planes. Using the face within the sketch still fails, but it does work if we use the inside face directly (see code comments). So it appear that the issue is introduced in the |
Yes, the offset face is causing the problem but when I looked at the vertices of the offset they all look good. For a while I thought I could potentially "fix" the offset but after more investigation I failed to find a way to do so. |
I've found that all of my examples above (the box, the simplified model, and the original complex model) all display correctly in FreeCAD if I un-comment the line below to enable offset_builder.SetApprox(True) So perhaps we can add a boolean to the main |
There already is an issue on this: #547 I'll comment further about this feature there. |
I'm not sure where to post this and I'm not sure if this is a bug in build123d, FreeCAD, or something else. So I'm looking for some guidance in debugging I guess.
I have a part that seems to build find and also displays as expected in Codium using ocp_vscode. However, when I export the file to STEP and import it into FreeCAD, a bunch of surfaces appear to be missing.
Has anyone run into this? Does anyone have any recommendations to debug this?
For reference, here is the part in ocp_vscode:
And here it is imported into FreeCAD (latest version, 0.21.2):
Notice that the top surfaces are missing.
The text was updated successfully, but these errors were encountered: