def addBaseGeometry(self, selection):
        added = False
        shapes = self.obj.BaseShapes
        for sel in selection:
            job = PathUtils.findParentJob(self.obj)
            base = job.Proxy.resourceClone(job, sel.Object)
            if not base:
                PathLog.notice((translate("Path", "%s is not a Base Model object of the job %s")+"\n") % (sel.Object.Label, job.Label))
                continue
            if base in shapes:
                PathLog.notice((translate("Path", "Base shape %s already in the list")+"\n") % (sel.Object.Label))
                continue
            if base.isDerivedFrom('Part::Part2DObject'):
                if sel.HasSubObjects:
                    # selectively add some elements of the drawing to the Base
                    for sub in sel.SubElementNames:
                        if 'Vertex' in sub:
                            PathLog.info(translate("Path", "Ignoring vertex"))
                        else:
                            self.obj.Proxy.addBase(self.obj, base, sub)
                else:
                    # when adding an entire shape to BaseShapes we can take its sub shapes out of Base
                    self.obj.Base = [(p,el) for p,el in self.obj.Base if p != base]
                    shapes.append(base)
                    self.obj.BaseShapes = shapes
                added = True
            else:
                # user wants us to engrave an edge of face of a base model
                base = self.super().addBaseGeometry(selection)
                added = added or base

        return added
Esempio n. 2
0
    def createTagsPositionDisabled(self, obj, positionsIn, disabledIn):
        rawTags = []
        for i, pos in enumerate(positionsIn):
            tag = Tag(i, pos.x, pos.y, obj.Width.Value, obj.Height.Value, obj.Angle, obj.Radius, not i in disabledIn)
            tag.createSolidsAt(self.pathData.minZ, self.toolRadius)
            rawTags.append(tag)
        # disable all tags that intersect with their previous tag
        prev = None
        tags = []
        positions = []
        disabled = []
        for i, tag in enumerate(self.pathData.sortedTags(rawTags)):
            if tag.enabled:
                if prev:
                    if prev.solid.common(tag.solid).Faces:
                        PathLog.notice("Tag #%d intersects with previous tag - disabling\n" % i)
                        PathLog.debug("this tag = %d [%s]" % (i, tag.solid.BoundBox))
                        tag.enabled = False
                elif self.pathData.edges:
                    e = self.pathData.edges[0]
                    p0 = e.valueAt(e.FirstParameter)
                    p1 = e.valueAt(e.LastParameter)
                    if tag.solid.isInside(p0, PathGeom.Tolerance, True) or tag.solid.isInside(p1, PathGeom.Tolerance, True):
                        PathLog.notice("Tag #%d intersects with starting point - disabling\n" % i)
                        tag.enabled = False

            if tag.enabled:
                prev = tag
                PathLog.debug("previousTag = %d [%s]" % (i, prev))
            else:
                disabled.append(i)
            tag.id = i # assigne final id
            tags.append(tag)
            positions.append(tag.originAt(self.pathData.minZ))
        return (tags, positions, disabled)
Esempio n. 3
0
 def addBase(self, obj, base, sub):
     PathLog.track()
     baselist = obj.Base
     if baselist is None:
         baselist = []
     item = (base, sub)
     if item in baselist:
         PathLog.notice(translate("Path", "this object already in the list" + "\n"))
     else:
         baselist.append(item)
         obj.Base = baselist
Esempio n. 4
0
 def sortedTags(self, tags):
     ordered = []
     for edge in self.bottomEdges:
         ts = [t for t in tags if DraftGeomUtils.isPtOnEdge(t.originAt(self.minZ), edge)]
         for t in sorted(ts, key=lambda t: (t.originAt(self.minZ) - edge.valueAt(edge.FirstParameter)).Length):
             tags.remove(t)
             ordered.append(t)
     # disable all tags that are not on the base wire.
     for tag in tags:
         PathLog.notice("Tag #%d not on base wire - disabling\n" % len(ordered))
         tag.enabled = False
         ordered.append(tag)
     return ordered
