Salome HOME
93e695b96a44c0c345a531132a08fbe4e4d978ad
[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 myBuilder = myStudy.NewBuilder()
40
41 father = myStudy.FindComponent("GEOM")
42 if father is None:
43         father = myBuilder.NewComponent("GEOM")
44         A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName")
45         FName = A1._narrow(SALOMEDS.AttributeName)
46         FName.SetValue("Geometry")
47         A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap")
48         aPixmap = A2._narrow(SALOMEDS.AttributePixMap)
49         aPixmap.SetPixMap("ICON_OBJBROWSER_Geometry")
50         myBuilder.DefineComponentInstance(father,geom)
51
52 # -----------------------------------------------------------------------------
53 # add To Study
54 # -----------------------------------------------------------------------------
55
56 def SubShapeName(aSubObj, aMainObj):
57     name = "SubShape"
58     print name
59     return name
60
61 # -----------------------------------------------------------------------------
62 # Operations
63 # -----------------------------------------------------------------------------
64
65 def addToStudy(aShape, aName):
66     try:
67         aSObject = geom.AddInStudy(myStudy, aShape, aName, None)
68     except:
69         print "addToStudy() failed"
70         return ""
71     return aShape.GetStudyEntry()
72
73 def addToStudyInFather(aFather, aShape, aName):
74     try:
75 #        myBuilder.NewCommand()
76         aSObject = geom.AddInStudy(myStudy, aShape, aName, aFather)
77 #        myBuilder.CommitCommand()
78     except:
79         print "addToStudyInFather() failed"
80         return ""
81     return aShape.GetStudyEntry()
82
83 # -----------------------------------------------------------------------------
84 # enumeration ShapeType as a dictionary
85 # -----------------------------------------------------------------------------
86
87 ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
88
89 # -----------------------------------------------------------------------------
90 # Get Operations Interfaces
91 # -----------------------------------------------------------------------------
92
93 BasicOp  = geom.GetIBasicOperations    (myStudyId)
94 CurvesOp = geom.GetICurvesOperations   (myStudyId)
95 PrimOp   = geom.GetI3DPrimOperations   (myStudyId)
96 ShapesOp = geom.GetIShapesOperations   (myStudyId)
97 HealOp   = geom.GetIHealingOperations  (myStudyId)
98 InsertOp = geom.GetIInsertOperations   (myStudyId)
99 BoolOp   = geom.GetIBooleanOperations  (myStudyId)
100 TrsfOp   = geom.GetITransformOperations(myStudyId)
101 LocalOp  = geom.GetILocalOperations    (myStudyId)
102 MeasuOp  = geom.GetIMeasureOperations  (myStudyId)
103 BlocksOp = geom.GetIBlocksOperations   (myStudyId)
104 GroupOp  = geom.GetIGroupOperations   (myStudyId)
105
106 # -----------------------------------------------------------------------------
107 # Basic primitives
108 # -----------------------------------------------------------------------------
109
110 def MakeVertex(x,y,z):
111     anObj = BasicOp.MakePointXYZ(x,y,z)
112     if BasicOp.IsDone() == 0:
113       print "MakePointXYZ : ", BasicOp.GetErrorCode()
114     return anObj
115
116 def MakeVertexWithRef(vertex,x,y,z):
117     anObj = BasicOp.MakePointWithReference(vertex,x,y,z)
118     if BasicOp.IsDone() == 0:
119       print "MakePointWithReference : ", BasicOp.GetErrorCode()
120     return anObj
121
122 def MakeVertexOnCurve(curve,par):
123     anObj = BasicOp.MakePointOnCurve(curve,par)
124     if BasicOp.IsDone() == 0:
125       print "MakePointOnCurve : ", BasicOp.GetErrorCode()
126     return anObj
127
128 def MakeVectorDXDYDZ(dx,dy,dz):
129     anObj = BasicOp.MakeVectorDXDYDZ(dx,dy,dz)
130     if BasicOp.IsDone() == 0:
131       print "MakeVectorDXDYDZ : ", BasicOp.GetErrorCode()
132     return anObj
133
134 def MakeVector(p1,p2):
135     anObj = BasicOp.MakeVectorTwoPnt(p1, p2)
136     if BasicOp.IsDone() == 0:
137       print "MakeVectorTwoPnt : ", BasicOp.GetErrorCode()
138     return anObj
139
140 def MakeLine(p1, d1):
141     anObj = BasicOp.MakeLine(p1,d1)
142     if BasicOp.IsDone() == 0:
143       print "MakeLine : ", BasicOp.GetErrorCode()
144     return anObj
145
146 def MakeLineTwoPnt(p1, p2):
147     anObj = BasicOp.MakeLineTwoPnt(p1,p2)
148     if BasicOp.IsDone() == 0:
149       print "MakeLineTwoPnt : ", BasicOp.GetErrorCode()
150     return anObj
151
152 def MakePlane(p1,v1,trimsize):
153     anObj = BasicOp.MakePlanePntVec(p1,v1,trimsize)
154     if BasicOp.IsDone() == 0:
155       print "MakePlanePntVec : ", BasicOp.GetErrorCode()
156     return anObj
157
158 def MakePlaneThreePnt(p1,p2,p3,trimsize):
159     anObj = BasicOp.MakePlaneThreePnt(p1,p2,p3,trimsize)
160     if BasicOp.IsDone() == 0:
161       print "MakePlaneThreePnt : ", BasicOp.GetErrorCode()
162     return anObj
163
164 def MakePlaneFace(face,trimsize):
165     anObj = BasicOp.MakePlaneFace(face,trimsize)
166     if BasicOp.IsDone() == 0:
167       print "MakePlaneFace : ", BasicOp.GetErrorCode()
168     return anObj
169
170 def MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ):
171     anObj = BasicOp.MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ)
172     if BasicOp.IsDone() == 0:
173       print "MakeMarker : ", BasicOp.GetErrorCode()
174     return anObj
175
176 # -----------------------------------------------------------------------------
177 # Curves
178 # -----------------------------------------------------------------------------
179
180 def MakeArc(p1,p2,p3):
181     anObj = CurvesOp.MakeArc(p1,p2,p3)
182     if CurvesOp.IsDone() == 0:
183       print "MakeArc : ", CurvesOp.GetErrorCode()
184     return anObj
185
186 def MakeCircle(p1,v1,radius):
187     anObj = CurvesOp.MakeCirclePntVecR(p1,v1,radius)
188     if CurvesOp.IsDone() == 0:
189       print "MakeCirclePntVecR : ", CurvesOp.GetErrorCode()
190     return anObj
191
192 def MakeCircleThreePnt(p1,p2,p3):
193     anObj = CurvesOp.MakeCircleThreePnt(p1,p2,p3)
194     if CurvesOp.IsDone() == 0:
195       print "MakeCircleThreePnt : ", CurvesOp.GetErrorCode()
196     return anObj
197
198 def MakeEllipse(p1,v1,radiusMaj,radiusMin):
199     anObj = CurvesOp.MakeEllipse(p1,v1,radiusMaj, radiusMin)
200     if CurvesOp.IsDone() == 0:
201       print "MakeEllipse : ", CurvesOp.GetErrorCode()
202     return anObj
203
204 def MakePolyline(ListShape):
205     anObj = CurvesOp.MakePolyline(ListShape)
206     if CurvesOp.IsDone() == 0:
207       print "MakePolyline : ", CurvesOp.GetErrorCode()
208     return anObj
209
210 def MakeBezier(ListShape):
211     anObj = CurvesOp.MakeSplineBezier(ListShape)
212     if CurvesOp.IsDone() == 0:
213       print "MakeSplineBezier : ", CurvesOp.GetErrorCode()
214     return anObj
215
216 def MakeInterpol(ListShape):
217     anObj = CurvesOp.MakeSplineInterpolation(ListShape)
218     if CurvesOp.IsDone() == 0:
219       print "MakeSplineInterpolation : ", CurvesOp.GetErrorCode()
220     return anObj
221
222 # <WPL>: Nine double values, defining origin,
223 # OZ and OX directions of the working plane.
224 def MakeSketcher(Cmd, WPL = [0,0,0, 0,0,1, 1,0,0]):
225     anObj = CurvesOp.MakeSketcher(Cmd, WPL)
226     if CurvesOp.IsDone() == 0:
227       print "MakeSketcher : ", CurvesOp.GetErrorCode()
228     return anObj
229
230 # -----------------------------------------------------------------------------
231 # Create 3D Primitives
232 # -----------------------------------------------------------------------------
233
234 def MakeBox(x1,y1,z1,x2,y2,z2):
235     pnt1 = MakeVertex(x1,y1,z1)
236     pnt2 = MakeVertex(x2,y2,z2)
237     return MakeBoxTwoPnt(pnt1,pnt2)
238
239 def MakeBoxDXDYDZ(dx,dy,dz):
240     anObj = PrimOp.MakeBoxDXDYDZ(dx,dy,dz)
241     if PrimOp.IsDone() == 0:
242       print "MakeBoxDXDYDZ : ", PrimOp.GetErrorCode()
243     return anObj
244
245 def MakeBoxTwoPnt(point1, point2):
246     anObj = PrimOp.MakeBoxTwoPnt(point1, point2)
247     if PrimOp.IsDone() == 0:
248       print "MakeBoxTwoPnt : ", PrimOp.GetErrorCode()
249     return anObj
250
251 def MakeCylinder(p1,v1,radius,height):
252     anObj = PrimOp.MakeCylinderPntVecRH(p1,v1,radius,height)
253     if PrimOp.IsDone() == 0:
254       print "MakeCylinderPntVecRH : ", PrimOp.GetErrorCode()
255     return anObj
256
257 def MakeCylinderRH(radius,height):
258     anObj = PrimOp.MakeCylinderRH(radius,height)
259     if PrimOp.IsDone() == 0:
260       print "MakeCylinderRH : ", PrimOp.GetErrorCode()
261     return anObj
262
263 def MakeSpherePntR(point,radius):
264     anObj = PrimOp.MakeSpherePntR(point,radius)
265     if PrimOp.IsDone() == 0:
266       print "MakeSpherePntR : ", PrimOp.GetErrorCode()
267     return anObj
268
269 def MakeSphere(x,y,z,radius):
270     point = MakeVertex(x,y,z)
271     anObj = MakeSpherePntR(point,radius)
272     return anObj
273
274 def MakeSphereR(radius):
275     anObj = PrimOp.MakeSphereR(radius)
276     if PrimOp.IsDone() == 0:
277       print "MakeSphereR : ", PrimOp.GetErrorCode()
278     return anObj
279
280 def MakeCone(p1,v1,radius1,radius2,height):
281     anObj = PrimOp.MakeConePntVecR1R2H(p1,v1,radius1,radius2,height)
282     if PrimOp.IsDone() == 0:
283       print "MakeConePntVecR1R2H : ", PrimOp.GetErrorCode()
284     return anObj
285
286 def MakeConeR1R2H(radius1,radius2,height):
287     anObj = PrimOp.MakeConeR1R2H(radius1,radius2,height)
288     if PrimOp.IsDone() == 0:
289       print "MakeConeR1R2H : ", PrimOp.GetErrorCode()
290     return anObj
291
292 def MakeTorus(p1,v1,major_radius,minor_radius):
293     anObj = PrimOp.MakeTorusPntVecRR(p1,v1,major_radius,minor_radius)
294     if PrimOp.IsDone() == 0:
295       print "MakeTorusPntVecRR : ", PrimOp.GetErrorCode()
296     return anObj
297
298 def MakeTorusRR(major_radius,minor_radius):
299     anObj = PrimOp.MakeTorusRR(major_radius,minor_radius)
300     if PrimOp.IsDone() == 0:
301       print "MakeTorusRR : ", PrimOp.GetErrorCode()
302     return anObj
303
304 def MakePrism(baseShape,point1,point2):
305     anObj = PrimOp.MakePrismTwoPnt(baseShape,point1,point2)
306     if PrimOp.IsDone() == 0:
307       print "MakePrismTwoPnt : ", PrimOp.GetErrorCode()
308     return anObj
309
310 def MakePrismVecH(baseShape,vector,height):
311     anObj = PrimOp.MakePrismVecH(baseShape,vector,height)
312     if PrimOp.IsDone() == 0:
313       print "MakePrismVecH : ", PrimOp.GetErrorCode()
314     return anObj
315
316 def MakePipe(baseShape,pathShape):
317     anObj = PrimOp.MakePipe(baseShape,pathShape)
318     if PrimOp.IsDone() == 0:
319       print "MakePipe : ", PrimOp.GetErrorCode()
320     return anObj
321
322 def MakeRevolution(aShape,axis,angle):
323     anObj = PrimOp.MakeRevolutionAxisAngle(aShape,axis,angle)
324     if PrimOp.IsDone() == 0:
325       print "MakeRevolutionAxisAngle : ", PrimOp.GetErrorCode()
326     return anObj
327
328 # -----------------------------------------------------------------------------
329 # Create base shapes
330 # -----------------------------------------------------------------------------
331
332 def MakeEdge(p1,p2):
333     anObj = ShapesOp.MakeEdge(p1,p2)
334     if ShapesOp.IsDone() == 0:
335       print "MakeEdge : ", ShapesOp.GetErrorCode()
336     return anObj
337
338 def MakeWire(ListShape):
339     anObj = ShapesOp.MakeWire(ListShape)
340     if ShapesOp.IsDone() == 0:
341       print "MakeWire : ", ShapesOp.GetErrorCode()
342     return anObj
343
344 def MakeFace(aShapeWire,WantPlanarFace):
345     anObj = ShapesOp.MakeFace(aShapeWire,WantPlanarFace)
346     if ShapesOp.IsDone() == 0:
347       print "MakeFace : ", ShapesOp.GetErrorCode()
348     return anObj
349
350 def MakeFaceWires(ListWires,WantPlanarFace):
351     anObj = ShapesOp.MakeFaceWires(ListWires,WantPlanarFace)
352     if ShapesOp.IsDone() == 0:
353       print "MakeFaceWires : ", ShapesOp.GetErrorCode()
354     return anObj
355
356 def MakeFaces(ListWires,WantPlanarFace):
357     anObj = MakeFaceWires(ListWires,WantPlanarFace)
358     return anObj
359
360 def MakeShell(ListOfShapes):
361     anObj = ShapesOp.MakeShell(ListOfShapes)
362     if ShapesOp.IsDone() == 0:
363         print "MakeShell : ", ShapesOp.GetErrorCode()
364     return anObj
365
366 def MakeSolid(ListOfShells):
367     anObj = ShapesOp.MakeSolidShells(ListOfShells)
368     if ShapesOp.IsDone() == 0:
369         print "MakeSolid : ", ShapesOp.GetErrorCode()
370     return anObj
371
372 def MakeCompound(ListShape):
373     anObj = ShapesOp.MakeCompound(ListShape)
374     if ShapesOp.IsDone() == 0:
375       print "MakeCompound : ", ShapesOp.GetErrorCode()
376     return anObj
377
378 def ChangeOrientation(Shape):
379     anObj = ShapesOp.ChangeOrientation(Shape)
380     if ShapesOp.IsDone() == 0:
381       print "ChangeOrientation : ", ShapesOp.GetErrorCode()
382     return anObj
383
384 def OrientationChange(Shape):
385     anObj = ChangeOrientation(Shape)
386     return anObj
387
388 # -----------------------------------------------------------------------------
389 # Access to sub-shapes by their unique IDs inside the main shape.
390 # -----------------------------------------------------------------------------
391
392 # Obtain a composite sub-shape of <aShape>, composed from sub-shapes
393 # of <aShape>, selected by their unique IDs inside <aShape>
394 def GetSubShape(aShape, ListOfID):
395     anObj = geom.AddSubShape(aShape,ListOfID)
396     return anObj
397
398 # Obtain unique ID of sub-shape <aSubShape> inside <aShape>
399 def GetSubShapeID(aShape, aSubShape):
400     anID = LocalOp.GetSubShapeIndex(aShape, aSubShape)
401     if LocalOp.IsDone() == 0:
402       print "GetSubShapeIndex : ", LocalOp.GetErrorCode()
403     return anID
404
405 # -----------------------------------------------------------------------------
406 # Decompose objects
407 # -----------------------------------------------------------------------------
408
409 def SubShapeAll(aShape, aType):
410     ListObj = ShapesOp.MakeExplode(aShape,aType,0)
411     if ShapesOp.IsDone() == 0:
412       print "MakeExplode : ", ShapesOp.GetErrorCode()
413     return ListObj
414
415 def SubShapeAllSorted(aShape,aType):
416     ListObj = ShapesOp.MakeExplode(aShape,aType,1)
417     if ShapesOp.IsDone() == 0:
418       print "MakeExplode : ", ShapesOp.GetErrorCode()
419     return ListObj
420
421 # Obtain a compound of sub-shapes of <aShape>,
422 # selected by they indices in list of all sub-shapes of type <aType>
423 def SubShape(aShape, aType, ListOfInd):
424     ListOfIDs = []
425     AllShapeList = SubShapeAll(aShape, aType)
426     for ind in ListOfInd:
427         ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
428     anObj = GetSubShape(aShape, ListOfIDs)
429     return anObj
430
431 # Obtain a compound of sub-shapes of <aShape>,
432 # selected by they indices in sorted list of all sub-shapes of type <aType>
433 def SubShapeSorted(aShape, aType, ListOfInd):
434     ListOfIDs = []
435     AllShapeList = SubShapeAllSorted(aShape, aType)
436     for ind in ListOfInd:
437         ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
438     anObj = GetSubShape(aShape, ListOfIDs)
439     return anObj
440
441 # -----------------------------------------------------------------------------
442 # Healing operations
443 # -----------------------------------------------------------------------------
444
445 def ProcessShape(Shape, Operators, Parameters, Values):
446     anObj = HealOp.ProcessShape(Shape, Operators, Parameters, Values)
447     if HealOp.IsDone() == 0:
448         print "ProcessShape : ", HealOp.GetErrorCode()
449     return anObj
450
451 def SuppressFaces(aShape,ListOfId):
452     anObj = HealOp.SuppressFaces(aShape,ListOfId)
453     if HealOp.IsDone() == 0:
454       print "SuppressFaces : ", HealOp.GetErrorCode()
455     return anObj
456
457 def MakeSewing(ListShape,precision):
458     comp = MakeCompound(ListShape)
459     anObj = Sew(comp,precision)
460     return anObj
461
462 def Sew(aShape,precision):
463     anObj = HealOp.Sew(aShape,precision)
464     if HealOp.IsDone() == 0:
465       print "Sew : ", HealOp.GetErrorCode()
466     return anObj
467
468 def SuppressInternalWires(aShape, Wires):
469     anObj = HealOp.RemoveIntWires(aShape, Wires)
470     if HealOp.IsDone() == 0:
471       print "SuppressInternalWires : ", HealOp.GetErrorCode()
472     return anObj
473
474 def SuppressHoles(aShape, ListOfId):
475     anObj = HealOp.FillHoles(aShape,ListOfId)
476     if HealOp.IsDone() == 0:
477       print "SuppressHoles : ", HealOp.GetErrorCode()
478     return anObj
479
480 def CloseContour(aShape, Wires, IsCommonVertex):
481     anObj = HealOp.CloseContour(aShape, Wires, IsCommonVertex)
482     if HealOp.IsDone() == 0:
483       print "CloseContour : ", HealOp.GetErrorCode()
484     return anObj
485
486 def DivideEdge(aShape, EdgeID, Value, IsByParameter):
487     anObj = HealOp.DivideEdge(aShape, EdgeID, Value, IsByParameter)
488     if HealOp.IsDone() == 0:
489       print "DivideEdge : ", HealOp.GetErrorCode()
490     return anObj
491
492 def GetFreeBoundary(Shape):
493     anObj = HealOp.GetFreeBoundary(Shape)
494     if HealOp.IsDone() == 0:
495       print "GetFreeBoundaries : ", HealOp.GetErrorCode()
496     return anObj
497
498 # -----------------------------------------------------------------------------
499 # Create advanced objects
500 # -----------------------------------------------------------------------------
501
502 def MakeCopy(aShape):
503     anObj = InsertOp.MakeCopy(aShape)
504     if InsertOp.IsDone() == 0:
505       print "MakeCopy : ", InsertOp.GetErrorCode()
506     return anObj
507
508 def MakeFilling(aShape,mindeg,maxdeg,tol2d,tol3d,nbiter):
509     anObj = PrimOp.MakeFilling(aShape,mindeg,maxdeg,tol2d,tol3d,nbiter)
510     if PrimOp.IsDone() == 0:
511       print "MakeFilling : ", PrimOp.GetErrorCode()
512     return anObj
513
514 def MakeGlueFaces(aShape,aTolerance):
515     anObj = ShapesOp.MakeGlueFaces(aShape,aTolerance)
516     if ShapesOp.IsDone() == 0:
517       print "MakeGlueFaces : ", ShapesOp.GetErrorCode()
518     return anObj
519
520 # -----------------------------------------------------------------------------
521 # Boolean (Common, Cut, Fuse, Section)
522 # -----------------------------------------------------------------------------
523
524 def MakeBoolean(shape1,shape2,operation):
525     anObj = BoolOp.MakeBoolean(shape1,shape2,operation)
526     if BoolOp.IsDone() == 0:
527       print "MakeBoolean : ", BoolOp.GetErrorCode()
528     return anObj
529
530 def MakeCommon(s1, s2):
531     return MakeBoolean(s1, s2, 1)
532
533 def MakeCut(s1, s2):
534     return MakeBoolean(s1, s2, 2)
535
536 def MakeFuse(s1, s2):
537     return MakeBoolean(s1, s2, 3)
538
539 def MakeSection(s1, s2):
540     return MakeBoolean(s1, s2, 4)
541
542 def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
543                   Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
544     anObj = BoolOp.MakePartition(ListShapes, ListTools,
545                                  ListKeepInside, ListRemoveInside,
546                                  Limit, RemoveWebs, ListMaterials);
547     if BoolOp.IsDone() == 0:
548       print "MakePartition : ", BoolOp.GetErrorCode()
549     return anObj
550
551 def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
552               Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
553     anObj = MakePartition(ListShapes, ListTools,
554                           ListKeepInside, ListRemoveInside,
555                           Limit, RemoveWebs, ListMaterials);
556     return anObj
557
558 # -----------------------------------------------------------------------------
559 # Transform objects
560 # -----------------------------------------------------------------------------
561
562 def MakeTranslationTwoPoints(aShape,point1,point2):
563     anObj = TrsfOp.TranslateTwoPointsCopy(aShape,point1,point2)
564     if TrsfOp.IsDone() == 0:
565       print "TranslateTwoPointsCopy : ", TrsfOp.GetErrorCode()
566     return anObj
567
568 def MakeTranslation(aShape,dx,dy,dz):
569     anObj = TrsfOp.TranslateDXDYDZCopy(aShape,dx,dy,dz)
570     if TrsfOp.IsDone() == 0:
571       print "TranslateDXDYDZCopy : ", TrsfOp.GetErrorCode()
572     return anObj
573
574 def MakeRotation(aShape,axis,angle):
575     anObj = TrsfOp.RotateCopy(aShape,axis,angle)
576     if TrsfOp.IsDone() == 0:
577       print "RotateCopy : ", TrsfOp.GetErrorCode()
578     return anObj
579
580 def MakeScaleTransform(aShape,theCenterofScale,factor):
581     anObj = TrsfOp.ScaleShapeCopy(aShape,theCenterofScale,factor)
582     if TrsfOp.IsDone() == 0:
583       print "ScaleShapeCopy : ", TrsfOp.GetErrorCode()
584     return anObj
585
586 def MakeMirrorByPlane(aShape,aPlane):
587     anObj = TrsfOp.MirrorPlaneCopy(aShape,aPlane)
588     if TrsfOp.IsDone() == 0:
589       print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode()
590     return anObj
591
592 def MakePosition(aShape,theStartLCS,theEndLCS):
593     anObj = TrsfOp.PositionShapeCopy(aShape,theStartLCS,theEndLCS)
594     if TrsfOp.IsDone() == 0:
595       print "PositionShapeCopy : ", TrsfOp.GetErrorCode()
596     return anObj
597
598 def MakeOffset(aShape, anOffset):
599     anObj = TrsfOp.OffsetShapeCopy(aShape, anOffset)
600     if TrsfOp.IsDone() == 0:
601       print "OffsetShapeCopy : ", TrsfOp.GetErrorCode()
602     return anObj
603
604 # -----------------------------------------------------------------------------
605 # Patterns
606 # -----------------------------------------------------------------------------
607
608 def MakeMultiTranslation1D(aShape,aDir,aStep,aNbTimes):
609     anObj = TrsfOp.MultiTranslate1D(aShape,aDir,aStep,aNbTimes)
610     if TrsfOp.IsDone() == 0:
611       print "MultiTranslate1D : ", TrsfOp.GetErrorCode()
612     return anObj
613
614 def MakeMultiTranslation2D(aShape,d1,step1,nbtimes1,d2,step2,nbtimes2):
615     anObj = TrsfOp.MultiTranslate2D(aShape,d1,step1,nbtimes1,d2,step2,nbtimes2)
616     if TrsfOp.IsDone() == 0:
617       print "MultiTranslate2D : ", TrsfOp.GetErrorCode()
618     return anObj
619
620 def MultiRotate1D(aShape,aVec,aNbTimes):
621     anObj = TrsfOp.MultiRotate1D(aShape,aVec,aNbTimes)
622     if TrsfOp.IsDone() == 0:
623       print "MultiRotate1D : ", TrsfOp.GetErrorCode()
624     return anObj
625
626 def MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2):
627     anObj = TrsfOp.MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
628     if TrsfOp.IsDone() == 0:
629       print "MultiRotate2D : ", TrsfOp.GetErrorCode()
630     return anObj
631
632 def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes):
633     aVec = MakeLine(aPoint,aDir)
634     anObj = MultiRotate1D(aShape,aVec,aNbTimes)
635     return anObj
636
637 def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2):
638     aVec = MakeLine(aPoint,aDir)
639     anObj = MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
640     return anObj
641
642 # -----------------------------------------------------------------------------
643 # Local operations
644 # -----------------------------------------------------------------------------
645
646 def MakeFilletAll(aShape,radius):
647     anObj = LocalOp.MakeFilletAll(aShape,radius)
648     if LocalOp.IsDone() == 0:
649       print "MakeFilletAll : ", LocalOp.GetErrorCode()
650     return anObj
651
652 def MakeFillet(aShape,radius,aShapeType,ListShape):
653     anObj = None
654     if aShapeType == ShapeType["EDGE"]:
655         anObj = LocalOp.MakeFilletEdges(aShape,radius,ListShape)
656     else:
657         anObj = LocalOp.MakeFilletFaces(aShape,radius,ListShape)
658     if LocalOp.IsDone() == 0:
659       print "MakeFillet : ", LocalOp.GetErrorCode()
660     return anObj
661
662 def MakeChamferAll(aShape,d):
663     anObj = LocalOp.MakeChamferAll(aShape,d)
664     if LocalOp.IsDone() == 0:
665       print "MakeChamferAll : ", LocalOp.GetErrorCode()
666     return anObj
667
668 def MakeChamferEdge(aShape,d1,d2,face1,face2):
669     anObj = LocalOp.MakeChamferEdge(aShape,d1,d2,face1,face2)
670     if LocalOp.IsDone() == 0:
671       print "MakeChamferEdge : ", LocalOp.GetErrorCode()
672     return anObj
673
674 def MakeChamferFaces(aShape,d1,d2,ListShape):
675     anObj = LocalOp.MakeChamferFaces(aShape,d1,d2,ListShape)
676     if LocalOp.IsDone() == 0:
677       print "MakeChamferFaces : ", LocalOp.GetErrorCode()
678     return anObj
679
680 def MakeChamfer(aShape,d1,d2,aShapeType,ListShape):
681     anObj = None
682     if aShapeType == ShapeType["EDGE"]:
683         anObj = MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1])
684     else:
685         anObj = MakeChamferFaces(aShape,d1,d2,ListShape)
686     return anObj
687
688 def Archimede(aShape,weight,WaterDensity,MeshingDeflection):
689     anObj = LocalOp.MakeArchimede(aShape,weight,WaterDensity,MeshingDeflection)
690     if LocalOp.IsDone() == 0:
691       print "MakeArchimede : ", LocalOp.GetErrorCode()
692     return anObj
693
694 # -----------------------------------------------------------------------------
695 # Information objects
696 # -----------------------------------------------------------------------------
697
698 def PointCoordinates(Point):
699     aTuple = MeasuOp.PointCoordinates(Point)
700     if MeasuOp.IsDone() == 0:
701       print "PointCoordinates : ", MeasuOp.GetErrorCode()
702     return aTuple
703
704 def BasicProperties(Shape):
705     aTuple = MeasuOp.GetBasicProperties(Shape)
706     if MeasuOp.IsDone() == 0:
707       print "BasicProperties : ", MeasuOp.GetErrorCode()
708     return aTuple
709
710 def BoundingBox(Shape):
711     aTuple = MeasuOp.GetBoundingBox(Shape)
712     if MeasuOp.IsDone() == 0:
713       print "BoundingBox : ", MeasuOp.GetErrorCode()
714     return aTuple
715
716 def Inertia(Shape):
717     aTuple = MeasuOp.GetInertia(Shape)
718     if MeasuOp.IsDone() == 0:
719       print "Inertia : ", MeasuOp.GetErrorCode()
720     return aTuple
721
722 def MinDistance(Shape1, Shape2):
723     aTuple = MeasuOp.GetMinDistance(Shape1, Shape2)
724     if MeasuOp.IsDone() == 0:
725       print "MinDistance : ", MeasuOp.GetErrorCode()
726     return aTuple[0]
727
728 def Tolerance(Shape):
729     aTuple = MeasuOp.GetTolerance(Shape)
730     if MeasuOp.IsDone() == 0:
731       print "Tolerance : ", MeasuOp.GetErrorCode()
732     return aTuple
733
734 def WhatIs(Shape):
735     aDescr = MeasuOp.WhatIs(Shape)
736     if MeasuOp.IsDone() == 0:
737       print "WhatIs : ", MeasuOp.GetErrorCode()
738     return aDescr
739
740 def MakeCDG(aShape):
741     anObj = MeasuOp.GetCentreOfMass(aShape)
742     if MeasuOp.IsDone() == 0:
743       print "GetCentreOfMass : ", MeasuOp.GetErrorCode()
744     return anObj
745
746 def CheckShape(aShape):
747     (IsValid, Status) = MeasuOp.CheckShape(aShape)
748     if MeasuOp.IsDone() == 0:
749       print "CheckShape : ", MeasuOp.GetErrorCode()
750     else:
751       if IsValid == 0:
752         print Status
753     return IsValid
754
755 # -----------------------------------------------------------------------------
756 # Import/Export objects
757 # -----------------------------------------------------------------------------
758
759 def Import(filename, formatname):
760     anObj = InsertOp.Import(filename, formatname)
761     if InsertOp.IsDone() == 0:
762       print "Import : ", InsertOp.GetErrorCode()
763     return anObj
764
765 def Export(aShape, filename, formatname):
766     InsertOp.Export(aShape, filename, formatname)
767     if InsertOp.IsDone() == 0:
768       print "Export : ", InsertOp.GetErrorCode()
769
770 # -----------------------------------------------------------------------------
771 # Block operations
772 # -----------------------------------------------------------------------------
773
774 def MakeQuad(E1, E2, E3, E4):
775     anObj = BlocksOp.MakeQuad(E1, E2, E3, E4)
776     if BlocksOp.IsDone() == 0:
777       print "MakeQuad : ", BlocksOp.GetErrorCode()
778     return anObj
779
780 def MakeQuad2Edges(E1, E2):
781     anObj = BlocksOp.MakeQuad2Edges(E1, E2)
782     if BlocksOp.IsDone() == 0:
783       print "MakeQuad2Edges : ", BlocksOp.GetErrorCode()
784     return anObj
785
786 def MakeQuad4Vertices(V1, V2, V3, V4):
787     anObj = BlocksOp.MakeQuad4Vertices(V1, V2, V3, V4)
788     if BlocksOp.IsDone() == 0:
789       print "MakeQuad4Vertices : ", BlocksOp.GetErrorCode()
790     return anObj
791
792 def MakeHexa(F1, F2, F3, F4, F5, F6):
793     anObj = BlocksOp.MakeHexa(F1, F2, F3, F4, F5, F6)
794     if BlocksOp.IsDone() == 0:
795       print "MakeHexa : ", BlocksOp.GetErrorCode()
796     return anObj
797
798 def MakeHexa2Faces(F1, F2):
799     anObj = BlocksOp.MakeHexa2Faces(F1, F2)
800     if BlocksOp.IsDone() == 0:
801       print "MakeHexa2Faces : ", BlocksOp.GetErrorCode()
802     return anObj
803
804 def MakeMultiTransformation1D(Block, DirFaceID1, DirFaceID2, NbTimes):
805     anObj = BlocksOp.MakeMultiTransformation1D(Block, DirFaceID1, DirFaceID2, NbTimes)
806     if BlocksOp.IsDone() == 0:
807       print "MakeMultiTransformation1D : ", BlocksOp.GetErrorCode()
808     return anObj
809
810 def MakeMultiTransformation2D(Block, DirFaceID1U, DirFaceID2U, NbTimesU,
811                                      DirFaceID1V, DirFaceID2V, NbTimesV):
812     anObj = BlocksOp.MakeMultiTransformation2D(Block, DirFaceID1U, DirFaceID2U, NbTimesU,
813                                                       DirFaceID1V, DirFaceID2V, NbTimesV)
814     if BlocksOp.IsDone() == 0:
815       print "MakeMultiTransformation2D : ", BlocksOp.GetErrorCode()
816     return anObj
817
818 def MakeBlockExplode(Compound, MinNbFaces, MaxNbFaces):
819     aList = BlocksOp.ExplodeCompoundOfBlocks(Compound, MinNbFaces, MaxNbFaces)
820     if BlocksOp.IsDone() == 0:
821       print "MakeBlockExplode : ", BlocksOp.GetErrorCode()
822     return aList
823
824 def CheckCompoundOfBlocks(Compound):
825     (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(Compound)
826     if BlocksOp.IsDone() == 0:
827       print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode()
828     else:
829       if IsValid == 0:
830         Descr = BlocksOp.PrintBCErrors(Compound, BCErrors)
831         print Descr
832     return IsValid
833
834 # -----------------------------------------------------------------------------
835 # Group operations
836 # -----------------------------------------------------------------------------
837
838 def CreateGroup(MainShape, ShapeType):
839     anObj = GroupOp.CreateGroup(MainShape, ShapeType)
840     if GroupOp.IsDone() == 0:
841        print "CreateGroup : ", GroupOp.GetErrorCode()
842     return anObj
843
844 def AddObject(Group, SubShapeID):
845     GroupOp.AddObject(Group, SubShapeID)
846     if GroupOp.IsDone() == 0:
847       print "AddObject : ", GroupOp.GetErrorCode()
848
849 def RemoveObject(Group, SubShapeID):
850     GroupOp.RemoveObject(Group, SubShapeID)
851     if GroupOp.IsDone() == 0:
852       print "RemoveObject : ", GroupOp.GetErrorCode()
853
854 def GetObjectIDs(Group):
855     ListIDs = GroupOp.GetObjects(Group)
856     if GroupOp.IsDone() == 0:
857       print "GetObjectIDs : ", GroupOp.GetErrorCode()
858     return ListIDs
859
860 def addPath(Path):
861     if (sys.path.count(Path) < 1):
862         sys.path.append(Path)