1 # GEOM GEOM_SWIG : binding of C++ omplementaion with Python
3 # Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 # Author : Paul RASCLE, EDF
29 from batchmode_salome import *
35 sleeping_time_max = 1.0
37 g = lcc.FindOrLoadComponent("FactoryServer", "GEOM")
38 if g is not None: break
41 time.sleep(sleeping_time)
42 sleeping_time = max(sleeping_time_max, 2*sleeping_time)
44 geom = g._narrow( GEOM.GEOM_Gen )
63 def init_geom(theStudy):
65 global myStudy, myBuilder, myStudyId, BasicOp, CurvesOp, PrimOp, ShapesOp, HealOp
66 global InsertOp, BoolOp, TrsfOp, LocalOp, MeasuOp, BlocksOp, GroupOp, father
69 myStudyId = myStudy._get_StudyId()
70 myBuilder = myStudy.NewBuilder()
71 father = myStudy.FindComponent("GEOM")
73 father = myBuilder.NewComponent("GEOM")
74 A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName")
75 FName = A1._narrow(SALOMEDS.AttributeName)
76 FName.SetValue("Geometry")
77 A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap")
78 aPixmap = A2._narrow(SALOMEDS.AttributePixMap)
79 aPixmap.SetPixMap("ICON_OBJBROWSER_Geometry")
80 myBuilder.DefineComponentInstance(father,geom)
83 # -----------------------------------------------------------------------------
84 # Assign Operations Interfaces
85 # -----------------------------------------------------------------------------
87 BasicOp = geom.GetIBasicOperations (myStudyId)
88 CurvesOp = geom.GetICurvesOperations (myStudyId)
89 PrimOp = geom.GetI3DPrimOperations (myStudyId)
90 ShapesOp = geom.GetIShapesOperations (myStudyId)
91 HealOp = geom.GetIHealingOperations (myStudyId)
92 InsertOp = geom.GetIInsertOperations (myStudyId)
93 BoolOp = geom.GetIBooleanOperations (myStudyId)
94 TrsfOp = geom.GetITransformOperations(myStudyId)
95 LocalOp = geom.GetILocalOperations (myStudyId)
96 MeasuOp = geom.GetIMeasureOperations (myStudyId)
97 BlocksOp = geom.GetIBlocksOperations (myStudyId)
98 GroupOp = geom.GetIGroupOperations (myStudyId)
103 # * Get name for sub-shape aSubObj of shape aMainObj
105 def SubShapeName(aSubObj, aMainObj):
110 # * Publish in study aShape with name aName
112 def addToStudy(aShape, aName):
114 aSObject = geom.AddInStudy(myStudy, aShape, aName, None)
116 print "addToStudy() failed"
118 return aShape.GetStudyEntry()
120 # * Publish in study aShape with name aName as sub-object of previously published aFather
122 def addToStudyInFather(aFather, aShape, aName):
124 aSObject = geom.AddInStudy(myStudy, aShape, aName, aFather)
126 print "addToStudyInFather() failed"
128 return aShape.GetStudyEntry()
130 # -----------------------------------------------------------------------------
131 # enumeration ShapeType as a dictionary
132 # -----------------------------------------------------------------------------
134 ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
136 # -----------------------------------------------------------------------------
138 # -----------------------------------------------------------------------------
140 def MakeVertex(theX, theY, theZ):
141 anObj = BasicOp.MakePointXYZ(theX, theY, theZ)
142 if BasicOp.IsDone() == 0:
143 print "MakePointXYZ : ", BasicOp.GetErrorCode()
146 def MakeVertexWithRef(vertex,x,y,z):
147 anObj = BasicOp.MakePointWithReference(vertex,x,y,z)
148 if BasicOp.IsDone() == 0:
149 print "MakePointWithReference : ", BasicOp.GetErrorCode()
152 def MakeVertexOnCurve(curve,par):
153 anObj = BasicOp.MakePointOnCurve(curve,par)
154 if BasicOp.IsDone() == 0:
155 print "MakePointOnCurve : ", BasicOp.GetErrorCode()
158 def MakeVertexOnLinesIntersection(line1,line2):
159 anObj = BasicOp.MakePointOnLinesIntersection(line1,line2)
160 if BasicOp.IsDone() == 0:
161 print "MakePointOnLinesIntersection : ", BasicOp.GetErrorCode()
164 def MakeVectorDXDYDZ(dx,dy,dz):
165 anObj = BasicOp.MakeVectorDXDYDZ(dx,dy,dz)
166 if BasicOp.IsDone() == 0:
167 print "MakeVectorDXDYDZ : ", BasicOp.GetErrorCode()
170 def MakeVector(p1,p2):
171 anObj = BasicOp.MakeVectorTwoPnt(p1, p2)
172 if BasicOp.IsDone() == 0:
173 print "MakeVectorTwoPnt : ", BasicOp.GetErrorCode()
176 def MakeLine(p1, d1):
177 anObj = BasicOp.MakeLine(p1,d1)
178 if BasicOp.IsDone() == 0:
179 print "MakeLine : ", BasicOp.GetErrorCode()
182 def MakeLineTwoPnt(p1, p2):
183 anObj = BasicOp.MakeLineTwoPnt(p1,p2)
184 if BasicOp.IsDone() == 0:
185 print "MakeLineTwoPnt : ", BasicOp.GetErrorCode()
188 def MakeLineTwoFaces(f1, f2):
189 anObj = BasicOp.MakeLineTwoFaces(f1,f2)
190 if BasicOp.IsDone() == 0:
191 print "MakeLineTwoFaces : ", BasicOp.GetErrorCode()
194 def MakePlane(p1,v1,trimsize):
195 anObj = BasicOp.MakePlanePntVec(p1,v1,trimsize)
196 if BasicOp.IsDone() == 0:
197 print "MakePlanePntVec : ", BasicOp.GetErrorCode()
200 def MakePlaneThreePnt(p1,p2,p3,trimsize):
201 anObj = BasicOp.MakePlaneThreePnt(p1,p2,p3,trimsize)
202 if BasicOp.IsDone() == 0:
203 print "MakePlaneThreePnt : ", BasicOp.GetErrorCode()
206 def MakePlaneFace(face,trimsize):
207 anObj = BasicOp.MakePlaneFace(face,trimsize)
208 if BasicOp.IsDone() == 0:
209 print "MakePlaneFace : ", BasicOp.GetErrorCode()
212 def MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ):
213 anObj = BasicOp.MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ)
214 if BasicOp.IsDone() == 0:
215 print "MakeMarker : ", BasicOp.GetErrorCode()
218 def MakeMarkerPntTwoVec(theOrigin, theXVec, theYVec):
220 * Create a local coordinate system.
221 * \param theOrigin Point of coordinate system origin.
222 * \param theXVec Vector of X direction
223 * \param theYVec Vector of Y direction
224 * \return New GEOM_Object, containing the created coordinate system.
226 O = PointCoordinates( theOrigin )
228 for vec in [ theXVec, theYVec ]:
229 v1, v2 = SubShapeAll( vec, ShapeType["VERTEX"] )
230 p1 = PointCoordinates( v1 )
231 p2 = PointCoordinates( v2 )
232 for i in range( 0, 3 ):
233 OXOY.append( p2[i] - p1[i] )
235 anObj = BasicOp.MakeMarker( O[0], O[1], O[2],
236 OXOY[0], OXOY[1], OXOY[2],
237 OXOY[3], OXOY[4], OXOY[5], )
238 if BasicOp.IsDone() == 0:
239 print "MakeMarker : ", BasicOp.GetErrorCode()
242 # -----------------------------------------------------------------------------
244 # -----------------------------------------------------------------------------
246 def MakeArc(p1,p2,p3):
247 anObj = CurvesOp.MakeArc(p1,p2,p3)
248 if CurvesOp.IsDone() == 0:
249 print "MakeArc : ", CurvesOp.GetErrorCode()
252 def MakeCircle(p1,v1,radius):
253 anObj = CurvesOp.MakeCirclePntVecR(p1,v1,radius)
254 if CurvesOp.IsDone() == 0:
255 print "MakeCirclePntVecR : ", CurvesOp.GetErrorCode()
258 def MakeCircleThreePnt(p1,p2,p3):
259 anObj = CurvesOp.MakeCircleThreePnt(p1,p2,p3)
260 if CurvesOp.IsDone() == 0:
261 print "MakeCircleThreePnt : ", CurvesOp.GetErrorCode()
264 def MakeCircleCenter2Pnt(p1,p2,p3):
265 anObj = CurvesOp.MakeCircleCenter2Pnt(p1,p2,p3)
266 if CurvesOp.IsDone() == 0:
267 print "MakeCircleCenter2Pnt : ", CurvesOp.GetErrorCode()
270 def MakeEllipse(p1,v1,radiusMaj,radiusMin):
271 anObj = CurvesOp.MakeEllipse(p1,v1,radiusMaj, radiusMin)
272 if CurvesOp.IsDone() == 0:
273 print "MakeEllipse : ", CurvesOp.GetErrorCode()
276 def MakePolyline(ListShape):
277 anObj = CurvesOp.MakePolyline(ListShape)
278 if CurvesOp.IsDone() == 0:
279 print "MakePolyline : ", CurvesOp.GetErrorCode()
282 def MakeBezier(ListShape):
283 anObj = CurvesOp.MakeSplineBezier(ListShape)
284 if CurvesOp.IsDone() == 0:
285 print "MakeSplineBezier : ", CurvesOp.GetErrorCode()
288 def MakeInterpol(ListShape):
289 anObj = CurvesOp.MakeSplineInterpolation(ListShape)
290 if CurvesOp.IsDone() == 0:
291 print "MakeSplineInterpolation : ", CurvesOp.GetErrorCode()
294 # <WPL>: Nine double values, defining origin,
295 # OZ and OX directions of the working plane.
296 def MakeSketcher(Cmd, WPL = [0,0,0, 0,0,1, 1,0,0]):
297 anObj = CurvesOp.MakeSketcher(Cmd, WPL)
298 if CurvesOp.IsDone() == 0:
299 print "MakeSketcher : ", CurvesOp.GetErrorCode()
302 def MakeSketcherOnPlane(theCommand, theWorkingPlane):
304 * Create a sketcher (wire or face), following the textual description,
305 * passed through \a theCommand argument. \n
306 * For format of the description string see the previous method.\n
307 * \param theCommand String, defining the sketcher in local
308 * coordinates of the working plane.
309 * \param theWorkingPlane Planar Face of the working plane.
310 * \return New GEOM_Object, containing the created wire.
312 anObj = CurvesOp.MakeSketcherOnPlane(theCommand, theWorkingPlane)
313 if CurvesOp.IsDone() == 0:
314 print "MakeSketcher : ", CurvesOp.GetErrorCode()
317 # -----------------------------------------------------------------------------
318 # Create 3D Primitives
319 # -----------------------------------------------------------------------------
321 def MakeBox(x1,y1,z1,x2,y2,z2):
322 pnt1 = MakeVertex(x1,y1,z1)
323 pnt2 = MakeVertex(x2,y2,z2)
324 return MakeBoxTwoPnt(pnt1,pnt2)
326 def MakeBoxDXDYDZ(dx,dy,dz):
327 anObj = PrimOp.MakeBoxDXDYDZ(dx,dy,dz)
328 if PrimOp.IsDone() == 0:
329 print "MakeBoxDXDYDZ : ", PrimOp.GetErrorCode()
332 def MakeBoxTwoPnt(point1, point2):
333 anObj = PrimOp.MakeBoxTwoPnt(point1, point2)
334 if PrimOp.IsDone() == 0:
335 print "MakeBoxTwoPnt : ", PrimOp.GetErrorCode()
338 def MakeCylinder(p1,v1,radius,height):
339 anObj = PrimOp.MakeCylinderPntVecRH(p1,v1,radius,height)
340 if PrimOp.IsDone() == 0:
341 print "MakeCylinderPntVecRH : ", PrimOp.GetErrorCode()
344 def MakeCylinderRH(radius,height):
345 anObj = PrimOp.MakeCylinderRH(radius,height)
346 if PrimOp.IsDone() == 0:
347 print "MakeCylinderRH : ", PrimOp.GetErrorCode()
350 def MakeSpherePntR(point,radius):
351 anObj = PrimOp.MakeSpherePntR(point,radius)
352 if PrimOp.IsDone() == 0:
353 print "MakeSpherePntR : ", PrimOp.GetErrorCode()
356 def MakeSphere(x,y,z,radius):
357 point = MakeVertex(x,y,z)
358 anObj = MakeSpherePntR(point,radius)
361 def MakeSphereR(radius):
362 anObj = PrimOp.MakeSphereR(radius)
363 if PrimOp.IsDone() == 0:
364 print "MakeSphereR : ", PrimOp.GetErrorCode()
367 def MakeCone(p1,v1,radius1,radius2,height):
368 anObj = PrimOp.MakeConePntVecR1R2H(p1,v1,radius1,radius2,height)
369 if PrimOp.IsDone() == 0:
370 print "MakeConePntVecR1R2H : ", PrimOp.GetErrorCode()
373 def MakeConeR1R2H(radius1,radius2,height):
374 anObj = PrimOp.MakeConeR1R2H(radius1,radius2,height)
375 if PrimOp.IsDone() == 0:
376 print "MakeConeR1R2H : ", PrimOp.GetErrorCode()
379 def MakeTorus(p1,v1,major_radius,minor_radius):
380 anObj = PrimOp.MakeTorusPntVecRR(p1,v1,major_radius,minor_radius)
381 if PrimOp.IsDone() == 0:
382 print "MakeTorusPntVecRR : ", PrimOp.GetErrorCode()
385 def MakeTorusRR(major_radius,minor_radius):
386 anObj = PrimOp.MakeTorusRR(major_radius,minor_radius)
387 if PrimOp.IsDone() == 0:
388 print "MakeTorusRR : ", PrimOp.GetErrorCode()
391 def MakePrism(baseShape,point1,point2):
392 anObj = PrimOp.MakePrismTwoPnt(baseShape,point1,point2)
393 if PrimOp.IsDone() == 0:
394 print "MakePrismTwoPnt : ", PrimOp.GetErrorCode()
397 def MakePrismVecH(baseShape,vector,height):
398 anObj = PrimOp.MakePrismVecH(baseShape,vector,height)
399 if PrimOp.IsDone() == 0:
400 print "MakePrismVecH : ", PrimOp.GetErrorCode()
403 def MakePipe(baseShape,pathShape):
404 anObj = PrimOp.MakePipe(baseShape,pathShape)
405 if PrimOp.IsDone() == 0:
406 print "MakePipe : ", PrimOp.GetErrorCode()
409 def MakeRevolution(aShape,axis,angle):
410 anObj = PrimOp.MakeRevolutionAxisAngle(aShape,axis,angle)
411 if PrimOp.IsDone() == 0:
412 print "MakeRevolutionAxisAngle : ", PrimOp.GetErrorCode()
415 # -----------------------------------------------------------------------------
417 # -----------------------------------------------------------------------------
420 anObj = ShapesOp.MakeEdge(p1,p2)
421 if ShapesOp.IsDone() == 0:
422 print "MakeEdge : ", ShapesOp.GetErrorCode()
425 def MakeWire(ListShape):
426 anObj = ShapesOp.MakeWire(ListShape)
427 if ShapesOp.IsDone() == 0:
428 print "MakeWire : ", ShapesOp.GetErrorCode()
431 def MakeFace(aShapeWire,WantPlanarFace):
432 anObj = ShapesOp.MakeFace(aShapeWire,WantPlanarFace)
433 if ShapesOp.IsDone() == 0:
434 print "MakeFace : ", ShapesOp.GetErrorCode()
437 def MakeFaceWires(ListWires,WantPlanarFace):
438 anObj = ShapesOp.MakeFaceWires(ListWires,WantPlanarFace)
439 if ShapesOp.IsDone() == 0:
440 print "MakeFaceWires : ", ShapesOp.GetErrorCode()
443 def MakeFaces(ListWires,WantPlanarFace):
444 anObj = MakeFaceWires(ListWires,WantPlanarFace)
447 def MakeShell(ListOfShapes):
448 anObj = ShapesOp.MakeShell(ListOfShapes)
449 if ShapesOp.IsDone() == 0:
450 print "MakeShell : ", ShapesOp.GetErrorCode()
453 def MakeSolid(ListOfShells):
454 anObj = ShapesOp.MakeSolidShells(ListOfShells)
455 if ShapesOp.IsDone() == 0:
456 print "MakeSolid : ", ShapesOp.GetErrorCode()
459 def MakeCompound(ListShape):
460 anObj = ShapesOp.MakeCompound(ListShape)
461 if ShapesOp.IsDone() == 0:
462 print "MakeCompound : ", ShapesOp.GetErrorCode()
465 def NumberOfFaces(theShape):
466 nb_faces = ShapesOp.NumberOfFaces(theShape)
467 if ShapesOp.IsDone() == 0:
468 print "NumberOfFaces : ", ShapesOp.GetErrorCode()
471 def NumberOfEdges(theShape):
472 nb_edges = ShapesOp.NumberOfEdges(theShape)
473 if ShapesOp.IsDone() == 0:
474 print "NumberOfEdges : ", ShapesOp.GetErrorCode()
477 def ChangeOrientation(Shape):
478 anObj = ShapesOp.ChangeOrientation(Shape)
479 if ShapesOp.IsDone() == 0:
480 print "ChangeOrientation : ", ShapesOp.GetErrorCode()
483 def OrientationChange(Shape):
484 anObj = ChangeOrientation(Shape)
487 def GetFreeFacesIDs(theShape):
488 anIDs = ShapesOp.GetFreeFacesIDs(theShape)
489 if ShapesOp.IsDone() == 0:
490 print "GetFreeFacesIDs : ", ShapesOp.GetErrorCode()
493 def GetSharedShapes(theShape1, theShape2, theShapeType):
494 aList = ShapesOp.GetSharedShapes(theShape1, theShape2, theShapeType)
495 if ShapesOp.IsDone() == 0:
496 print "GetSharedShapes : ", ShapesOp.GetErrorCode()
499 def GetShapesOnPlane(theShape, theShapeType, theAx1, theState):
500 aList = ShapesOp.GetShapesOnPlane(theShape, theShapeType, theAx1, theState)
501 if ShapesOp.IsDone() == 0:
502 print "GetShapesOnPlane : ", ShapesOp.GetErrorCode()
505 def GetShapesOnPlaneIDs(theShape, theShapeType, theAx1, theState):
506 aList = ShapesOp.GetShapesOnPlaneIDs(theShape, theShapeType, theAx1, theState)
507 if ShapesOp.IsDone() == 0:
508 print "GetShapesOnPlaneIDs : ", ShapesOp.GetErrorCode()
511 def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState):
512 aList = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState)
513 if ShapesOp.IsDone() == 0:
514 print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode()
517 def GetShapesOnCylinderIDs(theShape, theShapeType, theAxis, theRadius, theState):
518 aList = ShapesOp.GetShapesOnCylinderIDs(theShape, theShapeType, theAxis, theRadius, theState)
519 if ShapesOp.IsDone() == 0:
520 print "GetShapesOnCylinderIDs : ", ShapesOp.GetErrorCode()
523 def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState):
524 aList = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState)
525 if ShapesOp.IsDone() == 0:
526 print "GetShapesOnSphere : ", ShapesOp.GetErrorCode()
529 def GetShapesOnSphereIDs(theShape, theShapeType, theCenter, theRadius, theState):
530 aList = ShapesOp.GetShapesOnSphereIDs(theShape, theShapeType, theCenter, theRadius, theState)
531 if ShapesOp.IsDone() == 0:
532 print "GetShapesOnSphereIDs : ", ShapesOp.GetErrorCode()
535 def GetShapesOnQuadrangle(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState):
536 aList = ShapesOp.GetShapesOnQuadrangle(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState)
537 if ShapesOp.IsDone() == 0:
538 print "GetShapesOnQuadrangle : ", ShapesOp.GetErrorCode()
541 def GetShapesOnQuadrangleIDs(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState):
542 aList = ShapesOp.GetShapesOnQuadrangleIDs(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState)
543 if ShapesOp.IsDone() == 0:
544 print "GetShapesOnQuadrangleIDs : ", ShapesOp.GetErrorCode()
547 def GetInPlace(theShapeWhere, theShapeWhat):
548 anObj = ShapesOp.GetInPlace(theShapeWhere, theShapeWhat)
549 if ShapesOp.IsDone() == 0:
550 print "GetInPlace : ", ShapesOp.GetErrorCode()
553 # -----------------------------------------------------------------------------
554 # Access to sub-shapes by their unique IDs inside the main shape.
555 # -----------------------------------------------------------------------------
557 # Obtain a composite sub-shape of <aShape>, composed from sub-shapes
558 # of <aShape>, selected by their unique IDs inside <aShape>
559 def GetSubShape(aShape, ListOfID):
560 anObj = geom.AddSubShape(aShape,ListOfID)
563 # Obtain unique ID of sub-shape <aSubShape> inside <aShape>
564 def GetSubShapeID(aShape, aSubShape):
565 anID = LocalOp.GetSubShapeIndex(aShape, aSubShape)
566 if LocalOp.IsDone() == 0:
567 print "GetSubShapeIndex : ", LocalOp.GetErrorCode()
570 # -----------------------------------------------------------------------------
572 # -----------------------------------------------------------------------------
574 def SubShapeAll(aShape, aType):
575 ListObj = ShapesOp.MakeExplode(aShape,aType,0)
576 if ShapesOp.IsDone() == 0:
577 print "MakeExplode : ", ShapesOp.GetErrorCode()
580 def SubShapeAllIDs(aShape, aType):
581 ListObj = ShapesOp.SubShapeAllIDs(aShape,aType,0)
582 if ShapesOp.IsDone() == 0:
583 print "SubShapeAllIDs : ", ShapesOp.GetErrorCode()
586 def SubShapeAllSorted(aShape, aType):
587 ListObj = ShapesOp.MakeExplode(aShape,aType,1)
588 if ShapesOp.IsDone() == 0:
589 print "MakeExplode : ", ShapesOp.GetErrorCode()
592 def SubShapeAllSortedIDs(aShape, aType):
593 ListIDs = ShapesOp.SubShapeAllIDs(aShape,aType,1)
594 if ShapesOp.IsDone() == 0:
595 print "SubShapeAllSortedIDs : ", ShapesOp.GetErrorCode()
598 # Obtain a compound of sub-shapes of <aShape>,
599 # selected by they indices in list of all sub-shapes of type <aType>
600 def SubShape(aShape, aType, ListOfInd):
602 AllShapeList = SubShapeAll(aShape, aType)
603 for ind in ListOfInd:
604 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
605 anObj = GetSubShape(aShape, ListOfIDs)
608 # Obtain a compound of sub-shapes of <aShape>,
609 # selected by they indices in sorted list of all sub-shapes of type <aType>
610 def SubShapeSorted(aShape, aType, ListOfInd):
612 AllShapeList = SubShapeAllSorted(aShape, aType)
613 for ind in ListOfInd:
614 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
615 anObj = GetSubShape(aShape, ListOfIDs)
618 # -----------------------------------------------------------------------------
620 # -----------------------------------------------------------------------------
622 def ProcessShape(Shape, Operators, Parameters, Values):
623 anObj = HealOp.ProcessShape(Shape, Operators, Parameters, Values)
624 if HealOp.IsDone() == 0:
625 print "ProcessShape : ", HealOp.GetErrorCode()
628 def SuppressFaces(aShape,ListOfId):
629 anObj = HealOp.SuppressFaces(aShape,ListOfId)
630 if HealOp.IsDone() == 0:
631 print "SuppressFaces : ", HealOp.GetErrorCode()
634 def MakeSewing(ListShape,precision):
635 comp = MakeCompound(ListShape)
636 anObj = Sew(comp,precision)
639 def Sew(aShape,precision):
640 anObj = HealOp.Sew(aShape,precision)
641 if HealOp.IsDone() == 0:
642 print "Sew : ", HealOp.GetErrorCode()
645 def SuppressInternalWires(aShape, Wires):
646 anObj = HealOp.RemoveIntWires(aShape, Wires)
647 if HealOp.IsDone() == 0:
648 print "SuppressInternalWires : ", HealOp.GetErrorCode()
651 def SuppressHoles(aShape, ListOfId):
652 anObj = HealOp.FillHoles(aShape,ListOfId)
653 if HealOp.IsDone() == 0:
654 print "SuppressHoles : ", HealOp.GetErrorCode()
657 def CloseContour(aShape, Wires, IsCommonVertex):
658 anObj = HealOp.CloseContour(aShape, Wires, IsCommonVertex)
659 if HealOp.IsDone() == 0:
660 print "CloseContour : ", HealOp.GetErrorCode()
663 def DivideEdge(aShape, EdgeID, Value, IsByParameter):
664 anObj = HealOp.DivideEdge(aShape, EdgeID, Value, IsByParameter)
665 if HealOp.IsDone() == 0:
666 print "DivideEdge : ", HealOp.GetErrorCode()
669 def GetFreeBoundary(Shape):
670 anObj = HealOp.GetFreeBoundary(Shape)
671 if HealOp.IsDone() == 0:
672 print "GetFreeBoundaries : ", HealOp.GetErrorCode()
675 # -----------------------------------------------------------------------------
676 # Create advanced objects
677 # -----------------------------------------------------------------------------
679 def MakeCopy(aShape):
680 anObj = InsertOp.MakeCopy(aShape)
681 if InsertOp.IsDone() == 0:
682 print "MakeCopy : ", InsertOp.GetErrorCode()
685 def MakeFilling(aShape,mindeg,maxdeg,tol2d,tol3d,nbiter):
686 anObj = PrimOp.MakeFilling(aShape,mindeg,maxdeg,tol2d,tol3d,nbiter)
687 if PrimOp.IsDone() == 0:
688 print "MakeFilling : ", PrimOp.GetErrorCode()
691 def MakeGlueFaces(aShape,aTolerance):
692 anObj = ShapesOp.MakeGlueFaces(aShape,aTolerance)
693 if ShapesOp.IsDone() == 0:
694 print "MakeGlueFaces : ", ShapesOp.GetErrorCode()
697 # -----------------------------------------------------------------------------
698 # Boolean (Common, Cut, Fuse, Section)
699 # -----------------------------------------------------------------------------
701 def MakeBoolean(shape1,shape2,operation):
702 anObj = BoolOp.MakeBoolean(shape1,shape2,operation)
703 if BoolOp.IsDone() == 0:
704 print "MakeBoolean : ", BoolOp.GetErrorCode()
707 def MakeCommon(s1, s2):
708 return MakeBoolean(s1, s2, 1)
711 return MakeBoolean(s1, s2, 2)
713 def MakeFuse(s1, s2):
714 return MakeBoolean(s1, s2, 3)
716 def MakeSection(s1, s2):
717 return MakeBoolean(s1, s2, 4)
719 def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
720 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[],
721 KeepNonlimitShapes=0):
722 anObj = BoolOp.MakePartition(ListShapes, ListTools,
723 ListKeepInside, ListRemoveInside,
724 Limit, RemoveWebs, ListMaterials,
726 if BoolOp.IsDone() == 0:
727 print "MakePartition : ", BoolOp.GetErrorCode()
730 def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
731 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[],
732 KeepNonlimitShapes=0):
733 anObj = MakePartition(ListShapes, ListTools,
734 ListKeepInside, ListRemoveInside,
735 Limit, RemoveWebs, ListMaterials,
739 def MakeHalfPartition(theShape, thePlane):
740 anObj = BoolOp.MakeHalfPartition(theShape, thePlane)
741 if BoolOp.IsDone() == 0:
742 print "MakeHalfPartition : ", BoolOp.GetErrorCode()
745 # -----------------------------------------------------------------------------
747 # -----------------------------------------------------------------------------
749 def MakeTranslationTwoPoints(aShape,point1,point2):
750 anObj = TrsfOp.TranslateTwoPointsCopy(aShape,point1,point2)
751 if TrsfOp.IsDone() == 0:
752 print "TranslateTwoPointsCopy : ", TrsfOp.GetErrorCode()
755 def MakeTranslation(aShape,dx,dy,dz):
756 anObj = TrsfOp.TranslateDXDYDZCopy(aShape,dx,dy,dz)
757 if TrsfOp.IsDone() == 0:
758 print "TranslateDXDYDZCopy : ", TrsfOp.GetErrorCode()
761 def MakeTranslationVector(theObject, theVector):
762 anObj = TrsfOp.TranslateVectorCopy(theObject, theVector)
763 if TrsfOp.IsDone() == 0:
764 print "TranslateVectorCopy : ", TrsfOp.GetErrorCode()
767 def MakeRotation(aShape,axis,angle):
768 anObj = TrsfOp.RotateCopy(aShape,axis,angle)
769 if TrsfOp.IsDone() == 0:
770 print "RotateCopy : ", TrsfOp.GetErrorCode()
773 def MakeRotationThreePoints(aShape, centpoint, point1, point2):
774 anObj = TrsfOp.RotateThreePointsCopy(aShape, centpoint, point1, point2)
775 if TrsfOp.IsDone() == 0:
776 print "RotateThreePointsCopy : ", TrsfOp.GetErrorCode()
779 def MakeScaleTransform(aShape,theCenterofScale,factor):
780 anObj = TrsfOp.ScaleShapeCopy(aShape,theCenterofScale,factor)
781 if TrsfOp.IsDone() == 0:
782 print "ScaleShapeCopy : ", TrsfOp.GetErrorCode()
785 def MakeMirrorByPlane(aShape,aPlane):
786 anObj = TrsfOp.MirrorPlaneCopy(aShape,aPlane)
787 if TrsfOp.IsDone() == 0:
788 print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode()
791 def MakeMirrorByAxis(theObject, theAxis):
792 anObj = TrsfOp.MirrorAxisCopy(theObject, theAxis)
793 if TrsfOp.IsDone() == 0:
794 print "MirrorAxisCopy : ", TrsfOp.GetErrorCode()
797 def MakeMirrorByPoint(theObject, thePoint):
798 anObj = TrsfOp.MirrorPointCopy(theObject, thePoint)
799 if TrsfOp.IsDone() == 0:
800 print "MirrorPointCopy : ", TrsfOp.GetErrorCode()
803 def MakePosition(aShape,theStartLCS,theEndLCS):
804 anObj = TrsfOp.PositionShapeCopy(aShape,theStartLCS,theEndLCS)
805 if TrsfOp.IsDone() == 0:
806 print "PositionShapeCopy : ", TrsfOp.GetErrorCode()
809 def MakeOffset(aShape, anOffset):
810 anObj = TrsfOp.OffsetShapeCopy(aShape, anOffset)
811 if TrsfOp.IsDone() == 0:
812 print "OffsetShapeCopy : ", TrsfOp.GetErrorCode()
815 # -----------------------------------------------------------------------------
817 # -----------------------------------------------------------------------------
819 def MakeMultiTranslation1D(aShape,aDir,aStep,aNbTimes):
820 anObj = TrsfOp.MultiTranslate1D(aShape,aDir,aStep,aNbTimes)
821 if TrsfOp.IsDone() == 0:
822 print "MultiTranslate1D : ", TrsfOp.GetErrorCode()
825 def MakeMultiTranslation2D(aShape,d1,step1,nbtimes1,d2,step2,nbtimes2):
826 anObj = TrsfOp.MultiTranslate2D(aShape,d1,step1,nbtimes1,d2,step2,nbtimes2)
827 if TrsfOp.IsDone() == 0:
828 print "MultiTranslate2D : ", TrsfOp.GetErrorCode()
831 def MultiRotate1D(aShape,aVec,aNbTimes):
832 anObj = TrsfOp.MultiRotate1D(aShape,aVec,aNbTimes)
833 if TrsfOp.IsDone() == 0:
834 print "MultiRotate1D : ", TrsfOp.GetErrorCode()
837 def MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2):
838 anObj = TrsfOp.MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
839 if TrsfOp.IsDone() == 0:
840 print "MultiRotate2D : ", TrsfOp.GetErrorCode()
843 def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes):
844 aVec = MakeLine(aPoint,aDir)
845 anObj = MultiRotate1D(aShape,aVec,aNbTimes)
848 def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2):
849 aVec = MakeLine(aPoint,aDir)
850 anObj = MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
853 # -----------------------------------------------------------------------------
855 # -----------------------------------------------------------------------------
857 def MakeFilletAll(aShape,radius):
858 anObj = LocalOp.MakeFilletAll(aShape,radius)
859 if LocalOp.IsDone() == 0:
860 print "MakeFilletAll : ", LocalOp.GetErrorCode()
863 def MakeFillet(aShape,radius,aShapeType,ListShape):
865 if aShapeType == ShapeType["EDGE"]:
866 anObj = LocalOp.MakeFilletEdges(aShape,radius,ListShape)
868 anObj = LocalOp.MakeFilletFaces(aShape,radius,ListShape)
869 if LocalOp.IsDone() == 0:
870 print "MakeFillet : ", LocalOp.GetErrorCode()
873 def MakeFilletR1R2(aShape,radius1,radius2,aShapeType,ListShape):
875 if aShapeType == ShapeType["EDGE"]:
876 anObj = LocalOp.MakeFilletEdgesR1R2(aShape,radius1,radius2,ListShape)
878 anObj = LocalOp.MakeFilletFacesR1R2(aShape,radius1,radius2,ListShape)
879 if LocalOp.IsDone() == 0:
880 print "MakeFilletR1R2 : ", LocalOp.GetErrorCode()
883 def MakeChamferAll(aShape,d):
884 anObj = LocalOp.MakeChamferAll(aShape,d)
885 if LocalOp.IsDone() == 0:
886 print "MakeChamferAll : ", LocalOp.GetErrorCode()
889 def MakeChamferEdge(aShape,d1,d2,face1,face2):
890 anObj = LocalOp.MakeChamferEdge(aShape,d1,d2,face1,face2)
891 if LocalOp.IsDone() == 0:
892 print "MakeChamferEdge : ", LocalOp.GetErrorCode()
895 def MakeChamferEdgeAD(aShape,d,angle,face1,face2):
896 anObj = LocalOp.MakeChamferEdgeAD(aShape,d,angle,face1,face2)
897 if LocalOp.IsDone() == 0:
898 print "MakeChamferEdgeAD : ", LocalOp.GetErrorCode()
901 def MakeChamferFaces(aShape,d1,d2,ListShape):
902 anObj = LocalOp.MakeChamferFaces(aShape,d1,d2,ListShape)
903 if LocalOp.IsDone() == 0:
904 print "MakeChamferFaces : ", LocalOp.GetErrorCode()
907 def MakeChamferFacesAD(aShape,d,angle,ListShape):
908 anObj = LocalOp.MakeChamferFacesAD(aShape,d,angle,ListShape)
909 if LocalOp.IsDone() == 0:
910 print "MakeChamferFacesAD : ", LocalOp.GetErrorCode()
913 def MakeChamferEdges(aShape,d1,d2,ListShape):
914 anObj = LocalOp.MakeChamferEdges(aShape,d1,d2,ListShape)
915 if LocalOp.IsDone() == 0:
916 print "MakeChamferEdges : ", LocalOp.GetErrorCode()
919 def MakeChamferEdgesAD(aShape,d,angle,ListShape):
920 anObj = LocalOp.MakeChamferEdgesAD(aShape,d,angle,ListShape)
921 if LocalOp.IsDone() == 0:
922 print "MakeChamferEdgesAD : ", LocalOp.GetErrorCode()
925 def MakeChamfer(aShape,d1,d2,aShapeType,ListShape):
927 if aShapeType == ShapeType["EDGE"]:
928 anObj = MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1])
930 anObj = MakeChamferFaces(aShape,d1,d2,ListShape)
933 def Archimede(aShape,weight,WaterDensity,MeshingDeflection):
934 anObj = LocalOp.MakeArchimede(aShape,weight,WaterDensity,MeshingDeflection)
935 if LocalOp.IsDone() == 0:
936 print "MakeArchimede : ", LocalOp.GetErrorCode()
939 # -----------------------------------------------------------------------------
940 # Information objects
941 # -----------------------------------------------------------------------------
943 def PointCoordinates(Point):
944 aTuple = MeasuOp.PointCoordinates(Point)
945 if MeasuOp.IsDone() == 0:
946 print "PointCoordinates : ", MeasuOp.GetErrorCode()
949 def BasicProperties(Shape):
950 aTuple = MeasuOp.GetBasicProperties(Shape)
951 if MeasuOp.IsDone() == 0:
952 print "BasicProperties : ", MeasuOp.GetErrorCode()
955 def BoundingBox(Shape):
956 aTuple = MeasuOp.GetBoundingBox(Shape)
957 if MeasuOp.IsDone() == 0:
958 print "BoundingBox : ", MeasuOp.GetErrorCode()
962 aTuple = MeasuOp.GetInertia(Shape)
963 if MeasuOp.IsDone() == 0:
964 print "Inertia : ", MeasuOp.GetErrorCode()
967 def MinDistance(Shape1, Shape2):
968 aTuple = MeasuOp.GetMinDistance(Shape1, Shape2)
969 if MeasuOp.IsDone() == 0:
970 print "MinDistance : ", MeasuOp.GetErrorCode()
973 def Tolerance(Shape):
974 aTuple = MeasuOp.GetTolerance(Shape)
975 if MeasuOp.IsDone() == 0:
976 print "Tolerance : ", MeasuOp.GetErrorCode()
980 aDescr = MeasuOp.WhatIs(Shape)
981 if MeasuOp.IsDone() == 0:
982 print "WhatIs : ", MeasuOp.GetErrorCode()
986 anObj = MeasuOp.GetCentreOfMass(aShape)
987 if MeasuOp.IsDone() == 0:
988 print "GetCentreOfMass : ", MeasuOp.GetErrorCode()
991 def CheckShape(theShape, theIsCheckGeom = 0):
993 (IsValid, Status) = MeasuOp.CheckShapeWithGeometry(theShape)
995 (IsValid, Status) = MeasuOp.CheckShape(theShape)
997 if MeasuOp.IsDone() == 0:
998 print "CheckShape : ", MeasuOp.GetErrorCode()
1004 # -----------------------------------------------------------------------------
1005 # Import/Export objects
1006 # -----------------------------------------------------------------------------
1008 def Import(filename, formatname):
1009 anObj = InsertOp.Import(filename, formatname)
1010 if InsertOp.IsDone() == 0:
1011 print "Import : ", InsertOp.GetErrorCode()
1014 def ImportBREP(theFileName):
1015 return Import(theFileName, "BREP")
1017 def ImportIGES(theFileName):
1018 return Import(theFileName, "IGES")
1020 def ImportSTEP(theFileName):
1021 return Import(theFileName, "STEP")
1023 def Export(aShape, filename, formatname):
1024 InsertOp.Export(aShape, filename, formatname)
1025 if InsertOp.IsDone() == 0:
1026 print "Export : ", InsertOp.GetErrorCode()
1028 def ExportBREP(theObject, theFileName):
1029 return Export(theObject, theFileName, "BREP")
1031 def ExportIGES(theObject, theFileName):
1032 return Export(theObject, theFileName, "IGES")
1034 def ExportSTEP(theObject, theFileName):
1035 return Export(theObject, theFileName, "STEP")
1037 # -----------------------------------------------------------------------------
1039 # -----------------------------------------------------------------------------
1041 def MakeQuad(E1, E2, E3, E4):
1042 anObj = BlocksOp.MakeQuad(E1, E2, E3, E4)
1043 if BlocksOp.IsDone() == 0:
1044 print "MakeQuad : ", BlocksOp.GetErrorCode()
1047 def MakeQuad2Edges(E1, E2):
1048 anObj = BlocksOp.MakeQuad2Edges(E1, E2)
1049 if BlocksOp.IsDone() == 0:
1050 print "MakeQuad2Edges : ", BlocksOp.GetErrorCode()
1053 def MakeQuad4Vertices(V1, V2, V3, V4):
1054 anObj = BlocksOp.MakeQuad4Vertices(V1, V2, V3, V4)
1055 if BlocksOp.IsDone() == 0:
1056 print "MakeQuad4Vertices : ", BlocksOp.GetErrorCode()
1059 def MakeHexa(F1, F2, F3, F4, F5, F6):
1060 anObj = BlocksOp.MakeHexa(F1, F2, F3, F4, F5, F6)
1061 if BlocksOp.IsDone() == 0:
1062 print "MakeHexa : ", BlocksOp.GetErrorCode()
1065 def MakeHexa2Faces(F1, F2):
1066 anObj = BlocksOp.MakeHexa2Faces(F1, F2)
1067 if BlocksOp.IsDone() == 0:
1068 print "MakeHexa2Faces : ", BlocksOp.GetErrorCode()
1071 def GetPoint(theShape, theX, theY, theZ, theEpsilon):
1072 anObj = BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon)
1073 if BlocksOp.IsDone() == 0:
1074 print "GetPoint : ", BlocksOp.GetErrorCode()
1077 def GetEdge(theShape, thePoint1, thePoint2):
1078 anObj = BlocksOp.GetEdge(theShape, thePoint1, thePoint2)
1079 if BlocksOp.IsDone() == 0:
1080 print "GetEdge : ", BlocksOp.GetErrorCode()
1083 def GetEdgeNearPoint(theShape, thePoint):
1084 anObj = BlocksOp.GetEdgeNearPoint(theShape, thePoint)
1085 if BlocksOp.IsDone() == 0:
1086 print "GetEdgeNearPoint : ", BlocksOp.GetErrorCode()
1089 def GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4):
1090 anObj = BlocksOp.GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4)
1091 if BlocksOp.IsDone() == 0:
1092 print "GetFaceByPoints : ", BlocksOp.GetErrorCode()
1095 def GetFaceByEdges(theShape, theEdge1, theEdge2):
1096 anObj = BlocksOp.GetFaceByEdges(theShape, theEdge1, theEdge2)
1097 if BlocksOp.IsDone() == 0:
1098 print "GetFaceByEdges : ", BlocksOp.GetErrorCode()
1101 def GetOppositeFace(theBlock, theFace):
1102 anObj = BlocksOp.GetOppositeFace(theBlock, theFace)
1103 if BlocksOp.IsDone() == 0:
1104 print "GetOppositeFace : ", BlocksOp.GetErrorCode()
1107 def GetFaceNearPoint(theShape, thePoint):
1108 anObj = BlocksOp.GetFaceNearPoint(theShape, thePoint)
1109 if BlocksOp.IsDone() == 0:
1110 print "GetFaceNearPoint : ", BlocksOp.GetErrorCode()
1113 def GetFaceByNormale(theBlock, theVector):
1114 anObj = BlocksOp.GetFaceByNormale(theBlock, theVector)
1115 if BlocksOp.IsDone() == 0:
1116 print "GetFaceByNormale : ", BlocksOp.GetErrorCode()
1119 def CheckCompoundOfBlocks(theCompound):
1120 (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(theCompound)
1121 if BlocksOp.IsDone() == 0:
1122 print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode()
1125 Descr = BlocksOp.PrintBCErrors(theCompound, BCErrors)
1129 def RemoveExtraEdges(theShape):
1130 anObj = BlocksOp.RemoveExtraEdges(theShape)
1131 if BlocksOp.IsDone() == 0:
1132 print "RemoveExtraEdges : ", BlocksOp.GetErrorCode()
1135 def CheckAndImprove(theShape):
1136 anObj = BlocksOp.CheckAndImprove(theShape)
1137 if BlocksOp.IsDone() == 0:
1138 print "CheckAndImprove : ", BlocksOp.GetErrorCode()
1141 def MakeBlockExplode(theCompound, theMinNbFaces, theMaxNbFaces):
1142 aList = BlocksOp.ExplodeCompoundOfBlocks(theCompound, theMinNbFaces, theMaxNbFaces)
1143 if BlocksOp.IsDone() == 0:
1144 print "MakeBlockExplode : ", BlocksOp.GetErrorCode()
1147 def GetBlockNearPoint(theCompound, thePoint):
1148 anObj = BlocksOp.GetBlockNearPoint(theCompound, thePoint)
1149 if BlocksOp.IsDone() == 0:
1150 print "GetBlockNearPoint : ", BlocksOp.GetErrorCode()
1153 def GetBlockByParts(theCompound, theParts):
1154 anObj = BlocksOp.GetBlockByParts(theCompound, theParts)
1155 if BlocksOp.IsDone() == 0:
1156 print "GetBlockByParts : ", BlocksOp.GetErrorCode()
1159 def GetBlocksByParts(theCompound, theParts):
1160 aList = BlocksOp.GetBlocksByParts(theCompound, theParts)
1161 if BlocksOp.IsDone() == 0:
1162 print "GetBlocksByParts : ", BlocksOp.GetErrorCode()
1165 def MakeMultiTransformation1D(Block, DirFaceID1, DirFaceID2, NbTimes):
1166 anObj = BlocksOp.MakeMultiTransformation1D(Block, DirFaceID1, DirFaceID2, NbTimes)
1167 if BlocksOp.IsDone() == 0:
1168 print "MakeMultiTransformation1D : ", BlocksOp.GetErrorCode()
1171 def MakeMultiTransformation2D(Block, DirFaceID1U, DirFaceID2U, NbTimesU,
1172 DirFaceID1V, DirFaceID2V, NbTimesV):
1173 anObj = BlocksOp.MakeMultiTransformation2D(Block, DirFaceID1U, DirFaceID2U, NbTimesU,
1174 DirFaceID1V, DirFaceID2V, NbTimesV)
1175 if BlocksOp.IsDone() == 0:
1176 print "MakeMultiTransformation2D : ", BlocksOp.GetErrorCode()
1179 def Propagate(theShape):
1180 listChains = BlocksOp.Propagate(theShape)
1181 if BlocksOp.IsDone() == 0:
1182 print "Propagate : ", BlocksOp.GetErrorCode()
1185 # -----------------------------------------------------------------------------
1187 # -----------------------------------------------------------------------------
1189 def CreateGroup(MainShape, ShapeType):
1190 anObj = GroupOp.CreateGroup(MainShape, ShapeType)
1191 if GroupOp.IsDone() == 0:
1192 print "CreateGroup : ", GroupOp.GetErrorCode()
1195 def AddObject(Group, SubShapeID):
1196 GroupOp.AddObject(Group, SubShapeID)
1197 if GroupOp.IsDone() == 0:
1198 print "AddObject : ", GroupOp.GetErrorCode()
1200 def RemoveObject(Group, SubShapeID):
1201 GroupOp.RemoveObject(Group, SubShapeID)
1202 if GroupOp.IsDone() == 0:
1203 print "RemoveObject : ", GroupOp.GetErrorCode()
1205 def UnionList (theGroup, theSubShapes):
1206 GroupOp.UnionList(theGroup, theSubShapes)
1207 if GroupOp.IsDone() == 0:
1208 print "UnionList : ", GroupOp.GetErrorCode()
1210 def UnionIDs(theGroup, theSubShapes):
1211 GroupOp.UnionIDs(theGroup, theSubShapes)
1212 if GroupOp.IsDone() == 0:
1213 print "UnionIDs : ", GroupOp.GetErrorCode()
1215 def DifferenceList (theGroup, theSubShapes):
1216 GroupOp.DifferenceList(theGroup, theSubShapes)
1217 if GroupOp.IsDone() == 0:
1218 print "DifferenceList : ", GroupOp.GetErrorCode()
1220 def DifferenceIDs(theGroup, theSubShapes):
1221 GroupOp.DifferenceIDs(theGroup, theSubShapes)
1222 if GroupOp.IsDone() == 0:
1223 print "DifferenceIDs : ", GroupOp.GetErrorCode()
1225 def GetObjectIDs(Group):
1226 ListIDs = GroupOp.GetObjects(Group)
1227 if GroupOp.IsDone() == 0:
1228 print "GetObjectIDs : ", GroupOp.GetErrorCode()
1231 def GetType(theGroup):
1232 aType = GroupOp.GetType(theGroup)
1233 if GroupOp.IsDone() == 0:
1234 print "GetType : ", GroupOp.GetErrorCode()
1237 def GetMainShape(theGroup):
1238 anObj = GroupOp.GetMainShape(theGroup)
1239 if GroupOp.IsDone() == 0:
1240 print "GetMainShape : ", GroupOp.GetErrorCode()
1243 def GetEdgesByLength (theShape, min_length, max_length, include_min = 1, include_max = 1):
1245 Create group of edges of theShape, whose length is in range [min_length, max_length].
1246 If include_min/max == 0, edges with length == min/max_length will not be included in result.
1249 edges = SubShapeAll(theShape, ShapeType["EDGE"])
1252 Props = BasicProperties(edge)
1253 if min_length <= Props[0] and Props[0] <= max_length:
1254 if (not include_min) and (min_length == Props[0]):
1257 if (not include_max) and (Props[0] == max_length):
1260 edges_in_range.append(edge)
1262 if len(edges_in_range) <= 0:
1263 print "No edges found by given criteria"
1266 group_edges = CreateGroup(theShape, ShapeType["EDGE"])
1267 UnionList(group_edges, edges_in_range)
1271 # Add Path to the system path
1274 if (sys.path.count(Path) < 1):
1275 sys.path.append(Path)