Esempio n. 5
0
    def addBase(self, obj, base, sub):
        PathLog.track()
        base = PathUtil.getPublicObject(base)

        if self._setBaseAndStock(obj):
            if base == self.job.Proxy.baseObject(self.job):
                base = self.baseobject
            baselist = obj.Base
            if baselist is None:
                baselist = []
            item = (base, sub)
            if item in baselist:
                PathLog.notice(translate("Path", "this object already in the list" + "\n"))
            else:
                baselist.append(item)
                obj.Base = baselist
Esempio n. 6
0
    def addBase(self, obj, base, sub):
        PathLog.track(obj, base, sub)
        base = PathUtil.getPublicObject(base)

        if self._setBaseAndStock(obj):
            if base == self.job.Proxy.baseObject(self.job):
                base = self.baseobject
            baselist = obj.Base
            if baselist is None:
                baselist = []
            for p, el in baselist:
                if p == base and sub in el:
                    PathLog.notice((translate("Path", "Base object %s.%s already in the list")+"\n") % (base.Label, sub))
                    return

            baselist.append((base, sub))
            obj.Base = baselist
 def getLeadEnd(self, obj, queue, action):
     '''returns the Gcode of LeadOut.'''
     global currLocation
     results = []
     horizFeed = PathDressup.toolController(obj.Base).HorizFeed.Value
     R = obj.Length.Value  # Radius of roll or length
     # set the correct twist command
     if self.getDirectionOfPath(obj) == 'right':
         arcdir = "G2"
     else:
         arcdir = "G3"
     if queue[1].Name == "G1":  # line
         p0 = queue[0].Placement.Base
         p1 = queue[1].Placement.Base
         v = self.normalize(p1.sub(p0))
     else:  # dealing with a circle
         p0 = queue[0].Placement.Base
         p1 = queue[1].Placement.Base
         v = self.normalize(p1.sub(p0))
     if self.getDirectionOfPath(obj) == 'right':
         off_v = FreeCAD.Vector(v.y*R, -v.x*R, 0.0)
     else:
         off_v = FreeCAD.Vector(-v.y*R, v.x*R, 0.0)
     offsetvector = FreeCAD.Vector(v.x*R, v.y*R, 0.0)
     if obj.RadiusCenter == 'Radius':
         leadend = (p1.add(off_v)).add(offsetvector)  # Rmode
     else:
         leadend = p1.add(off_v)  # Dmode
     IJ = off_v  # .negative()
     #results.append(queue[1])
     if obj.StyleOff == 'Arc':
         arcmove = Path.Command(arcdir, {"X": leadend.x, "Y": leadend.y, "I": IJ.x, "J": IJ.y, "F": horizFeed})  # add G2/G3 move
         results.append(arcmove)
     elif obj.StyleOff == 'Tangent':
         extendcommand = Path.Command('G1', {"X": leadend.x, "Y": leadend.y, "F": horizFeed})
         results.append(extendcommand)
     else:
         PathLog.notice(" CURRENT_IN Perp")
     if obj.UseMashineCRC:  # crc off
         results.append(Path.Command('G40', {}))
     return results
Esempio n. 8
0
    def addBaseGeometry(self, selection):
        added = False
        shapes = self.obj.BaseShapes
        for sel in selection:
            if sel.Object in shapes:
                PathLog.notice((translate("Path", "Base shape %s already in the list")+"\n") % (sel.Object.Label))
                continue
            if sel.Object.isDerivedFrom('Part::Part2DObject'):
                if sel.HasSubObjects:
                    for sub in sel.SubElementNames:
                        if 'Vertex' in sub:
                            PathLog.info(translate("Path", "Ignoring vertex"))
                        else:
                            self.obj.Proxy.addBase(self.obj, sel.Object, sub)
                else:
                    self.obj.Base = [(p,el) for p,el in self.obj.Base if p != sel.Object]
                    shapes.append(sel.Object)
                    self.obj.BaseShapes = shapes
                added = True
            else:
                base = self.super().addBaseGeometry(selection)
                added = added or base

        return added
