Example #1
0
    def execute(self, obj):
        if 'tGlue' in self.Type:
            z = getPCBheight()[1] + 0.04
            h = obj.Height.Value

            if h <= 0:
                h = 0.01
        else:  # bottomSide
            z = -0.04
            h = -obj.Height.Value

            if h >= 0:
                h = -0.01
        #
        obiekty = []
        #
        for i in obj.Base.Geometry:
            if i.__class__.__name__ == 'GeomLineSegment':
                x1 = i.StartPoint.x
                y1 = i.StartPoint.y
                x2 = i.EndPoint.x
                y2 = i.EndPoint.y
                #
                obiekty.append(self.createLine(x1, y1, x2, y2,
                                               obj.Width.Value))
            elif i.__class__.__name__ == 'GeomCircle':
                x = i.Center.x
                y = i.Center.y
                r = i.Radius
                #
                obiekty.append(self.createCircle(x, y, r, obj.Width.Value))
            elif i.__class__.__name__ == 'GeomArcOfCircle':
                curve = degrees(i.LastParameter - i.FirstParameter)
                xs = i.Center.x
                ys = i.Center.y
                r = i.Radius

                math = mathFunctions()
                p1 = [
                    math.cosinus(degrees(i.FirstParameter)) * r,
                    math.sinus(degrees(i.FirstParameter)) * r
                ]
                p1 = [p1[0] + xs, p1[1] + ys]
                p2 = math.obrocPunkt2(p1, [xs, ys], curve)
                #
                obiekty.append(self.createArc(p1, p2, curve, obj.Width.Value))
        #
        #path = obiekty[0]
        #for i in range(1, len(obiekty)):
        #path = path.fuse(obiekty[i])
        #path = path.removeSplitter()
        path = Part.makeCompound(obiekty)
        # cut to board shape
        if self.cutToBoard:
            path = cutToBoardShape(path)
        ###################################################
        if obj.Flat == False:
            path = path.extrude(FreeCAD.Base.Vector(0, 0, h))
        path.Placement.Base.z = z
        obj.Shape = path
Example #2
0
 def execute(self, obj):
     if 'tGlue' in self.Type:
         z = getPCBheight()[1] + 0.04
         h = obj.Height.Value
         
         if h <= 0:
             h = 0.01
     else:  # bottomSide
         z = -0.04
         h = -obj.Height.Value
         
         if h >= 0:
             h = -0.01
     #
     obiekty = []
     #
     for i in obj.Base.Geometry:
         if i.__class__.__name__ == 'GeomLineSegment':
             x1 = i.StartPoint.x
             y1 = i.StartPoint.y
             x2 = i.EndPoint.x
             y2 = i.EndPoint.y
             #
             obiekty.append(self.createLine(x1, y1, x2, y2, obj.Width.Value))
         elif i.__class__.__name__ == 'GeomCircle':
             x = i.Center.x
             y = i.Center.y
             r = i.Radius
             #
             obiekty.append(self.createCircle(x, y, r, obj.Width.Value))
         elif i.__class__.__name__ == 'GeomArcOfCircle':
             curve = degrees(i.LastParameter - i.FirstParameter)
             xs = i.Center.x
             ys = i.Center.y
             r = i.Radius
             
             math = mathFunctions()
             p1 = [math.cosinus(degrees(i.FirstParameter)) * r, math.sinus(degrees(i.FirstParameter)) * r]
             p1 = [p1[0] + xs, p1[1] + ys]
             p2 = math.obrocPunkt2(p1, [xs, ys], curve)
             #
             obiekty.append(self.createArc(p1, p2, curve, obj.Width.Value))
     #
     #path = obiekty[0]
     #for i in range(1, len(obiekty)):
         #path = path.fuse(obiekty[i])
     #path = path.removeSplitter()
     path = Part.makeCompound(obiekty)
     # cut to board shape
     if self.cutToBoard:
         path = cutToBoardShape(path)
     ###################################################
     if obj.Flat == False:
         path = path.extrude(FreeCAD.Base.Vector(0, 0, h))
     path.Placement.Base.z = z
     obj.Shape = path
