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.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 # Author : Paul RASCLE, EDF
29 from batchmode_salome import *
35 sleeping_time_max = 1.0
37 g = lcc.FindOrLoadComponent("FactoryServer", "GEOM")
38 if g is not None: break
41 time.sleep(sleeping_time)
42 sleeping_time = max(sleeping_time_max, 2*sleeping_time)
44 geom = g._narrow( GEOM.GEOM_Gen )
63 def init_geom(theStudy):
65 global myStudy, myBuilder, myStudyId, BasicOp, CurvesOp, PrimOp, ShapesOp, HealOp
66 global InsertOp, BoolOp, TrsfOp, LocalOp, MeasuOp, BlocksOp, GroupOp, father
69 myStudyId = myStudy._get_StudyId()
70 myBuilder = myStudy.NewBuilder()
71 father = myStudy.FindComponent("GEOM")
73 father = myBuilder.NewComponent("GEOM")
74 A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName")
75 FName = A1._narrow(SALOMEDS.AttributeName)
76 FName.SetValue("Geometry")
77 A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap")
78 aPixmap = A2._narrow(SALOMEDS.AttributePixMap)
79 aPixmap.SetPixMap("ICON_OBJBROWSER_Geometry")
80 myBuilder.DefineComponentInstance(father,geom)
83 # -----------------------------------------------------------------------------
84 # Assign Operations Interfaces
85 # -----------------------------------------------------------------------------
87 BasicOp = geom.GetIBasicOperations (myStudyId)
88 CurvesOp = geom.GetICurvesOperations (myStudyId)
89 PrimOp = geom.GetI3DPrimOperations (myStudyId)
90 ShapesOp = geom.GetIShapesOperations (myStudyId)
91 HealOp = geom.GetIHealingOperations (myStudyId)
92 InsertOp = geom.GetIInsertOperations (myStudyId)
93 BoolOp = geom.GetIBooleanOperations (myStudyId)
94 TrsfOp = geom.GetITransformOperations(myStudyId)
95 LocalOp = geom.GetILocalOperations (myStudyId)
96 MeasuOp = geom.GetIMeasureOperations (myStudyId)
97 BlocksOp = geom.GetIBlocksOperations (myStudyId)
98 GroupOp = geom.GetIGroupOperations (myStudyId)
103 # * Get name for sub-shape aSubObj of shape aMainObj
105 def SubShapeName(aSubObj, aMainObj):
110 # * Publish in study aShape with name aName
112 def addToStudy(aShape, aName):
114 aSObject = geom.AddInStudy(myStudy, aShape, aName, None)
116 print "addToStudy() failed"
118 return aShape.GetStudyEntry()
120 # * Publish in study aShape with name aName as sub-object of previously published aFather
122 def addToStudyInFather(aFather, aShape, aName):
124 aSObject = geom.AddInStudy(myStudy, aShape, aName, aFather)
126 print "addToStudyInFather() failed"
128 return aShape.GetStudyEntry()
130 # -----------------------------------------------------------------------------
131 # enumeration ShapeType as a dictionary
132 # -----------------------------------------------------------------------------
134 ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
136 # -----------------------------------------------------------------------------
138 # -----------------------------------------------------------------------------
140 def MakeVertex(theX, theY, theZ):
141 anObj = BasicOp.MakePointXYZ(theX, theY, theZ)
142 if BasicOp.IsDone() == 0:
143 print "MakePointXYZ : ", BasicOp.GetErrorCode()
146 def MakeVertexWithRef(vertex,x,y,z):
147 anObj = BasicOp.MakePointWithReference(vertex,x,y,z)
148 if BasicOp.IsDone() == 0:
149 print "MakePointWithReference : ", BasicOp.GetErrorCode()
152 def MakeVertexOnCurve(curve,par):
153 anObj = BasicOp.MakePointOnCurve(curve,par)
154 if BasicOp.IsDone() == 0:
155 print "MakePointOnCurve : ", BasicOp.GetErrorCode()
158 def MakeVertexOnLinesIntersection(line1,line2):
159 anObj = BasicOp.MakePointOnLinesIntersection(line1,line2)
160 if BasicOp.IsDone() == 0:
161 print "MakePointOnLinesIntersection : ", BasicOp.GetErrorCode()
164 def MakeVectorDXDYDZ(dx,dy,dz):
165 anObj = BasicOp.MakeVectorDXDYDZ(dx,dy,dz)
166 if BasicOp.IsDone() == 0:
167 print "MakeVectorDXDYDZ : ", BasicOp.GetErrorCode()
170 def MakeVector(p1,p2):
171 anObj = BasicOp.MakeVectorTwoPnt(p1, p2)
172 if BasicOp.IsDone() == 0:
173 print "MakeVectorTwoPnt : ", BasicOp.GetErrorCode()
176 def MakeLine(p1, d1):
177 anObj = BasicOp.MakeLine(p1,d1)
178 if BasicOp.IsDone() == 0:
179 print "MakeLine : ", BasicOp.GetErrorCode()
182 def MakeLineTwoPnt(p1, p2):
183 anObj = BasicOp.MakeLineTwoPnt(p1,p2)
184 if BasicOp.IsDone() == 0:
185 print "MakeLineTwoPnt : ", BasicOp.GetErrorCode()
188 def MakeLineTwoFaces(f1, f2):
189 anObj = BasicOp.MakeLineTwoFaces(f1,f2)
190 if BasicOp.IsDone() == 0:
191 print "MakeLineTwoFaces : ", BasicOp.GetErrorCode()
194 def MakePlane(p1,v1,trimsize):
195 anObj = BasicOp.MakePlanePntVec(p1,v1,trimsize)
196 if BasicOp.IsDone() == 0:
197 print "MakePlanePntVec : ", BasicOp.GetErrorCode()
200 def MakePlaneThreePnt(p1,p2,p3,trimsize):
201 anObj = BasicOp.MakePlaneThreePnt(p1,p2,p3,trimsize)
202 if BasicOp.IsDone() == 0:
203 print "MakePlaneThreePnt : ", BasicOp.GetErrorCode()
206 def MakePlaneFace(face,trimsize):
207 anObj = BasicOp.MakePlaneFace(face,trimsize)
208 if BasicOp.IsDone() == 0:
209 print "MakePlaneFace : ", BasicOp.GetErrorCode()
212 def MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ):
213 anObj = BasicOp.MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ)
214 if BasicOp.IsDone() == 0:
215 print "MakeMarker : ", BasicOp.GetErrorCode()
218 def MakeMarkerPntTwoVec(theOrigin, theXVec, theYVec):
220 * Create a local coordinate system.
221 * \param theOrigin Point of coordinate system origin.
222 * \param theXVec Vector of X direction
223 * \param theYVec Vector of Y direction
224 * \return New GEOM_Object, containing the created coordinate system.
226 O = PointCoordinates( theOrigin )
228 for vec in [ theXVec, theYVec ]:
229 v1, v2 = SubShapeAll( vec, ShapeType["VERTEX"] )
230 p1 = PointCoordinates( v1 )
231 p2 = PointCoordinates( v2 )
232 for i in range( 0, 3 ):
233 OXOY.append( p2[i] - p1[i] )
235 anObj = BasicOp.MakeMarker( O[0], O[1], O[2],
236 OXOY[0], OXOY[1], OXOY[2],
237 OXOY[3], OXOY[4], OXOY[5], )
238 if BasicOp.IsDone() == 0:
239 print "MakeMarker : ", BasicOp.GetErrorCode()
242 # -----------------------------------------------------------------------------
244 # -----------------------------------------------------------------------------
246 def MakeArc(p1,p2,p3):
247 anObj = CurvesOp.MakeArc(p1,p2,p3)
248 if CurvesOp.IsDone() == 0:
249 print "MakeArc : ", CurvesOp.GetErrorCode()
252 def MakeCircle(p1,v1,radius):
253 anObj = CurvesOp.MakeCirclePntVecR(p1,v1,radius)
254 if CurvesOp.IsDone() == 0:
255 print "MakeCirclePntVecR : ", CurvesOp.GetErrorCode()
258 def MakeCircleThreePnt(p1,p2,p3):
259 anObj = CurvesOp.MakeCircleThreePnt(p1,p2,p3)
260 if CurvesOp.IsDone() == 0:
261 print "MakeCircleThreePnt : ", CurvesOp.GetErrorCode()
264 def MakeCircleCenter2Pnt(p1,p2,p3):
265 anObj = CurvesOp.MakeCircleCenter2Pnt(p1,p2,p3)
266 if CurvesOp.IsDone() == 0:
267 print "MakeCircleCenter2Pnt : ", CurvesOp.GetErrorCode()
270 def MakeEllipse(p1,v1,radiusMaj,radiusMin):
271 anObj = CurvesOp.MakeEllipse(p1,v1,radiusMaj, radiusMin)
272 if CurvesOp.IsDone() == 0:
273 print "MakeEllipse : ", CurvesOp.GetErrorCode()
276 def MakePolyline(ListShape):
277 anObj = CurvesOp.MakePolyline(ListShape)
278 if CurvesOp.IsDone() == 0:
279 print "MakePolyline : ", CurvesOp.GetErrorCode()
282 def MakeBezier(ListShape):
283 anObj = CurvesOp.MakeSplineBezier(ListShape)
284 if CurvesOp.IsDone() == 0:
285 print "MakeSplineBezier : ", CurvesOp.GetErrorCode()
288 def MakeInterpol(ListShape):
289 anObj = CurvesOp.MakeSplineInterpolation(ListShape)
290 if CurvesOp.IsDone() == 0:
291 print "MakeSplineInterpolation : ", CurvesOp.GetErrorCode()
294 # <WPL>: Nine double values, defining origin,
295 # OZ and OX directions of the working plane.
296 def MakeSketcher(Cmd, WPL = [0,0,0, 0,0,1, 1,0,0]):
297 anObj = CurvesOp.MakeSketcher(Cmd, WPL)
298 if CurvesOp.IsDone() == 0:
299 print "MakeSketcher : ", CurvesOp.GetErrorCode()
302 def MakeSketcherOnPlane(theCommand, theWorkingPlane):
304 * Create a sketcher (wire or face), following the textual description,
305 * passed through \a theCommand argument. \n
306 * For format of the description string see the previous method.\n
307 * \param theCommand String, defining the sketcher in local
308 * coordinates of the working plane.
309 * \param theWorkingPlane Planar Face of the working plane.
310 * \return New GEOM_Object, containing the created wire.
312 anObj = CurvesOp.MakeSketcherOnPlane(theCommand, theWorkingPlane)
313 if CurvesOp.IsDone() == 0:
314 print "MakeSketcher : ", CurvesOp.GetErrorCode()
317 # -----------------------------------------------------------------------------
318 # Create 3D Primitives
319 # -----------------------------------------------------------------------------
321 def MakeBox(x1,y1,z1,x2,y2,z2):
322 pnt1 = MakeVertex(x1,y1,z1)
323 pnt2 = MakeVertex(x2,y2,z2)
324 return MakeBoxTwoPnt(pnt1,pnt2)
326 def MakeBoxDXDYDZ(dx,dy,dz):
327 anObj = PrimOp.MakeBoxDXDYDZ(dx,dy,dz)
328 if PrimOp.IsDone() == 0:
329 print "MakeBoxDXDYDZ : ", PrimOp.GetErrorCode()
332 def MakeBoxTwoPnt(point1, point2):
333 anObj = PrimOp.MakeBoxTwoPnt(point1, point2)
334 if PrimOp.IsDone() == 0:
335 print "MakeBoxTwoPnt : ", PrimOp.GetErrorCode()
338 def MakeCylinder(p1,v1,radius,height):
339 anObj = PrimOp.MakeCylinderPntVecRH(p1,v1,radius,height)
340 if PrimOp.IsDone() == 0:
341 print "MakeCylinderPntVecRH : ", PrimOp.GetErrorCode()
344 def MakeCylinderRH(radius,height):
345 anObj = PrimOp.MakeCylinderRH(radius,height)
346 if PrimOp.IsDone() == 0:
347 print "MakeCylinderRH : ", PrimOp.GetErrorCode()
350 def MakeSpherePntR(point,radius):
351 anObj = PrimOp.MakeSpherePntR(point,radius)
352 if PrimOp.IsDone() == 0:
353 print "MakeSpherePntR : ", PrimOp.GetErrorCode()
356 def MakeSphere(x,y,z,radius):
357 point = MakeVertex(x,y,z)
358 anObj = MakeSpherePntR(point,radius)
361 def MakeSphereR(radius):
362 anObj = PrimOp.MakeSphereR(radius)
363 if PrimOp.IsDone() == 0:
364 print "MakeSphereR : ", PrimOp.GetErrorCode()
367 def MakeCone(p1,v1,radius1,radius2,height):
368 anObj = PrimOp.MakeConePntVecR1R2H(p1,v1,radius1,radius2,height)
369 if PrimOp.IsDone() == 0:
370 print "MakeConePntVecR1R2H : ", PrimOp.GetErrorCode()
373 def MakeConeR1R2H(radius1,radius2,height):
374 anObj = PrimOp.MakeConeR1R2H(radius1,radius2,height)
375 if PrimOp.IsDone() == 0:
376 print "MakeConeR1R2H : ", PrimOp.GetErrorCode()
379 def MakeTorus(p1,v1,major_radius,minor_radius):
380 anObj = PrimOp.MakeTorusPntVecRR(p1,v1,major_radius,minor_radius)
381 if PrimOp.IsDone() == 0:
382 print "MakeTorusPntVecRR : ", PrimOp.GetErrorCode()
385 def MakeTorusRR(major_radius,minor_radius):
386 anObj = PrimOp.MakeTorusRR(major_radius,minor_radius)
387 if PrimOp.IsDone() == 0:
388 print "MakeTorusRR : ", PrimOp.GetErrorCode()
391 def MakePrism(baseShape,point1,point2):
392 anObj = PrimOp.MakePrismTwoPnt(baseShape,point1,point2)
393 if PrimOp.IsDone() == 0:
394 print "MakePrismTwoPnt : ", PrimOp.GetErrorCode()
397 def MakePrism2Ways(baseShape,point1,point2):
398 anObj = PrimOp.MakePrismTwoPnt2Ways(baseShape,point1,point2)
399 if PrimOp.IsDone() == 0:
400 print "MakePrismTwoPnt2Ways : ", PrimOp.GetErrorCode()
403 def MakePrismVecH(baseShape,vector,height):
404 anObj = PrimOp.MakePrismVecH(baseShape,vector,height)
405 if PrimOp.IsDone() == 0:
406 print "MakePrismVecH : ", PrimOp.GetErrorCode()
409 def MakePrismVecH2Ways(baseShape,vector,height):
410 anObj = PrimOp.MakePrismVecH2Ways(baseShape,vector,height)
411 if PrimOp.IsDone() == 0:
412 print "MakePrismVecH2Ways : ", PrimOp.GetErrorCode()
415 def MakePipe(baseShape,pathShape):
416 anObj = PrimOp.MakePipe(baseShape,pathShape)
417 if PrimOp.IsDone() == 0:
418 print "MakePipe : ", PrimOp.GetErrorCode()
421 def MakeRevolution(aShape,axis,angle):
422 anObj = PrimOp.MakeRevolutionAxisAngle(aShape,axis,angle)
423 if PrimOp.IsDone() == 0:
424 print "MakeRevolutionAxisAngle : ", PrimOp.GetErrorCode()
427 def MakeRevolution2Ways(aShape,axis,angle):
428 anObj = PrimOp.MakeRevolutionAxisAngle2Ways(aShape,axis,angle)
429 if PrimOp.IsDone() == 0:
430 print "MakeRevolutionAxisAngle2Ways : ", PrimOp.GetErrorCode()
433 # -----------------------------------------------------------------------------
435 # -----------------------------------------------------------------------------
438 anObj = ShapesOp.MakeEdge(p1,p2)
439 if ShapesOp.IsDone() == 0:
440 print "MakeEdge : ", ShapesOp.GetErrorCode()
443 def MakeWire(ListShape):
444 anObj = ShapesOp.MakeWire(ListShape)
445 if ShapesOp.IsDone() == 0:
446 print "MakeWire : ", ShapesOp.GetErrorCode()
449 def MakeFace(aShapeWire,WantPlanarFace):
450 anObj = ShapesOp.MakeFace(aShapeWire,WantPlanarFace)
451 if ShapesOp.IsDone() == 0:
452 print "MakeFace : ", ShapesOp.GetErrorCode()
455 def MakeFaceWires(ListWires,WantPlanarFace):
456 anObj = ShapesOp.MakeFaceWires(ListWires,WantPlanarFace)
457 if ShapesOp.IsDone() == 0:
458 print "MakeFaceWires : ", ShapesOp.GetErrorCode()
461 def MakeFaces(ListWires,WantPlanarFace):
462 anObj = MakeFaceWires(ListWires,WantPlanarFace)
465 def MakeShell(ListOfShapes):
466 anObj = ShapesOp.MakeShell(ListOfShapes)
467 if ShapesOp.IsDone() == 0:
468 print "MakeShell : ", ShapesOp.GetErrorCode()
471 def MakeSolid(ListOfShells):
472 anObj = ShapesOp.MakeSolidShells(ListOfShells)
473 if ShapesOp.IsDone() == 0:
474 print "MakeSolid : ", ShapesOp.GetErrorCode()
477 def MakeCompound(ListShape):
478 anObj = ShapesOp.MakeCompound(ListShape)
479 if ShapesOp.IsDone() == 0:
480 print "MakeCompound : ", ShapesOp.GetErrorCode()
483 def NumberOfFaces(theShape):
484 nb_faces = ShapesOp.NumberOfFaces(theShape)
485 if ShapesOp.IsDone() == 0:
486 print "NumberOfFaces : ", ShapesOp.GetErrorCode()
489 def NumberOfEdges(theShape):
490 nb_edges = ShapesOp.NumberOfEdges(theShape)
491 if ShapesOp.IsDone() == 0:
492 print "NumberOfEdges : ", ShapesOp.GetErrorCode()
495 def ChangeOrientation(Shape):
496 anObj = ShapesOp.ChangeOrientation(Shape)
497 if ShapesOp.IsDone() == 0:
498 print "ChangeOrientation : ", ShapesOp.GetErrorCode()
501 def OrientationChange(Shape):
502 anObj = ChangeOrientation(Shape)
505 def GetFreeFacesIDs(theShape):
506 anIDs = ShapesOp.GetFreeFacesIDs(theShape)
507 if ShapesOp.IsDone() == 0:
508 print "GetFreeFacesIDs : ", ShapesOp.GetErrorCode()
511 def GetSharedShapes(theShape1, theShape2, theShapeType):
512 aList = ShapesOp.GetSharedShapes(theShape1, theShape2, theShapeType)
513 if ShapesOp.IsDone() == 0:
514 print "GetSharedShapes : ", ShapesOp.GetErrorCode()
517 def GetShapesOnPlane(theShape, theShapeType, theAx1, theState):
518 aList = ShapesOp.GetShapesOnPlane(theShape, theShapeType, theAx1, theState)
519 if ShapesOp.IsDone() == 0:
520 print "GetShapesOnPlane : ", ShapesOp.GetErrorCode()
523 def GetShapesOnPlaneIDs(theShape, theShapeType, theAx1, theState):
524 aList = ShapesOp.GetShapesOnPlaneIDs(theShape, theShapeType, theAx1, theState)
525 if ShapesOp.IsDone() == 0:
526 print "GetShapesOnPlaneIDs : ", ShapesOp.GetErrorCode()
529 def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState):
530 aList = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState)
531 if ShapesOp.IsDone() == 0:
532 print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode()
535 def GetShapesOnCylinderIDs(theShape, theShapeType, theAxis, theRadius, theState):
536 aList = ShapesOp.GetShapesOnCylinderIDs(theShape, theShapeType, theAxis, theRadius, theState)
537 if ShapesOp.IsDone() == 0:
538 print "GetShapesOnCylinderIDs : ", ShapesOp.GetErrorCode()
541 def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState):
542 aList = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState)
543 if ShapesOp.IsDone() == 0:
544 print "GetShapesOnSphere : ", ShapesOp.GetErrorCode()
547 def GetShapesOnSphereIDs(theShape, theShapeType, theCenter, theRadius, theState):
548 aList = ShapesOp.GetShapesOnSphereIDs(theShape, theShapeType, theCenter, theRadius, theState)
549 if ShapesOp.IsDone() == 0:
550 print "GetShapesOnSphereIDs : ", ShapesOp.GetErrorCode()
553 def GetShapesOnQuadrangle(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState):
554 aList = ShapesOp.GetShapesOnQuadrangle(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState)
555 if ShapesOp.IsDone() == 0:
556 print "GetShapesOnQuadrangle : ", ShapesOp.GetErrorCode()
559 def GetShapesOnQuadrangleIDs(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState):
560 aList = ShapesOp.GetShapesOnQuadrangleIDs(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState)
561 if ShapesOp.IsDone() == 0:
562 print "GetShapesOnQuadrangleIDs : ", ShapesOp.GetErrorCode()
565 def GetInPlace(theShapeWhere, theShapeWhat):
566 anObj = ShapesOp.GetInPlace(theShapeWhere, theShapeWhat)
567 if ShapesOp.IsDone() == 0:
568 print "GetInPlace : ", ShapesOp.GetErrorCode()
571 # -----------------------------------------------------------------------------
572 # Access to sub-shapes by their unique IDs inside the main shape.
573 # -----------------------------------------------------------------------------
575 # Obtain a composite sub-shape of <aShape>, composed from sub-shapes
576 # of <aShape>, selected by their unique IDs inside <aShape>
577 def GetSubShape(aShape, ListOfID):
578 anObj = geom.AddSubShape(aShape,ListOfID)
581 # Obtain unique ID of sub-shape <aSubShape> inside <aShape>
582 def GetSubShapeID(aShape, aSubShape):
583 anID = LocalOp.GetSubShapeIndex(aShape, aSubShape)
584 if LocalOp.IsDone() == 0:
585 print "GetSubShapeIndex : ", LocalOp.GetErrorCode()
588 # -----------------------------------------------------------------------------
590 # -----------------------------------------------------------------------------
592 def SubShapeAll(aShape, aType):
593 ListObj = ShapesOp.MakeExplode(aShape,aType,0)
594 if ShapesOp.IsDone() == 0:
595 print "MakeExplode : ", ShapesOp.GetErrorCode()
598 def SubShapeAllIDs(aShape, aType):
599 ListObj = ShapesOp.SubShapeAllIDs(aShape,aType,0)
600 if ShapesOp.IsDone() == 0:
601 print "SubShapeAllIDs : ", ShapesOp.GetErrorCode()
604 def SubShapeAllSorted(aShape, aType):
605 ListObj = ShapesOp.MakeExplode(aShape,aType,1)
606 if ShapesOp.IsDone() == 0:
607 print "MakeExplode : ", ShapesOp.GetErrorCode()
610 def SubShapeAllSortedIDs(aShape, aType):
611 ListIDs = ShapesOp.SubShapeAllIDs(aShape,aType,1)
612 if ShapesOp.IsDone() == 0:
613 print "SubShapeAllSortedIDs : ", ShapesOp.GetErrorCode()
616 # Obtain a compound of sub-shapes of <aShape>,
617 # selected by they indices in list of all sub-shapes of type <aType>
618 def SubShape(aShape, aType, ListOfInd):
620 AllShapeList = SubShapeAll(aShape, aType)
621 for ind in ListOfInd:
622 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
623 anObj = GetSubShape(aShape, ListOfIDs)
626 # Obtain a compound of sub-shapes of <aShape>,
627 # selected by they indices in sorted list of all sub-shapes of type <aType>
628 def SubShapeSorted(aShape, aType, ListOfInd):
630 AllShapeList = SubShapeAllSorted(aShape, aType)
631 for ind in ListOfInd:
632 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
633 anObj = GetSubShape(aShape, ListOfIDs)
636 # -----------------------------------------------------------------------------
638 # -----------------------------------------------------------------------------
640 def ProcessShape(Shape, Operators, Parameters, Values):
641 anObj = HealOp.ProcessShape(Shape, Operators, Parameters, Values)
642 if HealOp.IsDone() == 0:
643 print "ProcessShape : ", HealOp.GetErrorCode()
646 def SuppressFaces(aShape,ListOfId):
647 anObj = HealOp.SuppressFaces(aShape,ListOfId)
648 if HealOp.IsDone() == 0:
649 print "SuppressFaces : ", HealOp.GetErrorCode()
652 def MakeSewing(ListShape,precision):
653 comp = MakeCompound(ListShape)
654 anObj = Sew(comp,precision)
657 def Sew(aShape,precision):
658 anObj = HealOp.Sew(aShape,precision)
659 if HealOp.IsDone() == 0:
660 print "Sew : ", HealOp.GetErrorCode()
663 def SuppressInternalWires(aShape, Wires):
664 anObj = HealOp.RemoveIntWires(aShape, Wires)
665 if HealOp.IsDone() == 0:
666 print "SuppressInternalWires : ", HealOp.GetErrorCode()
669 def SuppressHoles(aShape, ListOfId):
670 anObj = HealOp.FillHoles(aShape,ListOfId)
671 if HealOp.IsDone() == 0:
672 print "SuppressHoles : ", HealOp.GetErrorCode()
675 def CloseContour(aShape, Wires, IsCommonVertex):
676 anObj = HealOp.CloseContour(aShape, Wires, IsCommonVertex)
677 if HealOp.IsDone() == 0:
678 print "CloseContour : ", HealOp.GetErrorCode()
681 def DivideEdge(aShape, EdgeID, Value, IsByParameter):
682 anObj = HealOp.DivideEdge(aShape, EdgeID, Value, IsByParameter)
683 if HealOp.IsDone() == 0:
684 print "DivideEdge : ", HealOp.GetErrorCode()
687 def GetFreeBoundary(Shape):
688 anObj = HealOp.GetFreeBoundary(Shape)
689 if HealOp.IsDone() == 0:
690 print "GetFreeBoundaries : ", HealOp.GetErrorCode()
693 # -----------------------------------------------------------------------------
694 # Create advanced objects
695 # -----------------------------------------------------------------------------
697 def MakeCopy(aShape):
698 anObj = InsertOp.MakeCopy(aShape)
699 if InsertOp.IsDone() == 0:
700 print "MakeCopy : ", InsertOp.GetErrorCode()
703 def MakeFilling(aShape,mindeg,maxdeg,tol2d,tol3d,nbiter,isApprox=0):
704 anObj = PrimOp.MakeFilling(aShape,mindeg,maxdeg,tol2d,tol3d,nbiter,isApprox)
705 if PrimOp.IsDone() == 0:
706 print "MakeFilling : ", PrimOp.GetErrorCode()
709 def MakeGlueFaces(aShape,aTolerance):
710 anObj = ShapesOp.MakeGlueFaces(aShape,aTolerance)
711 if ShapesOp.IsDone() == 0:
712 print "MakeGlueFaces : ", ShapesOp.GetErrorCode()
715 # -----------------------------------------------------------------------------
716 # Boolean (Common, Cut, Fuse, Section)
717 # -----------------------------------------------------------------------------
719 def MakeBoolean(shape1,shape2,operation):
720 anObj = BoolOp.MakeBoolean(shape1,shape2,operation)
721 if BoolOp.IsDone() == 0:
722 print "MakeBoolean : ", BoolOp.GetErrorCode()
725 def MakeCommon(s1, s2):
726 return MakeBoolean(s1, s2, 1)
729 return MakeBoolean(s1, s2, 2)
731 def MakeFuse(s1, s2):
732 return MakeBoolean(s1, s2, 3)
734 def MakeSection(s1, s2):
735 return MakeBoolean(s1, s2, 4)
737 def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
738 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[],
739 KeepNonlimitShapes=0):
740 anObj = BoolOp.MakePartition(ListShapes, ListTools,
741 ListKeepInside, ListRemoveInside,
742 Limit, RemoveWebs, ListMaterials,
744 if BoolOp.IsDone() == 0:
745 print "MakePartition : ", BoolOp.GetErrorCode()
748 def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
749 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[],
750 KeepNonlimitShapes=0):
751 anObj = MakePartition(ListShapes, ListTools,
752 ListKeepInside, ListRemoveInside,
753 Limit, RemoveWebs, ListMaterials,
757 def MakeHalfPartition(theShape, thePlane):
758 anObj = BoolOp.MakeHalfPartition(theShape, thePlane)
759 if BoolOp.IsDone() == 0:
760 print "MakeHalfPartition : ", BoolOp.GetErrorCode()
763 # -----------------------------------------------------------------------------
765 # -----------------------------------------------------------------------------
767 def MakeTranslationTwoPoints(aShape,point1,point2):
768 anObj = TrsfOp.TranslateTwoPointsCopy(aShape,point1,point2)
769 if TrsfOp.IsDone() == 0:
770 print "TranslateTwoPointsCopy : ", TrsfOp.GetErrorCode()
773 def MakeTranslation(aShape,dx,dy,dz):
774 anObj = TrsfOp.TranslateDXDYDZCopy(aShape,dx,dy,dz)
775 if TrsfOp.IsDone() == 0:
776 print "TranslateDXDYDZCopy : ", TrsfOp.GetErrorCode()
779 def MakeTranslationVector(theObject, theVector):
780 anObj = TrsfOp.TranslateVectorCopy(theObject, theVector)
781 if TrsfOp.IsDone() == 0:
782 print "TranslateVectorCopy : ", TrsfOp.GetErrorCode()
785 def MakeRotation(aShape,axis,angle):
786 anObj = TrsfOp.RotateCopy(aShape,axis,angle)
787 if TrsfOp.IsDone() == 0:
788 print "RotateCopy : ", TrsfOp.GetErrorCode()
791 def MakeRotationThreePoints(aShape, centpoint, point1, point2):
792 anObj = TrsfOp.RotateThreePointsCopy(aShape, centpoint, point1, point2)
793 if TrsfOp.IsDone() == 0:
794 print "RotateThreePointsCopy : ", TrsfOp.GetErrorCode()
797 def MakeScaleTransform(aShape,theCenterofScale,factor):
798 anObj = TrsfOp.ScaleShapeCopy(aShape,theCenterofScale,factor)
799 if TrsfOp.IsDone() == 0:
800 print "ScaleShapeCopy : ", TrsfOp.GetErrorCode()
803 def MakeMirrorByPlane(aShape,aPlane):
804 anObj = TrsfOp.MirrorPlaneCopy(aShape,aPlane)
805 if TrsfOp.IsDone() == 0:
806 print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode()
809 def MakeMirrorByAxis(theObject, theAxis):
810 anObj = TrsfOp.MirrorAxisCopy(theObject, theAxis)
811 if TrsfOp.IsDone() == 0:
812 print "MirrorAxisCopy : ", TrsfOp.GetErrorCode()
815 def MakeMirrorByPoint(theObject, thePoint):
816 anObj = TrsfOp.MirrorPointCopy(theObject, thePoint)
817 if TrsfOp.IsDone() == 0:
818 print "MirrorPointCopy : ", TrsfOp.GetErrorCode()
821 def MakePosition(aShape,theStartLCS,theEndLCS):
822 anObj = TrsfOp.PositionShapeCopy(aShape,theStartLCS,theEndLCS)
823 if TrsfOp.IsDone() == 0:
824 print "PositionShapeCopy : ", TrsfOp.GetErrorCode()
827 def MakeOffset(aShape, anOffset):
828 anObj = TrsfOp.OffsetShapeCopy(aShape, anOffset)
829 if TrsfOp.IsDone() == 0:
830 print "OffsetShapeCopy : ", TrsfOp.GetErrorCode()
833 # -----------------------------------------------------------------------------
835 # -----------------------------------------------------------------------------
837 def MakeMultiTranslation1D(aShape,aDir,aStep,aNbTimes):
838 anObj = TrsfOp.MultiTranslate1D(aShape,aDir,aStep,aNbTimes)
839 if TrsfOp.IsDone() == 0:
840 print "MultiTranslate1D : ", TrsfOp.GetErrorCode()
843 def MakeMultiTranslation2D(aShape,d1,step1,nbtimes1,d2,step2,nbtimes2):
844 anObj = TrsfOp.MultiTranslate2D(aShape,d1,step1,nbtimes1,d2,step2,nbtimes2)
845 if TrsfOp.IsDone() == 0:
846 print "MultiTranslate2D : ", TrsfOp.GetErrorCode()
849 def MultiRotate1D(aShape,aVec,aNbTimes):
850 anObj = TrsfOp.MultiRotate1D(aShape,aVec,aNbTimes)
851 if TrsfOp.IsDone() == 0:
852 print "MultiRotate1D : ", TrsfOp.GetErrorCode()
855 def MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2):
856 anObj = TrsfOp.MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
857 if TrsfOp.IsDone() == 0:
858 print "MultiRotate2D : ", TrsfOp.GetErrorCode()
861 def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes):
862 aVec = MakeLine(aPoint,aDir)
863 anObj = MultiRotate1D(aShape,aVec,aNbTimes)
866 def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2):
867 aVec = MakeLine(aPoint,aDir)
868 anObj = MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
871 # -----------------------------------------------------------------------------
873 # -----------------------------------------------------------------------------
875 def MakeFilletAll(aShape,radius):
876 anObj = LocalOp.MakeFilletAll(aShape,radius)
877 if LocalOp.IsDone() == 0:
878 print "MakeFilletAll : ", LocalOp.GetErrorCode()
881 def MakeFillet(aShape,radius,aShapeType,ListShape):
883 if aShapeType == ShapeType["EDGE"]:
884 anObj = LocalOp.MakeFilletEdges(aShape,radius,ListShape)
886 anObj = LocalOp.MakeFilletFaces(aShape,radius,ListShape)
887 if LocalOp.IsDone() == 0:
888 print "MakeFillet : ", LocalOp.GetErrorCode()
891 def MakeFilletR1R2(aShape,radius1,radius2,aShapeType,ListShape):
893 if aShapeType == ShapeType["EDGE"]:
894 anObj = LocalOp.MakeFilletEdgesR1R2(aShape,radius1,radius2,ListShape)
896 anObj = LocalOp.MakeFilletFacesR1R2(aShape,radius1,radius2,ListShape)
897 if LocalOp.IsDone() == 0:
898 print "MakeFilletR1R2 : ", LocalOp.GetErrorCode()
901 def MakeChamferAll(aShape,d):
902 anObj = LocalOp.MakeChamferAll(aShape,d)
903 if LocalOp.IsDone() == 0:
904 print "MakeChamferAll : ", LocalOp.GetErrorCode()
907 def MakeChamferEdge(aShape,d1,d2,face1,face2):
908 anObj = LocalOp.MakeChamferEdge(aShape,d1,d2,face1,face2)
909 if LocalOp.IsDone() == 0:
910 print "MakeChamferEdge : ", LocalOp.GetErrorCode()
913 def MakeChamferEdgeAD(aShape,d,angle,face1,face2):
914 anObj = LocalOp.MakeChamferEdgeAD(aShape,d,angle,face1,face2)
915 if LocalOp.IsDone() == 0:
916 print "MakeChamferEdgeAD : ", LocalOp.GetErrorCode()
919 def MakeChamferFaces(aShape,d1,d2,ListShape):
920 anObj = LocalOp.MakeChamferFaces(aShape,d1,d2,ListShape)
921 if LocalOp.IsDone() == 0:
922 print "MakeChamferFaces : ", LocalOp.GetErrorCode()
925 def MakeChamferFacesAD(aShape,d,angle,ListShape):
926 anObj = LocalOp.MakeChamferFacesAD(aShape,d,angle,ListShape)
927 if LocalOp.IsDone() == 0:
928 print "MakeChamferFacesAD : ", LocalOp.GetErrorCode()
931 def MakeChamferEdges(aShape,d1,d2,ListShape):
932 anObj = LocalOp.MakeChamferEdges(aShape,d1,d2,ListShape)
933 if LocalOp.IsDone() == 0:
934 print "MakeChamferEdges : ", LocalOp.GetErrorCode()
937 def MakeChamferEdgesAD(aShape,d,angle,ListShape):
938 anObj = LocalOp.MakeChamferEdgesAD(aShape,d,angle,ListShape)
939 if LocalOp.IsDone() == 0:
940 print "MakeChamferEdgesAD : ", LocalOp.GetErrorCode()
943 def MakeChamfer(aShape,d1,d2,aShapeType,ListShape):
945 if aShapeType == ShapeType["EDGE"]:
946 anObj = MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1])
948 anObj = MakeChamferFaces(aShape,d1,d2,ListShape)
951 def Archimede(aShape,weight,WaterDensity,MeshingDeflection):
952 anObj = LocalOp.MakeArchimede(aShape,weight,WaterDensity,MeshingDeflection)
953 if LocalOp.IsDone() == 0:
954 print "MakeArchimede : ", LocalOp.GetErrorCode()
957 # -----------------------------------------------------------------------------
958 # Information objects
959 # -----------------------------------------------------------------------------
961 def PointCoordinates(Point):
962 aTuple = MeasuOp.PointCoordinates(Point)
963 if MeasuOp.IsDone() == 0:
964 print "PointCoordinates : ", MeasuOp.GetErrorCode()
967 def BasicProperties(Shape):
968 aTuple = MeasuOp.GetBasicProperties(Shape)
969 if MeasuOp.IsDone() == 0:
970 print "BasicProperties : ", MeasuOp.GetErrorCode()
973 def BoundingBox(Shape):
974 aTuple = MeasuOp.GetBoundingBox(Shape)
975 if MeasuOp.IsDone() == 0:
976 print "BoundingBox : ", MeasuOp.GetErrorCode()
980 aTuple = MeasuOp.GetInertia(Shape)
981 if MeasuOp.IsDone() == 0:
982 print "Inertia : ", MeasuOp.GetErrorCode()
985 def MinDistance(Shape1, Shape2):
986 aTuple = MeasuOp.GetMinDistance(Shape1, Shape2)
987 if MeasuOp.IsDone() == 0:
988 print "MinDistance : ", MeasuOp.GetErrorCode()
991 def Tolerance(Shape):
992 aTuple = MeasuOp.GetTolerance(Shape)
993 if MeasuOp.IsDone() == 0:
994 print "Tolerance : ", MeasuOp.GetErrorCode()
998 aDescr = MeasuOp.WhatIs(Shape)
999 if MeasuOp.IsDone() == 0:
1000 print "WhatIs : ", MeasuOp.GetErrorCode()
1003 def MakeCDG(aShape):
1004 anObj = MeasuOp.GetCentreOfMass(aShape)
1005 if MeasuOp.IsDone() == 0:
1006 print "GetCentreOfMass : ", MeasuOp.GetErrorCode()
1009 def CheckShape(theShape, theIsCheckGeom = 0):
1011 (IsValid, Status) = MeasuOp.CheckShapeWithGeometry(theShape)
1013 (IsValid, Status) = MeasuOp.CheckShape(theShape)
1015 if MeasuOp.IsDone() == 0:
1016 print "CheckShape : ", MeasuOp.GetErrorCode()
1022 # -----------------------------------------------------------------------------
1023 # Import/Export objects
1024 # -----------------------------------------------------------------------------
1026 def Import(filename, formatname):
1027 anObj = InsertOp.Import(filename, formatname)
1028 if InsertOp.IsDone() == 0:
1029 print "Import : ", InsertOp.GetErrorCode()
1032 def ImportBREP(theFileName):
1033 return Import(theFileName, "BREP")
1035 def ImportIGES(theFileName):
1036 return Import(theFileName, "IGES")
1038 def ImportSTEP(theFileName):
1039 return Import(theFileName, "STEP")
1041 def Export(aShape, filename, formatname):
1042 InsertOp.Export(aShape, filename, formatname)
1043 if InsertOp.IsDone() == 0:
1044 print "Export : ", InsertOp.GetErrorCode()
1046 def ExportBREP(theObject, theFileName):
1047 return Export(theObject, theFileName, "BREP")
1049 def ExportIGES(theObject, theFileName):
1050 return Export(theObject, theFileName, "IGES")
1052 def ExportSTEP(theObject, theFileName):
1053 return Export(theObject, theFileName, "STEP")
1055 # -----------------------------------------------------------------------------
1057 # -----------------------------------------------------------------------------
1059 def MakeQuad(E1, E2, E3, E4):
1060 anObj = BlocksOp.MakeQuad(E1, E2, E3, E4)
1061 if BlocksOp.IsDone() == 0:
1062 print "MakeQuad : ", BlocksOp.GetErrorCode()
1065 def MakeQuad2Edges(E1, E2):
1066 anObj = BlocksOp.MakeQuad2Edges(E1, E2)
1067 if BlocksOp.IsDone() == 0:
1068 print "MakeQuad2Edges : ", BlocksOp.GetErrorCode()
1071 def MakeQuad4Vertices(V1, V2, V3, V4):
1072 anObj = BlocksOp.MakeQuad4Vertices(V1, V2, V3, V4)
1073 if BlocksOp.IsDone() == 0:
1074 print "MakeQuad4Vertices : ", BlocksOp.GetErrorCode()
1077 def MakeHexa(F1, F2, F3, F4, F5, F6):
1078 anObj = BlocksOp.MakeHexa(F1, F2, F3, F4, F5, F6)
1079 if BlocksOp.IsDone() == 0:
1080 print "MakeHexa : ", BlocksOp.GetErrorCode()
1083 def MakeHexa2Faces(F1, F2):
1084 anObj = BlocksOp.MakeHexa2Faces(F1, F2)
1085 if BlocksOp.IsDone() == 0:
1086 print "MakeHexa2Faces : ", BlocksOp.GetErrorCode()
1089 def GetPoint(theShape, theX, theY, theZ, theEpsilon):
1090 anObj = BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon)
1091 if BlocksOp.IsDone() == 0:
1092 print "GetPoint : ", BlocksOp.GetErrorCode()
1095 def GetEdge(theShape, thePoint1, thePoint2):
1096 anObj = BlocksOp.GetEdge(theShape, thePoint1, thePoint2)
1097 if BlocksOp.IsDone() == 0:
1098 print "GetEdge : ", BlocksOp.GetErrorCode()
1101 def GetEdgeNearPoint(theShape, thePoint):
1102 anObj = BlocksOp.GetEdgeNearPoint(theShape, thePoint)
1103 if BlocksOp.IsDone() == 0:
1104 print "GetEdgeNearPoint : ", BlocksOp.GetErrorCode()
1107 def GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4):
1108 anObj = BlocksOp.GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4)
1109 if BlocksOp.IsDone() == 0:
1110 print "GetFaceByPoints : ", BlocksOp.GetErrorCode()
1113 def GetFaceByEdges(theShape, theEdge1, theEdge2):
1114 anObj = BlocksOp.GetFaceByEdges(theShape, theEdge1, theEdge2)
1115 if BlocksOp.IsDone() == 0:
1116 print "GetFaceByEdges : ", BlocksOp.GetErrorCode()
1119 def GetOppositeFace(theBlock, theFace):
1120 anObj = BlocksOp.GetOppositeFace(theBlock, theFace)
1121 if BlocksOp.IsDone() == 0:
1122 print "GetOppositeFace : ", BlocksOp.GetErrorCode()
1125 def GetFaceNearPoint(theShape, thePoint):
1126 anObj = BlocksOp.GetFaceNearPoint(theShape, thePoint)
1127 if BlocksOp.IsDone() == 0:
1128 print "GetFaceNearPoint : ", BlocksOp.GetErrorCode()
1131 def GetFaceByNormale(theBlock, theVector):
1132 anObj = BlocksOp.GetFaceByNormale(theBlock, theVector)
1133 if BlocksOp.IsDone() == 0:
1134 print "GetFaceByNormale : ", BlocksOp.GetErrorCode()
1137 def CheckCompoundOfBlocks(theCompound):
1138 (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(theCompound)
1139 if BlocksOp.IsDone() == 0:
1140 print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode()
1143 Descr = BlocksOp.PrintBCErrors(theCompound, BCErrors)
1147 def RemoveExtraEdges(theShape):
1148 anObj = BlocksOp.RemoveExtraEdges(theShape)
1149 if BlocksOp.IsDone() == 0:
1150 print "RemoveExtraEdges : ", BlocksOp.GetErrorCode()
1153 def CheckAndImprove(theShape):
1154 anObj = BlocksOp.CheckAndImprove(theShape)
1155 if BlocksOp.IsDone() == 0:
1156 print "CheckAndImprove : ", BlocksOp.GetErrorCode()
1159 def MakeBlockExplode(theCompound, theMinNbFaces, theMaxNbFaces):
1160 aList = BlocksOp.ExplodeCompoundOfBlocks(theCompound, theMinNbFaces, theMaxNbFaces)
1161 if BlocksOp.IsDone() == 0:
1162 print "MakeBlockExplode : ", BlocksOp.GetErrorCode()
1165 def GetBlockNearPoint(theCompound, thePoint):
1166 anObj = BlocksOp.GetBlockNearPoint(theCompound, thePoint)
1167 if BlocksOp.IsDone() == 0:
1168 print "GetBlockNearPoint : ", BlocksOp.GetErrorCode()
1171 def GetBlockByParts(theCompound, theParts):
1172 anObj = BlocksOp.GetBlockByParts(theCompound, theParts)
1173 if BlocksOp.IsDone() == 0:
1174 print "GetBlockByParts : ", BlocksOp.GetErrorCode()
1177 def GetBlocksByParts(theCompound, theParts):
1178 aList = BlocksOp.GetBlocksByParts(theCompound, theParts)
1179 if BlocksOp.IsDone() == 0:
1180 print "GetBlocksByParts : ", BlocksOp.GetErrorCode()
1183 def MakeMultiTransformation1D(Block, DirFaceID1, DirFaceID2, NbTimes):
1184 anObj = BlocksOp.MakeMultiTransformation1D(Block, DirFaceID1, DirFaceID2, NbTimes)
1185 if BlocksOp.IsDone() == 0:
1186 print "MakeMultiTransformation1D : ", BlocksOp.GetErrorCode()
1189 def MakeMultiTransformation2D(Block, DirFaceID1U, DirFaceID2U, NbTimesU,
1190 DirFaceID1V, DirFaceID2V, NbTimesV):
1191 anObj = BlocksOp.MakeMultiTransformation2D(Block, DirFaceID1U, DirFaceID2U, NbTimesU,
1192 DirFaceID1V, DirFaceID2V, NbTimesV)
1193 if BlocksOp.IsDone() == 0:
1194 print "MakeMultiTransformation2D : ", BlocksOp.GetErrorCode()
1197 def Propagate(theShape):
1198 listChains = BlocksOp.Propagate(theShape)
1199 if BlocksOp.IsDone() == 0:
1200 print "Propagate : ", BlocksOp.GetErrorCode()
1203 # -----------------------------------------------------------------------------
1205 # -----------------------------------------------------------------------------
1207 def CreateGroup(MainShape, ShapeType):
1208 anObj = GroupOp.CreateGroup(MainShape, ShapeType)
1209 if GroupOp.IsDone() == 0:
1210 print "CreateGroup : ", GroupOp.GetErrorCode()
1213 def AddObject(Group, SubShapeID):
1214 GroupOp.AddObject(Group, SubShapeID)
1215 if GroupOp.IsDone() == 0:
1216 print "AddObject : ", GroupOp.GetErrorCode()
1218 def RemoveObject(Group, SubShapeID):
1219 GroupOp.RemoveObject(Group, SubShapeID)
1220 if GroupOp.IsDone() == 0:
1221 print "RemoveObject : ", GroupOp.GetErrorCode()
1223 def UnionList (theGroup, theSubShapes):
1224 GroupOp.UnionList(theGroup, theSubShapes)
1225 if GroupOp.IsDone() == 0:
1226 print "UnionList : ", GroupOp.GetErrorCode()
1228 def UnionIDs(theGroup, theSubShapes):
1229 GroupOp.UnionIDs(theGroup, theSubShapes)
1230 if GroupOp.IsDone() == 0:
1231 print "UnionIDs : ", GroupOp.GetErrorCode()
1233 def DifferenceList (theGroup, theSubShapes):
1234 GroupOp.DifferenceList(theGroup, theSubShapes)
1235 if GroupOp.IsDone() == 0:
1236 print "DifferenceList : ", GroupOp.GetErrorCode()
1238 def DifferenceIDs(theGroup, theSubShapes):
1239 GroupOp.DifferenceIDs(theGroup, theSubShapes)
1240 if GroupOp.IsDone() == 0:
1241 print "DifferenceIDs : ", GroupOp.GetErrorCode()
1243 def GetObjectIDs(Group):
1244 ListIDs = GroupOp.GetObjects(Group)
1245 if GroupOp.IsDone() == 0:
1246 print "GetObjectIDs : ", GroupOp.GetErrorCode()
1249 def GetType(theGroup):
1250 aType = GroupOp.GetType(theGroup)
1251 if GroupOp.IsDone() == 0:
1252 print "GetType : ", GroupOp.GetErrorCode()
1255 def GetMainShape(theGroup):
1256 anObj = GroupOp.GetMainShape(theGroup)
1257 if GroupOp.IsDone() == 0:
1258 print "GetMainShape : ", GroupOp.GetErrorCode()
1261 def GetEdgesByLength (theShape, min_length, max_length, include_min = 1, include_max = 1):
1263 Create group of edges of theShape, whose length is in range [min_length, max_length].
1264 If include_min/max == 0, edges with length == min/max_length will not be included in result.
1267 edges = SubShapeAll(theShape, ShapeType["EDGE"])
1270 Props = BasicProperties(edge)
1271 if min_length <= Props[0] and Props[0] <= max_length:
1272 if (not include_min) and (min_length == Props[0]):
1275 if (not include_max) and (Props[0] == max_length):
1278 edges_in_range.append(edge)
1280 if len(edges_in_range) <= 0:
1281 print "No edges found by given criteria"
1284 group_edges = CreateGroup(theShape, ShapeType["EDGE"])
1285 UnionList(group_edges, edges_in_range)
1289 # Add Path to the system path
1292 if (sys.path.count(Path) < 1):
1293 sys.path.append(Path)