Esempio n. 9
0
    def addBase(self, obj, base, sub):
        PathLog.track(obj, base, sub)
        base = PathUtil.getPublicObject(base)

        if self._setBaseAndStock(obj):
            for model in self.job.Model.Group:
                if base == self.job.Proxy.baseObject(self.job, model):
                    base = model
                    break

            baselist = obj.Base
            if baselist is None:
                baselist = []

            for p, el in baselist:
                if p == base and sub in el:
                    PathLog.notice((translate("Path", "Base object %s.%s already in the list")+"\n") % (base.Label, sub))
                    return

            if not self.opRejectAddBase(obj, base, sub):
                baselist.append((base, sub))
                obj.Base = baselist
            else:
                PathLog.notice((translate("Path", "Base object %s.%s rejected by operation")+"\n") % (base.Label, sub))
        if not self.pathData:
            self.setup(obj)
        return self.pathData.pointIsOnPath(point)

    def pointAtBottom(self, obj, point):
        if not self.pathData:
            self.setup(obj)
        return self.pathData.pointAtBottom(point)


def Create(baseObject, name='DressupTag'):
    '''
    Create(basePath, name='DressupTag') ... create tag dressup object for the given base path.
    '''
    if not baseObject.isDerivedFrom('Path::Feature'):
        PathLog.error(translate('Path_DressupTag', 'The selected object is not a path')+'\n')
        return None

    if baseObject.isDerivedFrom('Path::FeatureCompoundPython'):
        PathLog.error(translate('Path_DressupTag', 'Please select a Profile object'))
        return None

    obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
    dbo = ObjectTagDressup(obj, baseObject)
    job = PathUtils.findParentJob(baseObject)
    job.Proxy.addOperation(obj, baseObject)
    dbo.setup(obj, True)
    return obj

PathLog.notice("Loading Path_DressupTag... done\n")
Esempio n. 11
0
    def supportsTagGeneration(self, obj):
        return False

    def pointIsOnPath(self, obj, p):
        for e in self.edges:
            if DraftGeomUtils.isPtOnEdge(p, e):
                return True
        return False


def Create(baseObject, name='DressupTag'):
    '''
    Create(basePath, name = 'DressupTag') ... create tag dressup object for the given base path.
    '''
    if not baseObject.isDerivedFrom('Path::Feature'):
        PathLog.error(translate('Path_DressupTag', 'The selected object is not a path\n'))
        return None

    if baseObject.isDerivedFrom('Path::FeatureCompoundPython'):
        PathLog.error(translate('Path_DressupTag', 'Please select a Profile object'))
        return None

    obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "TagDressup")
    dbo = ObjectDressup(obj, baseObject)
    job = PathUtils.findParentJob(baseObject)
    job.adddOperation(obj)
    dbo.assignDefaultValues()
    return obj

PathLog.notice('Loading Path_DressupTag... done\n')
        if not hasattr(self, 'pathData'):
            self.setup(obj)
        return self.pathData.pointIsOnPath(point)

    def pointAtBottom(self, obj, point):
        if not hasattr(self, 'pathData'):
            self.setup(obj)
        return self.pathData.pointAtBottom(point)


def Create(baseObject, name='DressupTag'):
    '''
    Create(basePath, name='DressupTag') ... create tag dressup object for the given base path.
    '''
    if not baseObject.isDerivedFrom('Path::Feature'):
        PathLog.error(translate('Path_DressupTag', 'The selected object is not a path')+'\n')
        return None

    if baseObject.isDerivedFrom('Path::FeatureCompoundPython'):
        PathLog.error(translate('Path_DressupTag', 'Please select a Profile object'))
        return None

    obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "TagDressup")
    dbo = ObjectTagDressup(obj, baseObject)
    job = PathUtils.findParentJob(baseObject)
    job.Proxy.addOperation(obj)
    dbo.setup(obj, True)
    return obj

PathLog.notice("Loading Path_DressupTag... done\n")
Esempio n. 13
0
                'MenuText': QtCore.QT_TRANSLATE_NOOP('Path_DressupTag', 'Tag Dress-up'),
                'ToolTip': QtCore.QT_TRANSLATE_NOOP('Path_DressupTag', 'Creates a Tag Dress-up object from a selected path')}

    def IsActive(self):
        if FreeCAD.ActiveDocument is not None:
            for o in FreeCAD.ActiveDocument.Objects:
                if o.Name[:3] == 'Job':
                        return True
        return False

    def Activated(self):
        # check that the selection contains exactly what we want
        selection = FreeCADGui.Selection.getSelection()
        if len(selection) != 1:
            PathLog.error(translate('Path_DressupTag', 'Please select one path object')+'\n')
            return
        baseObject = selection[0]

        # everything ok!
        FreeCAD.ActiveDocument.openTransaction(translate('Path_DressupTag', 'Create Tag Dress-up'))
        FreeCADGui.addModule('PathScripts.PathDressupTagGui')
        FreeCADGui.doCommand("PathScripts.PathDressupTagGui.Create(App.ActiveDocument.%s)" % baseObject.Name)
        FreeCAD.ActiveDocument.commitTransaction()
        FreeCAD.ActiveDocument.recompute()

if FreeCAD.GuiUp:
    # register the FreeCAD command
    FreeCADGui.addCommand('Path_DressupTag', CommandPathDressupTag())

PathLog.notice('Loading PathDressupTagGui... done\n')
Esempio n. 14
0
 def getLeadStart(self, obj, queue, action):
     '''returns Lead In G-code.'''
     global currLocation
     results = []
     # zdepth = currLocation["Z"]
     op = PathDressup.baseOp(obj.Base)
     tc = PathDressup.toolController(obj.Base)
     horizFeed = tc.HorizFeed.Value
     vertFeed = tc.VertFeed.Value
     toolnummer = tc.ToolNumber
     # set the correct twist command
     if self.getDirectionOfPath(obj) == 'left':
         arcdir = "G3"
     else:
         arcdir = "G2"
     R = obj.Length.Value  # Radius of roll or length
     if queue[1].Name == "G1":  # line
         p0 = queue[0].Placement.Base
         p1 = queue[1].Placement.Base
         v = self.normalize(p1.sub(p0))
         # PathLog.notice(" CURRENT_IN  : P0 Z:{} p1 Z:{}".format(p0.z,p1.z))
     else:
         p0 = queue[0].Placement.Base
         p1 = queue[1].Placement.Base
         # PathLog.notice(" CURRENT_IN ARC : P0 X:{} Y:{} P1 X:{} Y:{} ".format(p0.x,p0.y,p1.x,p1.y))
         v = self.normalize(p1.sub(p0))
     if self.getDirectionOfPath(obj) == 'right':
         off_v = FreeCAD.Vector(v.y * R, -v.x * R, 0.0)
     else:
         off_v = FreeCAD.Vector(-v.y * R, v.x * R, 0.0)
     offsetvector = FreeCAD.Vector(v.x * R, v.y * R, 0)  # IJ
     if obj.RadiusCenter == 'Radius':
         leadstart = (p0.add(off_v)).sub(offsetvector)  # Rmode
     else:
         leadstart = p0.add(off_v)  # Dmode
     if action == 'start':
         extendcommand = Path.Command('G0', {
             "X": 0.0,
             "Y": 0.0,
             "Z": op.ClearanceHeight.Value
         })
         results.append(extendcommand)
         extendcommand = Path.Command('G0', {
             "X": leadstart.x,
             "Y": leadstart.y,
             "Z": op.ClearanceHeight.Value
         })
         results.append(extendcommand)
         extendcommand = Path.Command('G0', {
             "X": leadstart.x,
             "Y": leadstart.y,
             "Z": op.SafeHeight.Value
         })
         results.append(extendcommand)
     if action == 'layer':
         if not obj.KeepToolDown:
             extendcommand = Path.Command('G0', {"Z": op.SafeHeight.Value})
             results.append(extendcommand)
         extendcommand = Path.Command('G0', {
             "X": leadstart.x,
             "Y": leadstart.y
         })
         results.append(extendcommand)
     extendcommand = Path.Command('G1', {
         "X": leadstart.x,
         "Y": leadstart.y,
         "Z": p1.z,
         "F": vertFeed
     })
     results.append(extendcommand)
     if obj.UseMashineCRC:
         if self.getDirectionOfPath(obj) == 'right':
             results.append(Path.Command('G42', {'D': toolnummer}))
         else:
             results.append(Path.Command('G41', {'D': toolnummer}))
     if obj.StyleOn == 'Arc':
         arcmove = Path.Command(
             arcdir, {
                 "X": p0.x,
                 "Y": p0.y,
                 "I": offsetvector.x,
                 "J": offsetvector.y,
                 "F": horizFeed
             })  # add G2/G3 move
         results.append(arcmove)
     elif obj.StyleOn == 'Tangent':
         extendcommand = Path.Command('G1', {
             "X": p0.x,
             "Y": p0.y,
             "F": horizFeed
         })
         results.append(extendcommand)
     else:
         PathLog.notice(" CURRENT_IN Perp")
     return results
Esempio n. 15
0
        # everything ok!
        FreeCAD.ActiveDocument.openTransaction("Create LeadInOut Dressup")
        FreeCADGui.addModule("PathScripts.PathDressupLeadInOut")
        FreeCADGui.addModule("PathScripts.PathUtils")
        FreeCADGui.doCommand(
            'obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "LeadInOutDressup")'
        )
        FreeCADGui.doCommand(
            "dbo = PathScripts.PathDressupLeadInOut.ObjectDressup(obj)"
        )
        FreeCADGui.doCommand("base = FreeCAD.ActiveDocument." + selection[0].Name)
        FreeCADGui.doCommand("job = PathScripts.PathUtils.findParentJob(base)")
        FreeCADGui.doCommand("obj.Base = base")
        FreeCADGui.doCommand("job.Proxy.addOperation(obj, base)")
        FreeCADGui.doCommand("dbo.setup(obj)")
        FreeCADGui.doCommand(
            "obj.ViewObject.Proxy = PathScripts.PathDressupLeadInOut.ViewProviderDressup(obj.ViewObject)"
        )
        FreeCADGui.doCommand(
            "Gui.ActiveDocument.getObject(base.Name).Visibility = False"
        )
        FreeCAD.ActiveDocument.commitTransaction()
        FreeCAD.ActiveDocument.recompute()


if FreeCAD.GuiUp:
    # register the FreeCAD command
    FreeCADGui.addCommand("Path_DressupLeadInOut", CommandPathDressupLeadInOut())

PathLog.notice("Loading Path_DressupLeadInOut... done\n")
Esempio n. 16
0
            for o in FreeCAD.ActiveDocument.Objects:
                if o.Name[:3] == "Job":
                    return True
        return False

    def Activated(self):
        # check that the selection contains exactly what we want
        selection = FreeCADGui.Selection.getSelection()
        if len(selection) != 1:
            PathLog.error(
                translate("Path_DressupTag", "Please select one path object") +
                "\n")
            return
        baseObject = selection[0]

        # everything ok!
        FreeCAD.ActiveDocument.openTransaction("Create Tag Dress-up")
        FreeCADGui.addModule("PathScripts.PathDressupTagGui")
        FreeCADGui.doCommand(
            "PathScripts.PathDressupTagGui.Create(App.ActiveDocument.%s)" %
            baseObject.Name)
        FreeCAD.ActiveDocument.commitTransaction()
        FreeCAD.ActiveDocument.recompute()


if FreeCAD.GuiUp:
    # register the FreeCAD command
    FreeCADGui.addCommand("Path_DressupTag", CommandPathDressupTag())

PathLog.notice("Loading PathDressupTagGui... done\n")
Esempio n. 17
0
        return False

    def Activated(self):
        # check that the selection contains exactly what we want
        selection = FreeCADGui.Selection.getSelection()
        if len(selection) != 1:
            PathLog.error(
                translate('Path_DressupPathBoundary',
                          'Please select one path object') + '\n')
            return
        baseObject = selection[0]

        # everything ok!
        FreeCAD.ActiveDocument.openTransaction(
            translate('Path_DressupPathBoundary',
                      'Create Path Boundary Dress-up'))
        FreeCADGui.addModule('PathScripts.PathDressupPathBoundaryGui')
        FreeCADGui.doCommand(
            "PathScripts.PathDressupPathBoundaryGui.Create(App.ActiveDocument.%s)"
            % baseObject.Name)
        FreeCAD.ActiveDocument.commitTransaction()
        FreeCAD.ActiveDocument.recompute()


if FreeCAD.GuiUp:
    # register the FreeCAD command
    FreeCADGui.addCommand('Path_DressupPathBoundary',
                          CommandPathDressupPathBoundary())

