1 # GEOM GEOM_SWIG : binding of C++ omplementaion with Python
3 # Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
25 # Author : Paul RASCLE, EDF
31 geom = lcc.FindOrLoadComponent("FactoryServer", "GEOM")
32 myBuilder = myStudy.NewBuilder()
34 father = myStudy.FindComponent("GEOM")
36 father = myBuilder.NewComponent("GEOM")
37 A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName")
38 FName = A1._narrow(SALOMEDS.AttributeName)
39 FName.SetValue("Geometry")
40 A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap")
41 aPixmap = A2._narrow(SALOMEDS.AttributePixMap)
42 aPixmap.SetPixMap("ICON_OBJBROWSER_Geometry")
43 myBuilder.DefineComponentInstance(father,geom)
45 # -----------------------------------------------------------------------------
47 # -----------------------------------------------------------------------------
49 gg = ImportComponentGUI("GEOM")
51 def SubShapeName(aSubObj, aMainObj):
52 aSubId = orb.object_to_string(aSubObj)
53 aMainId = orb.object_to_string(aMainObj)
54 index = gg.getIndexTopology(aSubId, aMainId)
55 name = gg.getShapeTypeString(aSubId) + "_%d"%(index)
58 # -----------------------------------------------------------------------------
59 # The code below is common with batchmode_geompy.py
60 # -----------------------------------------------------------------------------
62 def addToStudy(aShape, aName):
64 aSObject = geom.AddInStudy(myStudy, aShape, aName, None)
66 print "addToStudy() failed"
68 return aShape.GetStudyEntry()
70 def addToStudyInFather(aFather, aShape, aName):
72 # myBuilder.NewCommand()
73 aSObject = geom.AddInStudy(myStudy, aShape, aName, aFather)
74 # myBuilder.CommitCommand()
76 print "addToStudyInFather() failed"
78 return aShape.GetStudyEntry()
80 # -----------------------------------------------------------------------------
81 # enumeration ShapeType as a dictionary
82 # -----------------------------------------------------------------------------
84 ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
86 # -----------------------------------------------------------------------------
87 # Get Operations Interfaces
88 # -----------------------------------------------------------------------------
90 BasicOp = geom.GetIBasicOperations (myStudyId)
91 CurvesOp = geom.GetICurvesOperations (myStudyId)
92 PrimOp = geom.GetI3DPrimOperations (myStudyId)
93 ShapesOp = geom.GetIShapesOperations (myStudyId)
94 HealOp = geom.GetIHealingOperations (myStudyId)
95 InsertOp = geom.GetIInsertOperations (myStudyId)
96 BoolOp = geom.GetIBooleanOperations (myStudyId)
97 TrsfOp = geom.GetITransformOperations(myStudyId)
98 LocalOp = geom.GetILocalOperations (myStudyId)
99 MeasuOp = geom.GetIMeasureOperations (myStudyId)
100 BlocksOp = geom.GetIBlocksOperations (myStudyId)
101 GroupOp = geom.GetIGroupOperations (myStudyId)
103 # -----------------------------------------------------------------------------
105 # -----------------------------------------------------------------------------
107 def MakeVertex(x,y,z):
108 anObj = BasicOp.MakePointXYZ(x,y,z)
109 if BasicOp.IsDone() == 0:
110 print "MakePointXYZ : ", BasicOp.GetErrorCode()
113 def MakeVertexWithRef(vertex,x,y,z):
114 anObj = BasicOp.MakePointWithReference(vertex,x,y,z)
115 if BasicOp.IsDone() == 0:
116 print "MakePointWithReference : ", BasicOp.GetErrorCode()
119 def MakeVertexOnCurve(curve,par):
120 anObj = BasicOp.MakePointOnCurve(curve,par)
121 if BasicOp.IsDone() == 0:
122 print "MakePointOnCurve : ", BasicOp.GetErrorCode()
125 def MakeVectorDXDYDZ(dx,dy,dz):
126 anObj = BasicOp.MakeVectorDXDYDZ(dx,dy,dz)
127 if BasicOp.IsDone() == 0:
128 print "MakeVectorDXDYDZ : ", BasicOp.GetErrorCode()
131 def MakeVector(p1,p2):
132 anObj = BasicOp.MakeVectorTwoPnt(p1, p2)
133 if BasicOp.IsDone() == 0:
134 print "MakeVectorTwoPnt : ", BasicOp.GetErrorCode()
137 def MakeLine(p1, p2):
138 anObj = BasicOp.MakeLineTwoPnt(p1,p2)
139 if BasicOp.IsDone() == 0:
140 print "MakeLineTwoPnt : ", BasicOp.GetErrorCode()
143 def MakePlane(p1,v1,trimsize):
144 anObj = BasicOp.MakePlanePntVec(p1,v1,trimsize)
145 if BasicOp.IsDone() == 0:
146 print "MakePlanePntVec : ", BasicOp.GetErrorCode()
149 def MakePlaneThreePnt(p1,p2,p3,trimsize):
150 anObj = BasicOp.MakePlaneThreePnt(p1,p2,p3,trimsize)
151 if BasicOp.IsDone() == 0:
152 print "MakePlaneThreePnt : ", BasicOp.GetErrorCode()
155 def MakePlaneFace(face,trimsize):
156 anObj = BasicOp.MakePlaneFace(face,trimsize)
157 if BasicOp.IsDone() == 0:
158 print "MakePlaneFace : ", BasicOp.GetErrorCode()
161 def MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ):
162 anObj = BasicOp.MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ)
163 if BasicOp.IsDone() == 0:
164 print "MakeMarker : ", BasicOp.GetErrorCode()
167 # -----------------------------------------------------------------------------
169 # -----------------------------------------------------------------------------
171 def MakeArc(p1,p2,p3):
172 anObj = CurvesOp.MakeArc(p1,p2,p3)
173 if CurvesOp.IsDone() == 0:
174 print "MakeArc : ", CurvesOp.GetErrorCode()
177 def MakeCircle(p1,v1,radius):
178 anObj = CurvesOp.MakeCirclePntVecR(p1,v1,radius)
179 if CurvesOp.IsDone() == 0:
180 print "MakeCirclePntVecR : ", CurvesOp.GetErrorCode()
183 def MakeCircleThreePnt(p1,p2,p3):
184 anObj = CurvesOp.MakeCircleThreePnt(p1,p2,p3)
185 if CurvesOp.IsDone() == 0:
186 print "MakeCircleThreePnt : ", CurvesOp.GetErrorCode()
189 def MakeEllipse(p1,v1,radiusMaj,radiusMin):
190 anObj = CurvesOp.MakeEllipse(p1,v1,radiusMaj, radiusMin)
191 if CurvesOp.IsDone() == 0:
192 print "MakeEllipse : ", CurvesOp.GetErrorCode()
195 def MakePolyline(ListShape):
196 anObj = CurvesOp.MakePolyline(ListShape)
197 if CurvesOp.IsDone() == 0:
198 print "MakePolyline : ", CurvesOp.GetErrorCode()
201 def MakeBezier(ListShape):
202 anObj = CurvesOp.MakeSplineBezier(ListShape)
203 if CurvesOp.IsDone() == 0:
204 print "MakeSplineBezier : ", CurvesOp.GetErrorCode()
207 def MakeInterpol(ListShape):
208 anObj = CurvesOp.MakeSplineInterpolation(ListShape)
209 if CurvesOp.IsDone() == 0:
210 print "MakeSplineInterpolation : ", CurvesOp.GetErrorCode()
213 def MakeSketcher(Cmd, WPL):
214 anObj = CurvesOp.MakeSketcher(Cmd, WPL)
215 if CurvesOp.IsDone() == 0:
216 print "MakeSketcher : ", CurvesOp.GetErrorCode()
219 # -----------------------------------------------------------------------------
220 # Create 3D Primitives
221 # -----------------------------------------------------------------------------
223 def MakeBox(x1,y1,z1,x2,y2,z2):
224 pnt1 = MakeVertex(x1,y1,z1)
225 pnt2 = MakeVertex(x2,y2,z2)
226 return MakeBoxTwoPnt(pnt1,pnt2)
228 def MakeBoxDXDYDZ(dx,dy,dz):
229 anObj = PrimOp.MakeBoxDXDYDZ(dx,dy,dz)
230 if PrimOp.IsDone() == 0:
231 print "MakeBoxDXDYDZ : ", PrimOp.GetErrorCode()
234 def MakeBoxTwoPnt(point1, point2):
235 anObj = PrimOp.MakeBoxTwoPnt(point1, point2)
236 if PrimOp.IsDone() == 0:
237 print "MakeBoxTwoPnt : ", PrimOp.GetErrorCode()
240 def MakeCylinder(p1,v1,radius,height):
241 anObj = PrimOp.MakeCylinderPntVecRH(p1,v1,radius,height)
242 if PrimOp.IsDone() == 0:
243 print "MakeCylinderPntVecRH : ", PrimOp.GetErrorCode()
246 def MakeCylinderRH(radius,height):
247 anObj = PrimOp.MakeCylinderRH(radius,height)
248 if PrimOp.IsDone() == 0:
249 print "MakeCylinderRH : ", PrimOp.GetErrorCode()
252 def MakeSphere(point,radius):
253 anObj = PrimOp.MakeSpherePntR(point,radius)
254 if PrimOp.IsDone() == 0:
255 print "MakeSpherePntR : ", PrimOp.GetErrorCode()
258 def MakeSphereR(radius):
259 anObj = PrimOp.MakeSphereR(radius)
260 if PrimOp.IsDone() == 0:
261 print "MakeSphereR : ", PrimOp.GetErrorCode()
264 def MakeCone(p1,v1,radius1,radius2,height):
265 anObj = PrimOp.MakeConePntVecR1R2H(p1,v1,radius1,radius2,height)
266 if PrimOp.IsDone() == 0:
267 print "MakeConePntVecR1R2H : ", PrimOp.GetErrorCode()
270 def MakeConeR1R2H(radius1,radius2,height):
271 anObj = PrimOp.MakeConeR1R2H(radius1,radius2,height)
272 if PrimOp.IsDone() == 0:
273 print "MakeConeR1R2H : ", PrimOp.GetErrorCode()
276 def MakeTorus(p1,v1,major_radius,minor_radius):
277 anObj = PrimOp.MakeTorusPntVecRR(p1,v1,major_radius,minor_radius)
278 if PrimOp.IsDone() == 0:
279 print "MakeTorusPntVecRR : ", PrimOp.GetErrorCode()
282 def MakeTorusRR(major_radius,minor_radius):
283 anObj = PrimOp.MakeTorusRR(major_radius,minor_radius)
284 if PrimOp.IsDone() == 0:
285 print "MakeTorusRR : ", PrimOp.GetErrorCode()
288 def MakePrism(baseShape,vector,height):
289 anObj = PrimOp.MakePrismVecH(baseShape,vector,height)
290 if PrimOp.IsDone() == 0:
291 print "MakePrismVecH : ", PrimOp.GetErrorCode()
294 def MakePrismTwoPnt(baseShape,point1,point2):
295 anObj = PrimOp.MakePrismTwoPnt(baseShape,point1,point2)
296 if PrimOp.IsDone() == 0:
297 print "MakePrismTwoPnt : ", PrimOp.GetErrorCode()
300 def MakePipe(baseShape,pathShape):
301 anObj = PrimOp.MakePipe(baseShape,pathShape)
302 if PrimOp.IsDone() == 0:
303 print "MakePipe : ", PrimOp.GetErrorCode()
306 def MakeRevolution(aShape,axis,angle):
307 anObj = PrimOp.MakeRevolutionAxisAngle(aShape,axis,angle)
308 if PrimOp.IsDone() == 0:
309 print "MakeRevolutionAxisAngle : ", PrimOp.GetErrorCode()
312 # -----------------------------------------------------------------------------
314 # -----------------------------------------------------------------------------
317 anObj = ShapesOp.MakeEdge(p1,p2)
318 if ShapesOp.IsDone() == 0:
319 print "MakeEdge : ", ShapesOp.GetErrorCode()
322 def MakeWire(ListShape):
323 anObj = ShapesOp.MakeWire(ListShape)
324 if ShapesOp.IsDone() == 0:
325 print "MakeWire : ", ShapesOp.GetErrorCode()
328 def MakeFace(aShapeWire,WantPlanarFace):
329 anObj = ShapesOp.MakeFace(aShapeWire,WantPlanarFace)
330 if ShapesOp.IsDone() == 0:
331 print "MakeFace : ", ShapesOp.GetErrorCode()
334 def MakeFaceWires(ListWires,WantPlanarFace):
335 anObj = ShapesOp.MakeFaceWires(ListWires,WantPlanarFace)
336 if ShapesOp.IsDone() == 0:
337 print "MakeFaceWires : ", ShapesOp.GetErrorCode()
340 def MakeShell(ListOfShapes):
341 anObj = ShapesOp.MakeShell(ListOfShapes)
342 if ShapesOp.IsDone() == 0:
343 print "MakeShell : ", ShapesOp.GetErrorCode()
346 def MakeSolid(ListOfShells):
347 anObj = ShapesOp.MakeSolidShells(ListOfShells)
348 if ShapesOp.IsDone() == 0:
349 print "MakeSolid : ", ShapesOp.GetErrorCode()
352 def MakeCompound(ListShape):
353 anObj = ShapesOp.MakeCompound(ListShape)
354 if ShapesOp.IsDone() == 0:
355 print "MakeCompound : ", ShapesOp.GetErrorCode()
358 def ChangeOrientation(Shape):
359 anObj = ShapesOp.ChangeOrientation(Shape)
360 if ShapesOp.IsDone() == 0:
361 print "ChangeOrientation : ", ShapesOp.GetErrorCode()
364 # -----------------------------------------------------------------------------
366 # -----------------------------------------------------------------------------
368 def SubShape(aShape,ListOfId):
369 anObj = geom.AddSubShape(aShape,ListOfId)
372 def SubShapeAll(aShape,type):
373 ListObj = ShapesOp.MakeExplode(aShape,type,0)
374 if ShapesOp.IsDone() == 0:
375 print "MakeExplode : ", ShapesOp.GetErrorCode()
378 def SubShapeAllSorted(aShape,type):
379 ListObj = ShapesOp.MakeExplode(aShape,type,1)
380 if ShapesOp.IsDone() == 0:
381 print "MakeExplode : ", ShapesOp.GetErrorCode()
384 def GetSubShapeID(aShape, aSubShape):
385 return LocalOp.GetSubShapeIndex(aShape, aSubShape)
387 # -----------------------------------------------------------------------------
389 # -----------------------------------------------------------------------------
391 def ProcessShape(Shape, Operators, Parameters, Values):
392 anObj = HealOp.ProcessShape(Shape, Operators, Parameters, Values)
393 if HealOp.IsDone() == 0:
394 print "ProcessShape : ", HealOp.GetErrorCode()
397 def SuppressFaces(aShape,ListOfId):
398 anObj = HealOp.SuppressFaces(aShape,ListOfId)
399 if HealOp.IsDone() == 0:
400 print "SuppressFaces : ", HealOp.GetErrorCode()
403 def MakeSewing(ListShape,precision):
404 comp = MakeCompound(ListShape)
405 anObj = Sew(comp,precision)
408 def Sew(aShape,precision):
409 anObj = HealOp.Sew(aShape,precision)
410 if HealOp.IsDone() == 0:
411 print "Sew : ", HealOp.GetErrorCode()
414 def SuppressInternalWires(aShape, Wires):
415 anObj = HealOp.RemoveIntWires(aShape, Wires)
416 if HealOp.IsDone() == 0:
417 print "SuppressInternalWires : ", HealOp.GetErrorCode()
420 def SuppressHoles(aShape, ListOfId):
421 anObj = HealOp.FillHoles(aShape,ListOfId)
422 if HealOp.IsDone() == 0:
423 print "SuppressHoles : ", HealOp.GetErrorCode()
426 def CloseContour(aShape, Wires, IsCommonVertex):
427 anObj = HealOp.CloseContour(aShape, Wires, IsCommonVertex)
428 if HealOp.IsDone() == 0:
429 print "CloseContour : ", HealOp.GetErrorCode()
432 def DivideEdge(aShape, EdgeID, Value, IsByParameter):
433 anObj = HealOp.DivideEdge(aShape, EdgeID, Value, IsByParameter)
434 if HealOp.IsDone() == 0:
435 print "DivideEdge : ", HealOp.GetErrorCode()
438 def GetFreeBoundary(Shape):
439 anObj = HealOp.GetFreeBoundary(Shape)
440 if HealOp.IsDone() == 0:
441 print "GetFreeBoundaries : ", HealOp.GetErrorCode()
444 # -----------------------------------------------------------------------------
445 # Create advanced objects
446 # -----------------------------------------------------------------------------
448 def MakeCopy(aShape):
449 anObj = InsertOp.MakeCopy(aShape)
450 if InsertOp.IsDone() == 0:
451 print "MakeCopy : ", InsertOp.GetErrorCode()
454 def MakeFilling(aShape,mindeg,maxdeg,tol2d,tol3d,nbiter):
455 anObj = PrimOp.MakeFilling(aShape,mindeg,maxdeg,tol2d,tol3d,nbiter)
456 if PrimOp.IsDone() == 0:
457 print "MakeFilling : ", PrimOp.GetErrorCode()
460 def MakeGlueFaces(aShape,aTolerance):
461 anObj = ShapesOp.MakeGlueFaces(aShape,aTolerance)
462 if ShapesOp.IsDone() == 0:
463 print "MakeGlueFaces : ", ShapesOp.GetErrorCode()
466 # -----------------------------------------------------------------------------
467 # Boolean (Common, Cut, Fuse, Section)
468 # -----------------------------------------------------------------------------
470 def MakeBoolean(shape1,shape2,operation):
471 anObj = BoolOp.MakeBoolean(shape1,shape2,operation)
472 if BoolOp.IsDone() == 0:
473 print "MakeBoolean : ", BoolOp.GetErrorCode()
476 def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
477 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
478 anObj = BoolOp.MakePartition(ListShapes, ListTools,
479 ListKeepInside, ListRemoveInside,
480 Limit, RemoveWebs, ListMaterials);
481 if BoolOp.IsDone() == 0:
482 print "MakePartition : ", BoolOp.GetErrorCode()
485 # -----------------------------------------------------------------------------
487 # -----------------------------------------------------------------------------
489 def MakeTranslationTwoPoints(aShape,point1,point2):
490 anObj = TrsfOp.TranslateTwoPointsCopy(aShape,point1,point2)
491 if TrsfOp.IsDone() == 0:
492 print "TranslateTwoPointsCopy : ", TrsfOp.GetErrorCode()
495 def MakeTranslation(aShape,dx,dy,dz):
496 anObj = TrsfOp.TranslateDXDYDZCopy(aShape,dx,dy,dz)
497 if TrsfOp.IsDone() == 0:
498 print "TranslateDXDYDZCopy : ", TrsfOp.GetErrorCode()
501 def MakeRotation(aShape,axis,angle):
502 anObj = TrsfOp.RotateCopy(aShape,axis,angle)
503 if TrsfOp.IsDone() == 0:
504 print "RotateCopy : ", TrsfOp.GetErrorCode()
507 def MakeScaleTransform(aShape,theCenterofScale,factor):
508 anObj = TrsfOp.ScaleShapeCopy(aShape,theCenterofScale,factor)
509 if TrsfOp.IsDone() == 0:
510 print "ScaleShapeCopy : ", TrsfOp.GetErrorCode()
513 def MakeMirrorByPlane(aShape,aPlane):
514 anObj = TrsfOp.MirrorPlaneCopy(aShape,aPlane)
515 if TrsfOp.IsDone() == 0:
516 print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode()
519 def MakePosition(aShape,theStartLCS,theEndLCS):
520 anObj = TrsfOp.PositionShapeCopy(aShape,theStartLCS,theEndLCS)
521 if TrsfOp.IsDone() == 0:
522 print "PositionShapeCopy : ", TrsfOp.GetErrorCode()
525 def MakeOffset(aShape, anOffset):
526 anObj = TrsfOp.OffsetShapeCopy(aShape, anOffset)
527 if TrsfOp.IsDone() == 0:
528 print "OffsetShapeCopy : ", TrsfOp.GetErrorCode()
531 # -----------------------------------------------------------------------------
533 # -----------------------------------------------------------------------------
535 def MakeMultiTranslation1D(aShape,aDir,aStep,aNbTimes):
536 anObj = TrsfOp.MultiTranslate1D(aShape,aDir,aStep,aNbTimes)
537 if TrsfOp.IsDone() == 0:
538 print "MultiTranslate1D : ", TrsfOp.GetErrorCode()
541 def MakeMultiTranslation2D(aShape,d1,step1,nbtimes1,d2,step2,nbtimes2):
542 anObj = TrsfOp.MultiTranslate2D(aShape,d1,step1,nbtimes1,d2,step2,nbtimes2)
543 if TrsfOp.IsDone() == 0:
544 print "MultiTranslate2D : ", TrsfOp.GetErrorCode()
547 def MakeMultiRotation1D(aShape,aVec,aNbTimes):
548 anObj = TrsfOp.MultiRotate1D(aShape,aVec,aNbTimes)
549 if TrsfOp.IsDone() == 0:
550 print "MultiRotate1D : ", TrsfOp.GetErrorCode()
553 def MakeMultiRotation2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2):
554 anObj = TrsfOp.MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
555 if TrsfOp.IsDone() == 0:
556 print "MultiRotate2D : ", TrsfOp.GetErrorCode()
559 # -----------------------------------------------------------------------------
561 # -----------------------------------------------------------------------------
563 def MakeFilletAll(aShape,radius):
564 anObj = LocalOp.MakeFilletAll(aShape,radius)
565 if LocalOp.IsDone() == 0:
566 print "MakeFilletAll : ", LocalOp.GetErrorCode()
569 def MakeFillet(aShape,radius,aShapeType,ListShape):
571 if aShapeType == ShapeType["EDGE"]:
572 anObj = LocalOp.MakeFilletEdges(aShape,radius,ListShape)
574 anObj = LocalOp.MakeFilletFaces(aShape,radius,ListShape)
575 if LocalOp.IsDone() == 0:
576 print "MakeFillet : ", LocalOp.GetErrorCode()
579 def MakeChamferAll(aShape,d):
580 anObj = LocalOp.MakeChamferAll(aShape,d)
581 if LocalOp.IsDone() == 0:
582 print "MakeChamferAll : ", LocalOp.GetErrorCode()
585 def MakeChamferEdge(aShape,d1,d2,face1,face2):
586 anObj = LocalOp.MakeChamferEdge(aShape,d1,d2,face1,face2)
587 if LocalOp.IsDone() == 0:
588 print "MakeChamferEdge : ", LocalOp.GetErrorCode()
591 def MakeChamferFaces(aShape,d1,d2,ListShape):
592 anObj = LocalOp.MakeChamferFaces(aShape,d1,d2,ListShape)
593 if LocalOp.IsDone() == 0:
594 print "MakeChamferFaces : ", LocalOp.GetErrorCode()
597 def Archimede(aShape,weight,WaterDensity,MeshingDeflection):
598 anObj = LocalOp.MakeArchimede(aShape,weight,WaterDensity,MeshingDeflection)
599 if LocalOp.IsDone() == 0:
600 print "MakeArchimede : ", LocalOp.GetErrorCode()
603 def MakeMultiTransformation1D(Block, DirFaceID1, DirFaceID2, NbTimes):
604 anObj = BlocksOp.MakeMultiTransformation1D(Block, DirFaceID1, DirFaceID2, NbTimes)
605 if BlocksOp.IsDone() == 0:
606 print "MakeMultiTransformation1D : ", BlocksOp.GetErrorCode()
609 def MakeMultiTransformation2D(Block, DirFaceID1U, DirFaceID2U, NbTimesU, DirFaceID1V, DirFaceID2V, NbTimesV):
610 anObj = BlocksOp.MakeMultiTransformation2D(Block, DirFaceID1U, DirFaceID2U, NbTimesU, DirFaceID1V, DirFaceID2V, NbTimesV)
611 if BlocksOp.IsDone() == 0:
612 print "MakeMultiTransformation2D : ", BlocksOp.GetErrorCode()
615 def MakeBlockExplode(Compound, MinNbFaces, MaxNbFaces):
616 aList = BlocksOp.ExplodeCompoundOfBlocks(Compound, MinNbFaces, MaxNbFaces)
617 if BlocksOp.IsDone() == 0:
618 print "MakeBlockExplode : ", BlocksOp.GetErrorCode()
621 # -----------------------------------------------------------------------------
622 # Information objects
623 # -----------------------------------------------------------------------------
625 def PointCoordinates(Point):
626 aTuple = MeasuOp.PointCoordinates(Point)
627 if MeasuOp.IsDone() == 0:
628 print "PointCoordinates : ", MeasuOp.GetErrorCode()
631 def BasicProperties(Shape):
632 aTuple = MeasuOp.GetBasicProperties(Shape)
633 if MeasuOp.IsDone() == 0:
634 print "BasicProperties : ", MeasuOp.GetErrorCode()
637 def BoundingBox(Shape):
638 aTuple = MeasuOp.GetBoundingBox(Shape)
639 if MeasuOp.IsDone() == 0:
640 print "BoundingBox : ", MeasuOp.GetErrorCode()
644 aTuple = MeasuOp.GetInertia(Shape)
645 if MeasuOp.IsDone() == 0:
646 print "Inertia : ", MeasuOp.GetErrorCode()
649 def MinDistance(Shape1, Shape2):
650 aTuple = MeasuOp.GetMinDistance(Shape1, Shape2)
651 if MeasuOp.IsDone() == 0:
652 print "MinDistance : ", MeasuOp.GetErrorCode()
655 def Tolerance(Shape):
656 aTuple = MeasuOp.GetTolerance(Shape)
657 if MeasuOp.IsDone() == 0:
658 print "Tolerance : ", MeasuOp.GetErrorCode()
662 aDescr = MeasuOp.WhatIs(Shape)
663 if MeasuOp.IsDone() == 0:
664 print "WhatIs : ", MeasuOp.GetErrorCode()
668 anObj = MeasuOp.GetCentreOfMass(aShape)
669 if MeasuOp.IsDone() == 0:
670 print "GetCentreOfMass : ", MeasuOp.GetErrorCode()
673 def CheckShape(aShape):
674 (IsValid, Status) = MeasuOp.CheckShape(aShape)
675 if MeasuOp.IsDone() == 0:
676 print "CheckShape : ", MeasuOp.GetErrorCode()
682 # -----------------------------------------------------------------------------
683 # Import/Export objects
684 # -----------------------------------------------------------------------------
686 def Import(filename, formatname):
687 anObj = InsertOp.Import(filename, formatname)
688 if InsertOp.IsDone() == 0:
689 print "Import : ", InsertOp.GetErrorCode()
692 def Export(aShape, filename, formatname):
693 InsertOp.Export(aShape, filename, formatname)
694 if InsertOp.IsDone() == 0:
695 print "Export : ", InsertOp.GetErrorCode()
697 # -----------------------------------------------------------------------------
699 # -----------------------------------------------------------------------------
701 def MakeQuadFace(E1, E2, E3, E4):
702 anObj = BlocksOp.MakeQuadFaceFourEdges(E1, E2, E3, E4)
703 if BlocksOp.IsDone() == 0:
704 print "MakeQuadFace : ", BlocksOp.GetErrorCode()
707 def MakeQuadFaceTwoEdges(E1, E2):
708 anObj = BlocksOp.MakeQuadFaceTwoEdges(E1, E2)
709 if BlocksOp.IsDone() == 0:
710 print "MakeQuadFaceEdge : ", BlocksOp.GetErrorCode()
713 def MakeQuadFaceVertices(V1, V2, V3, V4):
714 anObj = BlocksOp.MakeQuadFaceFourVertices(V1, V2, V3, V4)
715 if BlocksOp.IsDone() == 0:
716 print "MakeQuadFaceVertex : ", BlocksOp.GetErrorCode()
719 def MakeHexaSolid(F1, F2, F3, F4, F5, F6):
720 anObj = BlocksOp.MakeHexaSolidSixFaces(F1, F2, F3, F4, F5, F6)
721 if BlocksOp.IsDone() == 0:
722 print "MakeHexaSolid : ", BlocksOp.GetErrorCode()
725 def MakeHexaSolidTwoFaces(F1, F2):
726 anObj = BlocksOp.MakeHexaSolidTwoFaces(F1, F2)
727 if BlocksOp.IsDone() == 0:
728 print "MakeHexaSolidTwoFace : ", BlocksOp.GetErrorCode()
731 # -----------------------------------------------------------------------------
733 # -----------------------------------------------------------------------------
735 def CreateGroup(MainShape, ShapeType):
736 anObj = GroupOp.CreateGroup(MainShape, ShapeType)
737 if GroupOp.IsDone() == 0:
738 print "CreateGroup : ", GroupOp.GetErrorCode()
741 def AddObject(Group, SubShapeID):
742 anObj = GroupOp.AddObject(Group, SubShapeID)
743 if GroupOp.IsDone() == 0:
744 print "AddObject : ", GroupOp.GetErrorCode()
747 def RemoveObject(Group, SubShapeID):
748 anObj = GroupOp.RemoveObject(Group, SubShapeID)
749 if GroupOp.IsDone() == 0:
750 print "RemoveObject : ", GroupOp.GetErrorCode()
753 def GetObjectIDs(Group):
754 anObj = GroupOp.GetObjects(Group)
755 if GroupOp.IsDone() == 0:
756 print "GetObjectIDs : ", GroupOp.GetErrorCode()
760 if (sys.path.count(Path) < 1):
761 sys.path.append(Path)