def Activated(self): from GDMLObjects import GDMLElTube, ViewProvider a=FreeCAD.ActiveDocument.addObject("Part::FeaturePython", \ "GDMLElTube") print("GDMLElTube Object - added") # obj,dx, dy, dz, lunit, material GDMLElTube(a,10,20,30,"mm",0) print("GDMLElTube initiated") ViewProvider(a.ViewObject) print("GDMLElTube ViewProvided - added") FreeCAD.ActiveDocument.recompute() FreeCADGui.SendMsgToActiveView("ViewFit")
def createEltube(part,solid,material,px,py,pz,rot,displayMode) : from GDMLObjects import GDMLElTube, ViewProvider GDMLShared.trace("CreateElTube : ") GDMLShared.trace(solid.attrib) dx = GDMLShared.getVal(solid,'dx') dy = GDMLShared.getVal(solid,'dy') dz = GDMLShared.getVal(solid,'dz') lunit = getText(solid,'lunit',"mm") #myeltube=volObj.newObject("Part::FeaturePython","GDMLElTube:"+getName(solid)) myeltube=part.newObject("Part::FeaturePython","GDMLElTube:"+getName(solid)) GDMLElTube(myeltube,dx, dy, dz,lunit,material) GDMLShared.trace("CreateElTube : ") GDMLShared.trace("Position : "+str(px)+','+str(py)+','+str(pz)) base = FreeCAD.Vector(0,0,0) myeltube.Placement = GDMLShared.processPlacement(base,rot) GDMLShared.trace(myeltube.Placement.Rotation) # set ViewProvider before setDisplay ViewProvider(myeltube.ViewObject) setDisplayMode(myeltube,displayMode) return myeltube