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(theX, theY, theZ):
107 anObj = BasicOp.MakePointXYZ(theX, theY, theZ)
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 NumberOfFaces(theShape):
375 nb_faces = ShapesOp.NumberOfFaces(theShape)
376 if ShapesOp.IsDone() == 0:
377 print "NumberOfFaces : ", ShapesOp.GetErrorCode()
380 def NumberOfEdges(theShape):
381 nb_edges = ShapesOp.NumberOfEdges(theShape)
382 if ShapesOp.IsDone() == 0:
383 print "NumberOfEdges : ", ShapesOp.GetErrorCode()
386 def ChangeOrientation(Shape):
387 anObj = ShapesOp.ChangeOrientation(Shape)
388 if ShapesOp.IsDone() == 0:
389 print "ChangeOrientation : ", ShapesOp.GetErrorCode()
392 def OrientationChange(Shape):
393 anObj = ChangeOrientation(Shape)
396 def GetFreeFacesIDs(theShape):
397 anIDs = ShapesOp.GetFreeFacesIDs(theShape)
398 if ShapesOp.IsDone() == 0:
399 print "GetFreeFacesIDs : ", ShapesOp.GetErrorCode()
402 def GetSharedShapes(theShape1, theShape2, theShapeType):
403 aList = ShapesOp.GetSharedShapes(theShape1, theShape2, theShapeType)
404 if ShapesOp.IsDone() == 0:
405 print "GetSharedShapes : ", ShapesOp.GetErrorCode()
408 def GetShapesOnPlane(theShape, theShapeType, theAx1, theState):
409 aList = ShapesOp.GetShapesOnPlane(theShape, theShapeType, theAx1, theState)
410 if ShapesOp.IsDone() == 0:
411 print "GetShapesOnPlane : ", ShapesOp.GetErrorCode()
414 def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState):
415 aList = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState)
416 if ShapesOp.IsDone() == 0:
417 print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode()
420 def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState):
421 aList = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState)
422 if ShapesOp.IsDone() == 0:
423 print "GetShapesOnSphere : ", ShapesOp.GetErrorCode()
426 def GetInPlace(theShapeWhere, theShapeWhat):
427 anObj = ShapesOp.GetInPlace(theShapeWhere, theShapeWhat)
428 if ShapesOp.IsDone() == 0:
429 print "GetInPlace : ", ShapesOp.GetErrorCode()
432 # -----------------------------------------------------------------------------
433 # Access to sub-shapes by their unique IDs inside the main shape.
434 # -----------------------------------------------------------------------------
436 # Obtain a composite sub-shape of <aShape>, composed from sub-shapes
437 # of <aShape>, selected by their unique IDs inside <aShape>
438 def GetSubShape(aShape, ListOfID):
439 anObj = geom.AddSubShape(aShape,ListOfID)
442 # Obtain unique ID of sub-shape <aSubShape> inside <aShape>
443 def GetSubShapeID(aShape, aSubShape):
444 anID = LocalOp.GetSubShapeIndex(aShape, aSubShape)
445 if LocalOp.IsDone() == 0:
446 print "GetSubShapeIndex : ", LocalOp.GetErrorCode()
449 # -----------------------------------------------------------------------------
451 # -----------------------------------------------------------------------------
453 def SubShapeAll(aShape, aType):
454 ListObj = ShapesOp.MakeExplode(aShape,aType,0)
455 if ShapesOp.IsDone() == 0:
456 print "MakeExplode : ", ShapesOp.GetErrorCode()
459 def SubShapeAllIDs(aShape, aType):
460 ListObj = ShapesOp.SubShapeAllIDs(aShape,aType,0)
461 if ShapesOp.IsDone() == 0:
462 print "SubShapeAllIDs : ", ShapesOp.GetErrorCode()
465 def SubShapeAllSorted(aShape, aType):
466 ListObj = ShapesOp.MakeExplode(aShape,aType,1)
467 if ShapesOp.IsDone() == 0:
468 print "MakeExplode : ", ShapesOp.GetErrorCode()
471 def SubShapeAllSortedIDs(aShape, aType):
472 ListIDs = ShapesOp.SubShapeAllIDs(aShape,aType,1)
473 if ShapesOp.IsDone() == 0:
474 print "SubShapeAllSortedIDs : ", ShapesOp.GetErrorCode()
477 # Obtain a compound of sub-shapes of <aShape>,
478 # selected by they indices in list of all sub-shapes of type <aType>
479 def SubShape(aShape, aType, ListOfInd):
481 AllShapeList = SubShapeAll(aShape, aType)
482 for ind in ListOfInd:
483 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
484 anObj = GetSubShape(aShape, ListOfIDs)
487 # Obtain a compound of sub-shapes of <aShape>,
488 # selected by they indices in sorted list of all sub-shapes of type <aType>
489 def SubShapeSorted(aShape, aType, ListOfInd):
491 AllShapeList = SubShapeAllSorted(aShape, aType)
492 for ind in ListOfInd:
493 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
494 anObj = GetSubShape(aShape, ListOfIDs)
497 # -----------------------------------------------------------------------------
499 # -----------------------------------------------------------------------------
501 def ProcessShape(Shape, Operators, Parameters, Values):
502 anObj = HealOp.ProcessShape(Shape, Operators, Parameters, Values)
503 if HealOp.IsDone() == 0:
504 print "ProcessShape : ", HealOp.GetErrorCode()
507 def SuppressFaces(aShape,ListOfId):
508 anObj = HealOp.SuppressFaces(aShape,ListOfId)
509 if HealOp.IsDone() == 0:
510 print "SuppressFaces : ", HealOp.GetErrorCode()
513 def MakeSewing(ListShape,precision):
514 comp = MakeCompound(ListShape)
515 anObj = Sew(comp,precision)
518 def Sew(aShape,precision):
519 anObj = HealOp.Sew(aShape,precision)
520 if HealOp.IsDone() == 0:
521 print "Sew : ", HealOp.GetErrorCode()
524 def SuppressInternalWires(aShape, Wires):
525 anObj = HealOp.RemoveIntWires(aShape, Wires)
526 if HealOp.IsDone() == 0:
527 print "SuppressInternalWires : ", HealOp.GetErrorCode()
530 def SuppressHoles(aShape, ListOfId):
531 anObj = HealOp.FillHoles(aShape,ListOfId)
532 if HealOp.IsDone() == 0:
533 print "SuppressHoles : ", HealOp.GetErrorCode()
536 def CloseContour(aShape, Wires, IsCommonVertex):
537 anObj = HealOp.CloseContour(aShape, Wires, IsCommonVertex)
538 if HealOp.IsDone() == 0:
539 print "CloseContour : ", HealOp.GetErrorCode()
542 def DivideEdge(aShape, EdgeID, Value, IsByParameter):
543 anObj = HealOp.DivideEdge(aShape, EdgeID, Value, IsByParameter)
544 if HealOp.IsDone() == 0:
545 print "DivideEdge : ", HealOp.GetErrorCode()
548 def GetFreeBoundary(Shape):
549 anObj = HealOp.GetFreeBoundary(Shape)
550 if HealOp.IsDone() == 0:
551 print "GetFreeBoundaries : ", HealOp.GetErrorCode()
554 # -----------------------------------------------------------------------------
555 # Create advanced objects
556 # -----------------------------------------------------------------------------
558 def MakeCopy(aShape):
559 anObj = InsertOp.MakeCopy(aShape)
560 if InsertOp.IsDone() == 0:
561 print "MakeCopy : ", InsertOp.GetErrorCode()
564 def MakeFilling(aShape,mindeg,maxdeg,tol2d,tol3d,nbiter):
565 anObj = PrimOp.MakeFilling(aShape,mindeg,maxdeg,tol2d,tol3d,nbiter)
566 if PrimOp.IsDone() == 0:
567 print "MakeFilling : ", PrimOp.GetErrorCode()
570 def MakeGlueFaces(aShape,aTolerance):
571 anObj = ShapesOp.MakeGlueFaces(aShape,aTolerance)
572 if ShapesOp.IsDone() == 0:
573 print "MakeGlueFaces : ", ShapesOp.GetErrorCode()
576 # -----------------------------------------------------------------------------
577 # Boolean (Common, Cut, Fuse, Section)
578 # -----------------------------------------------------------------------------
580 def MakeBoolean(shape1,shape2,operation):
581 anObj = BoolOp.MakeBoolean(shape1,shape2,operation)
582 if BoolOp.IsDone() == 0:
583 print "MakeBoolean : ", BoolOp.GetErrorCode()
586 def MakeCommon(s1, s2):
587 return MakeBoolean(s1, s2, 1)
590 return MakeBoolean(s1, s2, 2)
592 def MakeFuse(s1, s2):
593 return MakeBoolean(s1, s2, 3)
595 def MakeSection(s1, s2):
596 return MakeBoolean(s1, s2, 4)
598 def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
599 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
600 anObj = BoolOp.MakePartition(ListShapes, ListTools,
601 ListKeepInside, ListRemoveInside,
602 Limit, RemoveWebs, ListMaterials);
603 if BoolOp.IsDone() == 0:
604 print "MakePartition : ", BoolOp.GetErrorCode()
607 def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
608 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
609 anObj = MakePartition(ListShapes, ListTools,
610 ListKeepInside, ListRemoveInside,
611 Limit, RemoveWebs, ListMaterials);
614 def MakeHalfPartition(theShape, thePlane):
615 anObj = BoolOp.MakeHalfPartition(theShape, thePlane)
616 if BoolOp.IsDone() == 0:
617 print "MakeHalfPartition : ", BoolOp.GetErrorCode()
620 # -----------------------------------------------------------------------------
622 # -----------------------------------------------------------------------------
624 def MakeTranslationTwoPoints(aShape,point1,point2):
625 anObj = TrsfOp.TranslateTwoPointsCopy(aShape,point1,point2)
626 if TrsfOp.IsDone() == 0:
627 print "TranslateTwoPointsCopy : ", TrsfOp.GetErrorCode()
630 def MakeTranslation(aShape,dx,dy,dz):
631 anObj = TrsfOp.TranslateDXDYDZCopy(aShape,dx,dy,dz)
632 if TrsfOp.IsDone() == 0:
633 print "TranslateDXDYDZCopy : ", TrsfOp.GetErrorCode()
636 def MakeTranslationVector(theObject, theVector):
637 anObj = TrsfOp.TranslateVectorCopy(theObject, theVector)
638 if TrsfOp.IsDone() == 0:
639 print "TranslateVectorCopy : ", TrsfOp.GetErrorCode()
642 def MakeRotation(aShape,axis,angle):
643 anObj = TrsfOp.RotateCopy(aShape,axis,angle)
644 if TrsfOp.IsDone() == 0:
645 print "RotateCopy : ", TrsfOp.GetErrorCode()
648 def MakeScaleTransform(aShape,theCenterofScale,factor):
649 anObj = TrsfOp.ScaleShapeCopy(aShape,theCenterofScale,factor)
650 if TrsfOp.IsDone() == 0:
651 print "ScaleShapeCopy : ", TrsfOp.GetErrorCode()
654 def MakeMirrorByPlane(aShape,aPlane):
655 anObj = TrsfOp.MirrorPlaneCopy(aShape,aPlane)
656 if TrsfOp.IsDone() == 0:
657 print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode()
660 def MakeMirrorByAxis(theObject, theAxis):
661 anObj = TrsfOp.MirrorAxisCopy(theObject, theAxis)
662 if TrsfOp.IsDone() == 0:
663 print "MirrorAxisCopy : ", TrsfOp.GetErrorCode()
666 def MakeMirrorByPoint(theObject, thePoint):
667 anObj = TrsfOp.MirrorPointCopy(theObject, thePoint)
668 if TrsfOp.IsDone() == 0:
669 print "MirrorPointCopy : ", TrsfOp.GetErrorCode()
672 def MakePosition(aShape,theStartLCS,theEndLCS):
673 anObj = TrsfOp.PositionShapeCopy(aShape,theStartLCS,theEndLCS)
674 if TrsfOp.IsDone() == 0:
675 print "PositionShapeCopy : ", TrsfOp.GetErrorCode()
678 def MakeOffset(aShape, anOffset):
679 anObj = TrsfOp.OffsetShapeCopy(aShape, anOffset)
680 if TrsfOp.IsDone() == 0:
681 print "OffsetShapeCopy : ", TrsfOp.GetErrorCode()
684 # -----------------------------------------------------------------------------
686 # -----------------------------------------------------------------------------
688 def MakeMultiTranslation1D(aShape,aDir,aStep,aNbTimes):
689 anObj = TrsfOp.MultiTranslate1D(aShape,aDir,aStep,aNbTimes)
690 if TrsfOp.IsDone() == 0:
691 print "MultiTranslate1D : ", TrsfOp.GetErrorCode()
694 def MakeMultiTranslation2D(aShape,d1,step1,nbtimes1,d2,step2,nbtimes2):
695 anObj = TrsfOp.MultiTranslate2D(aShape,d1,step1,nbtimes1,d2,step2,nbtimes2)
696 if TrsfOp.IsDone() == 0:
697 print "MultiTranslate2D : ", TrsfOp.GetErrorCode()
700 def MultiRotate1D(aShape,aVec,aNbTimes):
701 anObj = TrsfOp.MultiRotate1D(aShape,aVec,aNbTimes)
702 if TrsfOp.IsDone() == 0:
703 print "MultiRotate1D : ", TrsfOp.GetErrorCode()
706 def MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2):
707 anObj = TrsfOp.MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
708 if TrsfOp.IsDone() == 0:
709 print "MultiRotate2D : ", TrsfOp.GetErrorCode()
712 def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes):
713 aVec = MakeLine(aPoint,aDir)
714 anObj = MultiRotate1D(aShape,aVec,aNbTimes)
717 def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2):
718 aVec = MakeLine(aPoint,aDir)
719 anObj = MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
722 # -----------------------------------------------------------------------------
724 # -----------------------------------------------------------------------------
726 def MakeFilletAll(aShape,radius):
727 anObj = LocalOp.MakeFilletAll(aShape,radius)
728 if LocalOp.IsDone() == 0:
729 print "MakeFilletAll : ", LocalOp.GetErrorCode()
732 def MakeFillet(aShape,radius,aShapeType,ListShape):
734 if aShapeType == ShapeType["EDGE"]:
735 anObj = LocalOp.MakeFilletEdges(aShape,radius,ListShape)
737 anObj = LocalOp.MakeFilletFaces(aShape,radius,ListShape)
738 if LocalOp.IsDone() == 0:
739 print "MakeFillet : ", LocalOp.GetErrorCode()
742 def MakeChamferAll(aShape,d):
743 anObj = LocalOp.MakeChamferAll(aShape,d)
744 if LocalOp.IsDone() == 0:
745 print "MakeChamferAll : ", LocalOp.GetErrorCode()
748 def MakeChamferEdge(aShape,d1,d2,face1,face2):
749 anObj = LocalOp.MakeChamferEdge(aShape,d1,d2,face1,face2)
750 if LocalOp.IsDone() == 0:
751 print "MakeChamferEdge : ", LocalOp.GetErrorCode()
754 def MakeChamferFaces(aShape,d1,d2,ListShape):
755 anObj = LocalOp.MakeChamferFaces(aShape,d1,d2,ListShape)
756 if LocalOp.IsDone() == 0:
757 print "MakeChamferFaces : ", LocalOp.GetErrorCode()
760 def MakeChamfer(aShape,d1,d2,aShapeType,ListShape):
762 if aShapeType == ShapeType["EDGE"]:
763 anObj = MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1])
765 anObj = MakeChamferFaces(aShape,d1,d2,ListShape)
768 def Archimede(aShape,weight,WaterDensity,MeshingDeflection):
769 anObj = LocalOp.MakeArchimede(aShape,weight,WaterDensity,MeshingDeflection)
770 if LocalOp.IsDone() == 0:
771 print "MakeArchimede : ", LocalOp.GetErrorCode()
774 # -----------------------------------------------------------------------------
775 # Information objects
776 # -----------------------------------------------------------------------------
778 def PointCoordinates(Point):
779 aTuple = MeasuOp.PointCoordinates(Point)
780 if MeasuOp.IsDone() == 0:
781 print "PointCoordinates : ", MeasuOp.GetErrorCode()
784 def BasicProperties(Shape):
785 aTuple = MeasuOp.GetBasicProperties(Shape)
786 if MeasuOp.IsDone() == 0:
787 print "BasicProperties : ", MeasuOp.GetErrorCode()
790 def BoundingBox(Shape):
791 aTuple = MeasuOp.GetBoundingBox(Shape)
792 if MeasuOp.IsDone() == 0:
793 print "BoundingBox : ", MeasuOp.GetErrorCode()
797 aTuple = MeasuOp.GetInertia(Shape)
798 if MeasuOp.IsDone() == 0:
799 print "Inertia : ", MeasuOp.GetErrorCode()
802 def MinDistance(Shape1, Shape2):
803 aTuple = MeasuOp.GetMinDistance(Shape1, Shape2)
804 if MeasuOp.IsDone() == 0:
805 print "MinDistance : ", MeasuOp.GetErrorCode()
808 def Tolerance(Shape):
809 aTuple = MeasuOp.GetTolerance(Shape)
810 if MeasuOp.IsDone() == 0:
811 print "Tolerance : ", MeasuOp.GetErrorCode()
815 aDescr = MeasuOp.WhatIs(Shape)
816 if MeasuOp.IsDone() == 0:
817 print "WhatIs : ", MeasuOp.GetErrorCode()
821 anObj = MeasuOp.GetCentreOfMass(aShape)
822 if MeasuOp.IsDone() == 0:
823 print "GetCentreOfMass : ", MeasuOp.GetErrorCode()
826 def CheckShape(aShape):
827 (IsValid, Status) = MeasuOp.CheckShape(aShape)
828 if MeasuOp.IsDone() == 0:
829 print "CheckShape : ", MeasuOp.GetErrorCode()
835 # -----------------------------------------------------------------------------
836 # Import/Export objects
837 # -----------------------------------------------------------------------------
839 def Import(filename, formatname):
840 anObj = InsertOp.Import(filename, formatname)
841 if InsertOp.IsDone() == 0:
842 print "Import : ", InsertOp.GetErrorCode()
845 def ImportBREP(theFileName):
846 return Import(theFileName, "BREP")
848 def ImportIGES(theFileName):
849 return Import(theFileName, "IGES")
851 def ImportSTEP(theFileName):
852 return Import(theFileName, "STEP")
854 def Export(aShape, filename, formatname):
855 InsertOp.Export(aShape, filename, formatname)
856 if InsertOp.IsDone() == 0:
857 print "Export : ", InsertOp.GetErrorCode()
859 def ExportBREP(theObject, theFileName):
860 return Export(theObject, theFileName, "BREP")
862 def ExportIGES(theObject, theFileName):
863 return Export(theObject, theFileName, "IGES")
865 def ExportSTEP(theObject, theFileName):
866 return Export(theObject, theFileName, "STEP")
868 # -----------------------------------------------------------------------------
870 # -----------------------------------------------------------------------------
872 def MakeQuad(E1, E2, E3, E4):
873 anObj = BlocksOp.MakeQuad(E1, E2, E3, E4)
874 if BlocksOp.IsDone() == 0:
875 print "MakeQuad : ", BlocksOp.GetErrorCode()
878 def MakeQuad2Edges(E1, E2):
879 anObj = BlocksOp.MakeQuad2Edges(E1, E2)
880 if BlocksOp.IsDone() == 0:
881 print "MakeQuad2Edges : ", BlocksOp.GetErrorCode()
884 def MakeQuad4Vertices(V1, V2, V3, V4):
885 anObj = BlocksOp.MakeQuad4Vertices(V1, V2, V3, V4)
886 if BlocksOp.IsDone() == 0:
887 print "MakeQuad4Vertices : ", BlocksOp.GetErrorCode()
890 def MakeHexa(F1, F2, F3, F4, F5, F6):
891 anObj = BlocksOp.MakeHexa(F1, F2, F3, F4, F5, F6)
892 if BlocksOp.IsDone() == 0:
893 print "MakeHexa : ", BlocksOp.GetErrorCode()
896 def MakeHexa2Faces(F1, F2):
897 anObj = BlocksOp.MakeHexa2Faces(F1, F2)
898 if BlocksOp.IsDone() == 0:
899 print "MakeHexa2Faces : ", BlocksOp.GetErrorCode()
902 def GetPoint(theShape, theX, theY, theZ, theEpsilon):
903 anObj = BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon)
904 if BlocksOp.IsDone() == 0:
905 print "GetPoint : ", BlocksOp.GetErrorCode()
908 def GetEdge(theShape, thePoint1, thePoint2):
909 anObj = BlocksOp.GetEdge(theShape, thePoint1, thePoint2)
910 if BlocksOp.IsDone() == 0:
911 print "GetEdge : ", BlocksOp.GetErrorCode()
914 def GetEdgeNearPoint(theShape, thePoint):
915 anObj = BlocksOp.GetEdgeNearPoint(theShape, thePoint)
916 if BlocksOp.IsDone() == 0:
917 print "GetEdgeNearPoint : ", BlocksOp.GetErrorCode()
920 def GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4):
921 anObj = BlocksOp.GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4)
922 if BlocksOp.IsDone() == 0:
923 print "GetFaceByPoints : ", BlocksOp.GetErrorCode()
926 def GetFaceByEdges(theShape, theEdge1, theEdge2):
927 anObj = BlocksOp.GetFaceByEdges(theShape, theEdge1, theEdge2)
928 if BlocksOp.IsDone() == 0:
929 print "GetFaceByEdges : ", BlocksOp.GetErrorCode()
932 def GetOppositeFace(theBlock, theFace):
933 anObj = BlocksOp.GetOppositeFace(theBlock, theFace)
934 if BlocksOp.IsDone() == 0:
935 print "GetOppositeFace : ", BlocksOp.GetErrorCode()
938 def GetFaceNearPoint(theShape, thePoint):
939 anObj = BlocksOp.GetFaceNearPoint(theShape, thePoint)
940 if BlocksOp.IsDone() == 0:
941 print "GetFaceNearPoint : ", BlocksOp.GetErrorCode()
944 def GetFaceByNormale(theBlock, theVector):
945 anObj = BlocksOp.GetFaceByNormale(theBlock, theVector)
946 if BlocksOp.IsDone() == 0:
947 print "GetFaceByNormale : ", BlocksOp.GetErrorCode()
950 def CheckCompoundOfBlocks(theCompound):
951 (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(theCompound)
952 if BlocksOp.IsDone() == 0:
953 print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode()
956 Descr = BlocksOp.PrintBCErrors(theCompound, BCErrors)
960 def RemoveExtraEdges(theShape):
961 anObj = BlocksOp.RemoveExtraEdges(theShape)
962 if BlocksOp.IsDone() == 0:
963 print "RemoveExtraEdges : ", BlocksOp.GetErrorCode()
966 def CheckAndImprove(theShape):
967 anObj = BlocksOp.CheckAndImprove(theShape)
968 if BlocksOp.IsDone() == 0:
969 print "CheckAndImprove : ", BlocksOp.GetErrorCode()
972 def MakeBlockExplode(theCompound, theMinNbFaces, theMaxNbFaces):
973 aList = BlocksOp.ExplodeCompoundOfBlocks(theCompound, theMinNbFaces, theMaxNbFaces)
974 if BlocksOp.IsDone() == 0:
975 print "MakeBlockExplode : ", BlocksOp.GetErrorCode()
978 def GetBlockNearPoint(theCompound, thePoint):
979 anObj = BlocksOp.GetBlockNearPoint(theCompound, thePoint)
980 if BlocksOp.IsDone() == 0:
981 print "GetBlockNearPoint : ", BlocksOp.GetErrorCode()
984 def GetBlockByParts(theCompound, theParts):
985 anObj = BlocksOp.GetBlockByParts(theCompound, theParts)
986 if BlocksOp.IsDone() == 0:
987 print "GetBlockByParts : ", BlocksOp.GetErrorCode()
990 def GetBlocksByParts(theCompound, theParts):
991 aList = BlocksOp.GetBlocksByParts(theCompound, theParts)
992 if BlocksOp.IsDone() == 0:
993 print "GetBlocksByParts : ", BlocksOp.GetErrorCode()
996 def MakeMultiTransformation1D(Block, DirFaceID1, DirFaceID2, NbTimes):
997 anObj = BlocksOp.MakeMultiTransformation1D(Block, DirFaceID1, DirFaceID2, NbTimes)
998 if BlocksOp.IsDone() == 0:
999 print "MakeMultiTransformation1D : ", BlocksOp.GetErrorCode()
1002 def MakeMultiTransformation2D(Block, DirFaceID1U, DirFaceID2U, NbTimesU,
1003 DirFaceID1V, DirFaceID2V, NbTimesV):
1004 anObj = BlocksOp.MakeMultiTransformation2D(Block, DirFaceID1U, DirFaceID2U, NbTimesU,
1005 DirFaceID1V, DirFaceID2V, NbTimesV)
1006 if BlocksOp.IsDone() == 0:
1007 print "MakeMultiTransformation2D : ", BlocksOp.GetErrorCode()
1010 def Propagate(theShape):
1011 listChains = BlocksOp.Propagate(theShape)
1012 if BlocksOp.IsDone() == 0:
1013 print "Propagate : ", BlocksOp.GetErrorCode()
1016 # -----------------------------------------------------------------------------
1018 # -----------------------------------------------------------------------------
1020 def CreateGroup(MainShape, ShapeType):
1021 anObj = GroupOp.CreateGroup(MainShape, ShapeType)
1022 if GroupOp.IsDone() == 0:
1023 print "CreateGroup : ", GroupOp.GetErrorCode()
1026 def AddObject(Group, SubShapeID):
1027 GroupOp.AddObject(Group, SubShapeID)
1028 if GroupOp.IsDone() == 0:
1029 print "AddObject : ", GroupOp.GetErrorCode()
1031 def RemoveObject(Group, SubShapeID):
1032 GroupOp.RemoveObject(Group, SubShapeID)
1033 if GroupOp.IsDone() == 0:
1034 print "RemoveObject : ", GroupOp.GetErrorCode()
1036 def UnionList (theGroup, theSubShapes):
1037 GroupOp.UnionList(theGroup, theSubShapes)
1038 if GroupOp.IsDone() == 0:
1039 print "UnionList : ", GroupOp.GetErrorCode()
1041 def DifferenceList (theGroup, theSubShapes):
1042 GroupOp.DifferenceList(theGroup, theSubShapes)
1043 if GroupOp.IsDone() == 0:
1044 print "DifferenceList : ", GroupOp.GetErrorCode()
1046 def GetObjectIDs(Group):
1047 ListIDs = GroupOp.GetObjects(Group)
1048 if GroupOp.IsDone() == 0:
1049 print "GetObjectIDs : ", GroupOp.GetErrorCode()
1052 def GetType(theGroup):
1053 aType = GroupOp.GetType(theGroup)
1054 if GroupOp.IsDone() == 0:
1055 print "GetType : ", GroupOp.GetErrorCode()
1058 def GetMainShape(theGroup):
1059 anObj = GroupOp.GetMainShape(theGroup)
1060 if GroupOp.IsDone() == 0:
1061 print "GetMainShape : ", GroupOp.GetErrorCode()
1064 def GetEdgesByLength (theShape, min_length, max_length, include_min = 1, include_max = 1):
1066 Create group of edges of theShape, whose length is in range [min_length, max_length].
1067 If include_min/max == 0, edges with length == min/max_length will not be included in result.
1070 edges = SubShapeAll(theShape, ShapeType["EDGE"])
1073 Props = BasicProperties(edge)
1074 if min_length <= Props[0] and Props[0] <= max_length:
1075 if (not include_min) and (min_length == Props[0]):
1078 if (not include_max) and (Props[0] == max_length):
1081 edges_in_range.append(edge)
1083 if len(edges_in_range) <= 0:
1084 print "No edges found by given criteria"
1087 group_edges = CreateGroup(theShape, ShapeType["EDGE"])
1088 UnionList(group_edges, edges_in_range)
1092 # Add Path to the system path
1095 if (sys.path.count(Path) < 1):
1096 sys.path.append(Path)