PathLog.notice('Loading PathDressupPathBoundaryGui... done\n')
Esempio n. 18
0
        self.tags, self.obj.Positions, self.obj.Disabled = self.createTagsPositionDisabled(self.obj, positions, disabled)
        self.processTags(self.obj)

    def pointIsOnPath(self, obj, point):
        if not hasattr(self, 'pathData'):
            self.setup(obj)
        return self.pathData.pointIsOnPath(point)



def Create(baseObject, name = 'DressupTag'):
    '''
    Create(basePath, name = 'DressupTag') ... create tag dressup object for the given base path.
    '''
    if not baseObject.isDerivedFrom('Path::Feature'):
        PathLog.error(translate('PathDressup_Tag', 'The selected object is not a path\n'))
        return None

    if baseObject.isDerivedFrom('Path::FeatureCompoundPython'):
        PathLog.error(translate('PathDressup_Tag', 'Please select a Profile object'))
        return None

    obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "TagDressup")
    dbo = ObjectTagDressup(obj, baseObject)
    job = PathUtils.findParentJob(baseObject)
    job.Proxy.addOperation(obj)
    dbo.setup(obj, True)
    return obj

PathLog.notice("Loading PathDressupHoldingTags... done\n")
        baseObject = selection[0]
        if not baseObject.isDerivedFrom("Path::Feature"):
            PathLog.error(translate("The selected object is not a path")+"\n")
            return
        if baseObject.isDerivedFrom("Path::FeatureCompoundPython"):
            PathLog.error(translate("Please select a Profile object"))
            return

        # everything ok!
        FreeCAD.ActiveDocument.openTransaction(translate("Create LeadInOut Dressup"))
        FreeCADGui.addModule("PathScripts.PathDressupLeadInOut")
        FreeCADGui.addModule("PathScripts.PathUtils")
        FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "LeadInOutDressup")')
        FreeCADGui.doCommand('dbo = PathScripts.PathDressupLeadInOut.ObjectDressup(obj)')
        FreeCADGui.doCommand('base = FreeCAD.ActiveDocument.' + selection[0].Name)
        FreeCADGui.doCommand('job = PathScripts.PathUtils.findParentJob(base)')
        FreeCADGui.doCommand('obj.Base = base')
        FreeCADGui.doCommand('job.Proxy.addOperation(obj, base)')
        FreeCADGui.doCommand('PathScripts.PathDressupLeadInOut.ViewProviderDressup(obj.ViewObject)')
        FreeCADGui.doCommand('Gui.ActiveDocument.getObject(base.Name).Visibility = False')
        FreeCADGui.doCommand('dbo.setup(obj)')
        FreeCAD.ActiveDocument.commitTransaction()
        FreeCAD.ActiveDocument.recompute()


if FreeCAD.GuiUp:
    # register the FreeCAD command
    FreeCADGui.addCommand('Path_DressupLeadInOut', CommandPathDressupLeadInOut())

