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 # -----------------------------------------------------------------------------
54 # -----------------------------------------------------------------------------
56 def SubShapeName(aSubObj, aMainObj):
61 # -----------------------------------------------------------------------------
63 # -----------------------------------------------------------------------------
65 def addToStudy(aShape, aName):
67 aSObject = geom.AddInStudy(myStudy, aShape, aName, None)
69 print "addToStudy() failed"
71 return aShape.GetStudyEntry()
73 def addToStudyInFather(aFather, aShape, aName):
75 # myBuilder.NewCommand()
76 aSObject = geom.AddInStudy(myStudy, aShape, aName, aFather)
77 # myBuilder.CommitCommand()
79 print "addToStudyInFather() failed"
81 return aShape.GetStudyEntry()
83 # -----------------------------------------------------------------------------
84 # enumeration ShapeType as a dictionary
85 # -----------------------------------------------------------------------------
87 ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
89 # -----------------------------------------------------------------------------
90 # Get Operations Interfaces
91 # -----------------------------------------------------------------------------
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)
106 # -----------------------------------------------------------------------------
108 # -----------------------------------------------------------------------------
110 def MakeVertex(x,y,z):
111 anObj = BasicOp.MakePointXYZ(x,y,z)
112 if BasicOp.IsDone() == 0:
113 print "MakePointXYZ : ", BasicOp.GetErrorCode()
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()
122 def MakeVertexOnCurve(curve,par):
123 anObj = BasicOp.MakePointOnCurve(curve,par)
124 if BasicOp.IsDone() == 0:
125 print "MakePointOnCurve : ", BasicOp.GetErrorCode()
128 def MakeVectorDXDYDZ(dx,dy,dz):
129 anObj = BasicOp.MakeVectorDXDYDZ(dx,dy,dz)
130 if BasicOp.IsDone() == 0:
131 print "MakeVectorDXDYDZ : ", BasicOp.GetErrorCode()
134 def MakeVector(p1,p2):
135 anObj = BasicOp.MakeVectorTwoPnt(p1, p2)
136 if BasicOp.IsDone() == 0:
137 print "MakeVectorTwoPnt : ", BasicOp.GetErrorCode()
140 def MakeLine(p1, d1):
141 anObj = BasicOp.MakeLine(p1,d1)
142 if BasicOp.IsDone() == 0:
143 print "MakeLine : ", BasicOp.GetErrorCode()
146 def MakeLineTwoPnt(p1, p2):
147 anObj = BasicOp.MakeLineTwoPnt(p1,p2)
148 if BasicOp.IsDone() == 0:
149 print "MakeLineTwoPnt : ", BasicOp.GetErrorCode()
152 def MakePlane(p1,v1,trimsize):
153 anObj = BasicOp.MakePlanePntVec(p1,v1,trimsize)
154 if BasicOp.IsDone() == 0:
155 print "MakePlanePntVec : ", BasicOp.GetErrorCode()
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()
164 def MakePlaneFace(face,trimsize):
165 anObj = BasicOp.MakePlaneFace(face,trimsize)
166 if BasicOp.IsDone() == 0:
167 print "MakePlaneFace : ", BasicOp.GetErrorCode()
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()
176 # -----------------------------------------------------------------------------
178 # -----------------------------------------------------------------------------
180 def MakeArc(p1,p2,p3):
181 anObj = CurvesOp.MakeArc(p1,p2,p3)
182 if CurvesOp.IsDone() == 0:
183 print "MakeArc : ", CurvesOp.GetErrorCode()
186 def MakeCircle(p1,v1,radius):
187 anObj = CurvesOp.MakeCirclePntVecR(p1,v1,radius)
188 if CurvesOp.IsDone() == 0:
189 print "MakeCirclePntVecR : ", CurvesOp.GetErrorCode()
192 def MakeCircleThreePnt(p1,p2,p3):
193 anObj = CurvesOp.MakeCircleThreePnt(p1,p2,p3)
194 if CurvesOp.IsDone() == 0:
195 print "MakeCircleThreePnt : ", CurvesOp.GetErrorCode()
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()
204 def MakePolyline(ListShape):
205 anObj = CurvesOp.MakePolyline(ListShape)
206 if CurvesOp.IsDone() == 0:
207 print "MakePolyline : ", CurvesOp.GetErrorCode()
210 def MakeBezier(ListShape):
211 anObj = CurvesOp.MakeSplineBezier(ListShape)
212 if CurvesOp.IsDone() == 0:
213 print "MakeSplineBezier : ", CurvesOp.GetErrorCode()
216 def MakeInterpol(ListShape):
217 anObj = CurvesOp.MakeSplineInterpolation(ListShape)
218 if CurvesOp.IsDone() == 0:
219 print "MakeSplineInterpolation : ", CurvesOp.GetErrorCode()
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()
230 # -----------------------------------------------------------------------------
231 # Create 3D Primitives
232 # -----------------------------------------------------------------------------
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)
239 def MakeBoxDXDYDZ(dx,dy,dz):
240 anObj = PrimOp.MakeBoxDXDYDZ(dx,dy,dz)
241 if PrimOp.IsDone() == 0:
242 print "MakeBoxDXDYDZ : ", PrimOp.GetErrorCode()
245 def MakeBoxTwoPnt(point1, point2):
246 anObj = PrimOp.MakeBoxTwoPnt(point1, point2)
247 if PrimOp.IsDone() == 0:
248 print "MakeBoxTwoPnt : ", PrimOp.GetErrorCode()
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()
257 def MakeCylinderRH(radius,height):
258 anObj = PrimOp.MakeCylinderRH(radius,height)
259 if PrimOp.IsDone() == 0:
260 print "MakeCylinderRH : ", PrimOp.GetErrorCode()
263 def MakeSpherePntR(point,radius):
264 anObj = PrimOp.MakeSpherePntR(point,radius)
265 if PrimOp.IsDone() == 0:
266 print "MakeSpherePntR : ", PrimOp.GetErrorCode()
269 def MakeSphere(x,y,z,radius):
270 point = MakeVertex(x,y,z)
271 anObj = MakeSpherePntR(point,radius)
274 def MakeSphereR(radius):
275 anObj = PrimOp.MakeSphereR(radius)
276 if PrimOp.IsDone() == 0:
277 print "MakeSphereR : ", PrimOp.GetErrorCode()
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()
286 def MakeConeR1R2H(radius1,radius2,height):
287 anObj = PrimOp.MakeConeR1R2H(radius1,radius2,height)
288 if PrimOp.IsDone() == 0:
289 print "MakeConeR1R2H : ", PrimOp.GetErrorCode()
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()
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()
304 def MakePrism(baseShape,point1,point2):
305 anObj = PrimOp.MakePrismTwoPnt(baseShape,point1,point2)
306 if PrimOp.IsDone() == 0:
307 print "MakePrismTwoPnt : ", PrimOp.GetErrorCode()
310 def MakePrismVecH(baseShape,vector,height):
311 anObj = PrimOp.MakePrismVecH(baseShape,vector,height)
312 if PrimOp.IsDone() == 0:
313 print "MakePrismVecH : ", PrimOp.GetErrorCode()
316 def MakePipe(baseShape,pathShape):
317 anObj = PrimOp.MakePipe(baseShape,pathShape)
318 if PrimOp.IsDone() == 0:
319 print "MakePipe : ", PrimOp.GetErrorCode()
322 def MakeRevolution(aShape,axis,angle):
323 anObj = PrimOp.MakeRevolutionAxisAngle(aShape,axis,angle)
324 if PrimOp.IsDone() == 0:
325 print "MakeRevolutionAxisAngle : ", PrimOp.GetErrorCode()
328 # -----------------------------------------------------------------------------
330 # -----------------------------------------------------------------------------
333 anObj = ShapesOp.MakeEdge(p1,p2)
334 if ShapesOp.IsDone() == 0:
335 print "MakeEdge : ", ShapesOp.GetErrorCode()
338 def MakeWire(ListShape):
339 anObj = ShapesOp.MakeWire(ListShape)
340 if ShapesOp.IsDone() == 0:
341 print "MakeWire : ", ShapesOp.GetErrorCode()
344 def MakeFace(aShapeWire,WantPlanarFace):
345 anObj = ShapesOp.MakeFace(aShapeWire,WantPlanarFace)
346 if ShapesOp.IsDone() == 0:
347 print "MakeFace : ", ShapesOp.GetErrorCode()
350 def MakeFaceWires(ListWires,WantPlanarFace):
351 anObj = ShapesOp.MakeFaceWires(ListWires,WantPlanarFace)
352 if ShapesOp.IsDone() == 0:
353 print "MakeFaceWires : ", ShapesOp.GetErrorCode()
356 def MakeFaces(ListWires,WantPlanarFace):
357 anObj = MakeFaceWires(ListWires,WantPlanarFace)
360 def MakeShell(ListOfShapes):
361 anObj = ShapesOp.MakeShell(ListOfShapes)
362 if ShapesOp.IsDone() == 0:
363 print "MakeShell : ", ShapesOp.GetErrorCode()
366 def MakeSolid(ListOfShells):
367 anObj = ShapesOp.MakeSolidShells(ListOfShells)
368 if ShapesOp.IsDone() == 0:
369 print "MakeSolid : ", ShapesOp.GetErrorCode()
372 def MakeCompound(ListShape):
373 anObj = ShapesOp.MakeCompound(ListShape)
374 if ShapesOp.IsDone() == 0:
375 print "MakeCompound : ", ShapesOp.GetErrorCode()
378 def ChangeOrientation(Shape):
379 anObj = ShapesOp.ChangeOrientation(Shape)
380 if ShapesOp.IsDone() == 0:
381 print "ChangeOrientation : ", ShapesOp.GetErrorCode()
384 def OrientationChange(Shape):
385 anObj = ChangeOrientation(Shape)
388 # -----------------------------------------------------------------------------
389 # Access to sub-shapes by their unique IDs inside the main shape.
390 # -----------------------------------------------------------------------------
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)
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()
405 # -----------------------------------------------------------------------------
407 # -----------------------------------------------------------------------------
409 def SubShapeAll(aShape, aType):
410 ListObj = ShapesOp.MakeExplode(aShape,aType,0)
411 if ShapesOp.IsDone() == 0:
412 print "MakeExplode : ", ShapesOp.GetErrorCode()
415 def SubShapeAllSorted(aShape,aType):
416 ListObj = ShapesOp.MakeExplode(aShape,aType,1)
417 if ShapesOp.IsDone() == 0:
418 print "MakeExplode : ", ShapesOp.GetErrorCode()
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):
425 AllShapeList = SubShapeAll(aShape, aType)
426 for ind in ListOfInd:
427 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
428 anObj = GetSubShape(aShape, ListOfIDs)
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):
435 AllShapeList = SubShapeAllSorted(aShape, aType)
436 for ind in ListOfInd:
437 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
438 anObj = GetSubShape(aShape, ListOfIDs)
441 # -----------------------------------------------------------------------------
443 # -----------------------------------------------------------------------------
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()
451 def SuppressFaces(aShape,ListOfId):
452 anObj = HealOp.SuppressFaces(aShape,ListOfId)
453 if HealOp.IsDone() == 0:
454 print "SuppressFaces : ", HealOp.GetErrorCode()
457 def MakeSewing(ListShape,precision):
458 comp = MakeCompound(ListShape)
459 anObj = Sew(comp,precision)
462 def Sew(aShape,precision):
463 anObj = HealOp.Sew(aShape,precision)
464 if HealOp.IsDone() == 0:
465 print "Sew : ", HealOp.GetErrorCode()
468 def SuppressInternalWires(aShape, Wires):
469 anObj = HealOp.RemoveIntWires(aShape, Wires)
470 if HealOp.IsDone() == 0:
471 print "SuppressInternalWires : ", HealOp.GetErrorCode()
474 def SuppressHoles(aShape, ListOfId):
475 anObj = HealOp.FillHoles(aShape,ListOfId)
476 if HealOp.IsDone() == 0:
477 print "SuppressHoles : ", HealOp.GetErrorCode()
480 def CloseContour(aShape, Wires, IsCommonVertex):
481 anObj = HealOp.CloseContour(aShape, Wires, IsCommonVertex)
482 if HealOp.IsDone() == 0:
483 print "CloseContour : ", HealOp.GetErrorCode()
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()
492 def GetFreeBoundary(Shape):
493 anObj = HealOp.GetFreeBoundary(Shape)
494 if HealOp.IsDone() == 0:
495 print "GetFreeBoundaries : ", HealOp.GetErrorCode()
498 # -----------------------------------------------------------------------------
499 # Create advanced objects
500 # -----------------------------------------------------------------------------
502 def MakeCopy(aShape):
503 anObj = InsertOp.MakeCopy(aShape)
504 if InsertOp.IsDone() == 0:
505 print "MakeCopy : ", InsertOp.GetErrorCode()
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()
514 def MakeGlueFaces(aShape,aTolerance):
515 anObj = ShapesOp.MakeGlueFaces(aShape,aTolerance)
516 if ShapesOp.IsDone() == 0:
517 print "MakeGlueFaces : ", ShapesOp.GetErrorCode()
520 # -----------------------------------------------------------------------------
521 # Boolean (Common, Cut, Fuse, Section)
522 # -----------------------------------------------------------------------------
524 def MakeBoolean(shape1,shape2,operation):
525 anObj = BoolOp.MakeBoolean(shape1,shape2,operation)
526 if BoolOp.IsDone() == 0:
527 print "MakeBoolean : ", BoolOp.GetErrorCode()
530 def MakeCommon(s1, s2):
531 return MakeBoolean(s1, s2, 1)
534 return MakeBoolean(s1, s2, 2)
536 def MakeFuse(s1, s2):
537 return MakeBoolean(s1, s2, 3)
539 def MakeSection(s1, s2):
540 return MakeBoolean(s1, s2, 4)
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()
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);
558 # -----------------------------------------------------------------------------
560 # -----------------------------------------------------------------------------
562 def MakeTranslationTwoPoints(aShape,point1,point2):
563 anObj = TrsfOp.TranslateTwoPointsCopy(aShape,point1,point2)
564 if TrsfOp.IsDone() == 0:
565 print "TranslateTwoPointsCopy : ", TrsfOp.GetErrorCode()
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()
574 def MakeRotation(aShape,axis,angle):
575 anObj = TrsfOp.RotateCopy(aShape,axis,angle)
576 if TrsfOp.IsDone() == 0:
577 print "RotateCopy : ", TrsfOp.GetErrorCode()
580 def MakeScaleTransform(aShape,theCenterofScale,factor):
581 anObj = TrsfOp.ScaleShapeCopy(aShape,theCenterofScale,factor)
582 if TrsfOp.IsDone() == 0:
583 print "ScaleShapeCopy : ", TrsfOp.GetErrorCode()
586 def MakeMirrorByPlane(aShape,aPlane):
587 anObj = TrsfOp.MirrorPlaneCopy(aShape,aPlane)
588 if TrsfOp.IsDone() == 0:
589 print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode()
592 def MakePosition(aShape,theStartLCS,theEndLCS):
593 anObj = TrsfOp.PositionShapeCopy(aShape,theStartLCS,theEndLCS)
594 if TrsfOp.IsDone() == 0:
595 print "PositionShapeCopy : ", TrsfOp.GetErrorCode()
598 def MakeOffset(aShape, anOffset):
599 anObj = TrsfOp.OffsetShapeCopy(aShape, anOffset)
600 if TrsfOp.IsDone() == 0:
601 print "OffsetShapeCopy : ", TrsfOp.GetErrorCode()
604 # -----------------------------------------------------------------------------
606 # -----------------------------------------------------------------------------
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()
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()
620 def MultiRotate1D(aShape,aVec,aNbTimes):
621 anObj = TrsfOp.MultiRotate1D(aShape,aVec,aNbTimes)
622 if TrsfOp.IsDone() == 0:
623 print "MultiRotate1D : ", TrsfOp.GetErrorCode()
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()
632 def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes):
633 aVec = MakeLine(aPoint,aDir)
634 anObj = MultiRotate1D(aShape,aVec,aNbTimes)
637 def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2):
638 aVec = MakeLine(aPoint,aDir)
639 anObj = MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
642 # -----------------------------------------------------------------------------
644 # -----------------------------------------------------------------------------
646 def MakeFilletAll(aShape,radius):
647 anObj = LocalOp.MakeFilletAll(aShape,radius)
648 if LocalOp.IsDone() == 0:
649 print "MakeFilletAll : ", LocalOp.GetErrorCode()
652 def MakeFillet(aShape,radius,aShapeType,ListShape):
654 if aShapeType == ShapeType["EDGE"]:
655 anObj = LocalOp.MakeFilletEdges(aShape,radius,ListShape)
657 anObj = LocalOp.MakeFilletFaces(aShape,radius,ListShape)
658 if LocalOp.IsDone() == 0:
659 print "MakeFillet : ", LocalOp.GetErrorCode()
662 def MakeChamferAll(aShape,d):
663 anObj = LocalOp.MakeChamferAll(aShape,d)
664 if LocalOp.IsDone() == 0:
665 print "MakeChamferAll : ", LocalOp.GetErrorCode()
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()
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()
680 def MakeChamfer(aShape,d1,d2,aShapeType,ListShape):
682 if aShapeType == ShapeType["EDGE"]:
683 anObj = MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1])
685 anObj = MakeChamferFaces(aShape,d1,d2,ListShape)
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()
694 # -----------------------------------------------------------------------------
695 # Information objects
696 # -----------------------------------------------------------------------------
698 def PointCoordinates(Point):
699 aTuple = MeasuOp.PointCoordinates(Point)
700 if MeasuOp.IsDone() == 0:
701 print "PointCoordinates : ", MeasuOp.GetErrorCode()
704 def BasicProperties(Shape):
705 aTuple = MeasuOp.GetBasicProperties(Shape)
706 if MeasuOp.IsDone() == 0:
707 print "BasicProperties : ", MeasuOp.GetErrorCode()
710 def BoundingBox(Shape):
711 aTuple = MeasuOp.GetBoundingBox(Shape)
712 if MeasuOp.IsDone() == 0:
713 print "BoundingBox : ", MeasuOp.GetErrorCode()
717 aTuple = MeasuOp.GetInertia(Shape)
718 if MeasuOp.IsDone() == 0:
719 print "Inertia : ", MeasuOp.GetErrorCode()
722 def MinDistance(Shape1, Shape2):
723 aTuple = MeasuOp.GetMinDistance(Shape1, Shape2)
724 if MeasuOp.IsDone() == 0:
725 print "MinDistance : ", MeasuOp.GetErrorCode()
728 def Tolerance(Shape):
729 aTuple = MeasuOp.GetTolerance(Shape)
730 if MeasuOp.IsDone() == 0:
731 print "Tolerance : ", MeasuOp.GetErrorCode()
735 aDescr = MeasuOp.WhatIs(Shape)
736 if MeasuOp.IsDone() == 0:
737 print "WhatIs : ", MeasuOp.GetErrorCode()
741 anObj = MeasuOp.GetCentreOfMass(aShape)
742 if MeasuOp.IsDone() == 0:
743 print "GetCentreOfMass : ", MeasuOp.GetErrorCode()
746 def CheckShape(aShape):
747 (IsValid, Status) = MeasuOp.CheckShape(aShape)
748 if MeasuOp.IsDone() == 0:
749 print "CheckShape : ", MeasuOp.GetErrorCode()
755 # -----------------------------------------------------------------------------
756 # Import/Export objects
757 # -----------------------------------------------------------------------------
759 def Import(filename, formatname):
760 anObj = InsertOp.Import(filename, formatname)
761 if InsertOp.IsDone() == 0:
762 print "Import : ", InsertOp.GetErrorCode()
765 def Export(aShape, filename, formatname):
766 InsertOp.Export(aShape, filename, formatname)
767 if InsertOp.IsDone() == 0:
768 print "Export : ", InsertOp.GetErrorCode()
770 # -----------------------------------------------------------------------------
772 # -----------------------------------------------------------------------------
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()
780 def MakeQuad2Edges(E1, E2):
781 anObj = BlocksOp.MakeQuad2Edges(E1, E2)
782 if BlocksOp.IsDone() == 0:
783 print "MakeQuad2Edges : ", BlocksOp.GetErrorCode()
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()
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()
798 def MakeHexa2Faces(F1, F2):
799 anObj = BlocksOp.MakeHexa2Faces(F1, F2)
800 if BlocksOp.IsDone() == 0:
801 print "MakeHexa2Faces : ", BlocksOp.GetErrorCode()
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()
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()
818 def MakeBlockExplode(Compound, MinNbFaces, MaxNbFaces):
819 aList = BlocksOp.ExplodeCompoundOfBlocks(Compound, MinNbFaces, MaxNbFaces)
820 if BlocksOp.IsDone() == 0:
821 print "MakeBlockExplode : ", BlocksOp.GetErrorCode()
824 def CheckCompoundOfBlocks(Compound):
825 (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(Compound)
826 if BlocksOp.IsDone() == 0:
827 print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode()
830 Descr = BlocksOp.PrintBCErrors(Compound, BCErrors)
834 # -----------------------------------------------------------------------------
836 # -----------------------------------------------------------------------------
838 def CreateGroup(MainShape, ShapeType):
839 anObj = GroupOp.CreateGroup(MainShape, ShapeType)
840 if GroupOp.IsDone() == 0:
841 print "CreateGroup : ", GroupOp.GetErrorCode()
844 def AddObject(Group, SubShapeID):
845 GroupOp.AddObject(Group, SubShapeID)
846 if GroupOp.IsDone() == 0:
847 print "AddObject : ", GroupOp.GetErrorCode()
849 def RemoveObject(Group, SubShapeID):
850 GroupOp.RemoveObject(Group, SubShapeID)
851 if GroupOp.IsDone() == 0:
852 print "RemoveObject : ", GroupOp.GetErrorCode()
854 def GetObjectIDs(Group):
855 ListIDs = GroupOp.GetObjects(Group)
856 if GroupOp.IsDone() == 0:
857 print "GetObjectIDs : ", GroupOp.GetErrorCode()
861 if (sys.path.count(Path) < 1):
862 sys.path.append(Path)