コード例 #1
0
def createTrap(part,solid,material,px,py,pz,rot,displayMode) :
    from GDMLObjects import GDMLTrap, ViewProvider
    GDMLShared.trace("CreateTrap : ")
    GDMLShared.trace(solid.attrib)
    z  = GDMLShared.getVal(solid,'z')
    x1 = GDMLShared.getVal(solid,'x1')
    x2 = GDMLShared.getVal(solid,'x2')
    x3 = GDMLShared.getVal(solid,'x3')
    x4 = GDMLShared.getVal(solid,'x4')
    y1 = GDMLShared.getVal(solid,'y1')
    y2 = GDMLShared.getVal(solid,'y2')
    theta = GDMLShared.getVal(solid,'theta')
    phi = GDMLShared.getVal(solid,'phi')
    alpha = GDMLShared.getVal(solid,'alpah1')
    aunit = getText(solid,'aunit','rad')
    lunit = getText(solid,'lunit',"mm")
    #print z
    #mytrap=volObj.newObject("Part::FeaturePython","GDMLTrap:"+getName(solid))
    mytrap=part.newObject("Part::FeaturePython","GDMLTrap:"+getName(solid))
    GDMLTrap(mytrap,z,theta,phi,x1,x2,x3,x4,y1,y2,alpha,aunit,lunit,material)
    GDMLShared.trace("Position : "+str(px)+','+str(py)+','+str(pz))
    base = FreeCAD.Vector(0,0,0)
    mytrap.Placement = GDMLShared.processPlacement(base,rot)
    GDMLShared.trace(mytrap.Placement.Rotation)
    # set ViewProvider before setDisplay
    ViewProvider(mytrap.ViewObject)
    setDisplayMode(mytrap,displayMode)
    return mytrap
コード例 #2
0
 def Activated(self):
     from GDMLObjects import GDMLTrap, ViewProvider
     a=FreeCAD.ActiveDocument.addObject("Part::FeaturePython","GDMLTrap")
     print("GDMLTrap Object - added")
     # obj z, theta, phi, x1, x2, x3, x4, y1, y2,
     # pAlp2, aunits, lunits, material
     GDMLTrap(a,10.0,0.0,0.0,6.0,6.0,6.0,6.0,7.0,7.0,0.0,"rad","mm",0)
     print("GDMLTrap initiated")
     ViewProvider(a.ViewObject)
     print("GDMLTrap ViewProvided - added")
     FreeCAD.ActiveDocument.recompute()
     FreeCADGui.SendMsgToActiveView("ViewFit")