active body awareness
disable some commands when in body
This commit is contained in:
parent
57f3d26d68
commit
0b591d5189
|
@ -255,7 +255,7 @@ class _CommandCompoundFilter:
|
||||||
|
|
||||||
def IsActive(self):
|
def IsActive(self):
|
||||||
if App.ActiveDocument:
|
if App.ActiveDocument:
|
||||||
return True
|
return activeBody() is None
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -326,7 +326,7 @@ class _CommandExplode:
|
||||||
|
|
||||||
def IsActive(self):
|
def IsActive(self):
|
||||||
if App.ActiveDocument:
|
if App.ActiveDocument:
|
||||||
return True
|
return activeBody() is None
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ class _CommandFuseCompound:
|
||||||
|
|
||||||
def IsActive(self):
|
def IsActive(self):
|
||||||
if FreeCAD.ActiveDocument:
|
if FreeCAD.ActiveDocument:
|
||||||
return True
|
return activeBody() is None
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -395,7 +395,7 @@ class _CommandBoundBoxGroup:
|
||||||
'ToolTip': 'Bounding Box: make a box that precisely fits a shape.'}
|
'ToolTip': 'Bounding Box: make a box that precisely fits a shape.'}
|
||||||
|
|
||||||
def IsActive(self): # optional
|
def IsActive(self): # optional
|
||||||
return True
|
return activeBody() is None
|
||||||
|
|
||||||
if FreeCAD.GuiUp:
|
if FreeCAD.GuiUp:
|
||||||
FreeCADGui.addCommand('Lattice2_BoundBoxGroupCommand',_CommandBoundBoxGroup())
|
FreeCADGui.addCommand('Lattice2_BoundBoxGroupCommand',_CommandBoundBoxGroup())
|
||||||
|
|
|
@ -238,7 +238,7 @@ class GroupCommandLatticeDowngrade:
|
||||||
return { 'MenuText': 'Parametric Downgrade', 'ToolTip': 'Parametric Downgrade: downgrade and pack results into a compound.'}
|
return { 'MenuText': 'Parametric Downgrade', 'ToolTip': 'Parametric Downgrade: downgrade and pack results into a compound.'}
|
||||||
|
|
||||||
def IsActive(self): # optional
|
def IsActive(self): # optional
|
||||||
return True
|
return activeBody() is None
|
||||||
|
|
||||||
if FreeCAD.GuiUp:
|
if FreeCAD.GuiUp:
|
||||||
FreeCADGui.addCommand('Lattice2_Downgrade_GroupCommand',GroupCommandLatticeDowngrade())
|
FreeCADGui.addCommand('Lattice2_Downgrade_GroupCommand',GroupCommandLatticeDowngrade())
|
||||||
|
|
|
@ -63,7 +63,7 @@ class _CommandLatticeMakeCompound:
|
||||||
|
|
||||||
def IsActive(self):
|
def IsActive(self):
|
||||||
if FreeCAD.ActiveDocument:
|
if FreeCAD.ActiveDocument:
|
||||||
return True
|
return activeBody() is None
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -235,6 +235,9 @@ class ViewProviderLatticeMirror(LBF.ViewProviderLatticeFeature):
|
||||||
# -------------------------- Gui command --------------------------------------------------
|
# -------------------------- Gui command --------------------------------------------------
|
||||||
|
|
||||||
def CreateLatticeMirror(name, extra_code = ''):
|
def CreateLatticeMirror(name, extra_code = ''):
|
||||||
|
sel = FreeCADGui.Selection.getSelectionEx()
|
||||||
|
if not LBF.isObjectLattice(sel[0].Object) and activeBody():
|
||||||
|
raise SelectionError("PartDesign Mode", "You can only mirror placements while in body. Please deactivate the body to mirror shapes. PartDesign Feature mirroring is not supported yet.")
|
||||||
FreeCAD.ActiveDocument.openTransaction("Create LatticeMirror")
|
FreeCAD.ActiveDocument.openTransaction("Create LatticeMirror")
|
||||||
FreeCADGui.addModule("lattice2Mirror")
|
FreeCADGui.addModule("lattice2Mirror")
|
||||||
FreeCADGui.addModule("lattice2Executer")
|
FreeCADGui.addModule("lattice2Executer")
|
||||||
|
|
|
@ -34,7 +34,7 @@ from lattice2Common import *
|
||||||
import lattice2BaseFeature
|
import lattice2BaseFeature
|
||||||
import lattice2CompoundExplorer as LCE
|
import lattice2CompoundExplorer as LCE
|
||||||
import lattice2Executer
|
import lattice2Executer
|
||||||
from lattice2PopulateCopies import DereferenceArray
|
from lattice2PopulateCopies import DereferenceArray, throwBody
|
||||||
import lattice2ShapeCopy as ShapeCopy
|
import lattice2ShapeCopy as ShapeCopy
|
||||||
|
|
||||||
# -------------------------- document object --------------------------------------------------
|
# -------------------------- document object --------------------------------------------------
|
||||||
|
@ -197,6 +197,8 @@ def CreateLatticePopulateChildren(name, label, shapeObj, latticeObjFrom, lattice
|
||||||
def cmdPopulate_shapes_nonFromTo(refmode):
|
def cmdPopulate_shapes_nonFromTo(refmode):
|
||||||
sel = FreeCADGui.Selection.getSelectionEx()
|
sel = FreeCADGui.Selection.getSelectionEx()
|
||||||
(lattices, shapes) = lattice2BaseFeature.splitSelection(sel)
|
(lattices, shapes) = lattice2BaseFeature.splitSelection(sel)
|
||||||
|
if activeBody() and len(shapes)>0:
|
||||||
|
throwBody()
|
||||||
if len(shapes) > 0 and len(lattices) == 1:
|
if len(shapes) > 0 and len(lattices) == 1:
|
||||||
FreeCAD.ActiveDocument.openTransaction("Populate with Children")
|
FreeCAD.ActiveDocument.openTransaction("Populate with Children")
|
||||||
lattice = lattices[0]
|
lattice = lattices[0]
|
||||||
|
@ -224,6 +226,8 @@ def cmdPopulate_shapes_nonFromTo(refmode):
|
||||||
def cmdPopulate_shapes_FromTo():
|
def cmdPopulate_shapes_FromTo():
|
||||||
sel = FreeCADGui.Selection.getSelectionEx()
|
sel = FreeCADGui.Selection.getSelectionEx()
|
||||||
(lattices, shapes) = lattice2BaseFeature.splitSelection(sel)
|
(lattices, shapes) = lattice2BaseFeature.splitSelection(sel)
|
||||||
|
if activeBody() and len(shapes)>0:
|
||||||
|
throwBody()
|
||||||
if len(shapes) == 0 and len(sel) >= 3:
|
if len(shapes) == 0 and len(sel) >= 3:
|
||||||
shapes = sel[:-2]
|
shapes = sel[:-2]
|
||||||
lattices = sel[-2:]
|
lattices = sel[-2:]
|
||||||
|
|
|
@ -216,10 +216,15 @@ def CreateLatticePopulateCopies(name, label, shapeObj, latticeObjFrom, latticeOb
|
||||||
#finalize
|
#finalize
|
||||||
FreeCADGui.doCommand("Gui.Selection.addSelection(f)")
|
FreeCADGui.doCommand("Gui.Selection.addSelection(f)")
|
||||||
FreeCADGui.doCommand("f = None")
|
FreeCADGui.doCommand("f = None")
|
||||||
|
|
||||||
|
def throwBody():
|
||||||
|
raise SelectionError("PartDesign mode", "You can't use population tools on shapes in partdesign body. Use Lattice PartDesign Pattern instead. Or deactivate active body to use populate tools on shapes.")
|
||||||
|
|
||||||
def cmdPopulate_shapes_nonFromTo(refmode):
|
def cmdPopulate_shapes_nonFromTo(refmode):
|
||||||
sel = FreeCADGui.Selection.getSelectionEx()
|
sel = FreeCADGui.Selection.getSelectionEx()
|
||||||
(lattices, shapes) = lattice2BaseFeature.splitSelection(sel)
|
(lattices, shapes) = lattice2BaseFeature.splitSelection(sel)
|
||||||
|
if activeBody() and len(shapes)>0:
|
||||||
|
throwBody()
|
||||||
if len(shapes) > 0 and len(lattices) == 1:
|
if len(shapes) > 0 and len(lattices) == 1:
|
||||||
FreeCAD.ActiveDocument.openTransaction("Populate with copies")
|
FreeCAD.ActiveDocument.openTransaction("Populate with copies")
|
||||||
lattice = lattices[0]
|
lattice = lattices[0]
|
||||||
|
@ -247,6 +252,8 @@ def cmdPopulate_shapes_nonFromTo(refmode):
|
||||||
def cmdPopulate_shapes_FromTo():
|
def cmdPopulate_shapes_FromTo():
|
||||||
sel = FreeCADGui.Selection.getSelectionEx()
|
sel = FreeCADGui.Selection.getSelectionEx()
|
||||||
(lattices, shapes) = lattice2BaseFeature.splitSelection(sel)
|
(lattices, shapes) = lattice2BaseFeature.splitSelection(sel)
|
||||||
|
if activeBody() and len(shapes)>0:
|
||||||
|
throwBody()
|
||||||
if len(shapes) == 0 and len(sel) >= 3:
|
if len(shapes) == 0 and len(sel) >= 3:
|
||||||
shapes = sel[:-2]
|
shapes = sel[:-2]
|
||||||
lattices = sel[-2:]
|
lattices = sel[-2:]
|
||||||
|
|
|
@ -28,6 +28,7 @@ __doc__ = "Group command for Lattice Series features"
|
||||||
|
|
||||||
import lattice2ParaSeries as ParaSeries
|
import lattice2ParaSeries as ParaSeries
|
||||||
import lattice2TopoSeries as TopoSeries
|
import lattice2TopoSeries as TopoSeries
|
||||||
|
from lattice2Common import activeBody
|
||||||
|
|
||||||
import FreeCAD as App
|
import FreeCAD as App
|
||||||
if App.GuiUp:
|
if App.GuiUp:
|
||||||
|
@ -45,7 +46,7 @@ class CommandSeriesGroup:
|
||||||
'ToolTip': 'Series features (group): features that collect permutations of an object by changing dependent objects.'}
|
'ToolTip': 'Series features (group): features that collect permutations of an object by changing dependent objects.'}
|
||||||
|
|
||||||
def IsActive(self): # optional
|
def IsActive(self): # optional
|
||||||
return App.ActiveDocument is not None
|
return App.ActiveDocument is not None and activeBody() is None
|
||||||
|
|
||||||
if App.GuiUp:
|
if App.GuiUp:
|
||||||
FreeCADGui.addCommand('Lattice2_Series_GroupCommand',CommandSeriesGroup())
|
FreeCADGui.addCommand('Lattice2_Series_GroupCommand',CommandSeriesGroup())
|
||||||
|
|
|
@ -72,7 +72,8 @@ def findFont(font_file_name):
|
||||||
|
|
||||||
def makeLatticeShapeString(name):
|
def makeLatticeShapeString(name):
|
||||||
'''makeBoundBox(name): makes a BoundBox object.'''
|
'''makeBoundBox(name): makes a BoundBox object.'''
|
||||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
typ = 'Part::Part2DObjectPython' if activeBody() else 'Part::FeaturePython'
|
||||||
|
obj = FreeCAD.ActiveDocument.addObject(typ, name)
|
||||||
LatticeShapeString(obj)
|
LatticeShapeString(obj)
|
||||||
if FreeCAD.GuiUp:
|
if FreeCAD.GuiUp:
|
||||||
ViewProviderLatticeShapeString(obj.ViewObject)
|
ViewProviderLatticeShapeString(obj.ViewObject)
|
||||||
|
|
|
@ -167,7 +167,7 @@ class CommandLatticeSlice:
|
||||||
msgError(err)
|
msgError(err)
|
||||||
def IsActive(self):
|
def IsActive(self):
|
||||||
if FreeCAD.ActiveDocument:
|
if FreeCAD.ActiveDocument:
|
||||||
return True
|
return activeBody() is None
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -330,7 +330,7 @@ class CommandSublinkGroup:
|
||||||
'ToolTip': 'Sublink (group): extract elements from shapes.'}
|
'ToolTip': 'Sublink (group): extract elements from shapes.'}
|
||||||
|
|
||||||
def IsActive(self): # optional
|
def IsActive(self): # optional
|
||||||
return App.ActiveDocument is not None
|
return App.ActiveDocument is not None and activeBody() is None
|
||||||
|
|
||||||
if FreeCAD.GuiUp:
|
if FreeCAD.GuiUp:
|
||||||
FreeCADGui.addCommand('Lattice2_Sublink_GroupCommand',CommandSublinkGroup())
|
FreeCADGui.addCommand('Lattice2_Sublink_GroupCommand',CommandSublinkGroup())
|
||||||
|
|
Loading…
Reference in New Issue
Block a user