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
29 from batchmode_salome import *
34 while step < 50 and g == None:
35 g = lcc.FindOrLoadComponent("FactoryServer", "GEOM")
38 geom = g._narrow( GEOM.GEOM_Gen )
39 myBuilder = myStudy.NewBuilder()
41 father = myStudy.FindComponent("GEOM")
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)
52 # * Get name for sub-shape aSubObj of shape aMainObj
54 def SubShapeName(aSubObj, aMainObj):
59 # * Publish in study aShape with name aName
61 def addToStudy(aShape, aName):
63 aSObject = geom.AddInStudy(myStudy, aShape, aName, None)
65 print "addToStudy() failed"
67 return aShape.GetStudyEntry()
69 # * Publish in study aShape with name aName as sub-object of previously published aFather
71 def addToStudyInFather(aFather, aShape, aName):
73 aSObject = geom.AddInStudy(myStudy, aShape, aName, aFather)
75 print "addToStudyInFather() failed"
77 return aShape.GetStudyEntry()
79 # -----------------------------------------------------------------------------
80 # enumeration ShapeType as a dictionary
81 # -----------------------------------------------------------------------------
83 ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
85 # -----------------------------------------------------------------------------
86 # Get Operations Interfaces
87 # -----------------------------------------------------------------------------
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)
102 # -----------------------------------------------------------------------------
104 # -----------------------------------------------------------------------------
106 def MakeVertex(x,y,z):
107 anObj = BasicOp.MakePointXYZ(x,y,z)
108 if BasicOp.IsDone() == 0:
109 print "MakePointXYZ : ", BasicOp.GetErrorCode()
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()
118 def MakeVertexOnCurve(curve,par):
119 anObj = BasicOp.MakePointOnCurve(curve,par)
120 if BasicOp.IsDone() == 0:
121 print "MakePointOnCurve : ", BasicOp.GetErrorCode()
124 def MakeVectorDXDYDZ(dx,dy,dz):
125 anObj = BasicOp.MakeVectorDXDYDZ(dx,dy,dz)
126 if BasicOp.IsDone() == 0:
127 print "MakeVectorDXDYDZ : ", BasicOp.GetErrorCode()
130 def MakeVector(p1,p2):
131 anObj = BasicOp.MakeVectorTwoPnt(p1, p2)
132 if BasicOp.IsDone() == 0:
133 print "MakeVectorTwoPnt : ", BasicOp.GetErrorCode()
136 def MakeLine(p1, d1):
137 anObj = BasicOp.MakeLine(p1,d1)
138 if BasicOp.IsDone() == 0:
139 print "MakeLine : ", BasicOp.GetErrorCode()
142 def MakeLineTwoPnt(p1, p2):
143 anObj = BasicOp.MakeLineTwoPnt(p1,p2)
144 if BasicOp.IsDone() == 0:
145 print "MakeLineTwoPnt : ", BasicOp.GetErrorCode()
148 def MakePlane(p1,v1,trimsize):
149 anObj = BasicOp.MakePlanePntVec(p1,v1,trimsize)
150 if BasicOp.IsDone() == 0:
151 print "MakePlanePntVec : ", BasicOp.GetErrorCode()
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()
160 def MakePlaneFace(face,trimsize):
161 anObj = BasicOp.MakePlaneFace(face,trimsize)
162 if BasicOp.IsDone() == 0:
163 print "MakePlaneFace : ", BasicOp.GetErrorCode()
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()
172 # -----------------------------------------------------------------------------
174 # -----------------------------------------------------------------------------
176 def MakeArc(p1,p2,p3):
177 anObj = CurvesOp.MakeArc(p1,p2,p3)
178 if CurvesOp.IsDone() == 0:
179 print "MakeArc : ", CurvesOp.GetErrorCode()
182 def MakeCircle(p1,v1,radius):
183 anObj = CurvesOp.MakeCirclePntVecR(p1,v1,radius)
184 if CurvesOp.IsDone() == 0:
185 print "MakeCirclePntVecR : ", CurvesOp.GetErrorCode()
188 def MakeCircleThreePnt(p1,p2,p3):
189 anObj = CurvesOp.MakeCircleThreePnt(p1,p2,p3)
190 if CurvesOp.IsDone() == 0:
191 print "MakeCircleThreePnt : ", CurvesOp.GetErrorCode()
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()
200 def MakePolyline(ListShape):
201 anObj = CurvesOp.MakePolyline(ListShape)
202 if CurvesOp.IsDone() == 0:
203 print "MakePolyline : ", CurvesOp.GetErrorCode()
206 def MakeBezier(ListShape):
207 anObj = CurvesOp.MakeSplineBezier(ListShape)
208 if CurvesOp.IsDone() == 0:
209 print "MakeSplineBezier : ", CurvesOp.GetErrorCode()
212 def MakeInterpol(ListShape):
213 anObj = CurvesOp.MakeSplineInterpolation(ListShape)
214 if CurvesOp.IsDone() == 0:
215 print "MakeSplineInterpolation : ", CurvesOp.GetErrorCode()
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()
226 # -----------------------------------------------------------------------------
227 # Create 3D Primitives
228 # -----------------------------------------------------------------------------
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)
235 def MakeBoxDXDYDZ(dx,dy,dz):
236 anObj = PrimOp.MakeBoxDXDYDZ(dx,dy,dz)
237 if PrimOp.IsDone() == 0:
238 print "MakeBoxDXDYDZ : ", PrimOp.GetErrorCode()
241 def MakeBoxTwoPnt(point1, point2):
242 anObj = PrimOp.MakeBoxTwoPnt(point1, point2)
243 if PrimOp.IsDone() == 0:
244 print "MakeBoxTwoPnt : ", PrimOp.GetErrorCode()
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()
253 def MakeCylinderRH(radius,height):
254 anObj = PrimOp.MakeCylinderRH(radius,height)
255 if PrimOp.IsDone() == 0:
256 print "MakeCylinderRH : ", PrimOp.GetErrorCode()
259 def MakeSpherePntR(point,radius):
260 anObj = PrimOp.MakeSpherePntR(point,radius)
261 if PrimOp.IsDone() == 0:
262 print "MakeSpherePntR : ", PrimOp.GetErrorCode()
265 def MakeSphere(x,y,z,radius):
266 point = MakeVertex(x,y,z)
267 anObj = MakeSpherePntR(point,radius)
270 def MakeSphereR(radius):
271 anObj = PrimOp.MakeSphereR(radius)
272 if PrimOp.IsDone() == 0:
273 print "MakeSphereR : ", PrimOp.GetErrorCode()
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()
282 def MakeConeR1R2H(radius1,radius2,height):
283 anObj = PrimOp.MakeConeR1R2H(radius1,radius2,height)
284 if PrimOp.IsDone() == 0:
285 print "MakeConeR1R2H : ", PrimOp.GetErrorCode()
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()
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()
300 def MakePrism(baseShape,point1,point2):
301 anObj = PrimOp.MakePrismTwoPnt(baseShape,point1,point2)
302 if PrimOp.IsDone() == 0:
303 print "MakePrismTwoPnt : ", PrimOp.GetErrorCode()
306 def MakePrismVecH(baseShape,vector,height):
307 anObj = PrimOp.MakePrismVecH(baseShape,vector,height)
308 if PrimOp.IsDone() == 0:
309 print "MakePrismVecH : ", PrimOp.GetErrorCode()
312 def MakePipe(baseShape,pathShape):
313 anObj = PrimOp.MakePipe(baseShape,pathShape)
314 if PrimOp.IsDone() == 0:
315 print "MakePipe : ", PrimOp.GetErrorCode()
318 def MakeRevolution(aShape,axis,angle):
319 anObj = PrimOp.MakeRevolutionAxisAngle(aShape,axis,angle)
320 if PrimOp.IsDone() == 0:
321 print "MakeRevolutionAxisAngle : ", PrimOp.GetErrorCode()
324 # -----------------------------------------------------------------------------
326 # -----------------------------------------------------------------------------
329 anObj = ShapesOp.MakeEdge(p1,p2)
330 if ShapesOp.IsDone() == 0:
331 print "MakeEdge : ", ShapesOp.GetErrorCode()
334 def MakeWire(ListShape):
335 anObj = ShapesOp.MakeWire(ListShape)
336 if ShapesOp.IsDone() == 0:
337 print "MakeWire : ", ShapesOp.GetErrorCode()
340 def MakeFace(aShapeWire,WantPlanarFace):
341 anObj = ShapesOp.MakeFace(aShapeWire,WantPlanarFace)
342 if ShapesOp.IsDone() == 0:
343 print "MakeFace : ", ShapesOp.GetErrorCode()
346 def MakeFaceWires(ListWires,WantPlanarFace):
347 anObj = ShapesOp.MakeFaceWires(ListWires,WantPlanarFace)
348 if ShapesOp.IsDone() == 0:
349 print "MakeFaceWires : ", ShapesOp.GetErrorCode()
352 def MakeFaces(ListWires,WantPlanarFace):
353 anObj = MakeFaceWires(ListWires,WantPlanarFace)
356 def MakeShell(ListOfShapes):
357 anObj = ShapesOp.MakeShell(ListOfShapes)
358 if ShapesOp.IsDone() == 0:
359 print "MakeShell : ", ShapesOp.GetErrorCode()
362 def MakeSolid(ListOfShells):
363 anObj = ShapesOp.MakeSolidShells(ListOfShells)
364 if ShapesOp.IsDone() == 0:
365 print "MakeSolid : ", ShapesOp.GetErrorCode()
368 def MakeCompound(ListShape):
369 anObj = ShapesOp.MakeCompound(ListShape)
370 if ShapesOp.IsDone() == 0:
371 print "MakeCompound : ", ShapesOp.GetErrorCode()
374 def ChangeOrientation(Shape):
375 anObj = ShapesOp.ChangeOrientation(Shape)
376 if ShapesOp.IsDone() == 0:
377 print "ChangeOrientation : ", ShapesOp.GetErrorCode()
380 def OrientationChange(Shape):
381 anObj = ChangeOrientation(Shape)
384 # -----------------------------------------------------------------------------
385 # Access to sub-shapes by their unique IDs inside the main shape.
386 # -----------------------------------------------------------------------------
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)
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()
401 # -----------------------------------------------------------------------------
403 # -----------------------------------------------------------------------------
405 def SubShapeAll(aShape, aType):
406 ListObj = ShapesOp.MakeExplode(aShape,aType,0)
407 if ShapesOp.IsDone() == 0:
408 print "MakeExplode : ", ShapesOp.GetErrorCode()
411 def SubShapeAllSorted(aShape,aType):
412 ListObj = ShapesOp.MakeExplode(aShape,aType,1)
413 if ShapesOp.IsDone() == 0:
414 print "MakeExplode : ", ShapesOp.GetErrorCode()
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):
421 AllShapeList = SubShapeAll(aShape, aType)
422 for ind in ListOfInd:
423 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
424 anObj = GetSubShape(aShape, ListOfIDs)
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):
431 AllShapeList = SubShapeAllSorted(aShape, aType)
432 for ind in ListOfInd:
433 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
434 anObj = GetSubShape(aShape, ListOfIDs)
437 # -----------------------------------------------------------------------------
439 # -----------------------------------------------------------------------------
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()
447 def SuppressFaces(aShape,ListOfId):
448 anObj = HealOp.SuppressFaces(aShape,ListOfId)
449 if HealOp.IsDone() == 0:
450 print "SuppressFaces : ", HealOp.GetErrorCode()
453 def MakeSewing(ListShape,precision):
454 comp = MakeCompound(ListShape)
455 anObj = Sew(comp,precision)
458 def Sew(aShape,precision):
459 anObj = HealOp.Sew(aShape,precision)
460 if HealOp.IsDone() == 0:
461 print "Sew : ", HealOp.GetErrorCode()
464 def SuppressInternalWires(aShape, Wires):
465 anObj = HealOp.RemoveIntWires(aShape, Wires)
466 if HealOp.IsDone() == 0:
467 print "SuppressInternalWires : ", HealOp.GetErrorCode()
470 def SuppressHoles(aShape, ListOfId):
471 anObj = HealOp.FillHoles(aShape,ListOfId)
472 if HealOp.IsDone() == 0:
473 print "SuppressHoles : ", HealOp.GetErrorCode()
476 def CloseContour(aShape, Wires, IsCommonVertex):
477 anObj = HealOp.CloseContour(aShape, Wires, IsCommonVertex)
478 if HealOp.IsDone() == 0:
479 print "CloseContour : ", HealOp.GetErrorCode()
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()
488 def GetFreeBoundary(Shape):
489 anObj = HealOp.GetFreeBoundary(Shape)
490 if HealOp.IsDone() == 0:
491 print "GetFreeBoundaries : ", HealOp.GetErrorCode()
494 # -----------------------------------------------------------------------------
495 # Create advanced objects
496 # -----------------------------------------------------------------------------
498 def MakeCopy(aShape):
499 anObj = InsertOp.MakeCopy(aShape)
500 if InsertOp.IsDone() == 0:
501 print "MakeCopy : ", InsertOp.GetErrorCode()
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()
510 def MakeGlueFaces(aShape,aTolerance):
511 anObj = ShapesOp.MakeGlueFaces(aShape,aTolerance)
512 if ShapesOp.IsDone() == 0:
513 print "MakeGlueFaces : ", ShapesOp.GetErrorCode()
516 # -----------------------------------------------------------------------------
517 # Boolean (Common, Cut, Fuse, Section)
518 # -----------------------------------------------------------------------------
520 def MakeBoolean(shape1,shape2,operation):
521 anObj = BoolOp.MakeBoolean(shape1,shape2,operation)
522 if BoolOp.IsDone() == 0:
523 print "MakeBoolean : ", BoolOp.GetErrorCode()
526 def MakeCommon(s1, s2):
527 return MakeBoolean(s1, s2, 1)
530 return MakeBoolean(s1, s2, 2)
532 def MakeFuse(s1, s2):
533 return MakeBoolean(s1, s2, 3)
535 def MakeSection(s1, s2):
536 return MakeBoolean(s1, s2, 4)
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()
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);
554 # -----------------------------------------------------------------------------
556 # -----------------------------------------------------------------------------
558 def MakeTranslationTwoPoints(aShape,point1,point2):
559 anObj = TrsfOp.TranslateTwoPointsCopy(aShape,point1,point2)
560 if TrsfOp.IsDone() == 0:
561 print "TranslateTwoPointsCopy : ", TrsfOp.GetErrorCode()
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()
570 def MakeRotation(aShape,axis,angle):
571 anObj = TrsfOp.RotateCopy(aShape,axis,angle)
572 if TrsfOp.IsDone() == 0:
573 print "RotateCopy : ", TrsfOp.GetErrorCode()
576 def MakeScaleTransform(aShape,theCenterofScale,factor):
577 anObj = TrsfOp.ScaleShapeCopy(aShape,theCenterofScale,factor)
578 if TrsfOp.IsDone() == 0:
579 print "ScaleShapeCopy : ", TrsfOp.GetErrorCode()
582 def MakeMirrorByPlane(aShape,aPlane):
583 anObj = TrsfOp.MirrorPlaneCopy(aShape,aPlane)
584 if TrsfOp.IsDone() == 0:
585 print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode()
588 def MakePosition(aShape,theStartLCS,theEndLCS):
589 anObj = TrsfOp.PositionShapeCopy(aShape,theStartLCS,theEndLCS)
590 if TrsfOp.IsDone() == 0:
591 print "PositionShapeCopy : ", TrsfOp.GetErrorCode()
594 def MakeOffset(aShape, anOffset):
595 anObj = TrsfOp.OffsetShapeCopy(aShape, anOffset)
596 if TrsfOp.IsDone() == 0:
597 print "OffsetShapeCopy : ", TrsfOp.GetErrorCode()
600 # -----------------------------------------------------------------------------
602 # -----------------------------------------------------------------------------
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()
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()
616 def MultiRotate1D(aShape,aVec,aNbTimes):
617 anObj = TrsfOp.MultiRotate1D(aShape,aVec,aNbTimes)
618 if TrsfOp.IsDone() == 0:
619 print "MultiRotate1D : ", TrsfOp.GetErrorCode()
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()
628 def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes):
629 aVec = MakeLine(aPoint,aDir)
630 anObj = MultiRotate1D(aShape,aVec,aNbTimes)
633 def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2):
634 aVec = MakeLine(aPoint,aDir)
635 anObj = MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
638 # -----------------------------------------------------------------------------
640 # -----------------------------------------------------------------------------
642 def MakeFilletAll(aShape,radius):
643 anObj = LocalOp.MakeFilletAll(aShape,radius)
644 if LocalOp.IsDone() == 0:
645 print "MakeFilletAll : ", LocalOp.GetErrorCode()
648 def MakeFillet(aShape,radius,aShapeType,ListShape):
650 if aShapeType == ShapeType["EDGE"]:
651 anObj = LocalOp.MakeFilletEdges(aShape,radius,ListShape)
653 anObj = LocalOp.MakeFilletFaces(aShape,radius,ListShape)
654 if LocalOp.IsDone() == 0:
655 print "MakeFillet : ", LocalOp.GetErrorCode()
658 def MakeChamferAll(aShape,d):
659 anObj = LocalOp.MakeChamferAll(aShape,d)
660 if LocalOp.IsDone() == 0:
661 print "MakeChamferAll : ", LocalOp.GetErrorCode()
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()
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()
676 def MakeChamfer(aShape,d1,d2,aShapeType,ListShape):
678 if aShapeType == ShapeType["EDGE"]:
679 anObj = MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1])
681 anObj = MakeChamferFaces(aShape,d1,d2,ListShape)
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()
690 # -----------------------------------------------------------------------------
691 # Information objects
692 # -----------------------------------------------------------------------------
694 def PointCoordinates(Point):
695 aTuple = MeasuOp.PointCoordinates(Point)
696 if MeasuOp.IsDone() == 0:
697 print "PointCoordinates : ", MeasuOp.GetErrorCode()
700 def BasicProperties(Shape):
701 aTuple = MeasuOp.GetBasicProperties(Shape)
702 if MeasuOp.IsDone() == 0:
703 print "BasicProperties : ", MeasuOp.GetErrorCode()
706 def BoundingBox(Shape):
707 aTuple = MeasuOp.GetBoundingBox(Shape)
708 if MeasuOp.IsDone() == 0:
709 print "BoundingBox : ", MeasuOp.GetErrorCode()
713 aTuple = MeasuOp.GetInertia(Shape)
714 if MeasuOp.IsDone() == 0:
715 print "Inertia : ", MeasuOp.GetErrorCode()
718 def MinDistance(Shape1, Shape2):
719 aTuple = MeasuOp.GetMinDistance(Shape1, Shape2)
720 if MeasuOp.IsDone() == 0:
721 print "MinDistance : ", MeasuOp.GetErrorCode()
724 def Tolerance(Shape):
725 aTuple = MeasuOp.GetTolerance(Shape)
726 if MeasuOp.IsDone() == 0:
727 print "Tolerance : ", MeasuOp.GetErrorCode()
731 aDescr = MeasuOp.WhatIs(Shape)
732 if MeasuOp.IsDone() == 0:
733 print "WhatIs : ", MeasuOp.GetErrorCode()
737 anObj = MeasuOp.GetCentreOfMass(aShape)
738 if MeasuOp.IsDone() == 0:
739 print "GetCentreOfMass : ", MeasuOp.GetErrorCode()
742 def CheckShape(aShape):
743 (IsValid, Status) = MeasuOp.CheckShape(aShape)
744 if MeasuOp.IsDone() == 0:
745 print "CheckShape : ", MeasuOp.GetErrorCode()
751 # -----------------------------------------------------------------------------
752 # Import/Export objects
753 # -----------------------------------------------------------------------------
755 def Import(filename, formatname):
756 anObj = InsertOp.Import(filename, formatname)
757 if InsertOp.IsDone() == 0:
758 print "Import : ", InsertOp.GetErrorCode()
761 def ImportBREP(theFileName):
762 return Import(theFileName, "BREP")
764 def ImportIGES(theFileName):
765 return Import(theFileName, "IGES")
767 def ImportSTEP(theFileName):
768 return Import(theFileName, "STEP")
770 def Export(aShape, filename, formatname):
771 InsertOp.Export(aShape, filename, formatname)
772 if InsertOp.IsDone() == 0:
773 print "Export : ", InsertOp.GetErrorCode()
775 def ExportBREP(theObject, theFileName):
776 return Export(theObject, theFileName, "BREP")
778 def ExportIGES(theObject, theFileName):
779 return Export(theObject, theFileName, "IGES")
781 def ExportSTEP(theObject, theFileName):
782 return Export(theObject, theFileName, "STEP")
784 # -----------------------------------------------------------------------------
786 # -----------------------------------------------------------------------------
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()
794 def MakeQuad2Edges(E1, E2):
795 anObj = BlocksOp.MakeQuad2Edges(E1, E2)
796 if BlocksOp.IsDone() == 0:
797 print "MakeQuad2Edges : ", BlocksOp.GetErrorCode()
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()
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()
812 def MakeHexa2Faces(F1, F2):
813 anObj = BlocksOp.MakeHexa2Faces(F1, F2)
814 if BlocksOp.IsDone() == 0:
815 print "MakeHexa2Faces : ", BlocksOp.GetErrorCode()
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()
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()
832 def MakeBlockExplode(Compound, MinNbFaces, MaxNbFaces):
833 aList = BlocksOp.ExplodeCompoundOfBlocks(Compound, MinNbFaces, MaxNbFaces)
834 if BlocksOp.IsDone() == 0:
835 print "MakeBlockExplode : ", BlocksOp.GetErrorCode()
838 def CheckCompoundOfBlocks(Compound):
839 (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(Compound)
840 if BlocksOp.IsDone() == 0:
841 print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode()
844 Descr = BlocksOp.PrintBCErrors(Compound, BCErrors)
848 # -----------------------------------------------------------------------------
850 # -----------------------------------------------------------------------------
852 def CreateGroup(MainShape, ShapeType):
853 anObj = GroupOp.CreateGroup(MainShape, ShapeType)
854 if GroupOp.IsDone() == 0:
855 print "CreateGroup : ", GroupOp.GetErrorCode()
858 def AddObject(Group, SubShapeID):
859 GroupOp.AddObject(Group, SubShapeID)
860 if GroupOp.IsDone() == 0:
861 print "AddObject : ", GroupOp.GetErrorCode()
863 def RemoveObject(Group, SubShapeID):
864 GroupOp.RemoveObject(Group, SubShapeID)
865 if GroupOp.IsDone() == 0:
866 print "RemoveObject : ", GroupOp.GetErrorCode()
868 def GetObjectIDs(Group):
869 ListIDs = GroupOp.GetObjects(Group)
870 if GroupOp.IsDone() == 0:
871 print "GetObjectIDs : ", GroupOp.GetErrorCode()
875 if (sys.path.count(Path) < 1):
876 sys.path.append(Path)