Mon, 08/19/2024 - 15:06
Forums:
Hi,
I am trying to make simple converter from GTLF (GLB) to STEP format. I am using a simple box as my test input (see attached .zip).
Reading of the GTLF file seems to work fine using:
# Create an handle to a document
doc = TDocStd_Document("gltf-convert-doc")
# Create GLTF reader
gltf_reader = RWGltf_CafReader()
gltf_reader.SetDocument(doc)
read_status = gltf_reader.Perform(input_filename, Message_ProgressRange())
if read_status != IFSelect_RetDone:
raise AssertionError("Could not load GLTF file")
# Get as single shape
shape = gltf_reader.SingleShape()
I get a single compound top level shape with 6 faces.
If i display it with:
# Display GLTF shape
display, start_display, add_menu, add_function_to_menu = init_display()
display.DisplayShape(shape, update=True)
start_display()
Everything looks fine and box appears.
For converting and writing to STEP I am doing the following:
# Create STEP writer
step_writer = STEPControl_Writer()
Interface_Static.SetCVal("write.step.schema", "ap203")
# transfer shapes and write file
step_writer.Transfer(shape, STEPControl_AsIs)
write_status = step_writer.Write(output_filename)
if write_status != IFSelect_RetDone:
raise AssertionError("Could not write STEP file.")
Which seems to be working. It produces a .stp file with content. But when I open the file with a CAD program (such a CAD Assistant) it shows nothing (see attached screenshot).
Any insight would be much appreciated.
Attachments:
Mon, 08/19/2024 - 22:58
Hello, you trying to export mesh format into BRep format. In that case there are a few limitations.
1. CAD Assistent based on old OCCT and do not support STP with mesh
2. STP format support mesh only on AP214 and AP242. But I really recommend to use ONLY AP242
3. OCCT older then 7.7 do not support import or export STP files with mesh.
Best regards, Dmitrii
Tue, 08/20/2024 - 10:45
Thank you for the response.
I and using OCCT 7.8.1 and I have tried switching to AP242 with:
I tried opening the converted .stp file in FreeCAD this time. However the result is the same, just an empty document.
I have also attempted to convert the shape into BRep format (probably naively so) using:
With the topology dump output:
But also no luck, is displays fine using
DisplayShape(...)
, but the step file seems blank when opening, even though the file itself is not empty.Is there another approach I could take for this type of conversion or what am I missing?
Tue, 08/20/2024 - 11:29
FreeCAD based on OCCT, Im not sure about their version.
Could you check the file content and check that file contains some faces inside as a a lot of doubles and so one.
Or could you share result file?
Related topics:
Error when build triangle meshes - Forum Open Cascade Technology
STL to STEP - Forum Open Cascade Technology
Best regards, Dmitrii.