Skip to content

Commit

Permalink
Insert dressups at the same position in the operations list as the pa…
Browse files Browse the repository at this point in the history
…rent op is/was
  • Loading branch information
mlampert authored and yorikvanhavre committed Nov 4, 2018
1 parent de5b785 commit bfcd213
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 16 deletions.
8 changes: 5 additions & 3 deletions src/Mod/Path/PathScripts/PathDressupAxisMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,13 @@ def Activated(self):
FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "AxisMapDressup")')
FreeCADGui.doCommand('PathScripts.PathDressupAxisMap.ObjectDressup(obj)')
FreeCADGui.doCommand('obj.Base = FreeCAD.ActiveDocument.' + selection[0].Name)
FreeCADGui.doCommand('base = FreeCAD.ActiveDocument.' + selection[0].Name)
FreeCADGui.doCommand('job = PathScripts.PathUtils.findParentJob(base)')
FreeCADGui.doCommand('obj.Base = base')
FreeCADGui.doCommand('obj.Radius = 45')
FreeCADGui.doCommand('job.Proxy.addOperation(obj, base)')
FreeCADGui.doCommand('PathScripts.PathDressupAxisMap.ViewProviderDressup(obj.ViewObject)')
FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)')
FreeCADGui.doCommand('Gui.ActiveDocument.getObject(obj.Base.Name).Visibility = False')
FreeCADGui.doCommand('Gui.ActiveDocument.getObject(base.Name).Visibility = False')
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()

Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/PathDressupDogbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ def Create(base, name='DogboneDressup'):
obj = FreeCAD.ActiveDocument.addObject('Path::FeaturePython', 'DogboneDressup')
dbo = ObjectDressup(obj, base)
job = PathUtils.findParentJob(base)
job.Proxy.addOperation(obj)
job.Proxy.addOperation(obj, base)

if FreeCAD.GuiUp:
ViewProviderDressup(obj.ViewObject)
Expand Down
8 changes: 5 additions & 3 deletions src/Mod/Path/PathScripts/PathDressupDragknife.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,10 +499,12 @@ def Activated(self):
FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","DragknifeDressup")')
FreeCADGui.doCommand('PathScripts.PathDressupDragknife.ObjectDressup(obj)')
FreeCADGui.doCommand('obj.Base = FreeCAD.ActiveDocument.' + selection[0].Name)
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.PathDressupDragknife.ViewProviderDressup(obj.ViewObject)')
FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)')
FreeCADGui.doCommand('Gui.ActiveDocument.getObject(obj.Base.Name).Visibility = False')
FreeCADGui.doCommand('Gui.ActiveDocument.getObject(base.Name).Visibility = False')
FreeCADGui.doCommand('obj.filterangle = 20')
FreeCADGui.doCommand('obj.offset = 2')
FreeCADGui.doCommand('obj.pivotheight = 4')
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/PathDressupHoldingTags.py
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ def Create(baseObject, name='DressupTag'):
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "TagDressup")
dbo = ObjectTagDressup(obj, baseObject)
job = PathUtils.findParentJob(baseObject)
job.Proxy.addOperation(obj)
job.Proxy.addOperation(obj, baseObject)
dbo.setup(obj, True)
return obj

Expand Down
8 changes: 5 additions & 3 deletions src/Mod/Path/PathScripts/PathDressupLeadInOut.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,12 @@ def Activated(self):
FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "LeadInOutDressup")')
FreeCADGui.doCommand('dbo = PathScripts.PathDressupLeadInOut.ObjectDressup(obj)')
FreeCADGui.doCommand('obj.Base = FreeCAD.ActiveDocument.' + selection[0].Name)
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('PathScripts.PathUtils.addToJob(obj)')
FreeCADGui.doCommand('Gui.ActiveDocument.getObject(obj.Base.Name).Visibility = False')
FreeCADGui.doCommand('Gui.ActiveDocument.getObject(base.Name).Visibility = False')
FreeCADGui.doCommand('dbo.setup(obj)')
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
Expand Down
8 changes: 5 additions & 3 deletions src/Mod/Path/PathScripts/PathDressupRampEntry.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,10 +687,12 @@ def Activated(self):
FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "RampEntryDressup")')
FreeCADGui.doCommand('dbo = PathScripts.PathDressupRampEntry.ObjectDressup(obj)')
FreeCADGui.doCommand('obj.Base = FreeCAD.ActiveDocument.' + selection[0].Name)
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('PathScripts.PathUtils.addToJob(obj)')
FreeCADGui.doCommand('Gui.ActiveDocument.getObject(obj.Base.Name).Visibility = False')
FreeCADGui.doCommand('Gui.ActiveDocument.getObject(base.Name).Visibility = False')
FreeCADGui.doCommand('dbo.setup(obj)')
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
Expand Down
11 changes: 9 additions & 2 deletions src/Mod/Path/PathScripts/PathJob.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,17 @@ def __setstate__(self, state):
def execute(self, obj):
obj.Path = obj.Operations.Path

def addOperation(self, op):
def addOperation(self, op, before = None):
group = self.obj.Operations.Group
if op not in group:
group.append(op)
if before:
try:
group.insert(group.index(before), op)
except Exception as e:
PathLog.error(e)
group.append(op)
else:
group.append(op)
self.obj.Operations.Group = group
op.Path.Center = self.obj.Operations.Path.Center

Expand Down

0 comments on commit bfcd213

Please sign in to comment.