Example #3
0
 def generateConstraintAreas(self, areas, doc, layerNumber, grp, layerName, layerColor, layerTransparent):
     typeL = PCBconf.PCBconstraintAreas[PCBconf.softLayers[self.databaseType][layerNumber][1]][1]
     mainGroup = doc.addObject("App::DocumentObjectGroup", layerName)
     grp.addObject(mainGroup)
     
     for i in areas:
         ser = doc.addObject('Sketcher::SketchObject', "Sketch_{0}".format(layerName))
         ser.ViewObject.Visibility = False
         #
         if i[0] == 'rect':
             try:
                 height = i[5]
             except:
                 height = 0
             
             x1 = i[1]
             y1 = i[2]
             
             x2 = i[3]
             y2 = i[2]
             
             x3 = i[3]
             y3 = i[4]
             
             x4 = i[1]
             y4 = i[4]
             
             try:
                 if i[6] != 0:
                     xs = (i[1] + i[3]) / 2.
                     ys = (i[2] + i[4]) / 2.
             
                     mat = mathFunctions()
                     (x1, y1) = mat.obrocPunkt2([x1, y1], [xs, ys], i[6])
                     (x2, y2) = mat.obrocPunkt2([x2, y2], [xs, ys], i[6])
                     (x3, y3) = mat.obrocPunkt2([x3, y3], [xs, ys], i[6])
                     (x4, y4) = mat.obrocPunkt2([x4, y4], [xs, ys], i[6])
             except:
                 pass
             
             ser.addGeometry(Part.Line(FreeCAD.Vector(x1, y1, 0), FreeCAD.Vector(x2, y2, 0)))
             ser.addGeometry(Part.Line(FreeCAD.Vector(x2, y2, 0), FreeCAD.Vector(x3, y3, 0)))
             ser.addGeometry(Part.Line(FreeCAD.Vector(x3, y3, 0), FreeCAD.Vector(x4, y4, 0)))
             ser.addGeometry(Part.Line(FreeCAD.Vector(x4, y4, 0), FreeCAD.Vector(x1, y1, 0)))
         elif i[0] == 'circle':
             try:
                 height = i[5]
             except:
                 height = 0
             
             if i[4] == 0:
                 ser.addGeometry(Part.Circle(FreeCAD.Vector(i[1], i[2]), FreeCAD.Vector(0, 0, 1), i[3]))
             else:
                 ser.addGeometry(Part.Circle(FreeCAD.Vector(i[1], i[2]), FreeCAD.Vector(0, 0, 1), i[3] + i[4] / 2))
                 ser.addGeometry(Part.Circle(FreeCAD.Vector(i[1], i[2]), FreeCAD.Vector(0, 0, 1), i[3] - i[4] / 2))
         elif i[0] == 'polygon':
             try:
                 height = i[2]
             except:
                 height = 0
             
             for j in i[1]:
                 if j[0] == 'Line':
                     ser.addGeometry(Part.Line(FreeCAD.Vector(j[1], j[2], 0), FreeCAD.Vector(j[3], j[4], 0)))
                 elif j[0] == 'Arc':
                     x1 = j[1]
                     y1 = j[2]
                     x2 = j[3]
                     y2 = j[4]
                     [x3, y3] = self.arcMidPoint([x2, y2], [x1, y1], j[5])
                     
                     arc = Part.Arc(FreeCAD.Vector(x1, y1, 0.0), FreeCAD.Vector(x3, y3, 0.0), FreeCAD.Vector(x2, y2, 0.0))
                     ser.addGeometry(self.Draft2Sketch(arc, ser))
         #
         a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", layerName + "_{0}".format(0))
         layerObj = constraintAreaObject(a, typeL)
         a.Base = ser
         if height != 0:
             a.Height = height
         viewProviderConstraintAreaObject(a.ViewObject)
         mainGroup.addObject(a)
         FreeCADGui.activeDocument().getObject(a.Name).ShapeColor = layerColor
         FreeCADGui.activeDocument().getObject(a.Name).Transparency = layerTransparent
         FreeCADGui.activeDocument().getObject(a.Name).DisplayMode = 1
         self.updateView()
