You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I am trying to parse a step file hierarchy with XCAFDoc. However, I found that some assemblies are not correctly recognized.
For instance, here below [C-400-Shasi] is an assembly in freeCAD, but not an assembly in my sample code implemented with pythonOCC.
Here's the sample codes:
deffindComponents(self, label, comps):
"""Discover components from comps (LabelSequence) of an assembly (label). Components of an assembly are, by definition, references which refer to either a shape or another assembly. Components are essentially 'instances' of the referred shape or assembly, and carry a location vector specifing the location of the referred shape or assembly. """logger.debug("")
logger.debug("Finding components of label entry %s)", label.EntryDumpToString())
forjinrange(comps.Length()):
logger.debug("loop %i of %i", j+1, comps.Length())
cLabel=comps.Value(j+1) # component label <class 'OCC.Core.TDF.TDF_Label'>cShape=self.shape_tool.GetShape(cLabel)
logger.debug("Component number %i", j+1)
logger.debug("Component entry: %s", cLabel.EntryDumpToString())
name=self.getName(cLabel)
logger.debug("Component name: %s", name)
refLabel=TDF_Label() # label of referred shape (or assembly)isRef=self.shape_tool.GetReferredShape(cLabel, refLabel)
ifisRef: # I think all components are references, but just in case...refShape=self.shape_tool.GetShape(refLabel)
refLabelEntry=refLabel.EntryDumpToString()
logger.debug("Entry referred to: %s", refLabelEntry)
refName=self.getName(refLabel)
logger.debug("Name of referred item: %s", refName)
ifself.shape_tool.IsSimpleShape(refLabel):
logger.debug("Referred item is a Shape")
logger.debug("Name of Shape: %s", refName)
logger.info("Is compound? %s ", self.shape_tool.IsCompound(refLabel))
logger.info("Number of Components %s ", self.shape_tool.NbComponents(refLabel))
rComps=TDF_LabelSequence() # Components of Assysubchilds=FalseisAssy=self.shape_tool.GetComponents(refLabel, rComps, subchilds)
logger.debug("Assy name: %s", name)
logger.debug("Is Assembly? %s", isAssy)
logger.debug("Number of components: %s", rComps.Length())
tempAssyLocStack=list(self.assyLocStack)
tempAssyLocStack.reverse()
forlocintempAssyLocStack:
cShape.Move(loc)
color=self.getColor(refShape)
self.tree.create_node(name,
self.getNewUID(),
self.assyUidStack[-1],
{'a': False, 'l': None, 'c': color, 's': cShape})
elifself.shape_tool.IsAssembly(refLabel):
logger.debug("Referred item is an Assembly")
logger.debug("Name of Assembly: %s", refName)
name=self.getName(cLabel) # Instance nameaLoc=TopLoc_Location()
# Location vector is carried by componentaLoc=self.shape_tool.GetLocation(cLabel)
self.assyLocStack.append(aLoc)
newAssyUID=self.getNewUID()
self.tree.create_node(name,
newAssyUID,
self.assyUidStack[-1],
{'a': True, 'l': aLoc, 'c': None, 's': None})
self.assyUidStack.append(newAssyUID)
rComps=TDF_LabelSequence() # Components of Assysubchilds=FalseisAssy=self.shape_tool.GetComponents(refLabel, rComps, subchilds)
logger.debug("Assy name: %s", name)
logger.debug("Is Assembly? %s", isAssy)
logger.debug("Number of components: %s", rComps.Length())
ifrComps.Length():
self.findComponents(refLabel, rComps)
self.assyUidStack.pop()
self.assyLocStack.pop()
The text was updated successfully, but these errors were encountered:
@tpaviot Sorry for late response. Due to certain constraints, I am unable to provide the STEP file for the original example. However, I have included an another STEP file where the same issue is present:
The test step file is included in the following .zip file: test_step.zip
Hello, I am trying to parse a step file hierarchy with XCAFDoc. However, I found that some assemblies are not correctly recognized.
For instance, here below [C-400-Shasi] is an assembly in freeCAD, but not an assembly in my sample code implemented with pythonOCC.
Here's the sample codes:
The text was updated successfully, but these errors were encountered: