Prevent adding an entry method dressup to an op that's already has one.

This commit is contained in:
Markus Lampert
2018-01-21 19:45:51 -08:00
committed by wmayer
parent d1fa0d1d37
commit d538e88815
4 changed files with 57 additions and 10 deletions

View File

@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
# ***************************************************************************
# * *
# * Copyright (c) 2018 sliptonic <shopinthewoods@gmail.com> *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU Library General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with this program; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************
import FreeCAD
import FreeCADGui
import PathScripts.PathJob as PathJob
def selection():
'''isActive() ... return True if a dressup command is possible.'''
if FreeCAD.ActiveDocument:
sel = FreeCADGui.Selection.getSelectionEx()
if len(sel) == 1 and sel[0].Object.isDerivedFrom("Path::Feature") and PathJob.Instances():
return sel[0].Object
return None
def hasEntryMethod(path):
'''hasEntryDressup(path) ... returns true if the given object already has an entry method attached.'''
if 'RampEntry' in path.Name or 'LeadInOut' in path.Name:
return True
if hasattr(path, 'Base'):
return hasEntryMethod(path.Base)
return False

View File

@@ -23,13 +23,16 @@
# ***************************************************************************
from __future__ import print_function
import FreeCAD
import FreeCADGui
import Path
from PySide import QtCore
import math
import PathScripts.PathDressup as PathDressup
import PathScripts.PathLog as PathLog
import PathScripts.PathUtils as PathUtils
import math
from PySide import QtCore
from PathScripts.PathGeom import PathGeom
"""LeadInOut Dressup MASHIN-CRC USE ROLL-ON ROLL-OFF to profile"""
@@ -337,10 +340,9 @@ class CommandPathDressupLeadInOut:
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Path_DressupLeadInOut", "Creates a Cutter Radius Compensation G41/G42 Entry Dressup 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
op = PathDressup.selection()
if op:
return not PathDressup.hasEntryMethod(op)
return False
def Activated(self):

View File

@@ -25,6 +25,7 @@ import FreeCAD
import FreeCADGui
import Path
import Part
import PathScripts.PathDressup as PathDressup
import PathScripts.PathLog as PathLog
import math
@@ -613,10 +614,9 @@ class CommandPathDressupRampEntry:
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Path_DressupRampEntry", "Creates a Ramp Entry 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
op = PathDressup.selection()
if op:
return not PathDressup.hasEntryMethod(op)
return False
def Activated(self):