Ejemplo n.º 1
0
def run_FreeCAD_Parallelprojection(self,*args, **kwargs):

    f=store.store().get(self.getPinByName('face').getData())
    say("Face",f)
    e=store.store().get(self.getPinByName('edge').getData())
    say("Edge",e)
    if f== None or e == None:
        sayW("no face or no edge connected")
        return

    store.store().list()
    d=self.getPinByName('direction').getData()
    say("direction",d)
    shape=f.makeParallelProjection(e,d)
    self.setPinObject('Shape_out',shape)
Ejemplo n.º 2
0
 def getTransformation(self):
     #say("getTransformation method")
     arrin = self.getData()
     #say("got key:",arrin)
     if arrin != None:
         s = store.store().get(arrin)
         return s
     else:
         return None
Ejemplo n.º 3
0
 def getArray(self):
     #say("getArray method")
     arrin = self.getData()
     #say("got key:",arrin)
     if arrin != None:
         s = store.store().get(arrin)
         return s
     else:
         return None
Ejemplo n.º 4
0
def run_FreeCAD_Perspectiveprojection(self, *args, **kwargs):

    f = store.store().get(self.getPinByName('face').getData())
    say("Face", f)
    e = store.store().get(self.getPinByName('edge').getData())
    say("Edge", e)
    if f == None or e == None:
        sayW("no face or no edge connected")
        return

    store.store().list()
    d = self.getPinByName('direction').getData()
    say("direction", d)
    shape = f.makePerspectiveProjection(e, d)
    cc = self.getObject()
    if cc != None:
        cc.Label = self.objname.getData()
        cc.Shape = shape
        #cc.ViewObject.LineWidth=8
        cc.ViewObject.LineColor = (1., 1., 0.)
Ejemplo n.º 5
0
def run_FreeCAD_Reduce(self):

    flags = self.getData("selection")
    eids = self.getData("shapes")
    say(self.name)
    if eids is None:
        return
    shapes = [store.store().get(eid) for eid in eids]
    reduced = []
    for f, s in zip(shapes, flags):
        if s:
            reduced += [f]
    try:
        rc = Part.Compound(reduced)
    except:
        rc = Part.Shape()
    say("!!rc=", rc)
    self.setPinObject("Shape_out", rc)
    self.setColor(b=0, a=0.4)
Ejemplo n.º 6
0
def run_FreeCAD_Solid(self, bake=False, **kwargs):

    #shapes=self.getData("Shapes")
    #say(shapes)
    #return

    yPins = self.getPinByName("Shapes").affected_by

    outArray = []
    for pin in yPins:
        k = str(pin.uid)
        d = store.store().get(k)
        #       say(d)
        outArray.append(d)
    say(outArray)

    shapes = outArray
    say(shapes)

    colf = shapes

    for tol in range(1000):
        colf2 = [c.copy() for c in colf]
        try:
            #say ("try tolerance",tol)
            for f in colf2:
                f.Tolerance = tol
            sh = Part.Shell(colf2)

            sol = Part.Solid(sh)
            say(sol.isValid())
            if sol.isValid():
                say("solid created with tol", tol)
                if bake:
                    Part.show(sol)
                #cc=self.getObject();cc.Shape=sol

                self.setPinObject("Shape_out", sol)
                break
        except:
            pass
Ejemplo n.º 7
0
 def setTransformation(self, Transformation):
     store.store().add(str(self.uid), Transformation)
     self.setData(str(self.uid))
Ejemplo n.º 8
0
 def setArray(self, array):
     store.store().add(str(self.uid), array)
     self.setData(str(self.uid))
Ejemplo n.º 9
0
def run_FreeCAD_UVprojection(self,*args, **kwargs):

    f=store.store().get(self.getPinByName('face').getData())
    w=store.store().get(self.getPinByName('edge').getData())
    closed=True
    #closed=False

    if f==None:
        sayW("no face connected")
        return

    sf=f.Surface

    pointcount=max(self.getPinByName('pointCount').getData(),4)
    pts=w.discretize(pointcount)


    bs2d = Part.Geom2d.BSplineCurve2d()
    if closed:
        pts2da=[sf.parameter(p) for p in pts[1:]]
    else:
        pts2da=[sf.parameter(p) for p in pts]

    pts2d=[FreeCAD.Base.Vector2d(p[0],p[1]) for p in pts2da]
    pts2d=[FreeCAD.Base.Vector2d(p[0],p[1]) for p in pts2da[:-1]]
    if closed:
        bs2d.buildFromPolesMultsKnots(pts2d,[1]*(len(pts2d)+1),range(len(pts2d)+1),True,1)
    else:
        mults=[2]+[1]*(len(pts2d)-2)+[2]
        knots=range(len(mults))
        bs2d.buildFromPolesMultsKnots(pts2d,mults,knots,False,1)
        
    e1 = bs2d.toShape(sf)

    sp=FreeCAD.ActiveDocument.getObject("_Spline")
    if sp==None:
        sp=FreeCAD.ActiveDocument.addObject("Part::Spline","_Spline")
    sp.Shape=e1

    face=f
    edges=e1.Edges
    ee=edges[0]
    splita=[(ee,face)]
    r=Part.makeSplitShape(face, splita)

    ee.reverse()
    splitb=[(ee,face)]
    r2=Part.makeSplitShape(face, splitb)

    try:
        rc=r2[0][0]
        rc=r[0][0]
    except: return

    '''
    cc=self.getObject()
    if cc  !=  None:
        cc.Label=self.objname.getData()

    if self.getPinByName('inverse').getData():
        cc.Shape=r2[0][0]
    else:
        cc.Shape=r[0][0]
    '''
    if self.getData('inverse'):
        self.setPinObject("Shape_out",r2[0][0])
    else:
        self.setPinObject("Shape_out",r[0][0])
    return
    
    if self.getPinByName('Extrusion').getData():
        f = FreeCAD.getDocument('project').getObject('MyExtrude')
        if f == None:
            f = FreeCAD.getDocument('project').addObject('Part::Extrusion', 'MyExtrude')

        f.Base = sp
        f.DirMode = "Custom"
        f.Dir = FreeCAD.Vector(0.000000000000000, 0.000000000000000, 1.000000000000000)
        f.LengthFwd = self.getPinByName('ExtrusionUp').getData()
        f.LengthRev = self.getPinByName('ExtrusionDown').getData()
        f.Solid = True
        FreeCAD.activeDocument().recompute()