Пример #1
0
    def _buildPathOCC(self, obj, wire):
        import DraftGeomUtils
        output = ""
        if obj.Comment != "":
            output += '(' + str(obj.Comment) + ')\n'

        if obj.Direction == 'CCW':
            clockwise = False
        else:
            clockwise = True

        FirstEdge = None
        PathClosed = DraftGeomUtils.isReallyClosed(wire)

        output += PathUtils.MakePath(wire,
                                     obj.Side,
                                     self.radius,
                                     clockwise,
                                     obj.ClearanceHeight.Value,
                                     obj.StepDown,
                                     obj.StartDepth.Value,
                                     obj.FinalDepth.Value,
                                     FirstEdge,
                                     PathClosed,
                                     obj.SegLen.Value,
                                     self.vertFeed,
                                     self.horizFeed,
                                     self.vertRapid,
                                     self.horizRapid,
                                     PlungeAngle=obj.PlungeAngle.Value)

        return output
Пример #2
0
    def execute(self, obj):
        if obj.Base:

            # tie the toolnumber to the PathLoadTool object ToolNumber
            if len(obj.InList
                   ) > 0:  #check to see if obj is in the Project group yet
                project = obj.InList[0]
                tl = int(PathUtils.changeTool(obj, project))
                obj.ToolNumber = tl

            tool = PathUtils.getTool(obj, obj.ToolNumber)
            if tool:
                radius = tool.Diameter / 2
            else:
                # temporary value, to be taken from the properties later on
                radius = 0.001
            if obj.Base[0].Shape.ShapeType == "Wire":  #a pure wire was picked
                wire = obj.Base[0].Shape
            else:  #we are dealing with a face and it's edges or just a face
                if obj.Edge1:
                    e1 = FreeCAD.ActiveDocument.getObject(
                        obj.Base[0].Name).Shape.Edges[
                            eval(obj.Edge1[1][0].lstrip('Edge')) - 1]
                    if e1.BoundBox.ZMax <> e1.BoundBox.ZMin:
                        FreeCAD.Console.PrintError(
                            'vertical edges not valid yet\n')
                        return
                    if obj.Base[0].Shape.ShapeType == 'Wire':
                        wire = obj.Base[0].Shape
                    if obj.Base[0].Shape.ShapeType == 'Solid' or obj.Base[
                            0].Shape.ShapeType == 'Compound':
                        shape = obj.Base[0].Shape
                        for fw in shape.Wires:
                            if (fw.BoundBox.ZMax == e1.BoundBox.ZMax) and (
                                    fw.BoundBox.ZMin == e1.BoundBox.ZMin):
                                for e in fw.Edges:
                                    if e.isSame(e1):
                                        #FreeCAD.Console.PrintMessage('found the same objects\n')
                                        wire = fw
                elif obj.Face1:  # we are only dealing with a face or faces
                    f1 = FreeCAD.ActiveDocument.getObject(
                        obj.Base[0].Name).Shape.Faces[
                            eval(obj.Face1[1][0].lstrip('Face')) - 1]
                    # make the side Left and direction CW for normal cnc milling
                    obj.Direction = 'CW'
                    obj.Side = "Left"
                    # we only consider the outer wire if this is a single Face
                    wire = f1.OuterWire

            if obj.Direction == 'CCW':
                clockwise = False
            else:
                clockwise = True
            output = ""
            output += '(' + str(obj.Comment) + ')\n'

            FirstEdge = None
            if obj.Edge1:
                ename = obj.Edge1[1][0]
                edgeNumber = int(ename[4:]) - 1
                FirstEdge = obj.Base[0].Shape.Edges[edgeNumber]
            ZMax = obj.Base[0].Shape.BoundBox.ZMax

            ZCurrent = obj.ClearanceHeight.Value

            if obj.UseStartDepth:
                output += PathUtils.MakePath(
                    wire, obj.Side, radius, clockwise,
                    obj.ClearanceHeight.Value, obj.StepDown.Value,
                    obj.StartDepth.Value, obj.FinalDepth.Value, FirstEdge,
                    obj.PathClosed, obj.SegLen.Value, obj.VertFeed.Value,
                    obj.HorizFeed.Value)
            else:
                output += PathUtils.MakePath(
                    wire, obj.Side, radius, clockwise,
                    obj.ClearanceHeight.Value, obj.StepDown.Value, ZMax,
                    obj.FinalDepth.Value, FirstEdge, obj.PathClosed,
                    obj.SegLen.Value, obj.VertFeed.Value, obj.HorizFeed.Value)

            if obj.Active:
                path = Path.Path(output)
                obj.Path = path
                obj.ViewObject.Visibility = True

            else:
                path = Path.Path("(inactive operation)")
                obj.Path = path
                obj.ViewObject.Visibility = False