Example #4
0
    def generateConstraintAreas(self, areas, doc, layerNumber, grp, layerName,
                                layerColor, layerTransparent):
        typeL = PCBconf.PCBconstraintAreas[PCBconf.softLayers[
            self.databaseType][layerNumber][1]][1]
        mainGroup = doc.addObject("App::DocumentObjectGroup", layerName)
        grp.addObject(mainGroup)

        for i in areas:
            ser = doc.addObject('Sketcher::SketchObject',
                                "Sketch_{0}".format(layerName))
            ser.ViewObject.Visibility = False
            #
            if i[0] == 'rect':
                try:
                    height = i[5]
                except:
                    height = 0

                x1 = i[1]
                y1 = i[2]

                x2 = i[3]
                y2 = i[2]

                x3 = i[3]
                y3 = i[4]

                x4 = i[1]
                y4 = i[4]

                try:
                    if i[6] != 0:
                        xs = (i[1] + i[3]) / 2.
                        ys = (i[2] + i[4]) / 2.

                        mat = mathFunctions()
                        (x1, y1) = mat.obrocPunkt2([x1, y1], [xs, ys], i[6])
                        (x2, y2) = mat.obrocPunkt2([x2, y2], [xs, ys], i[6])
                        (x3, y3) = mat.obrocPunkt2([x3, y3], [xs, ys], i[6])
                        (x4, y4) = mat.obrocPunkt2([x4, y4], [xs, ys], i[6])
                except:
                    pass

                ser.addGeometry(
                    Part.Line(FreeCAD.Vector(x1, y1, 0),
                              FreeCAD.Vector(x2, y2, 0)))
                ser.addGeometry(
                    Part.Line(FreeCAD.Vector(x2, y2, 0),
                              FreeCAD.Vector(x3, y3, 0)))
                ser.addGeometry(
                    Part.Line(FreeCAD.Vector(x3, y3, 0),
                              FreeCAD.Vector(x4, y4, 0)))
                ser.addGeometry(
                    Part.Line(FreeCAD.Vector(x4, y4, 0),
                              FreeCAD.Vector(x1, y1, 0)))
            elif i[0] == 'circle':
                try:
                    height = i[5]
                except:
                    height = 0

                if i[4] == 0:
                    ser.addGeometry(
                        Part.Circle(FreeCAD.Vector(i[1], i[2]),
                                    FreeCAD.Vector(0, 0, 1), i[3]))
                else:
                    ser.addGeometry(
                        Part.Circle(FreeCAD.Vector(i[1], i[2]),
                                    FreeCAD.Vector(0, 0, 1), i[3] + i[4] / 2))
                    ser.addGeometry(
                        Part.Circle(FreeCAD.Vector(i[1], i[2]),
                                    FreeCAD.Vector(0, 0, 1), i[3] - i[4] / 2))
            elif i[0] == 'polygon':
                try:
                    height = i[2]
                except:
                    height = 0

                for j in i[1]:
                    if j[0] == 'Line':
                        ser.addGeometry(
                            Part.Line(FreeCAD.Vector(j[1], j[2], 0),
                                      FreeCAD.Vector(j[3], j[4], 0)))
                    elif j[0] == 'Arc':
                        x1 = j[1]
                        y1 = j[2]
                        x2 = j[3]
                        y2 = j[4]
                        [x3, y3] = self.arcMidPoint([x2, y2], [x1, y1], j[5])

                        arc = Part.Arc(FreeCAD.Vector(x1, y1, 0.0),
                                       FreeCAD.Vector(x3, y3, 0.0),
                                       FreeCAD.Vector(x2, y2, 0.0))
                        ser.addGeometry(self.Draft2Sketch(arc, ser))
            #
            a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",
                                                 layerName + "_{0}".format(0))
            layerObj = constraintAreaObject(a, typeL)
            a.Base = ser
            if height != 0:
                a.Height = height
            viewProviderConstraintAreaObject(a.ViewObject)
            mainGroup.addObject(a)
            FreeCADGui.activeDocument().getObject(
                a.Name).ShapeColor = layerColor
            FreeCADGui.activeDocument().getObject(
                a.Name).Transparency = layerTransparent
            FreeCADGui.activeDocument().getObject(a.Name).DisplayMode = 1
            self.updateView()
