def createPolycone(part,solid,material,px,py,pz,rot,displayMode) :
    from GDMLObjects import GDMLPolycone, GDMLzplane, \
            ViewProvider, ViewProviderExtension
    GDMLShared.trace("Create Polycone : ")
    GDMLShared.trace(solid.attrib)
    startphi = GDMLShared.getVal(solid,'startphi')
    deltaphi = GDMLShared.getVal(solid,'deltaphi')
    aunit = getText(solid,'aunit','rad')
    lunit = getText(solid,'lunit',"mm")
    #mypolycone=volObj.newObject("Part::FeaturePython","GDMLPolycone:"+getName(solid))
    mypolycone=part.newObject("Part::FeaturePython","GDMLPolycone:"+getName(solid))
    mypolycone.addExtension("App::OriginGroupExtensionPython", None)
    GDMLPolycone(mypolycone,startphi,deltaphi,aunit,lunit,material)
    ViewProviderExtension(mypolycone.ViewObject)

    #mypolycone.ViewObject.DisplayMode = "Shaded"
    GDMLShared.trace(solid.findall('zplane'))
    for zplane in solid.findall('zplane') : 
        GDMLShared.trace(zplane)
        rmin = GDMLShared.getVal(zplane,'rmin')
        rmax = GDMLShared.getVal(zplane,'rmax')
        z = GDMLShared.getVal(zplane,'z')
        myzplane=FreeCAD.ActiveDocument.addObject('App::FeaturePython','zplane') 
        mypolycone.addObject(myzplane)
        #myzplane=mypolycone.newObject('App::FeaturePython','zplane') 
        GDMLzplane(myzplane,rmin,rmax,z)
        ViewProvider(myzplane)

    GDMLShared.trace("Position : "+str(px)+','+str(py)+','+str(pz))
    base = FreeCAD.Vector(0,0,0)
    mypolycone.Placement = GDMLShared.processPlacement(base,rot)
    GDMLShared.trace(mypolycone.Placement.Rotation)
    # set ViewProvider before setDisplay
    setDisplayMode(mypolycone,displayMode)
    return mypolycone
Beispiel #2
0
def createXtru(part, solid, material, px, py, pz, rot, displayMode):
    from GDMLObjects import GDMLXtru, GDML2dVertex, GDMLSection, \
             ViewProvider, ViewProviderExtension
    GDMLShared.trace("CreateXtru : ")
    #print(solid)
    #print(getName(solid))
    myXtru = part.newObject("Part::FeaturePython",
                            "GDMLXtru-" + getName(solid))
    #myXtru.addExtension("App::OriginGroupExtensionPython", None)
    lunit = getText(solid, 'lunit', "mm")
    GDMLXtru(myXtru, lunit, material)
    ViewProviderExtension(myXtru.ViewObject)
    for vert2d in solid.findall('twoDimVertex'):
        x = GDMLShared.getVal(vert2d, 'x')
        y = GDMLShared.getVal(vert2d, 'y')
        my2dVert = FreeCAD.ActiveDocument.addObject('App::FeaturePython',
                                                    'GDML2DVertex')
        #myzplane=mypolycone.newObject('App::FeaturePython','zplane')
        GDML2dVertex(my2dVert, x, y)
        myXtru.addObject(my2dVert)
        ViewProvider(my2dVert)
    for section in solid.findall('section'):
        zOrder = GDMLShared.getVal(section, 'zOrder', 2)  # Get Int
        zPosition = GDMLShared.getVal(section, 'zPosition', 2)  # Get Int
        xOffset = GDMLShared.getVal(section, 'xOffset')
        yOffset = GDMLShared.getVal(section, 'yOffset')
        scalingFactor = GDMLShared.getVal(section, 'scalingFactor')
        mysection = FreeCAD.ActiveDocument.addObject('App::FeaturePython',
                                                     'GDMLSection')
        GDMLSection(mysection, zOrder, zPosition, xOffset, yOffset,
                    scalingFactor)
        myXtru.addObject(mysection)
        ViewProvider(mysection)

    GDMLShared.trace("Position : " + str(px) + ',' + str(py) + ',' + str(pz))
    base = FreeCAD.Vector(0, 0, 0)
    #base = FreeCAD.Vector(px,py,pz)
    myXtru.Placement = GDMLShared.processPlacement(base, rot)
    GDMLShared.trace(myXtru.Placement.Rotation)
    # Shape is still Null at this point
    #print("Xtru Shape : ")
    #print("Is Null : "+str(myXtru.Shape.isNull()))
    return (myXtru)
Beispiel #3
0
def createTessellated(part, solid, material, px, py, pz, rot, displayMode):
    from GDMLObjects import GDMLTessellated, GDMLTriangular, \
            GDMLQuadrangular,  ViewProvider, ViewProviderExtension
    GDMLShared.trace("CreateTessellated : ")
    GDMLShared.trace(solid.attrib)
    myTess = part.newObject("Part::FeaturePython",
                            "GDMLTessellated:" + getName(solid))
    #myTess.addExtension("App::OriginGroupExtensionPython", None)
    GDMLTessellated(myTess, material)
    ViewProviderExtension(myTess.ViewObject)
    ViewProvider(myTess.ViewObject)
    for elem in solid.getchildren():
        print(elem)
        v1 = elem.attrib['vertex1']
        v2 = elem.attrib['vertex2']
        v3 = elem.attrib['vertex3']
        vType = elem.attrib['type']
        if elem.tag == 'triangular':
            myTri = FreeCAD.ActiveDocument.addObject('App::FeaturePython',
                                                     'GDMLTriangle')
            GDMLTriangular(myTri, v1, v2, v3, vType)
            myTess.addObject(myTri)
            ViewProvider(myTri)

        if elem.tag == 'quadrangular':
            v4 = elem.attrib['vertex4']
            myQuad = FreeCAD.ActiveDocument.addObject('App::FeaturePython',
                                                      'GDMLQuadrangular')
            GDMLQuadrangular(myQuad, v1, v2, v3, v4, vType)
            myTess.addObject(myQuad)
            ViewProvider(myQuad)

    GDMLShared.trace("Position : " + str(px) + ',' + str(py) + ',' + str(pz))
    #base = FreeCAD.Vector(px,py,pz)
    base = FreeCAD.Vector(0, 0, 0)
    myTess.Placement = GDMLShared.processPlacement(base, rot)
    GDMLShared.trace(myTess.Placement.Rotation)
    # set ViewProvider before setDisplay
    ViewProvider(myTess.ViewObject)
    setDisplayMode(myTess, displayMode)
    return myTess