PathLog.notice("Loading PathDressupLeadInOut... done\n")
 def getLeadStart(self, obj, queue, action):
     '''returns Lead In G-code.'''
     global currLocation
     results = []
     # zdepth = currLocation["Z"]
     op = PathDressup.baseOp(obj.Base)
     tc = PathDressup.toolController(obj.Base)
     horizFeed = tc.HorizFeed.Value
     vertFeed = tc.VertFeed.Value
     toolnummer = tc.ToolNumber
     # set the correct twist command
     if self.getDirectionOfPath(obj) == 'left':
         arcdir = "G3"
     else:
         arcdir = "G2"
     R = obj.Length.Value  # Radius of roll or length
     if queue[1].Name == "G1":  # line
         p0 = queue[0].Placement.Base
         p1 = queue[1].Placement.Base
         v = self.normalize(p1.sub(p0))
         # PathLog.notice(" CURRENT_IN  : P0 Z:{} p1 Z:{}".format(p0.z,p1.z))
     else:
         p0 = queue[0].Placement.Base
         p1 = queue[1].Placement.Base
         # PathLog.notice(" CURRENT_IN ARC : P0 X:{} Y:{} P1 X:{} Y:{} ".format(p0.x,p0.y,p1.x,p1.y))
         v = self.normalize(p1.sub(p0))
     if self.getDirectionOfPath(obj) == 'right':
         off_v = FreeCAD.Vector(v.y*R, -v.x*R, 0.0)
     else:
         off_v = FreeCAD.Vector(-v.y*R, v.x*R, 0.0)
     offsetvector = FreeCAD.Vector(v.x*R, v.y*R, 0)  # IJ
     if obj.RadiusCenter == 'Radius':
         leadstart = (p0.add(off_v)).sub(offsetvector)  # Rmode
     else:
         leadstart = p0.add(off_v)  # Dmode
     if action == 'start':
         extendcommand = Path.Command('G0', {"X": 0.0, "Y": 0.0, "Z": op.ClearanceHeight.Value})
         results.append(extendcommand)
         extendcommand = Path.Command('G0', {"X": leadstart.x, "Y": leadstart.y, "Z": op.ClearanceHeight.Value})
         results.append(extendcommand)
         extendcommand = Path.Command('G0', {"X": leadstart.x, "Y": leadstart.y, "Z": op.SafeHeight.Value})
         results.append(extendcommand)
     if action == 'layer':
         if not obj.KeepToolDown:
             extendcommand = Path.Command('G0', {"Z": op.SafeHeight.Value})
             results.append(extendcommand)
         extendcommand = Path.Command('G0', {"X": leadstart.x, "Y": leadstart.y})
         results.append(extendcommand)
     extendcommand = Path.Command('G1', {"X": leadstart.x, "Y": leadstart.y, "Z": p1.z, "F": vertFeed})
     results.append(extendcommand)
     if obj.UseMashineCRC:
             if self.getDirectionOfPath(obj) == 'right':
                 results.append(Path.Command('G42', {'D': toolnummer}))
             else:
                 results.append(Path.Command('G41', {'D': toolnummer}))
     if obj.StyleOn == 'Arc':
         arcmove = Path.Command(arcdir, {"X": p0.x, "Y": p0.y, "I": offsetvector.x, "J": offsetvector.y, "F": horizFeed})  # add G2/G3 move
         results.append(arcmove)
     elif obj.StyleOn == 'Tangent':
         extendcommand = Path.Command('G1', {"X": p0.x, "Y": p0.y, "F": horizFeed})
         results.append(extendcommand)
     else:
         PathLog.notice(" CURRENT_IN Perp")
     return results
Esempio n. 21
0
                if o.Name[:3] == 'Job':
                    return True
        return False

    def Activated(self):
        # check that the selection contains exactly what we want
        selection = FreeCADGui.Selection.getSelection()
        if len(selection) != 1:
            PathLog.error(
                translate('Path_DressupTag', 'Please select one path object') +
                '\n')
            return
        baseObject = selection[0]

        # everything ok!
        FreeCAD.ActiveDocument.openTransaction(
            translate('Path_DressupTag', 'Create Tag Dress-up'))
        FreeCADGui.addModule('PathScripts.PathDressupTagGui')
        FreeCADGui.doCommand(
            "PathScripts.PathDressupTagGui.Create(App.ActiveDocument.%s)" %
            baseObject.Name)
        FreeCAD.ActiveDocument.commitTransaction()
        FreeCAD.ActiveDocument.recompute()


if FreeCAD.GuiUp:
    # register the FreeCAD command
    FreeCADGui.addCommand('Path_DressupTag', CommandPathDressupTag())

PathLog.notice('Loading PathDressupTagGui... done\n')
Esempio n. 22
0
        for e in self.edges:
            if DraftGeomUtils.isPtOnEdge(p, e):
                return True
        return False


def Create(baseObject, name='DressupTag'):
    '''
    Create(basePath, name = 'DressupTag') ... create tag dressup object for the given base path.
    '''
    if not baseObject.isDerivedFrom('Path::Feature'):
        PathLog.error(
            translate('Path_DressupTag', 'The selected object is not a path') +
            '\n')
        return None

    if baseObject.isDerivedFrom('Path::FeatureCompoundPython'):
        PathLog.error(
            translate('Path_DressupTag', 'Please select a Profile object'))
        return None

    obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
    dbo = ObjectDressup(obj, baseObject)
    job = PathUtils.findParentJob(baseObject)
    job.adddOperation(obj)
    dbo.assignDefaultValues()
    return obj


