# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
#
#
g=None
step = 0
-while step < 50 and g == None:
+sleeping_time = 0.01
+sleeping_time_max = 1.0
+while 1:
g = lcc.FindOrLoadComponent("FactoryServer", "GEOM")
+ if g is not None: break
step = step + 1
- time.sleep(4)
+ if step > 100: break
+ time.sleep(sleeping_time)
+ sleeping_time = max(sleeping_time_max, 2*sleeping_time)
+ pass
geom = g._narrow( GEOM.GEOM_Gen )
-myBuilder = myStudy.NewBuilder()
-father = myStudy.FindComponent("GEOM")
-if father is None:
+myBuilder = None
+myStudyId = 0
+father = None
+
+BasicOp = None
+CurvesOp = None
+PrimOp = None
+ShapesOp = None
+HealOp = None
+InsertOp = None
+BoolOp = None
+TrsfOp = None
+LocalOp = None
+MeasuOp = None
+BlocksOp = None
+GroupOp = None
+
+def init_geom(theStudy):
+
+ global myStudy, myBuilder, myStudyId, BasicOp, CurvesOp, PrimOp, ShapesOp, HealOp
+ global InsertOp, BoolOp, TrsfOp, LocalOp, MeasuOp, BlocksOp, GroupOp, father
+
+ myStudy = theStudy
+ myStudyId = myStudy._get_StudyId()
+ myBuilder = myStudy.NewBuilder()
+ father = myStudy.FindComponent("GEOM")
+ if father is None:
father = myBuilder.NewComponent("GEOM")
A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName")
FName = A1._narrow(SALOMEDS.AttributeName)
aPixmap = A2._narrow(SALOMEDS.AttributePixMap)
aPixmap.SetPixMap("ICON_OBJBROWSER_Geometry")
myBuilder.DefineComponentInstance(father,geom)
-
-# -----------------------------------------------------------------------------
-# add To Study
-# -----------------------------------------------------------------------------
-
+ pass
+
+ # -----------------------------------------------------------------------------
+ # Assign Operations Interfaces
+ # -----------------------------------------------------------------------------
+
+ BasicOp = geom.GetIBasicOperations (myStudyId)
+ CurvesOp = geom.GetICurvesOperations (myStudyId)
+ PrimOp = geom.GetI3DPrimOperations (myStudyId)
+ ShapesOp = geom.GetIShapesOperations (myStudyId)
+ HealOp = geom.GetIHealingOperations (myStudyId)
+ InsertOp = geom.GetIInsertOperations (myStudyId)
+ BoolOp = geom.GetIBooleanOperations (myStudyId)
+ TrsfOp = geom.GetITransformOperations(myStudyId)
+ LocalOp = geom.GetILocalOperations (myStudyId)
+ MeasuOp = geom.GetIMeasureOperations (myStudyId)
+ BlocksOp = geom.GetIBlocksOperations (myStudyId)
+ GroupOp = geom.GetIGroupOperations (myStudyId)
+ pass
+
+init_geom(myStudy)
+
+# * Get name for sub-shape aSubObj of shape aMainObj
+#
def SubShapeName(aSubObj, aMainObj):
name = "SubShape"
print name
return name
-# -----------------------------------------------------------------------------
-# Operations
-# -----------------------------------------------------------------------------
-
+# * Publish in study aShape with name aName
+#
def addToStudy(aShape, aName):
try:
aSObject = geom.AddInStudy(myStudy, aShape, aName, None)
return ""
return aShape.GetStudyEntry()
+# * Publish in study aShape with name aName as sub-object of previously published aFather
+#
def addToStudyInFather(aFather, aShape, aName):
try:
-# myBuilder.NewCommand()
aSObject = geom.AddInStudy(myStudy, aShape, aName, aFather)
-# myBuilder.CommitCommand()
except:
print "addToStudyInFather() failed"
return ""
ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
-# -----------------------------------------------------------------------------
-# Get Operations Interfaces
-# -----------------------------------------------------------------------------
-
-BasicOp = geom.GetIBasicOperations (myStudyId)
-CurvesOp = geom.GetICurvesOperations (myStudyId)
-PrimOp = geom.GetI3DPrimOperations (myStudyId)
-ShapesOp = geom.GetIShapesOperations (myStudyId)
-HealOp = geom.GetIHealingOperations (myStudyId)
-InsertOp = geom.GetIInsertOperations (myStudyId)
-BoolOp = geom.GetIBooleanOperations (myStudyId)
-TrsfOp = geom.GetITransformOperations(myStudyId)
-LocalOp = geom.GetILocalOperations (myStudyId)
-MeasuOp = geom.GetIMeasureOperations (myStudyId)
-BlocksOp = geom.GetIBlocksOperations (myStudyId)
-GroupOp = geom.GetIGroupOperations (myStudyId)
-
# -----------------------------------------------------------------------------
# Basic primitives
# -----------------------------------------------------------------------------
-def MakeVertex(x,y,z):
- anObj = BasicOp.MakePointXYZ(x,y,z)
+def MakeVertex(theX, theY, theZ):
+ anObj = BasicOp.MakePointXYZ(theX, theY, theZ)
if BasicOp.IsDone() == 0:
print "MakePointXYZ : ", BasicOp.GetErrorCode()
return anObj
print "MakeMarker : ", BasicOp.GetErrorCode()
return anObj
+def MakeMarkerPntTwoVec(theOrigin, theXVec, theYVec):
+ """
+ * Create a local coordinate system.
+ * \param theOrigin Point of coordinate system origin.
+ * \param theXVec Vector of X direction
+ * \param theYVec Vector of Y direction
+ * \return New GEOM_Object, containing the created coordinate system.
+ """
+ O = PointCoordinates( theOrigin )
+ OXOY = []
+ for vec in [ theXVec, theYVec ]:
+ v1, v2 = SubShapeAll( vec, ShapeType["VERTEX"] )
+ p1 = PointCoordinates( v1 )
+ p2 = PointCoordinates( v2 )
+ for i in range( 0, 3 ):
+ OXOY.append( p2[i] - p1[i] )
+ #
+ anObj = BasicOp.MakeMarker( O[0], O[1], O[2],
+ OXOY[0], OXOY[1], OXOY[2],
+ OXOY[3], OXOY[4], OXOY[5], )
+ if BasicOp.IsDone() == 0:
+ print "MakeMarker : ", BasicOp.GetErrorCode()
+ return anObj
+
# -----------------------------------------------------------------------------
# Curves
# -----------------------------------------------------------------------------
print "MakeSketcher : ", CurvesOp.GetErrorCode()
return anObj
+def MakeSketcherOnPlane(theCommand, theWorkingPlane):
+ """
+ * Create a sketcher (wire or face), following the textual description,
+ * passed through \a theCommand argument. \n
+ * For format of the description string see the previous method.\n
+ * \param theCommand String, defining the sketcher in local
+ * coordinates of the working plane.
+ * \param theWorkingPlane Planar Face of the working plane.
+ * \return New GEOM_Object, containing the created wire.
+ """
+ anObj = CurvesOp.MakeSketcherOnPlane(theCommand, theWorkingPlane)
+ if CurvesOp.IsDone() == 0:
+ print "MakeSketcher : ", CurvesOp.GetErrorCode()
+ return anObj
+
# -----------------------------------------------------------------------------
# Create 3D Primitives
# -----------------------------------------------------------------------------
print "MakeCompound : ", ShapesOp.GetErrorCode()
return anObj
+def NumberOfFaces(theShape):
+ nb_faces = ShapesOp.NumberOfFaces(theShape)
+ if ShapesOp.IsDone() == 0:
+ print "NumberOfFaces : ", ShapesOp.GetErrorCode()
+ return nb_faces
+
+def NumberOfEdges(theShape):
+ nb_edges = ShapesOp.NumberOfEdges(theShape)
+ if ShapesOp.IsDone() == 0:
+ print "NumberOfEdges : ", ShapesOp.GetErrorCode()
+ return nb_edges
+
def ChangeOrientation(Shape):
anObj = ShapesOp.ChangeOrientation(Shape)
if ShapesOp.IsDone() == 0:
anObj = ChangeOrientation(Shape)
return anObj
+def GetFreeFacesIDs(theShape):
+ anIDs = ShapesOp.GetFreeFacesIDs(theShape)
+ if ShapesOp.IsDone() == 0:
+ print "GetFreeFacesIDs : ", ShapesOp.GetErrorCode()
+ return anIDs
+
+def GetSharedShapes(theShape1, theShape2, theShapeType):
+ aList = ShapesOp.GetSharedShapes(theShape1, theShape2, theShapeType)
+ if ShapesOp.IsDone() == 0:
+ print "GetSharedShapes : ", ShapesOp.GetErrorCode()
+ return aList
+
+def GetShapesOnPlane(theShape, theShapeType, theAx1, theState):
+ aList = ShapesOp.GetShapesOnPlane(theShape, theShapeType, theAx1, theState)
+ if ShapesOp.IsDone() == 0:
+ print "GetShapesOnPlane : ", ShapesOp.GetErrorCode()
+ return aList
+
+def GetShapesOnPlaneIDs(theShape, theShapeType, theAx1, theState):
+ aList = ShapesOp.GetShapesOnPlaneIDs(theShape, theShapeType, theAx1, theState)
+ if ShapesOp.IsDone() == 0:
+ print "GetShapesOnPlaneIDs : ", ShapesOp.GetErrorCode()
+ return aList
+
+def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState):
+ aList = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState)
+ if ShapesOp.IsDone() == 0:
+ print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode()
+ return aList
+
+def GetShapesOnCylinderIDs(theShape, theShapeType, theAxis, theRadius, theState):
+ aList = ShapesOp.GetShapesOnCylinderIDs(theShape, theShapeType, theAxis, theRadius, theState)
+ if ShapesOp.IsDone() == 0:
+ print "GetShapesOnCylinderIDs : ", ShapesOp.GetErrorCode()
+ return aList
+
+def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState):
+ aList = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState)
+ if ShapesOp.IsDone() == 0:
+ print "GetShapesOnSphere : ", ShapesOp.GetErrorCode()
+ return aList
+
+def GetShapesOnSphereIDs(theShape, theShapeType, theCenter, theRadius, theState):
+ aList = ShapesOp.GetShapesOnSphereIDs(theShape, theShapeType, theCenter, theRadius, theState)
+ if ShapesOp.IsDone() == 0:
+ print "GetShapesOnSphereIDs : ", ShapesOp.GetErrorCode()
+ return aList
+
+def GetShapesOnQuadrangle(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState):
+ aList = ShapesOp.GetShapesOnQuadrangle(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState)
+ if ShapesOp.IsDone() == 0:
+ print "GetShapesOnQuadrangle : ", ShapesOp.GetErrorCode()
+ return aList
+
+def GetShapesOnQuadrangleIDs(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState):
+ aList = ShapesOp.GetShapesOnQuadrangleIDs(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState)
+ if ShapesOp.IsDone() == 0:
+ print "GetShapesOnQuadrangleIDs : ", ShapesOp.GetErrorCode()
+ return aList
+
+def GetInPlace(theShapeWhere, theShapeWhat):
+ anObj = ShapesOp.GetInPlace(theShapeWhere, theShapeWhat)
+ if ShapesOp.IsDone() == 0:
+ print "GetInPlace : ", ShapesOp.GetErrorCode()
+ return anObj
+
# -----------------------------------------------------------------------------
# Access to sub-shapes by their unique IDs inside the main shape.
# -----------------------------------------------------------------------------
print "MakeExplode : ", ShapesOp.GetErrorCode()
return ListObj
-def SubShapeAllSorted(aShape,aType):
+def SubShapeAllIDs(aShape, aType):
+ ListObj = ShapesOp.SubShapeAllIDs(aShape,aType,0)
+ if ShapesOp.IsDone() == 0:
+ print "SubShapeAllIDs : ", ShapesOp.GetErrorCode()
+ return ListObj
+
+def SubShapeAllSorted(aShape, aType):
ListObj = ShapesOp.MakeExplode(aShape,aType,1)
if ShapesOp.IsDone() == 0:
print "MakeExplode : ", ShapesOp.GetErrorCode()
return ListObj
+def SubShapeAllSortedIDs(aShape, aType):
+ ListIDs = ShapesOp.SubShapeAllIDs(aShape,aType,1)
+ if ShapesOp.IsDone() == 0:
+ print "SubShapeAllSortedIDs : ", ShapesOp.GetErrorCode()
+ return ListObj
+
# Obtain a compound of sub-shapes of <aShape>,
# selected by they indices in list of all sub-shapes of type <aType>
def SubShape(aShape, aType, ListOfInd):
Limit, RemoveWebs, ListMaterials);
return anObj
+def MakeHalfPartition(theShape, thePlane):
+ anObj = BoolOp.MakeHalfPartition(theShape, thePlane)
+ if BoolOp.IsDone() == 0:
+ print "MakeHalfPartition : ", BoolOp.GetErrorCode()
+ return anObj
+
# -----------------------------------------------------------------------------
# Transform objects
# -----------------------------------------------------------------------------
print "TranslateDXDYDZCopy : ", TrsfOp.GetErrorCode()
return anObj
+def MakeTranslationVector(theObject, theVector):
+ anObj = TrsfOp.TranslateVectorCopy(theObject, theVector)
+ if TrsfOp.IsDone() == 0:
+ print "TranslateVectorCopy : ", TrsfOp.GetErrorCode()
+ return anObj
+
def MakeRotation(aShape,axis,angle):
anObj = TrsfOp.RotateCopy(aShape,axis,angle)
if TrsfOp.IsDone() == 0:
print "RotateCopy : ", TrsfOp.GetErrorCode()
return anObj
+def MakeRotationThreePoints(aShape, centpoint, point1, point2):
+ anObj = TrsfOp.RotateThreePointsCopy(aShape, centpoint, point1, point2)
+ if TrsfOp.IsDone() == 0:
+ print "RotateThreePointsCopy : ", TrsfOp.GetErrorCode()
+ return anObj
+
def MakeScaleTransform(aShape,theCenterofScale,factor):
anObj = TrsfOp.ScaleShapeCopy(aShape,theCenterofScale,factor)
if TrsfOp.IsDone() == 0:
print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode()
return anObj
+def MakeMirrorByAxis(theObject, theAxis):
+ anObj = TrsfOp.MirrorAxisCopy(theObject, theAxis)
+ if TrsfOp.IsDone() == 0:
+ print "MirrorAxisCopy : ", TrsfOp.GetErrorCode()
+ return anObj
+
+def MakeMirrorByPoint(theObject, thePoint):
+ anObj = TrsfOp.MirrorPointCopy(theObject, thePoint)
+ if TrsfOp.IsDone() == 0:
+ print "MirrorPointCopy : ", TrsfOp.GetErrorCode()
+ return anObj
+
def MakePosition(aShape,theStartLCS,theEndLCS):
anObj = TrsfOp.PositionShapeCopy(aShape,theStartLCS,theEndLCS)
if TrsfOp.IsDone() == 0:
print "GetCentreOfMass : ", MeasuOp.GetErrorCode()
return anObj
-def CheckShape(aShape):
- (IsValid, Status) = MeasuOp.CheckShape(aShape)
+def CheckShape(theShape, theIsCheckGeom = 0):
+ if theIsCheckGeom:
+ (IsValid, Status) = MeasuOp.CheckShapeWithGeometry(theShape)
+ else:
+ (IsValid, Status) = MeasuOp.CheckShape(theShape)
+
if MeasuOp.IsDone() == 0:
print "CheckShape : ", MeasuOp.GetErrorCode()
else:
print "Import : ", InsertOp.GetErrorCode()
return anObj
+def ImportBREP(theFileName):
+ return Import(theFileName, "BREP")
+
+def ImportIGES(theFileName):
+ return Import(theFileName, "IGES")
+
+def ImportSTEP(theFileName):
+ return Import(theFileName, "STEP")
+
def Export(aShape, filename, formatname):
InsertOp.Export(aShape, filename, formatname)
if InsertOp.IsDone() == 0:
print "Export : ", InsertOp.GetErrorCode()
+def ExportBREP(theObject, theFileName):
+ return Export(theObject, theFileName, "BREP")
+
+def ExportIGES(theObject, theFileName):
+ return Export(theObject, theFileName, "IGES")
+
+def ExportSTEP(theObject, theFileName):
+ return Export(theObject, theFileName, "STEP")
+
# -----------------------------------------------------------------------------
# Block operations
# -----------------------------------------------------------------------------
print "MakeHexa2Faces : ", BlocksOp.GetErrorCode()
return anObj
+def GetPoint(theShape, theX, theY, theZ, theEpsilon):
+ anObj = BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon)
+ if BlocksOp.IsDone() == 0:
+ print "GetPoint : ", BlocksOp.GetErrorCode()
+ return anObj
+
+def GetEdge(theShape, thePoint1, thePoint2):
+ anObj = BlocksOp.GetEdge(theShape, thePoint1, thePoint2)
+ if BlocksOp.IsDone() == 0:
+ print "GetEdge : ", BlocksOp.GetErrorCode()
+ return anObj
+
+def GetEdgeNearPoint(theShape, thePoint):
+ anObj = BlocksOp.GetEdgeNearPoint(theShape, thePoint)
+ if BlocksOp.IsDone() == 0:
+ print "GetEdgeNearPoint : ", BlocksOp.GetErrorCode()
+ return anObj
+
+def GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4):
+ anObj = BlocksOp.GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4)
+ if BlocksOp.IsDone() == 0:
+ print "GetFaceByPoints : ", BlocksOp.GetErrorCode()
+ return anObj
+
+def GetFaceByEdges(theShape, theEdge1, theEdge2):
+ anObj = BlocksOp.GetFaceByEdges(theShape, theEdge1, theEdge2)
+ if BlocksOp.IsDone() == 0:
+ print "GetFaceByEdges : ", BlocksOp.GetErrorCode()
+ return anObj
+
+def GetOppositeFace(theBlock, theFace):
+ anObj = BlocksOp.GetOppositeFace(theBlock, theFace)
+ if BlocksOp.IsDone() == 0:
+ print "GetOppositeFace : ", BlocksOp.GetErrorCode()
+ return anObj
+
+def GetFaceNearPoint(theShape, thePoint):
+ anObj = BlocksOp.GetFaceNearPoint(theShape, thePoint)
+ if BlocksOp.IsDone() == 0:
+ print "GetFaceNearPoint : ", BlocksOp.GetErrorCode()
+ return anObj
+
+def GetFaceByNormale(theBlock, theVector):
+ anObj = BlocksOp.GetFaceByNormale(theBlock, theVector)
+ if BlocksOp.IsDone() == 0:
+ print "GetFaceByNormale : ", BlocksOp.GetErrorCode()
+ return anObj
+
+def CheckCompoundOfBlocks(theCompound):
+ (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(theCompound)
+ if BlocksOp.IsDone() == 0:
+ print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode()
+ else:
+ if IsValid == 0:
+ Descr = BlocksOp.PrintBCErrors(theCompound, BCErrors)
+ print Descr
+ return IsValid
+
+def RemoveExtraEdges(theShape):
+ anObj = BlocksOp.RemoveExtraEdges(theShape)
+ if BlocksOp.IsDone() == 0:
+ print "RemoveExtraEdges : ", BlocksOp.GetErrorCode()
+ return anObj
+
+def CheckAndImprove(theShape):
+ anObj = BlocksOp.CheckAndImprove(theShape)
+ if BlocksOp.IsDone() == 0:
+ print "CheckAndImprove : ", BlocksOp.GetErrorCode()
+ return anObj
+
+def MakeBlockExplode(theCompound, theMinNbFaces, theMaxNbFaces):
+ aList = BlocksOp.ExplodeCompoundOfBlocks(theCompound, theMinNbFaces, theMaxNbFaces)
+ if BlocksOp.IsDone() == 0:
+ print "MakeBlockExplode : ", BlocksOp.GetErrorCode()
+ return aList
+
+def GetBlockNearPoint(theCompound, thePoint):
+ anObj = BlocksOp.GetBlockNearPoint(theCompound, thePoint)
+ if BlocksOp.IsDone() == 0:
+ print "GetBlockNearPoint : ", BlocksOp.GetErrorCode()
+ return anObj
+
+def GetBlockByParts(theCompound, theParts):
+ anObj = BlocksOp.GetBlockByParts(theCompound, theParts)
+ if BlocksOp.IsDone() == 0:
+ print "GetBlockByParts : ", BlocksOp.GetErrorCode()
+ return anObj
+
+def GetBlocksByParts(theCompound, theParts):
+ aList = BlocksOp.GetBlocksByParts(theCompound, theParts)
+ if BlocksOp.IsDone() == 0:
+ print "GetBlocksByParts : ", BlocksOp.GetErrorCode()
+ return aList
+
def MakeMultiTransformation1D(Block, DirFaceID1, DirFaceID2, NbTimes):
anObj = BlocksOp.MakeMultiTransformation1D(Block, DirFaceID1, DirFaceID2, NbTimes)
if BlocksOp.IsDone() == 0:
print "MakeMultiTransformation2D : ", BlocksOp.GetErrorCode()
return anObj
-def MakeBlockExplode(Compound, MinNbFaces, MaxNbFaces):
- aList = BlocksOp.ExplodeCompoundOfBlocks(Compound, MinNbFaces, MaxNbFaces)
+def Propagate(theShape):
+ listChains = BlocksOp.Propagate(theShape)
if BlocksOp.IsDone() == 0:
- print "MakeBlockExplode : ", BlocksOp.GetErrorCode()
- return aList
-
-def CheckCompoundOfBlocks(Compound):
- (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(Compound)
- if BlocksOp.IsDone() == 0:
- print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode()
- else:
- if IsValid == 0:
- Descr = BlocksOp.PrintBCErrors(Compound, BCErrors)
- print Descr
- return IsValid
+ print "Propagate : ", BlocksOp.GetErrorCode()
+ return listChains
# -----------------------------------------------------------------------------
# Group operations
if GroupOp.IsDone() == 0:
print "RemoveObject : ", GroupOp.GetErrorCode()
+def UnionList (theGroup, theSubShapes):
+ GroupOp.UnionList(theGroup, theSubShapes)
+ if GroupOp.IsDone() == 0:
+ print "UnionList : ", GroupOp.GetErrorCode()
+
+def UnionIDs(theGroup, theSubShapes):
+ GroupOp.UnionIDs(theGroup, theSubShapes)
+ if GroupOp.IsDone() == 0:
+ print "UnionIDs : ", GroupOp.GetErrorCode()
+
+def DifferenceList (theGroup, theSubShapes):
+ GroupOp.DifferenceList(theGroup, theSubShapes)
+ if GroupOp.IsDone() == 0:
+ print "DifferenceList : ", GroupOp.GetErrorCode()
+
+def DifferenceIDs(theGroup, theSubShapes):
+ GroupOp.DifferenceIDs(theGroup, theSubShapes)
+ if GroupOp.IsDone() == 0:
+ print "DifferenceIDs : ", GroupOp.GetErrorCode()
+
def GetObjectIDs(Group):
ListIDs = GroupOp.GetObjects(Group)
if GroupOp.IsDone() == 0:
print "GetObjectIDs : ", GroupOp.GetErrorCode()
return ListIDs
+def GetType(theGroup):
+ aType = GroupOp.GetType(theGroup)
+ if GroupOp.IsDone() == 0:
+ print "GetType : ", GroupOp.GetErrorCode()
+ return aType
+
+def GetMainShape(theGroup):
+ anObj = GroupOp.GetMainShape(theGroup)
+ if GroupOp.IsDone() == 0:
+ print "GetMainShape : ", GroupOp.GetErrorCode()
+ return anObj
+
+def GetEdgesByLength (theShape, min_length, max_length, include_min = 1, include_max = 1):
+ """
+ Create group of edges of theShape, whose length is in range [min_length, max_length].
+ If include_min/max == 0, edges with length == min/max_length will not be included in result.
+ """
+
+ edges = SubShapeAll(theShape, ShapeType["EDGE"])
+ edges_in_range = []
+ for edge in edges:
+ Props = BasicProperties(edge)
+ if min_length <= Props[0] and Props[0] <= max_length:
+ if (not include_min) and (min_length == Props[0]):
+ skip = 1
+ else:
+ if (not include_max) and (Props[0] == max_length):
+ skip = 1
+ else:
+ edges_in_range.append(edge)
+
+ if len(edges_in_range) <= 0:
+ print "No edges found by given criteria"
+ return 0
+
+ group_edges = CreateGroup(theShape, ShapeType["EDGE"])
+ UnionList(group_edges, edges_in_range)
+
+ return group_edges
+
+# Add Path to the system path
+#
def addPath(Path):
if (sys.path.count(Path) < 1):
sys.path.append(Path)