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