PathLog.notice('Loading Path_DressupTag... done\n')
Esempio n. 23
0
        # everything ok!
        FreeCAD.ActiveDocument.openTransaction("Create RampEntry Dress-up")
        FreeCADGui.addModule("PathScripts.PathDressupRampEntry")
        FreeCADGui.addModule("PathScripts.PathUtils")
        FreeCADGui.doCommand(
            'obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "RampEntryDressup")'
        )
        FreeCADGui.doCommand(
            "dbo = PathScripts.PathDressupRampEntry.ObjectDressup(obj)")
        FreeCADGui.doCommand("base = FreeCAD.ActiveDocument." +
                             selection[0].Name)
        FreeCADGui.doCommand("job = PathScripts.PathUtils.findParentJob(base)")
        FreeCADGui.doCommand("obj.Base = base")
        FreeCADGui.doCommand("job.Proxy.addOperation(obj, base)")
        FreeCADGui.doCommand(
            "obj.ViewObject.Proxy = PathScripts.PathDressupRampEntry.ViewProviderDressup(obj.ViewObject)"
        )
        FreeCADGui.doCommand(
            "Gui.ActiveDocument.getObject(base.Name).Visibility = False")
        FreeCADGui.doCommand("dbo.setup(obj)")
        FreeCAD.ActiveDocument.commitTransaction()
        FreeCAD.ActiveDocument.recompute()


if FreeCAD.GuiUp:
    # register the FreeCAD command
    FreeCADGui.addCommand("Path_DressupRampEntry",
                          CommandPathDressupRampEntry())

PathLog.notice("Loading Path_DressupRampEntry... done\n")
        baseObject = selection[0]
        if not baseObject.isDerivedFrom("Path::Feature"):
            PathLog.error(translate("The selected object is not a path") + "\n")
            return
        if baseObject.isDerivedFrom("Path::FeatureCompoundPython"):
            PathLog.error(translate("Please select a Profile object"))
            return

        # everything ok!
        FreeCAD.ActiveDocument.openTransaction(translate("Create RampEntry Dress-up"))
        FreeCADGui.addModule("PathScripts.PathDressupRampEntry")
        FreeCADGui.addModule("PathScripts.PathUtils")
        FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "RampEntryDressup")')
        FreeCADGui.doCommand('dbo = PathScripts.PathDressupRampEntry.ObjectDressup(obj)')
        FreeCADGui.doCommand('base = FreeCAD.ActiveDocument.' + selection[0].Name)
        FreeCADGui.doCommand('job = PathScripts.PathUtils.findParentJob(base)')
        FreeCADGui.doCommand('obj.Base = base')
        FreeCADGui.doCommand('job.Proxy.addOperation(obj, base)')
        FreeCADGui.doCommand('PathScripts.PathDressupRampEntry.ViewProviderDressup(obj.ViewObject)')
        FreeCADGui.doCommand('Gui.ActiveDocument.getObject(base.Name).Visibility = False')
        FreeCADGui.doCommand('dbo.setup(obj)')
        FreeCAD.ActiveDocument.commitTransaction()
        FreeCAD.ActiveDocument.recompute()


if FreeCAD.GuiUp:
    # register the FreeCAD command
    FreeCADGui.addCommand('Path_DressupRampEntry', CommandPathDressupRampEntry())

PathLog.notice("Loading Path_DressupRampEntry... done\n")
Esempio n. 25
0
    def pointIsOnPath(self, obj, point):
        if not hasattr(self, 'pathData'):
            self.setup(obj)
        return self.pathData.pointIsOnPath(point)


def Create(baseObject, name='DressupTag'):
    '''
    Create(basePath, name = 'DressupTag') ... create tag dressup object for the given base path.
    '''
    if not baseObject.isDerivedFrom('Path::Feature'):
        PathLog.error(
            translate('PathDressup_Tag',
                      'The selected object is not a path\n'))
        return None

    if baseObject.isDerivedFrom('Path::FeatureCompoundPython'):
        PathLog.error(
            translate('PathDressup_Tag', 'Please select a Profile object'))
        return None

    obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "TagDressup")
    dbo = ObjectTagDressup(obj, baseObject)
    job = PathUtils.findParentJob(baseObject)
    job.Proxy.addOperation(obj)
    dbo.setup(obj, True)
    return obj


PathLog.notice("Loading PathDressupHoldingTags... done\n")