diff --git a/Gui/Resources/icons/Assembly_LockMover.svg b/Gui/Resources/icons/Assembly_LockMover.svg new file mode 100644 index 0000000..c2a318f --- /dev/null +++ b/Gui/Resources/icons/Assembly_LockMover.svg @@ -0,0 +1,493 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + Mon Oct 10 13:44:52 2011 +0000 + + + [wmayer] + + + + + FreeCAD LGPL2+ + + + + + FreeCAD + + + FreeCAD/src/Mod/Draft/Resources/icons/Draft_Move.svg + http://www.freecadweb.org/wiki/index.php?title=Artwork + + + [agryson] Alexander Gryson + + + + + arrow + move + arrows + compass + cross + + + Four equally sized arrow heads at 90° to eachother, all joined at the tail + + + + diff --git a/constraint.py b/constraint.py index 5ba7ccf..923de27 100644 --- a/constraint.py +++ b/constraint.py @@ -495,7 +495,7 @@ def getFixedParts(mcs,solver,cstrs,parts): firstInfo = elements[0].Proxy.getInfo() if not found: - if not firstInfo: + if not firstInfo or not solver: return ret if utils.isDraftObject(firstInfo.Part): Locked.lockElement(firstInfo,solver) diff --git a/gui.py b/gui.py index c0da6f2..d890b67 100644 --- a/gui.py +++ b/gui.py @@ -315,6 +315,20 @@ def GetResources(cls): def Activated(cls,checked): cls.setChecked(True if checked else False) +class AsmCmdLockMover(AsmCmdCheckable): + _id = 15 + _menuText = 'Lock mover' + _tooltip = 'Lock mover for fixed part' + _iconName = 'Assembly_LockMover.svg' + _saveParam = True + + @classmethod + def Activated(cls,checked): + super(AsmCmdLockMover,cls).Activated(checked) + AsmCmdMove._active = None + AsmCmdAxialMove._active = None + AsmCmdQuickMove._active = None + class AsmCmdTrace(AsmCmdCheckable): _id = 4 _menuText = 'Trace part move' diff --git a/mover.py b/mover.py index cbada1d..c22a785 100644 --- a/mover.py +++ b/mover.py @@ -210,6 +210,18 @@ def move(self): # AsmMovingPart.update() return self.draggerPlacement +def _checkFixedPart(info): + if not gui.AsmCmdManager.LockMover: + return + if isTypeOf(info.Parent,Assembly,True): + assembly = info.Parent.getLinkedObject(True).Proxy + else: + assembly = info.Parent.getAssembly() + cstrs = assembly.getConstraints() + parts = assembly.getPartGroup().Group + if info.Part in Constraint.getFixedParts(None,cstrs,parts): + raise RuntimeError('cannot move fixed part') + def getMovingElementInfo(): '''Extract information from current selection for part moving @@ -246,6 +258,7 @@ def getMovingElementInfo(): if len(sels[0].SubElementNames)==1: info = getElementInfo(ret[0].Assembly, ret[0].Subname, checkPlacement=True) + _checkFixedPart(info) return MovingPartInfo(SelObj=selObj, SelSubname=selSub, Hierarchy=ret, @@ -270,6 +283,7 @@ def getMovingElementInfo(): for r in ret2: if assembly == r.Assembly: info = getElementInfo(r.Assembly,r.Subname,checkPlacement=True) + _checkFixedPart(info) return MovingPartInfo(SelObj=selObj, SelSubname=selSub, Hierarchy=ret2,