diff --git a/src/Mod/Arch/InitGui.py b/src/Mod/Arch/InitGui.py index d42972df96..24ccb5bad8 100644 --- a/src/Mod/Arch/InitGui.py +++ b/src/Mod/Arch/InitGui.py @@ -81,7 +81,7 @@ class ArchWorkbench(Workbench): "Draft_FinishLine","Draft_CloseLine"] self.draftutils = ["Draft_VisGroup","Draft_Heal","Draft_FlipDimension", "Draft_ToggleConstructionMode","Draft_ToggleContinueMode","Draft_Edit", - "Draft_Slope","Draft_SetWorkingPlaneProxy"] + "Draft_Slope","Draft_SetWorkingPlaneProxy","Draft_AddConstruction"] self.snapList = ['Draft_Snap_Lock','Draft_Snap_Midpoint','Draft_Snap_Perpendicular', 'Draft_Snap_Grid','Draft_Snap_Intersection','Draft_Snap_Parallel', 'Draft_Snap_Endpoint','Draft_Snap_Angle','Draft_Snap_Center', diff --git a/src/Mod/Draft/DraftTools.py b/src/Mod/Draft/DraftTools.py index dda1bab308..38eca101af 100644 --- a/src/Mod/Draft/DraftTools.py +++ b/src/Mod/Draft/DraftTools.py @@ -5358,6 +5358,37 @@ class Draft_Label(Creator): self.create() +class Draft_AddConstruction(): + + def GetResources(self): + return {'Pixmap' : 'Draft_Construction', + 'MenuText': QtCore.QT_TRANSLATE_NOOP("Draft_AddConstruction", "Add to Construction group"), + 'ToolTip' : QtCore.QT_TRANSLATE_NOOP("Draft_AddConstruction", "Adds the selected objects to the Construction group")} + + def Activated(self): + import FreeCADGui + if hasattr(FreeCADGui,"draftToolBar"): + col = FreeCADGui.draftToolBar.getDefaultColor("constr") + col = (float(col[0]),float(col[1]),float(col[2]),0.0) + gname = Draft.getParam("constructiongroupname","Construction") + grp = FreeCAD.ActiveDocument.getObject(gname) + if not grp: + grp = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroup",gname) + for obj in FreeCADGui.Selection.getSelection(): + grp.addObject(obj) + obrep = obj.ViewObject + if "TextColor" in obrep.PropertiesList: + obrep.TextColor = col + if "PointColor" in obrep.PropertiesList: + obrep.PointColor = col + if "LineColor" in obrep.PropertiesList: + obrep.LineColor = col + if "ShapeColor" in obrep.PropertiesList: + obrep.ShapeColor = col + if hasattr(obrep,"Transparency"): + obrep.Transparency = 80 + + #--------------------------------------------------------------------------- # Snap tools #--------------------------------------------------------------------------- @@ -5602,6 +5633,7 @@ FreeCADGui.addCommand('Draft_ToggleGrid',ToggleGrid()) FreeCADGui.addCommand('Draft_FlipDimension',Draft_FlipDimension()) FreeCADGui.addCommand('Draft_AutoGroup',SetAutoGroup()) FreeCADGui.addCommand('Draft_SetWorkingPlaneProxy',SetWorkingPlaneProxy()) +FreeCADGui.addCommand('Draft_AddConstruction',Draft_AddConstruction()) # snap commands FreeCADGui.addCommand('Draft_Snap_Lock',Draft_Snap_Lock()) diff --git a/src/Mod/Draft/InitGui.py b/src/Mod/Draft/InitGui.py index 33a8712913..28d972da71 100644 --- a/src/Mod/Draft/InitGui.py +++ b/src/Mod/Draft/InitGui.py @@ -83,7 +83,7 @@ class DraftWorkbench (Workbench): self.lineList = ["Draft_UndoLine","Draft_FinishLine","Draft_CloseLine"] self.utils = ["Draft_VisGroup","Draft_Heal","Draft_FlipDimension", "Draft_ToggleConstructionMode","Draft_ToggleContinueMode","Draft_Edit", - "Draft_Slope","Draft_SetWorkingPlaneProxy"] + "Draft_Slope","Draft_SetWorkingPlaneProxy","Draft_AddConstruction"] self.snapList = ['Draft_Snap_Lock','Draft_Snap_Midpoint','Draft_Snap_Perpendicular', 'Draft_Snap_Grid','Draft_Snap_Intersection','Draft_Snap_Parallel', 'Draft_Snap_Endpoint','Draft_Snap_Angle','Draft_Snap_Center',