-
Notifications
You must be signed in to change notification settings - Fork 133
Open
Description
cad.xmlxcaf.zip
having a hard time getting the load XCAF files, here is my code:
import os
from OCC.Core.TDocStd import TDocStd_Document
from OCC.Core.TDF import TDF_LabelSequence
from OCC.Core.XmlXCAFDrivers import xmlxcafdrivers
from OCC.Core.XCAFApp import XCAFApp_Application
from OCC.Core.XCAFDoc import XCAFDoc_DocumentTool
from OCC.Core.TCollection import TCollection_ExtendedString
def read_xml_file(file_path):
# Initialize the application
print("Initializing application...")
app = XCAFApp_Application.GetApplication()
xmlxcafdrivers.DefineFormat(app)
if app is None:
raise Exception("Failed to initialize application")
# Create a new document
print("Creating new document...")
doc = TDocStd_Document("pythonocc-doc")
if doc is None:
raise Exception("Failed to create document")
# Create the storage driver
# Read the XML file
app.Open(file_path, doc)
# Access the shape tool
print("Accessing shape tool...")
shape_tool = XCAFDoc_DocumentTool.ShapeTool(doc.Main())
if shape_tool is None:
raise Exception("Failed to access shape tool")
labels = TDF_LabelSequence()
shape_tool.GetFreeShapes(labels)
# Debug information
print(f"Number of shapes at root : {labels.Length()}")
I got 0 shape , xml file in zip file
Metadata
Metadata
Assignees
Labels
No labels