Example #5
0
    def generateConstraintAreas(self, doc, layerNumber, grp, layerName,
                                layerColor, layerTransparent):
        typeL = PCBconf.softLayers[self.databaseType][layerNumber]['ltype']

        for i in self.wersjaFormatu.getConstraintAreas(layerNumber):
            ser = doc.addObject('Sketcher::SketchObject',
                                "Sketch_{0}".format(layerName))
            ser.ViewObject.Visibility = False
            #
            if i[0] == 'rect':
                try:
                    height = i[5]
                except:
                    height = 0

                x1 = i[1]
                y1 = i[2]

                x2 = i[3]
                y2 = i[2]

                x3 = i[3]
                y3 = i[4]

                x4 = i[1]
                y4 = i[4]

                try:
                    if i[6] != 0:
                        xs = (i[1] + i[3]) / 2.
                        ys = (i[2] + i[4]) / 2.

                        mat = mathFunctions()
                        (x1, y1) = mat.obrocPunkt2([x1, y1], [xs, ys], i[6])
                        (x2, y2) = mat.obrocPunkt2([x2, y2], [xs, ys], i[6])
                        (x3, y3) = mat.obrocPunkt2([x3, y3], [xs, ys], i[6])
                        (x4, y4) = mat.obrocPunkt2([x4, y4], [xs, ys], i[6])
                except:
                    pass

                ser.addGeometry(
                    Part.LineSegment(FreeCAD.Vector(x1, y1, 0),
                                     FreeCAD.Vector(x2, y2, 0)))
                ser.addGeometry(
                    Part.LineSegment(FreeCAD.Vector(x2, y2, 0),
                                     FreeCAD.Vector(x3, y3, 0)))
                ser.addGeometry(
                    Part.LineSegment(FreeCAD.Vector(x3, y3, 0),
                                     FreeCAD.Vector(x4, y4, 0)))
                ser.addGeometry(
                    Part.LineSegment(FreeCAD.Vector(x4, y4, 0),
                                     FreeCAD.Vector(x1, y1, 0)))
            elif i[0] == 'circle':
                try:
                    try:
                        height = i[5]
                    except:
                        height = 0

                    if i[4] == 0:
                        ser.addGeometry(
                            Part.Circle(FreeCAD.Vector(i[1], i[2], 0),
                                        FreeCAD.Vector(0, 0, 1), i[3]), False)
                    else:
                        ser.addGeometry(
                            Part.Circle(FreeCAD.Vector(i[1], i[2], 0),
                                        FreeCAD.Vector(0, 0, 1),
                                        i[3] + i[4] / 2))
                        ser.addGeometry(
                            Part.Circle(FreeCAD.Vector(i[1], i[2], 0),
                                        FreeCAD.Vector(0, 0, 1),
                                        i[3] - i[4] / 2))
                except Exception as e:
                    FreeCAD.Console.PrintWarning("3. {0}\n".format(e))
            elif i[0] == 'polygon':
                try:
                    height = i[2]
                except:
                    height = 0

                for j in i[1]:
                    if j[0] == 'Line':
                        ser.addGeometry(
                            Part.LineSegment(FreeCAD.Vector(j[1], j[2], 0),
                                             FreeCAD.Vector(j[3], j[4], 0)))
                    elif j[0] == 'Arc3P':
                        x1 = j[1]
                        y1 = j[2]
                        x2 = j[3]
                        y2 = j[4]
                        [x3, y3] = self.arcMidPoint([x2, y2], [x1, y1], j[5])

                        arc = Part.ArcOfCircle(FreeCAD.Vector(x1, y1, 0.0),
                                               FreeCAD.Vector(x3, y3, 0.0),
                                               FreeCAD.Vector(x2, y2, 0.0))
                        ser.addGeometry(arc)
            #
            #FreeCAD.ActiveDocument.recompute()
            ser.recompute()
            createConstraintArea(ser, typeL, height)
            self.updateView()