-
- anObjList = [self.Part.object(kResultBodyType, idx) for idx in xrange(aPartSize)]
- for idx, anObject in enumerate(anObjList):
- aResult = ModelAPI.modelAPI_Result(anObject)
- aBodyResult = ModelAPI.modelAPI_ResultBody(aResult)
- if not aBodyResult:
- continue
- aShape = aBodyResult.shape()
- aDump = aShape.getShapeStream()
- # Load shape to SALOME Geom
- aBrep = self.geompy.RestoreShape(aDump)
- self.geompy.addToStudy(aBrep, "NewGeomShape_{0}".format(idx + 1))
- self.geomObjects.append([aShape, aBrep])
-
- ## Exports all groups
- def exportGroups(self):
- # iterate all features to find groups
- aFeaturesNum = self.Part.size("Features")
- groupIndex = 0
- for anIndex in range(0, aFeaturesNum):
- aFeature = self.Part.object("Features", anIndex)
- aSelectionList = aFeature.data().selectionList("group_list")
- # if a group has been found
- if aSelectionList:
- groupIndex = groupIndex + 1
- self.createGroupFromList(aSelectionList, "NewGeomGroup_{0}".format(groupIndex))
-
- ## Creates a group by given list of selected objects and the name
- # @param theSelectionList: list of selected objects
- # @param theGroupName: name of the group to create
- def createGroupFromList(self, theSelectionList, theGroupName):
- # iterate on all selected entities of the group
- # and get the corresponding ID
- aSelectionNum = theSelectionList.size()
- Ids = []
- for aSelIndex in range(0, aSelectionNum):
- aSelection = theSelectionList.value(aSelIndex)
- aSelectionContext = aSelection.context()
- anID = aSelection.Id()
- Ids.append(anID)
- if aSelection.value().isVertex():
- groupType = "VERTEX"
- elif aSelection.value().isEdge():
- groupType = "EDGE"
- elif aSelection.value().isFace():
- groupType = "FACE"
- else:
- groupType = "SOLID"
-
- # iterate on exported objects and check if the current
- # group refers to this object
- for obj in self.geomObjects:
- if aSelectionContext.shape().isEqual(obj[0]):
- aGroup = self.geompy.CreateGroup(obj[1], self.geompy.ShapeType[groupType])
- self.geompy.UnionIDs(aGroup,Ids)
- self.geompy.addToStudyInFather(obj[1], aGroup, theGroupName)
-
+ imported, shape, subShapes, groups, fields = self.geompy.ImportXAO(tmpXAOFile)
+ self.geompy.addToStudy( shape, shape.GetName() )
+ # add sub-shapes and groups to the object browser
+ for obj in subShapes + groups:
+ name = obj.GetName()
+ self.geompy.addToStudyInFather(shape, obj, name)
+ # add fields to the object browser
+ for field in fields:
+ name = field.GetName()
+ self.geompy.addToStudyInFather(shape, field, name)
+ # add steps to the object browser
+ steps = field.getSteps()
+ for i_step in steps:
+ step = field.getStep(i_step)
+ i_stamp = step.GetStamp()
+ step_name = "Step %i %i"%(i_step, i_stamp)
+ self.geompy.addToStudyInFather( field, step, step_name )
+ # Remove the temporary file
+ os.remove(tmpXAOFile)
+ pass
+