]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOM_SWIG/batchmode_geompy.py
Salome HOME
Improve CheckShape function
[modules/geom.git] / src / GEOM_SWIG / batchmode_geompy.py
1 #  GEOM GEOM_SWIG : binding of C++ omplementaion with Python
2 #
3 #  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
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.
10 #
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.
15 #
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
19 #
20 #  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 #
22 #
23 #
24 #  File   : geompy.py
25 #  Author : Paul RASCLE, EDF
26 #  Module : GEOM
27 #  $Header$
28
29 from batchmode_salome import *
30 import GEOM
31
32 g=None
33 step = 0
34 while step < 50 and g == None:
35     g = lcc.FindOrLoadComponent("FactoryServer", "GEOM")
36     step = step + 1
37     time.sleep(4)
38 geom = g._narrow( GEOM.GEOM_Gen )
39
40 myBuilder = None
41 myStudyId = 0
42 father    = None
43
44 BasicOp  = None
45 CurvesOp = None
46 PrimOp   = None
47 ShapesOp = None
48 HealOp   = None
49 InsertOp = None 
50 BoolOp   = None 
51 TrsfOp   = None
52 LocalOp  = None
53 MeasuOp  = None
54 BlocksOp = None
55 GroupOp  = None 
56
57 def init_geom(theStudy):
58
59     global myStudy, myBuilder, myStudyId, BasicOp, CurvesOp, PrimOp, ShapesOp, HealOp
60     global InsertOp, BoolOp, TrsfOp, LocalOp, MeasuOp, BlocksOp, GroupOp, father
61     
62     myStudy = theStudy
63     myStudyId = myStudy._get_StudyId()
64     myBuilder = myStudy.NewBuilder()
65     father = myStudy.FindComponent("GEOM")
66     if father is None:
67         father = myBuilder.NewComponent("GEOM")
68         A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName")
69         FName = A1._narrow(SALOMEDS.AttributeName)
70         FName.SetValue("Geometry")
71         A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap")
72         aPixmap = A2._narrow(SALOMEDS.AttributePixMap)
73         aPixmap.SetPixMap("ICON_OBJBROWSER_Geometry")
74         myBuilder.DefineComponentInstance(father,geom)
75         pass
76          
77     # -----------------------------------------------------------------------------
78     # Assign Operations Interfaces
79     # -----------------------------------------------------------------------------
80
81     BasicOp  = geom.GetIBasicOperations    (myStudyId)
82     CurvesOp = geom.GetICurvesOperations   (myStudyId)
83     PrimOp   = geom.GetI3DPrimOperations   (myStudyId)
84     ShapesOp = geom.GetIShapesOperations   (myStudyId)
85     HealOp   = geom.GetIHealingOperations  (myStudyId)
86     InsertOp = geom.GetIInsertOperations   (myStudyId)
87     BoolOp   = geom.GetIBooleanOperations  (myStudyId)
88     TrsfOp   = geom.GetITransformOperations(myStudyId)
89     LocalOp  = geom.GetILocalOperations    (myStudyId)
90     MeasuOp  = geom.GetIMeasureOperations  (myStudyId)
91     BlocksOp = geom.GetIBlocksOperations   (myStudyId)
92     GroupOp  = geom.GetIGroupOperations   (myStudyId) 
93     pass
94
95 init_geom(myStudy)
96
97 #     *  Get name for sub-shape aSubObj of shape aMainObj
98 #
99 def SubShapeName(aSubObj, aMainObj):
100     name = "SubShape"
101     print name
102     return name
103
104 #     *  Publish in study aShape with name aName
105 #
106 def addToStudy(aShape, aName):
107     try:
108         aSObject = geom.AddInStudy(myStudy, aShape, aName, None)
109     except:
110         print "addToStudy() failed"
111         return ""
112     return aShape.GetStudyEntry()
113
114 #     *  Publish in study aShape with name aName as sub-object of previously published aFather
115 #
116 def addToStudyInFather(aFather, aShape, aName):
117     try:
118         aSObject = geom.AddInStudy(myStudy, aShape, aName, aFather)
119     except:
120         print "addToStudyInFather() failed"
121         return ""
122     return aShape.GetStudyEntry()
123
124 # -----------------------------------------------------------------------------
125 # enumeration ShapeType as a dictionary
126 # -----------------------------------------------------------------------------
127
128 ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
129
130 # -----------------------------------------------------------------------------
131 # Basic primitives
132 # -----------------------------------------------------------------------------
133
134 def MakeVertex(theX, theY, theZ):
135     anObj = BasicOp.MakePointXYZ(theX, theY, theZ)
136     if BasicOp.IsDone() == 0:
137       print "MakePointXYZ : ", BasicOp.GetErrorCode()
138     return anObj
139
140 def MakeVertexWithRef(vertex,x,y,z):
141     anObj = BasicOp.MakePointWithReference(vertex,x,y,z)
142     if BasicOp.IsDone() == 0:
143       print "MakePointWithReference : ", BasicOp.GetErrorCode()
144     return anObj
145
146 def MakeVertexOnCurve(curve,par):
147     anObj = BasicOp.MakePointOnCurve(curve,par)
148     if BasicOp.IsDone() == 0:
149       print "MakePointOnCurve : ", BasicOp.GetErrorCode()
150     return anObj
151
152 def MakeVectorDXDYDZ(dx,dy,dz):
153     anObj = BasicOp.MakeVectorDXDYDZ(dx,dy,dz)
154     if BasicOp.IsDone() == 0:
155       print "MakeVectorDXDYDZ : ", BasicOp.GetErrorCode()
156     return anObj
157
158 def MakeVector(p1,p2):
159     anObj = BasicOp.MakeVectorTwoPnt(p1, p2)
160     if BasicOp.IsDone() == 0:
161       print "MakeVectorTwoPnt : ", BasicOp.GetErrorCode()
162     return anObj
163
164 def MakeLine(p1, d1):
165     anObj = BasicOp.MakeLine(p1,d1)
166     if BasicOp.IsDone() == 0:
167       print "MakeLine : ", BasicOp.GetErrorCode()
168     return anObj
169
170 def MakeLineTwoPnt(p1, p2):
171     anObj = BasicOp.MakeLineTwoPnt(p1,p2)
172     if BasicOp.IsDone() == 0:
173       print "MakeLineTwoPnt : ", BasicOp.GetErrorCode()
174     return anObj
175
176 def MakePlane(p1,v1,trimsize):
177     anObj = BasicOp.MakePlanePntVec(p1,v1,trimsize)
178     if BasicOp.IsDone() == 0:
179       print "MakePlanePntVec : ", BasicOp.GetErrorCode()
180     return anObj
181
182 def MakePlaneThreePnt(p1,p2,p3,trimsize):
183     anObj = BasicOp.MakePlaneThreePnt(p1,p2,p3,trimsize)
184     if BasicOp.IsDone() == 0:
185       print "MakePlaneThreePnt : ", BasicOp.GetErrorCode()
186     return anObj
187
188 def MakePlaneFace(face,trimsize):
189     anObj = BasicOp.MakePlaneFace(face,trimsize)
190     if BasicOp.IsDone() == 0:
191       print "MakePlaneFace : ", BasicOp.GetErrorCode()
192     return anObj
193
194 def MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ):
195     anObj = BasicOp.MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ)
196     if BasicOp.IsDone() == 0:
197       print "MakeMarker : ", BasicOp.GetErrorCode()
198     return anObj
199
200 def MakeMarkerPntTwoVec(theOrigin, theXVec, theYVec):
201     """
202      *  Create a local coordinate system.
203      *  \param theOrigin Point of coordinate system origin.
204      *  \param theXVec Vector of X direction
205      *  \param theYVec Vector of Y direction
206      *  \return New GEOM_Object, containing the created coordinate system.
207     """
208     O = PointCoordinates( theOrigin )
209     OXOY = []
210     for vec in [ theXVec, theYVec ]:
211         v1, v2 = SubShapeAll( vec, ShapeType["VERTEX"] )
212         p1 = PointCoordinates( v1 )
213         p2 = PointCoordinates( v2 )
214         for i in range( 0, 3 ):
215              OXOY.append( p2[i] - p1[i] )
216     #
217     anObj = BasicOp.MakeMarker( O[0], O[1], O[2],
218                                 OXOY[0], OXOY[1], OXOY[2],
219                                 OXOY[3], OXOY[4], OXOY[5], )
220     if BasicOp.IsDone() == 0:
221       print "MakeMarker : ", BasicOp.GetErrorCode()
222     return anObj
223
224 # -----------------------------------------------------------------------------
225 # Curves
226 # -----------------------------------------------------------------------------
227
228 def MakeArc(p1,p2,p3):
229     anObj = CurvesOp.MakeArc(p1,p2,p3)
230     if CurvesOp.IsDone() == 0:
231       print "MakeArc : ", CurvesOp.GetErrorCode()
232     return anObj
233
234 def MakeCircle(p1,v1,radius):
235     anObj = CurvesOp.MakeCirclePntVecR(p1,v1,radius)
236     if CurvesOp.IsDone() == 0:
237       print "MakeCirclePntVecR : ", CurvesOp.GetErrorCode()
238     return anObj
239
240 def MakeCircleThreePnt(p1,p2,p3):
241     anObj = CurvesOp.MakeCircleThreePnt(p1,p2,p3)
242     if CurvesOp.IsDone() == 0:
243       print "MakeCircleThreePnt : ", CurvesOp.GetErrorCode()
244     return anObj
245
246 def MakeEllipse(p1,v1,radiusMaj,radiusMin):
247     anObj = CurvesOp.MakeEllipse(p1,v1,radiusMaj, radiusMin)
248     if CurvesOp.IsDone() == 0:
249       print "MakeEllipse : ", CurvesOp.GetErrorCode()
250     return anObj
251
252 def MakePolyline(ListShape):
253     anObj = CurvesOp.MakePolyline(ListShape)
254     if CurvesOp.IsDone() == 0:
255       print "MakePolyline : ", CurvesOp.GetErrorCode()
256     return anObj
257
258 def MakeBezier(ListShape):
259     anObj = CurvesOp.MakeSplineBezier(ListShape)
260     if CurvesOp.IsDone() == 0:
261       print "MakeSplineBezier : ", CurvesOp.GetErrorCode()
262     return anObj
263
264 def MakeInterpol(ListShape):
265     anObj = CurvesOp.MakeSplineInterpolation(ListShape)
266     if CurvesOp.IsDone() == 0:
267       print "MakeSplineInterpolation : ", CurvesOp.GetErrorCode()
268     return anObj
269
270 # <WPL>: Nine double values, defining origin,
271 # OZ and OX directions of the working plane.
272 def MakeSketcher(Cmd, WPL = [0,0,0, 0,0,1, 1,0,0]):
273     anObj = CurvesOp.MakeSketcher(Cmd, WPL)
274     if CurvesOp.IsDone() == 0:
275       print "MakeSketcher : ", CurvesOp.GetErrorCode()
276     return anObj
277
278 def MakeSketcherOnPlane(theCommand, theWorkingPlane):
279     """
280      *  Create a sketcher (wire or face), following the textual description,
281      *  passed through \a theCommand argument. \n
282      *  For format of the description string see the previous method.\n
283      *  \param theCommand String, defining the sketcher in local
284      *                    coordinates of the working plane.
285      *  \param theWorkingPlane Planar Face of the working plane.
286      *  \return New GEOM_Object, containing the created wire.
287     """
288     anObj = CurvesOp.MakeSketcherOnPlane(theCommand, theWorkingPlane)
289     if CurvesOp.IsDone() == 0:
290       print "MakeSketcher : ", CurvesOp.GetErrorCode()
291     return anObj
292
293 # -----------------------------------------------------------------------------
294 # Create 3D Primitives
295 # -----------------------------------------------------------------------------
296
297 def MakeBox(x1,y1,z1,x2,y2,z2):
298     pnt1 = MakeVertex(x1,y1,z1)
299     pnt2 = MakeVertex(x2,y2,z2)
300     return MakeBoxTwoPnt(pnt1,pnt2)
301
302 def MakeBoxDXDYDZ(dx,dy,dz):
303     anObj = PrimOp.MakeBoxDXDYDZ(dx,dy,dz)
304     if PrimOp.IsDone() == 0:
305       print "MakeBoxDXDYDZ : ", PrimOp.GetErrorCode()
306     return anObj
307
308 def MakeBoxTwoPnt(point1, point2):
309     anObj = PrimOp.MakeBoxTwoPnt(point1, point2)
310     if PrimOp.IsDone() == 0:
311       print "MakeBoxTwoPnt : ", PrimOp.GetErrorCode()
312     return anObj
313
314 def MakeCylinder(p1,v1,radius,height):
315     anObj = PrimOp.MakeCylinderPntVecRH(p1,v1,radius,height)
316     if PrimOp.IsDone() == 0:
317       print "MakeCylinderPntVecRH : ", PrimOp.GetErrorCode()
318     return anObj
319
320 def MakeCylinderRH(radius,height):
321     anObj = PrimOp.MakeCylinderRH(radius,height)
322     if PrimOp.IsDone() == 0:
323       print "MakeCylinderRH : ", PrimOp.GetErrorCode()
324     return anObj
325
326 def MakeSpherePntR(point,radius):
327     anObj = PrimOp.MakeSpherePntR(point,radius)
328     if PrimOp.IsDone() == 0:
329       print "MakeSpherePntR : ", PrimOp.GetErrorCode()
330     return anObj
331
332 def MakeSphere(x,y,z,radius):
333     point = MakeVertex(x,y,z)
334     anObj = MakeSpherePntR(point,radius)
335     return anObj
336
337 def MakeSphereR(radius):
338     anObj = PrimOp.MakeSphereR(radius)
339     if PrimOp.IsDone() == 0:
340       print "MakeSphereR : ", PrimOp.GetErrorCode()
341     return anObj
342
343 def MakeCone(p1,v1,radius1,radius2,height):
344     anObj = PrimOp.MakeConePntVecR1R2H(p1,v1,radius1,radius2,height)
345     if PrimOp.IsDone() == 0:
346       print "MakeConePntVecR1R2H : ", PrimOp.GetErrorCode()
347     return anObj
348
349 def MakeConeR1R2H(radius1,radius2,height):
350     anObj = PrimOp.MakeConeR1R2H(radius1,radius2,height)
351     if PrimOp.IsDone() == 0:
352       print "MakeConeR1R2H : ", PrimOp.GetErrorCode()
353     return anObj
354
355 def MakeTorus(p1,v1,major_radius,minor_radius):
356     anObj = PrimOp.MakeTorusPntVecRR(p1,v1,major_radius,minor_radius)
357     if PrimOp.IsDone() == 0:
358       print "MakeTorusPntVecRR : ", PrimOp.GetErrorCode()
359     return anObj
360
361 def MakeTorusRR(major_radius,minor_radius):
362     anObj = PrimOp.MakeTorusRR(major_radius,minor_radius)
363     if PrimOp.IsDone() == 0:
364       print "MakeTorusRR : ", PrimOp.GetErrorCode()
365     return anObj
366
367 def MakePrism(baseShape,point1,point2):
368     anObj = PrimOp.MakePrismTwoPnt(baseShape,point1,point2)
369     if PrimOp.IsDone() == 0:
370       print "MakePrismTwoPnt : ", PrimOp.GetErrorCode()
371     return anObj
372
373 def MakePrismVecH(baseShape,vector,height):
374     anObj = PrimOp.MakePrismVecH(baseShape,vector,height)
375     if PrimOp.IsDone() == 0:
376       print "MakePrismVecH : ", PrimOp.GetErrorCode()
377     return anObj
378
379 def MakePipe(baseShape,pathShape):
380     anObj = PrimOp.MakePipe(baseShape,pathShape)
381     if PrimOp.IsDone() == 0:
382       print "MakePipe : ", PrimOp.GetErrorCode()
383     return anObj
384
385 def MakeRevolution(aShape,axis,angle):
386     anObj = PrimOp.MakeRevolutionAxisAngle(aShape,axis,angle)
387     if PrimOp.IsDone() == 0:
388       print "MakeRevolutionAxisAngle : ", PrimOp.GetErrorCode()
389     return anObj
390
391 # -----------------------------------------------------------------------------
392 # Create base shapes
393 # -----------------------------------------------------------------------------
394
395 def MakeEdge(p1,p2):
396     anObj = ShapesOp.MakeEdge(p1,p2)
397     if ShapesOp.IsDone() == 0:
398       print "MakeEdge : ", ShapesOp.GetErrorCode()
399     return anObj
400
401 def MakeWire(ListShape):
402     anObj = ShapesOp.MakeWire(ListShape)
403     if ShapesOp.IsDone() == 0:
404       print "MakeWire : ", ShapesOp.GetErrorCode()
405     return anObj
406
407 def MakeFace(aShapeWire,WantPlanarFace):
408     anObj = ShapesOp.MakeFace(aShapeWire,WantPlanarFace)
409     if ShapesOp.IsDone() == 0:
410       print "MakeFace : ", ShapesOp.GetErrorCode()
411     return anObj
412
413 def MakeFaceWires(ListWires,WantPlanarFace):
414     anObj = ShapesOp.MakeFaceWires(ListWires,WantPlanarFace)
415     if ShapesOp.IsDone() == 0:
416       print "MakeFaceWires : ", ShapesOp.GetErrorCode()
417     return anObj
418
419 def MakeFaces(ListWires,WantPlanarFace):
420     anObj = MakeFaceWires(ListWires,WantPlanarFace)
421     return anObj
422
423 def MakeShell(ListOfShapes):
424     anObj = ShapesOp.MakeShell(ListOfShapes)
425     if ShapesOp.IsDone() == 0:
426         print "MakeShell : ", ShapesOp.GetErrorCode()
427     return anObj
428
429 def MakeSolid(ListOfShells):
430     anObj = ShapesOp.MakeSolidShells(ListOfShells)
431     if ShapesOp.IsDone() == 0:
432         print "MakeSolid : ", ShapesOp.GetErrorCode()
433     return anObj
434
435 def MakeCompound(ListShape):
436     anObj = ShapesOp.MakeCompound(ListShape)
437     if ShapesOp.IsDone() == 0:
438       print "MakeCompound : ", ShapesOp.GetErrorCode()
439     return anObj
440
441 def NumberOfFaces(theShape):
442     nb_faces = ShapesOp.NumberOfFaces(theShape)
443     if ShapesOp.IsDone() == 0:
444       print "NumberOfFaces : ", ShapesOp.GetErrorCode()
445     return nb_faces
446
447 def NumberOfEdges(theShape):
448     nb_edges = ShapesOp.NumberOfEdges(theShape)
449     if ShapesOp.IsDone() == 0:
450       print "NumberOfEdges : ", ShapesOp.GetErrorCode()
451     return nb_edges
452
453 def ChangeOrientation(Shape):
454     anObj = ShapesOp.ChangeOrientation(Shape)
455     if ShapesOp.IsDone() == 0:
456       print "ChangeOrientation : ", ShapesOp.GetErrorCode()
457     return anObj
458
459 def OrientationChange(Shape):
460     anObj = ChangeOrientation(Shape)
461     return anObj
462
463 def GetFreeFacesIDs(theShape):
464     anIDs = ShapesOp.GetFreeFacesIDs(theShape)
465     if ShapesOp.IsDone() == 0:
466       print "GetFreeFacesIDs : ", ShapesOp.GetErrorCode()
467     return anIDs
468
469 def GetSharedShapes(theShape1, theShape2, theShapeType):
470     aList = ShapesOp.GetSharedShapes(theShape1, theShape2, theShapeType)
471     if ShapesOp.IsDone() == 0:
472       print "GetSharedShapes : ", ShapesOp.GetErrorCode()
473     return aList
474
475 def GetShapesOnPlane(theShape, theShapeType, theAx1, theState):
476     aList = ShapesOp.GetShapesOnPlane(theShape, theShapeType, theAx1, theState)
477     if ShapesOp.IsDone() == 0:
478       print "GetShapesOnPlane : ", ShapesOp.GetErrorCode()
479     return aList
480
481 def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState):
482     aList = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState)
483     if ShapesOp.IsDone() == 0:
484       print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode()
485     return aList
486
487 def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState):
488     aList = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState)
489     if ShapesOp.IsDone() == 0:
490       print "GetShapesOnSphere : ", ShapesOp.GetErrorCode()
491     return aList
492
493 def GetInPlace(theShapeWhere, theShapeWhat):
494     anObj = ShapesOp.GetInPlace(theShapeWhere, theShapeWhat)
495     if ShapesOp.IsDone() == 0:
496       print "GetInPlace : ", ShapesOp.GetErrorCode()
497     return anObj
498
499 # -----------------------------------------------------------------------------
500 # Access to sub-shapes by their unique IDs inside the main shape.
501 # -----------------------------------------------------------------------------
502
503 # Obtain a composite sub-shape of <aShape>, composed from sub-shapes
504 # of <aShape>, selected by their unique IDs inside <aShape>
505 def GetSubShape(aShape, ListOfID):
506     anObj = geom.AddSubShape(aShape,ListOfID)
507     return anObj
508
509 # Obtain unique ID of sub-shape <aSubShape> inside <aShape>
510 def GetSubShapeID(aShape, aSubShape):
511     anID = LocalOp.GetSubShapeIndex(aShape, aSubShape)
512     if LocalOp.IsDone() == 0:
513       print "GetSubShapeIndex : ", LocalOp.GetErrorCode()
514     return anID
515
516 # -----------------------------------------------------------------------------
517 # Decompose objects
518 # -----------------------------------------------------------------------------
519
520 def SubShapeAll(aShape, aType):
521     ListObj = ShapesOp.MakeExplode(aShape,aType,0)
522     if ShapesOp.IsDone() == 0:
523       print "MakeExplode : ", ShapesOp.GetErrorCode()
524     return ListObj
525
526 def SubShapeAllIDs(aShape, aType):
527     ListObj = ShapesOp.SubShapeAllIDs(aShape,aType,0)
528     if ShapesOp.IsDone() == 0:
529       print "SubShapeAllIDs : ", ShapesOp.GetErrorCode()
530     return ListObj
531
532 def SubShapeAllSorted(aShape, aType):
533     ListObj = ShapesOp.MakeExplode(aShape,aType,1)
534     if ShapesOp.IsDone() == 0:
535       print "MakeExplode : ", ShapesOp.GetErrorCode()
536     return ListObj
537
538 def SubShapeAllSortedIDs(aShape, aType):
539     ListIDs = ShapesOp.SubShapeAllIDs(aShape,aType,1)
540     if ShapesOp.IsDone() == 0:
541       print "SubShapeAllSortedIDs : ", ShapesOp.GetErrorCode()
542     return ListObj
543
544 # Obtain a compound of sub-shapes of <aShape>,
545 # selected by they indices in list of all sub-shapes of type <aType>
546 def SubShape(aShape, aType, ListOfInd):
547     ListOfIDs = []
548     AllShapeList = SubShapeAll(aShape, aType)
549     for ind in ListOfInd:
550         ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
551     anObj = GetSubShape(aShape, ListOfIDs)
552     return anObj
553
554 # Obtain a compound of sub-shapes of <aShape>,
555 # selected by they indices in sorted list of all sub-shapes of type <aType>
556 def SubShapeSorted(aShape, aType, ListOfInd):
557     ListOfIDs = []
558     AllShapeList = SubShapeAllSorted(aShape, aType)
559     for ind in ListOfInd:
560         ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
561     anObj = GetSubShape(aShape, ListOfIDs)
562     return anObj
563
564 # -----------------------------------------------------------------------------
565 # Healing operations
566 # -----------------------------------------------------------------------------
567
568 def ProcessShape(Shape, Operators, Parameters, Values):
569     anObj = HealOp.ProcessShape(Shape, Operators, Parameters, Values)
570     if HealOp.IsDone() == 0:
571         print "ProcessShape : ", HealOp.GetErrorCode()
572     return anObj
573
574 def SuppressFaces(aShape,ListOfId):
575     anObj = HealOp.SuppressFaces(aShape,ListOfId)
576     if HealOp.IsDone() == 0:
577       print "SuppressFaces : ", HealOp.GetErrorCode()
578     return anObj
579
580 def MakeSewing(ListShape,precision):
581     comp = MakeCompound(ListShape)
582     anObj = Sew(comp,precision)
583     return anObj
584
585 def Sew(aShape,precision):
586     anObj = HealOp.Sew(aShape,precision)
587     if HealOp.IsDone() == 0:
588       print "Sew : ", HealOp.GetErrorCode()
589     return anObj
590
591 def SuppressInternalWires(aShape, Wires):
592     anObj = HealOp.RemoveIntWires(aShape, Wires)
593     if HealOp.IsDone() == 0:
594       print "SuppressInternalWires : ", HealOp.GetErrorCode()
595     return anObj
596
597 def SuppressHoles(aShape, ListOfId):
598     anObj = HealOp.FillHoles(aShape,ListOfId)
599     if HealOp.IsDone() == 0:
600       print "SuppressHoles : ", HealOp.GetErrorCode()
601     return anObj
602
603 def CloseContour(aShape, Wires, IsCommonVertex):
604     anObj = HealOp.CloseContour(aShape, Wires, IsCommonVertex)
605     if HealOp.IsDone() == 0:
606       print "CloseContour : ", HealOp.GetErrorCode()
607     return anObj
608
609 def DivideEdge(aShape, EdgeID, Value, IsByParameter):
610     anObj = HealOp.DivideEdge(aShape, EdgeID, Value, IsByParameter)
611     if HealOp.IsDone() == 0:
612       print "DivideEdge : ", HealOp.GetErrorCode()
613     return anObj
614
615 def GetFreeBoundary(Shape):
616     anObj = HealOp.GetFreeBoundary(Shape)
617     if HealOp.IsDone() == 0:
618       print "GetFreeBoundaries : ", HealOp.GetErrorCode()
619     return anObj
620
621 # -----------------------------------------------------------------------------
622 # Create advanced objects
623 # -----------------------------------------------------------------------------
624
625 def MakeCopy(aShape):
626     anObj = InsertOp.MakeCopy(aShape)
627     if InsertOp.IsDone() == 0:
628       print "MakeCopy : ", InsertOp.GetErrorCode()
629     return anObj
630
631 def MakeFilling(aShape,mindeg,maxdeg,tol2d,tol3d,nbiter):
632     anObj = PrimOp.MakeFilling(aShape,mindeg,maxdeg,tol2d,tol3d,nbiter)
633     if PrimOp.IsDone() == 0:
634       print "MakeFilling : ", PrimOp.GetErrorCode()
635     return anObj
636
637 def MakeGlueFaces(aShape,aTolerance):
638     anObj = ShapesOp.MakeGlueFaces(aShape,aTolerance)
639     if ShapesOp.IsDone() == 0:
640       print "MakeGlueFaces : ", ShapesOp.GetErrorCode()
641     return anObj
642
643 # -----------------------------------------------------------------------------
644 # Boolean (Common, Cut, Fuse, Section)
645 # -----------------------------------------------------------------------------
646
647 def MakeBoolean(shape1,shape2,operation):
648     anObj = BoolOp.MakeBoolean(shape1,shape2,operation)
649     if BoolOp.IsDone() == 0:
650       print "MakeBoolean : ", BoolOp.GetErrorCode()
651     return anObj
652
653 def MakeCommon(s1, s2):
654     return MakeBoolean(s1, s2, 1)
655
656 def MakeCut(s1, s2):
657     return MakeBoolean(s1, s2, 2)
658
659 def MakeFuse(s1, s2):
660     return MakeBoolean(s1, s2, 3)
661
662 def MakeSection(s1, s2):
663     return MakeBoolean(s1, s2, 4)
664
665 def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
666                   Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
667     anObj = BoolOp.MakePartition(ListShapes, ListTools,
668                                  ListKeepInside, ListRemoveInside,
669                                  Limit, RemoveWebs, ListMaterials);
670     if BoolOp.IsDone() == 0:
671       print "MakePartition : ", BoolOp.GetErrorCode()
672     return anObj
673
674 def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
675               Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
676     anObj = MakePartition(ListShapes, ListTools,
677                           ListKeepInside, ListRemoveInside,
678                           Limit, RemoveWebs, ListMaterials);
679     return anObj
680
681 def MakeHalfPartition(theShape, thePlane):
682     anObj = BoolOp.MakeHalfPartition(theShape, thePlane)
683     if BoolOp.IsDone() == 0:
684       print "MakeHalfPartition : ", BoolOp.GetErrorCode()
685     return anObj
686
687 # -----------------------------------------------------------------------------
688 # Transform objects
689 # -----------------------------------------------------------------------------
690
691 def MakeTranslationTwoPoints(aShape,point1,point2):
692     anObj = TrsfOp.TranslateTwoPointsCopy(aShape,point1,point2)
693     if TrsfOp.IsDone() == 0:
694       print "TranslateTwoPointsCopy : ", TrsfOp.GetErrorCode()
695     return anObj
696
697 def MakeTranslation(aShape,dx,dy,dz):
698     anObj = TrsfOp.TranslateDXDYDZCopy(aShape,dx,dy,dz)
699     if TrsfOp.IsDone() == 0:
700       print "TranslateDXDYDZCopy : ", TrsfOp.GetErrorCode()
701     return anObj
702
703 def MakeTranslationVector(theObject, theVector):
704     anObj = TrsfOp.TranslateVectorCopy(theObject, theVector)
705     if TrsfOp.IsDone() == 0:
706       print "TranslateVectorCopy : ", TrsfOp.GetErrorCode()
707     return anObj
708
709 def MakeRotation(aShape,axis,angle):
710     anObj = TrsfOp.RotateCopy(aShape,axis,angle)
711     if TrsfOp.IsDone() == 0:
712       print "RotateCopy : ", TrsfOp.GetErrorCode()
713     return anObj
714
715 def MakeScaleTransform(aShape,theCenterofScale,factor):
716     anObj = TrsfOp.ScaleShapeCopy(aShape,theCenterofScale,factor)
717     if TrsfOp.IsDone() == 0:
718       print "ScaleShapeCopy : ", TrsfOp.GetErrorCode()
719     return anObj
720
721 def MakeMirrorByPlane(aShape,aPlane):
722     anObj = TrsfOp.MirrorPlaneCopy(aShape,aPlane)
723     if TrsfOp.IsDone() == 0:
724       print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode()
725     return anObj
726
727 def MakeMirrorByAxis(theObject, theAxis):
728     anObj = TrsfOp.MirrorAxisCopy(theObject, theAxis)
729     if TrsfOp.IsDone() == 0:
730       print "MirrorAxisCopy : ", TrsfOp.GetErrorCode()
731     return anObj
732
733 def MakeMirrorByPoint(theObject, thePoint):
734     anObj = TrsfOp.MirrorPointCopy(theObject, thePoint)
735     if TrsfOp.IsDone() == 0:
736       print "MirrorPointCopy : ", TrsfOp.GetErrorCode()
737     return anObj
738
739 def MakePosition(aShape,theStartLCS,theEndLCS):
740     anObj = TrsfOp.PositionShapeCopy(aShape,theStartLCS,theEndLCS)
741     if TrsfOp.IsDone() == 0:
742       print "PositionShapeCopy : ", TrsfOp.GetErrorCode()
743     return anObj
744
745 def MakeOffset(aShape, anOffset):
746     anObj = TrsfOp.OffsetShapeCopy(aShape, anOffset)
747     if TrsfOp.IsDone() == 0:
748       print "OffsetShapeCopy : ", TrsfOp.GetErrorCode()
749     return anObj
750
751 # -----------------------------------------------------------------------------
752 # Patterns
753 # -----------------------------------------------------------------------------
754
755 def MakeMultiTranslation1D(aShape,aDir,aStep,aNbTimes):
756     anObj = TrsfOp.MultiTranslate1D(aShape,aDir,aStep,aNbTimes)
757     if TrsfOp.IsDone() == 0:
758       print "MultiTranslate1D : ", TrsfOp.GetErrorCode()
759     return anObj
760
761 def MakeMultiTranslation2D(aShape,d1,step1,nbtimes1,d2,step2,nbtimes2):
762     anObj = TrsfOp.MultiTranslate2D(aShape,d1,step1,nbtimes1,d2,step2,nbtimes2)
763     if TrsfOp.IsDone() == 0:
764       print "MultiTranslate2D : ", TrsfOp.GetErrorCode()
765     return anObj
766
767 def MultiRotate1D(aShape,aVec,aNbTimes):
768     anObj = TrsfOp.MultiRotate1D(aShape,aVec,aNbTimes)
769     if TrsfOp.IsDone() == 0:
770       print "MultiRotate1D : ", TrsfOp.GetErrorCode()
771     return anObj
772
773 def MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2):
774     anObj = TrsfOp.MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
775     if TrsfOp.IsDone() == 0:
776       print "MultiRotate2D : ", TrsfOp.GetErrorCode()
777     return anObj
778
779 def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes):
780     aVec = MakeLine(aPoint,aDir)
781     anObj = MultiRotate1D(aShape,aVec,aNbTimes)
782     return anObj
783
784 def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2):
785     aVec = MakeLine(aPoint,aDir)
786     anObj = MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
787     return anObj
788
789 # -----------------------------------------------------------------------------
790 # Local operations
791 # -----------------------------------------------------------------------------
792
793 def MakeFilletAll(aShape,radius):
794     anObj = LocalOp.MakeFilletAll(aShape,radius)
795     if LocalOp.IsDone() == 0:
796       print "MakeFilletAll : ", LocalOp.GetErrorCode()
797     return anObj
798
799 def MakeFillet(aShape,radius,aShapeType,ListShape):
800     anObj = None
801     if aShapeType == ShapeType["EDGE"]:
802         anObj = LocalOp.MakeFilletEdges(aShape,radius,ListShape)
803     else:
804         anObj = LocalOp.MakeFilletFaces(aShape,radius,ListShape)
805     if LocalOp.IsDone() == 0:
806       print "MakeFillet : ", LocalOp.GetErrorCode()
807     return anObj
808
809 def MakeChamferAll(aShape,d):
810     anObj = LocalOp.MakeChamferAll(aShape,d)
811     if LocalOp.IsDone() == 0:
812       print "MakeChamferAll : ", LocalOp.GetErrorCode()
813     return anObj
814
815 def MakeChamferEdge(aShape,d1,d2,face1,face2):
816     anObj = LocalOp.MakeChamferEdge(aShape,d1,d2,face1,face2)
817     if LocalOp.IsDone() == 0:
818       print "MakeChamferEdge : ", LocalOp.GetErrorCode()
819     return anObj
820
821 def MakeChamferFaces(aShape,d1,d2,ListShape):
822     anObj = LocalOp.MakeChamferFaces(aShape,d1,d2,ListShape)
823     if LocalOp.IsDone() == 0:
824       print "MakeChamferFaces : ", LocalOp.GetErrorCode()
825     return anObj
826
827 def MakeChamfer(aShape,d1,d2,aShapeType,ListShape):
828     anObj = None
829     if aShapeType == ShapeType["EDGE"]:
830         anObj = MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1])
831     else:
832         anObj = MakeChamferFaces(aShape,d1,d2,ListShape)
833     return anObj
834
835 def Archimede(aShape,weight,WaterDensity,MeshingDeflection):
836     anObj = LocalOp.MakeArchimede(aShape,weight,WaterDensity,MeshingDeflection)
837     if LocalOp.IsDone() == 0:
838       print "MakeArchimede : ", LocalOp.GetErrorCode()
839     return anObj
840
841 # -----------------------------------------------------------------------------
842 # Information objects
843 # -----------------------------------------------------------------------------
844
845 def PointCoordinates(Point):
846     aTuple = MeasuOp.PointCoordinates(Point)
847     if MeasuOp.IsDone() == 0:
848       print "PointCoordinates : ", MeasuOp.GetErrorCode()
849     return aTuple
850
851 def BasicProperties(Shape):
852     aTuple = MeasuOp.GetBasicProperties(Shape)
853     if MeasuOp.IsDone() == 0:
854       print "BasicProperties : ", MeasuOp.GetErrorCode()
855     return aTuple
856
857 def BoundingBox(Shape):
858     aTuple = MeasuOp.GetBoundingBox(Shape)
859     if MeasuOp.IsDone() == 0:
860       print "BoundingBox : ", MeasuOp.GetErrorCode()
861     return aTuple
862
863 def Inertia(Shape):
864     aTuple = MeasuOp.GetInertia(Shape)
865     if MeasuOp.IsDone() == 0:
866       print "Inertia : ", MeasuOp.GetErrorCode()
867     return aTuple
868
869 def MinDistance(Shape1, Shape2):
870     aTuple = MeasuOp.GetMinDistance(Shape1, Shape2)
871     if MeasuOp.IsDone() == 0:
872       print "MinDistance : ", MeasuOp.GetErrorCode()
873     return aTuple[0]
874
875 def Tolerance(Shape):
876     aTuple = MeasuOp.GetTolerance(Shape)
877     if MeasuOp.IsDone() == 0:
878       print "Tolerance : ", MeasuOp.GetErrorCode()
879     return aTuple
880
881 def WhatIs(Shape):
882     aDescr = MeasuOp.WhatIs(Shape)
883     if MeasuOp.IsDone() == 0:
884       print "WhatIs : ", MeasuOp.GetErrorCode()
885     return aDescr
886
887 def MakeCDG(aShape):
888     anObj = MeasuOp.GetCentreOfMass(aShape)
889     if MeasuOp.IsDone() == 0:
890       print "GetCentreOfMass : ", MeasuOp.GetErrorCode()
891     return anObj
892
893 def CheckShape(aShape):
894     (IsValid, Status) = MeasuOp.CheckShape(aShape)
895     if MeasuOp.IsDone() == 0:
896       print "CheckShape : ", MeasuOp.GetErrorCode()
897     else:
898       if IsValid == 0:
899         print Status
900     return IsValid
901
902 # -----------------------------------------------------------------------------
903 # Import/Export objects
904 # -----------------------------------------------------------------------------
905
906 def Import(filename, formatname):
907     anObj = InsertOp.Import(filename, formatname)
908     if InsertOp.IsDone() == 0:
909       print "Import : ", InsertOp.GetErrorCode()
910     return anObj
911
912 def ImportBREP(theFileName):
913     return Import(theFileName, "BREP")
914
915 def ImportIGES(theFileName):
916     return Import(theFileName, "IGES")
917
918 def ImportSTEP(theFileName):
919     return Import(theFileName, "STEP")
920
921 def Export(aShape, filename, formatname):
922     InsertOp.Export(aShape, filename, formatname)
923     if InsertOp.IsDone() == 0:
924       print "Export : ", InsertOp.GetErrorCode()
925
926 def ExportBREP(theObject, theFileName):
927     return Export(theObject, theFileName, "BREP")
928
929 def ExportIGES(theObject, theFileName):
930     return Export(theObject, theFileName, "IGES")
931
932 def ExportSTEP(theObject, theFileName):
933     return Export(theObject, theFileName, "STEP")
934
935 # -----------------------------------------------------------------------------
936 # Block operations
937 # -----------------------------------------------------------------------------
938
939 def MakeQuad(E1, E2, E3, E4):
940     anObj = BlocksOp.MakeQuad(E1, E2, E3, E4)
941     if BlocksOp.IsDone() == 0:
942       print "MakeQuad : ", BlocksOp.GetErrorCode()
943     return anObj
944
945 def MakeQuad2Edges(E1, E2):
946     anObj = BlocksOp.MakeQuad2Edges(E1, E2)
947     if BlocksOp.IsDone() == 0:
948       print "MakeQuad2Edges : ", BlocksOp.GetErrorCode()
949     return anObj
950
951 def MakeQuad4Vertices(V1, V2, V3, V4):
952     anObj = BlocksOp.MakeQuad4Vertices(V1, V2, V3, V4)
953     if BlocksOp.IsDone() == 0:
954       print "MakeQuad4Vertices : ", BlocksOp.GetErrorCode()
955     return anObj
956
957 def MakeHexa(F1, F2, F3, F4, F5, F6):
958     anObj = BlocksOp.MakeHexa(F1, F2, F3, F4, F5, F6)
959     if BlocksOp.IsDone() == 0:
960       print "MakeHexa : ", BlocksOp.GetErrorCode()
961     return anObj
962
963 def MakeHexa2Faces(F1, F2):
964     anObj = BlocksOp.MakeHexa2Faces(F1, F2)
965     if BlocksOp.IsDone() == 0:
966       print "MakeHexa2Faces : ", BlocksOp.GetErrorCode()
967     return anObj
968
969 def GetPoint(theShape, theX, theY, theZ, theEpsilon):
970     anObj = BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon)
971     if BlocksOp.IsDone() == 0:
972       print "GetPoint : ", BlocksOp.GetErrorCode()
973     return anObj
974
975 def GetEdge(theShape, thePoint1, thePoint2):
976     anObj = BlocksOp.GetEdge(theShape, thePoint1, thePoint2)
977     if BlocksOp.IsDone() == 0:
978       print "GetEdge : ", BlocksOp.GetErrorCode()
979     return anObj
980
981 def GetEdgeNearPoint(theShape, thePoint):
982     anObj = BlocksOp.GetEdgeNearPoint(theShape, thePoint)
983     if BlocksOp.IsDone() == 0:
984       print "GetEdgeNearPoint : ", BlocksOp.GetErrorCode()
985     return anObj
986
987 def GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4):
988     anObj = BlocksOp.GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4)
989     if BlocksOp.IsDone() == 0:
990       print "GetFaceByPoints : ", BlocksOp.GetErrorCode()
991     return anObj
992
993 def GetFaceByEdges(theShape, theEdge1, theEdge2):
994     anObj = BlocksOp.GetFaceByEdges(theShape, theEdge1, theEdge2)
995     if BlocksOp.IsDone() == 0:
996       print "GetFaceByEdges : ", BlocksOp.GetErrorCode()
997     return anObj
998
999 def GetOppositeFace(theBlock, theFace):
1000     anObj = BlocksOp.GetOppositeFace(theBlock, theFace)
1001     if BlocksOp.IsDone() == 0:
1002       print "GetOppositeFace : ", BlocksOp.GetErrorCode()
1003     return anObj
1004
1005 def GetFaceNearPoint(theShape, thePoint):
1006     anObj = BlocksOp.GetFaceNearPoint(theShape, thePoint)
1007     if BlocksOp.IsDone() == 0:
1008       print "GetFaceNearPoint : ", BlocksOp.GetErrorCode()
1009     return anObj
1010
1011 def GetFaceByNormale(theBlock, theVector):
1012     anObj = BlocksOp.GetFaceByNormale(theBlock, theVector)
1013     if BlocksOp.IsDone() == 0:
1014       print "GetFaceByNormale : ", BlocksOp.GetErrorCode()
1015     return anObj
1016
1017 def CheckCompoundOfBlocks(theCompound):
1018     (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(theCompound)
1019     if BlocksOp.IsDone() == 0:
1020       print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode()
1021     else:
1022       if IsValid == 0:
1023         Descr = BlocksOp.PrintBCErrors(theCompound, BCErrors)
1024         print Descr
1025     return IsValid
1026
1027 def RemoveExtraEdges(theShape):
1028     anObj = BlocksOp.RemoveExtraEdges(theShape)
1029     if BlocksOp.IsDone() == 0:
1030       print "RemoveExtraEdges : ", BlocksOp.GetErrorCode()
1031     return anObj
1032
1033 def CheckAndImprove(theShape):
1034     anObj = BlocksOp.CheckAndImprove(theShape)
1035     if BlocksOp.IsDone() == 0:
1036       print "CheckAndImprove : ", BlocksOp.GetErrorCode()
1037     return anObj
1038
1039 def MakeBlockExplode(theCompound, theMinNbFaces, theMaxNbFaces):
1040     aList = BlocksOp.ExplodeCompoundOfBlocks(theCompound, theMinNbFaces, theMaxNbFaces)
1041     if BlocksOp.IsDone() == 0:
1042       print "MakeBlockExplode : ", BlocksOp.GetErrorCode()
1043     return aList
1044
1045 def GetBlockNearPoint(theCompound, thePoint):
1046     anObj = BlocksOp.GetBlockNearPoint(theCompound, thePoint)
1047     if BlocksOp.IsDone() == 0:
1048       print "GetBlockNearPoint : ", BlocksOp.GetErrorCode()
1049     return anObj
1050
1051 def GetBlockByParts(theCompound, theParts):
1052     anObj = BlocksOp.GetBlockByParts(theCompound, theParts)
1053     if BlocksOp.IsDone() == 0:
1054       print "GetBlockByParts : ", BlocksOp.GetErrorCode()
1055     return anObj
1056
1057 def GetBlocksByParts(theCompound, theParts):
1058     aList = BlocksOp.GetBlocksByParts(theCompound, theParts)
1059     if BlocksOp.IsDone() == 0:
1060       print "GetBlocksByParts : ", BlocksOp.GetErrorCode()
1061     return aList
1062
1063 def MakeMultiTransformation1D(Block, DirFaceID1, DirFaceID2, NbTimes):
1064     anObj = BlocksOp.MakeMultiTransformation1D(Block, DirFaceID1, DirFaceID2, NbTimes)
1065     if BlocksOp.IsDone() == 0:
1066       print "MakeMultiTransformation1D : ", BlocksOp.GetErrorCode()
1067     return anObj
1068
1069 def MakeMultiTransformation2D(Block, DirFaceID1U, DirFaceID2U, NbTimesU,
1070                                      DirFaceID1V, DirFaceID2V, NbTimesV):
1071     anObj = BlocksOp.MakeMultiTransformation2D(Block, DirFaceID1U, DirFaceID2U, NbTimesU,
1072                                                       DirFaceID1V, DirFaceID2V, NbTimesV)
1073     if BlocksOp.IsDone() == 0:
1074       print "MakeMultiTransformation2D : ", BlocksOp.GetErrorCode()
1075     return anObj
1076
1077 def Propagate(theShape):
1078     listChains = BlocksOp.Propagate(theShape)
1079     if BlocksOp.IsDone() == 0:
1080       print "Propagate : ", BlocksOp.GetErrorCode()
1081     return listChains
1082
1083 # -----------------------------------------------------------------------------
1084 # Group operations
1085 # -----------------------------------------------------------------------------
1086
1087 def CreateGroup(MainShape, ShapeType):
1088     anObj = GroupOp.CreateGroup(MainShape, ShapeType)
1089     if GroupOp.IsDone() == 0:
1090        print "CreateGroup : ", GroupOp.GetErrorCode()
1091     return anObj
1092
1093 def AddObject(Group, SubShapeID):
1094     GroupOp.AddObject(Group, SubShapeID)
1095     if GroupOp.IsDone() == 0:
1096       print "AddObject : ", GroupOp.GetErrorCode()
1097
1098 def RemoveObject(Group, SubShapeID):
1099     GroupOp.RemoveObject(Group, SubShapeID)
1100     if GroupOp.IsDone() == 0:
1101       print "RemoveObject : ", GroupOp.GetErrorCode()
1102
1103 def UnionList (theGroup, theSubShapes):
1104     GroupOp.UnionList(theGroup, theSubShapes)
1105     if GroupOp.IsDone() == 0:
1106       print "UnionList : ", GroupOp.GetErrorCode()
1107
1108 def DifferenceList (theGroup, theSubShapes):
1109     GroupOp.DifferenceList(theGroup, theSubShapes)
1110     if GroupOp.IsDone() == 0:
1111       print "DifferenceList : ", GroupOp.GetErrorCode()
1112
1113 def GetObjectIDs(Group):
1114     ListIDs = GroupOp.GetObjects(Group)
1115     if GroupOp.IsDone() == 0:
1116       print "GetObjectIDs : ", GroupOp.GetErrorCode()
1117     return ListIDs
1118
1119 def GetType(theGroup):
1120     aType = GroupOp.GetType(theGroup)
1121     if GroupOp.IsDone() == 0:
1122       print "GetType : ", GroupOp.GetErrorCode()
1123     return aType
1124
1125 def GetMainShape(theGroup):
1126     anObj = GroupOp.GetMainShape(theGroup)
1127     if GroupOp.IsDone() == 0:
1128       print "GetMainShape : ", GroupOp.GetErrorCode()
1129     return anObj
1130
1131 def GetEdgesByLength (theShape, min_length, max_length, include_min = 1, include_max = 1):
1132     """
1133     Create group of edges of theShape, whose length is in range [min_length, max_length].
1134     If include_min/max == 0, edges with length == min/max_length will not be included in result.
1135     """
1136
1137     edges = SubShapeAll(theShape, ShapeType["EDGE"])
1138     edges_in_range = []
1139     for edge in edges:
1140         Props = BasicProperties(edge)
1141         if min_length <= Props[0] and Props[0] <= max_length:
1142             if (not include_min) and (min_length == Props[0]):
1143                 skip = 1
1144             else:
1145                 if (not include_max) and (Props[0] == max_length):
1146                     skip = 1
1147                 else:
1148                     edges_in_range.append(edge)
1149
1150     if len(edges_in_range) <= 0:
1151         print "No edges found by given criteria"
1152         return 0
1153
1154     group_edges = CreateGroup(theShape, ShapeType["EDGE"])
1155     UnionList(group_edges, edges_in_range)
1156
1157     return group_edges
1158
1159 # Add Path to the system path
1160 #
1161 def addPath(Path):
1162     if (sys.path.count(Path) < 1):
1163         sys.path.append(Path)