[SOLVED] OCCT 7.4.0 bug in STEP serialization

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
naxq0
Posts: 51
Joined: Wed Apr 25, 2018 7:45 am

[SOLVED] OCCT 7.4.0 bug in STEP serialization

Post by naxq0 »

I'm not sure what, but for some reason if I try translating some solids, the FreeCAD STEP export fails to correctly write the object.

I think this used to work on FreeCAD 0.18 (or at least, I did not realize that it was failing) But now when I try to extract the only solid in the files and center them, the geometry "is invalid"

Code: Select all

p = "shaftcw_RAW.step"
# p = "lockplate_RAW.step"
solid = Part.read(p).Solids[0] # Get the only solid
# solid.tessellate(0.1) # Doesn't make a difference!

# Center it
solid.exportStep('/tmp/OK.step')
solid.translate(-solid.CenterOfMass) # <---- breaks
solid.exportStep('/tmp/BROKEN.step')
This is how one of those files looks after it is broken:
debug.png
debug.png (78.4 KiB) Viewed 1282 times
The one thing I noticed in both files is that the python feature's Placement's base is NOT centered on the original files and after the translation it is. Not sure if that's related though. I tried to respect the placement by using:

Code: Select all

T = Base.Placement()
T.translate(-solid.CenterOfMass)
solid.Placement = solid.Placement.multiply(T)
but that didn't solve the issue. Am I doing something wrong while translating? Does anyone know what is going on or is it a bug?

OS: Ubuntu 20.04.2 LTS (Regolith:GNOME-Flashback:GNOME/regolith)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.
Build type: Release
Branch: unknown
Hash: 9e3b630bbfb6807e93eeffb655e6c20f218644fc
Python version: 3.8.5
Qt version: 5.12.8
Coin version: 4.0.0
OCC version: 7.5.1
Locale: English/United States (en_US)


The issue also appeared on my other computer:

OS: Ubuntu 18.04.5 LTS (Regolith:GNOME-Flashback:GNOME/regolith)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.
Build type: Release
Branch: unknown
Hash: c240777a7de9fbb69472e6cbf589e83559a9ef17
Python version: 3.6.9
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.5.1
Locale: English/UnitedStates (en_US)
Attachments
shaftcw_RAW.step
(64.51 KiB) Downloaded 30 times
lockplate_RAW.step
(26.83 KiB) Downloaded 34 times
Last edited by naxq0 on Wed Dec 01, 2021 2:52 pm, edited 1 time in total.
User avatar
naxq0
Posts: 51
Joined: Wed Apr 25, 2018 7:45 am

Re: STEP serialization breaking the solids?

Post by naxq0 »

I played around with it some more and it seems like STEP export is actually the problem...
I saw that the recent OCCT 7.5.2 release fixed the STEP exporter:

https://www.opencascade.com/open-cascad ... -release/
32264: Data Exchange - STEP exporter generates bad geometry [REGRESSION since 7.4.0]
The reason I suspect that it's the STEP export is that you can get a valid mesh before the export, but if you try to do that after importing, the mesh's "m.isSolid()" returns "False"

Code: Select all

m = Mesh.Mesh()
m.addFacets(solid.tessellate(0.01))
if m.isSolid():
    print("\t> Mesh was: OK!")
else:
    print("\t> Mesh was: NOT A SOLID!")
Either that or maybe after losing the first sketch the references break?
https://forum.freecadweb.org/viewtopic.php?t=7877
jmaustpc wrote: Fri Oct 03, 2014 3:18 am It sounds like you have some PartDesign objects in there...PartDesign workbench objects Placement is defined (by design) by the first sketch in the history for that object. The placement of the features built up from that first sketch are set by the contents of the subsequent sketches mapped to faces.


I really don't know how to proceed, does anyone know what might be happening here?
User avatar
naxq0
Posts: 51
Joined: Wed Apr 25, 2018 7:45 am

Re: STEP serialization breaking the solids?

Post by naxq0 »

I built FreeCAD 0.19 with OCCT 7.5.3 from source and I can confirm that the issue is solved

A bug in the STEP export is pretty critical so I hope the packaged FreeCAD upgrades its OCCT version soon :?
Post Reply