1 #==============================================================================
3 # Created : sam nov 10 00:49:10 CET 2001
4 # Author : Paul RASCLE, EDF
8 #==============================================================================
12 #import SALOMEDS_Attributes_idl
14 #NRI : BugID 1682 : from libSALOME_Swig import *
16 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
17 geom.GetCurrentStudy(salome.myStudyId)
18 myBuilder = salome.myStudy.NewBuilder()
20 gg = salome.ImportComponentGUI("Geometry")
22 father = salome.myStudy.FindComponent("GEOM")
24 father = myBuilder.NewComponent("GEOM")
25 A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName");
26 FName = A1._narrow(SALOMEDS.AttributeName)
27 FName.SetValue( salome.sg.getComponentUserName("GEOM") )
28 A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap");
29 aPixmap = A2._narrow(SALOMEDS.AttributePixMap);
30 aPixmap.SetPixMap( "ICON_OBJBROWSER_Geometry" );
31 myBuilder.DefineComponentInstance(father,geom)
34 # -----------------------------------------------------------------------------
36 # -----------------------------------------------------------------------------
38 def SubShapeName(aSubId, aMainId):
39 index = gg.getIndexTopology(aSubId, aMainId)
40 name = gg.getShapeTypeString(aSubId) + "_%d"%(index)
43 def addArguments(aShape):
45 ListIOR = geom.GetReferencedObjects(aShape)
47 if aShape._get_StudyShapeId()!="":
48 father = salome.IDToSObject(aShape._get_StudyShapeId())
50 myBuilder.NewCommand()
52 Arg = myBuilder.NewObject(father)
53 A1 = myBuilder.FindOrCreateAttribute(Arg, "AttributeName");
54 ArgName = A1._narrow(SALOMEDS.AttributeName)
55 ArgName.SetValue("Arguments")
56 A2 = myBuilder.FindOrCreateAttribute(Arg, "AttributeSelectable");
57 SelAttr = A2._narrow(SALOMEDS.AttributeSelectable);
58 SelAttr.SetSelectable(0);
62 Shape = salome.orb.string_to_object(anIOR)
64 if Shape._get_StudyShapeId()!="":
65 Obj = salome.IDToSObject(Shape._get_StudyShapeId())
67 Obj1 = myBuilder.NewObject(Arg)
68 myBuilder.Addreference(Obj1,Obj)
72 myBuilder.RemoveObject(Arg)
74 myBuilder.CommitCommand()
77 def addToStudy(aShape, aName):
78 myBuilder.NewCommand()
79 newObj = myBuilder.NewObject(father)
80 ior = salome.orb.object_to_string(aShape)
81 A1 = myBuilder.FindOrCreateAttribute(newObj, "AttributeIOR");
82 ObjIOR = A1._narrow(SALOMEDS.AttributeIOR)
84 A2 = myBuilder.FindOrCreateAttribute(newObj, "AttributeName");
85 ObjName = A2._narrow(SALOMEDS.AttributeName)
86 ObjName.SetValue(aName)
87 A3 = myBuilder.FindOrCreateAttribute(newObj, "AttributePixMap");
88 ObjPixmap = A3._narrow(SALOMEDS.AttributePixMap)
89 anIcon = gg.getShapeTypeIcon(ior);
90 ObjPixmap.SetPixMap(anIcon)
92 aShape._set_StudyShapeId(id)
93 myBuilder.CommitCommand()
95 addArguments( aShape )
97 #NRI : BugID 1682 : sg = SALOMEGUI_Swig()
98 #NRI : BugID 1682 : sg.updateObjBrowser(0)
99 salome.sg.updateObjBrowser(0)
102 def addToStudyInFather(aFather, aShape, aName):
104 #NRI : BugID 1682 : sg = SALOMEGUI_Swig()
105 myBuilder.NewCommand()
106 newObj = myBuilder.NewObject( salome.IDToSObject(aFather._get_StudyShapeId()) )
107 ior = salome.orb.object_to_string(aShape)
108 A1 = myBuilder.FindOrCreateAttribute(newObj, "AttributeIOR");
109 ObjIOR = A1._narrow(SALOMEDS.AttributeIOR)
111 A2 = myBuilder.FindOrCreateAttribute(newObj, "AttributeName");
112 ObjName = A2._narrow(SALOMEDS.AttributeName)
113 ObjName.SetValue(aName)
114 A3 = myBuilder.FindOrCreateAttribute(newObj, "AttributePixMap");
115 ObjPixmap = A3._narrow(SALOMEDS.AttributePixMap)
116 anIcon = gg.getShapeTypeIcon(ior);
117 ObjPixmap.SetPixMap(anIcon)
119 aShape._set_StudyShapeId(id)
120 myBuilder.CommitCommand()
122 addArguments( aShape )
124 #NRI : BugID 1682 : sg.updateObjBrowser(0)
125 salome.sg.updateObjBrowser(0)
128 # -----------------------------------------------------------------------------
130 # -----------------------------------------------------------------------------
132 def MakeVertex(x,y,z):
133 anObj = geom.MakeVertex(x,y,z)
134 ior = salome.orb.object_to_string(anObj)
138 def MakeVector(p1,p2):
139 anObj = geom.MakeVector(p1,p2)
140 ior = salome.orb.object_to_string(anObj)
145 anObj = geom.MakeLine(p1,d1)
146 ior = salome.orb.object_to_string(anObj)
150 def MakeArc(p1,p2,p3):
151 anObj = geom.MakeArc(p1,p2,p3)
152 ior = salome.orb.object_to_string(anObj)
156 def MakeCircle(p1,d1,radius):
157 anObj = geom.MakeCircle(p1,d1,radius)
158 ior = salome.orb.object_to_string(anObj)
162 def MakePlane(p1,d1,trimsize):
163 anObj = geom.MakePlane(p1,d1,trimsize)
164 ior = salome.orb.object_to_string(anObj)
168 # -----------------------------------------------------------------------------
170 # -----------------------------------------------------------------------------
172 def MakeBox(x1,y1,z1,x2,y2,z2):
173 anObj = geom.MakeBox(x1,y1,z1,x2,y2,z2)
174 ior = salome.orb.object_to_string(anObj)
178 def MakeCylinder(p1,d1,radius,height):
179 anObj = geom.MakeCylinder(p1,d1,radius,height)
180 ior = salome.orb.object_to_string(anObj)
184 def MakeSphere(x,y,z,radius):
185 anObj = geom.MakeSphere(x,y,z,radius)
186 ior = salome.orb.object_to_string(anObj)
190 def MakeCone(p1,d1,radius1,radius2,height):
191 anObj = geom.MakeCone(p1,d1,radius1,radius2,height)
192 ior = salome.orb.object_to_string(anObj)
196 def MakeTorus(p1,d1,major_radius,minor_radius):
197 anObj = geom.MakeTorus(p1,d1,major_radius,minor_radius)
198 ior = salome.orb.object_to_string(anObj)
202 # -----------------------------------------------------------------------------
203 # Create base objects
204 # -----------------------------------------------------------------------------
207 anObj = geom.MakeEdge(p1,p2)
208 ior = salome.orb.object_to_string(anObj)
212 def MakeWire(ListShape):
213 anObj = geom.MakeWire(ListShape)
214 ior = salome.orb.object_to_string(anObj)
218 def MakeFace(aShapeWire,WantPlanarFace):
219 anObj = geom.MakeFace(aShapeWire,WantPlanarFace)
220 ior = salome.orb.object_to_string(anObj)
224 def MakeCompound(ListShape):
225 anObj = geom.MakeCompound(ListShape)
226 ior = salome.orb.object_to_string(anObj)
230 # -----------------------------------------------------------------------------
231 # Create advanced objects
232 # -----------------------------------------------------------------------------
234 def MakeCopy(aShape):
235 anObj = geom.MakeCopy(aShape)
236 ior = salome.orb.object_to_string(anObj)
240 def MakePrism(baseShape,p1,p2):
241 anObj = geom.MakePrism(baseShape,p1,p2)
242 ior = salome.orb.object_to_string(anObj)
246 def MakeRevolution(aShape,axis,angle):
247 anObj = geom.MakeRevolution(aShape,axis,angle)
248 ior = salome.orb.object_to_string(anObj)
252 def MakeFilling(aShape,mindeg,maxdeg,tol3d,tol2d,nbiter):
253 anObj = geom.MakeFilling(aShape,mindeg,maxdeg,tol3d,tol2d,nbiter)
254 ior = salome.orb.object_to_string(anObj)
258 def MakePipe(pathShape,baseShape):
259 anObj = geom.MakePipe(pathShape,baseShape)
260 ior = salome.orb.object_to_string(anObj)
264 def MakeSewing(ListShape,precision):
265 anObj = geom.MakeSewing(ListShape,precision)
266 ior = salome.orb.object_to_string(anObj)
270 # -----------------------------------------------------------------------------
271 # Boolean (Common, Cut, Fuse, Section)
272 # -----------------------------------------------------------------------------
274 def MakeBoolean(shape1,shape2,operation):
275 anObj = geom.MakeBoolean(shape1,shape2,operation)
276 ior = salome.orb.object_to_string(anObj)
280 # -----------------------------------------------------------------------------
282 # -----------------------------------------------------------------------------
284 def MakeTranslation(aShape,x,y,z):
285 anObj = geom.MakeTranslation(aShape,x,y,z)
286 ior = salome.orb.object_to_string(anObj)
290 def MakeRotation(aShape,axis,angle):
291 anObj = geom.MakeRotation(aShape,axis,angle)
292 ior = salome.orb.object_to_string(anObj)
296 def MakeScaleTransform(aShape,theCenterofScale,factor):
297 anObj = geom.MakeScaleTransform(aShape,theCenterofScale,factor)
298 ior = salome.orb.object_to_string(anObj)
302 def MakeMirrorByPlane(aShape,aPlane):
303 anObj = geom.MakeMirrorByPlane(aShape,aPlane)
304 ior = salome.orb.object_to_string(anObj)
308 def OrientationChange(aShape):
309 anObj = geom.OrientationChange(aShape)
310 ior = salome.orb.object_to_string(anObj)
314 def MakeFillet(aShape,radius,ShapeType,ListShape):
315 anObj = geom.MakeFillet(aShape,radius,ShapeType,ListShape)
316 ior = salome.orb.object_to_string(anObj)
320 def MakeChamfer(aShape,d1,d2,ShapeType,ListShape):
321 anObj = geom.MakeChamfer(aShape,d1,d2,ShapeType,ListShape)
322 ior = salome.orb.object_to_string(anObj)
326 # -----------------------------------------------------------------------------
328 # -----------------------------------------------------------------------------
330 def SubShape(aShape,type,ListOfId):
331 anObj = geom.SubShape(aShape,type, ListOfId)
332 ior = salome.orb.object_to_string(anObj)
336 def SubShapeAll(aShape,type):
337 ListObj = geom.SubShapeAll(aShape,type)
338 for anObj in ListObj :
339 ior = salome.orb.object_to_string(anObj)
343 def SubShapeSorted(aShape,type,ListOfId):
344 anObj = geom.SubShapeSorted(aShape,type, ListOfId)
345 ior = salome.orb.object_to_string(anObj)
349 def SubShapeAllSorted(aShape,type):
350 ListObj = geom.SubShapeAllSorted(aShape,type)
351 for anObj in ListObj :
352 ior = salome.orb.object_to_string(anObj)
356 # -- enumeration ShapeType as a dictionary --
357 ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
359 def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[], Limit=ShapeType["SHAPE"]):
360 anObj = geom.Partition(ListShapes, ListTools, ListKeepInside, ListRemoveInside, Limit);
361 ior = salome.orb.object_to_string(anObj)
365 def SuppressFaces(aShape,ListOfId):
366 anObj = geom.SuppressFaces(aShape,ListOfId)
367 ior = salome.orb.object_to_string(anObj)
371 def SuppressHole(aShape,ListOfFace,ListOfWire,ListOfEndFace):
372 anObj = geom.SuppressHole(aShape,ListOfFace,ListOfWire,ListOfEndFace)
373 ior = salome.orb.object_to_string(anObj)
377 # -----------------------------------------------------------------------------
379 # -----------------------------------------------------------------------------
381 def MakeMultiTranslation1D(aShape,aDir,aStep,aNbTimes):
382 anObj = geom.MakeMultiTranslation1D(aShape,aDir,aStep,aNbTimes)
383 ior = salome.orb.object_to_string(anObj)
387 def MakeMultiTranslation2D(aShape,d1,step1,nbtimes1,d2,step2,nbtimes2):
388 anObj = geom.MakeMultiTranslation2D(aShape,d1,step1,nbtimes1,d2,step2,nbtimes2)
389 ior = salome.orb.object_to_string(anObj)
393 def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes):
394 anObj = geom.MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes)
395 ior = salome.orb.object_to_string(anObj)
399 def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2):
400 anObj = geom.MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2)
401 ior = salome.orb.object_to_string(anObj)
405 # -----------------------------------------------------------------------------
407 # -----------------------------------------------------------------------------
409 def ImportBREP(filename):
410 anObj = geom.ImportBREP(filename)
411 ior = salome.orb.object_to_string(anObj)
415 def ImportIGES(filename):
416 anObj = geom.ImportIGES(filename)
417 ior = salome.orb.object_to_string(anObj)
421 def ImportSTEP(filename):
422 anObj = geom.ImportSTEP(filename)
423 ior = salome.orb.object_to_string(anObj)
427 # -----------------------------------------------------------------------------
429 # -----------------------------------------------------------------------------
430 def ExportBREP(filename,aShape):
431 geom.ExportBREP(filename,aShape)
433 def ExportIGES(filename,aShape):
434 geom.ExportIGES(filename,aShape)
436 def ExportSTEP(filename,aShape):
437 geom.ExportSTEP(filename,aShape)
439 # -----------------------------------------------------------------------------
440 # Information objects
441 # -----------------------------------------------------------------------------
444 anObj = geom.MakeCDG(aShape)
445 ior = salome.orb.object_to_string(anObj)
449 def Archimede(aShape,weight,WaterDensity,MeshingDeflection):
450 anObj = geom.Archimede(aShape,weight,WaterDensity,MeshingDeflection)
451 ior = salome.orb.object_to_string(anObj)
455 def CheckShape(aShape):
456 Status = geom.CheckShape(aShape)