diff --git a/src/Mod/Arch/ArchBuilding.py b/src/Mod/Arch/ArchBuilding.py
index f8a6ac4d0..83b4be7b2 100644
--- a/src/Mod/Arch/ArchBuilding.py
+++ b/src/Mod/Arch/ArchBuilding.py
@@ -244,7 +244,9 @@ Building creation aborted.\n" )
ss += "]"
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Building"))
FreeCADGui.addModule("Arch")
- FreeCADGui.doCommand("Arch.makeBuilding("+ss+")")
+ FreeCADGui.doCommand("obj = Arch.makeBuilding("+ss+")")
+ FreeCADGui.addModule("Draft")
+ FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
diff --git a/src/Mod/Arch/ArchCommands.py b/src/Mod/Arch/ArchCommands.py
index 873309528..30a5443de 100644
--- a/src/Mod/Arch/ArchCommands.py
+++ b/src/Mod/Arch/ArchCommands.py
@@ -1290,9 +1290,11 @@ class _CommandComponent:
if sel:
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Component"))
FreeCADGui.addModule("Arch")
+ FreeCADGui.addModule("Draft")
FreeCADGui.Control.closeDialog()
for o in sel:
- FreeCADGui.doCommand("Arch.makeComponent(FreeCAD.ActiveDocument."+o.Name+")")
+ FreeCADGui.doCommand("obj = Arch.makeComponent(FreeCAD.ActiveDocument."+o.Name+")")
+ FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
@@ -1313,9 +1315,11 @@ class _CommandCloneComponent:
if sel:
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Component"))
FreeCADGui.addModule("Arch")
+ FreeCADGui.addModule("Draft")
FreeCADGui.Control.closeDialog()
for o in sel:
- FreeCADGui.doCommand("Arch.cloneComponent(FreeCAD.ActiveDocument."+o.Name+")")
+ FreeCADGui.doCommand("obj = Arch.cloneComponent(FreeCAD.ActiveDocument."+o.Name+")")
+ FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
diff --git a/src/Mod/Arch/ArchEquipment.py b/src/Mod/Arch/ArchEquipment.py
index aece75593..bfc5f2bb2 100644
--- a/src/Mod/Arch/ArchEquipment.py
+++ b/src/Mod/Arch/ArchEquipment.py
@@ -192,7 +192,9 @@ class _CommandEquipment:
base = s[0].Name
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Equipment")))
FreeCADGui.addModule("Arch")
- FreeCADGui.doCommand("Arch.makeEquipment(FreeCAD.ActiveDocument." + base + ")")
+ FreeCADGui.doCommand("obj = Arch.makeEquipment(FreeCAD.ActiveDocument." + base + ")")
+ FreeCADGui.addModule("Draft")
+ FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
# get diffuse color info from base object
diff --git a/src/Mod/Arch/ArchFloor.py b/src/Mod/Arch/ArchFloor.py
index 03f666824..754689b9d 100644
--- a/src/Mod/Arch/ArchFloor.py
+++ b/src/Mod/Arch/ArchFloor.py
@@ -103,7 +103,9 @@ Floor creation aborted.\n" )
ss += "]"
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Floor"))
FreeCADGui.addModule("Arch")
- FreeCADGui.doCommand("Arch.makeFloor("+ss+")")
+ FreeCADGui.doCommand("obj = Arch.makeFloor("+ss+")")
+ FreeCADGui.addModule("Draft")
+ FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
diff --git a/src/Mod/Arch/ArchFrame.py b/src/Mod/Arch/ArchFrame.py
index 54672bc13..bcb227eb3 100644
--- a/src/Mod/Arch/ArchFrame.py
+++ b/src/Mod/Arch/ArchFrame.py
@@ -84,7 +84,9 @@ class _CommandFrame:
if len(s) == 2:
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Frame"))
FreeCADGui.addModule("Arch")
- FreeCADGui.doCommand("Arch.makeFrame(FreeCAD.ActiveDocument."+s[0].Name+",FreeCAD.ActiveDocument."+s[1].Name+")")
+ FreeCADGui.doCommand("obj = Arch.makeFrame(FreeCAD.ActiveDocument."+s[0].Name+",FreeCAD.ActiveDocument."+s[1].Name+")")
+ FreeCADGui.addModule("Draft")
+ FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
diff --git a/src/Mod/Arch/ArchPanel.py b/src/Mod/Arch/ArchPanel.py
index 2208d288a..19688ff21 100644
--- a/src/Mod/Arch/ArchPanel.py
+++ b/src/Mod/Arch/ArchPanel.py
@@ -151,8 +151,10 @@ class CommandPanel:
return
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Panel")))
FreeCADGui.addModule("Arch")
+ FreeCADGui.addModule("Draft")
for obj in sel:
- FreeCADGui.doCommand("Arch.makePanel(FreeCAD.ActiveDocument." + obj.Name + ",thickness=" + str(self.Thickness) + ")")
+ FreeCADGui.doCommand("obj = Arch.makePanel(FreeCAD.ActiveDocument." + obj.Name + ",thickness=" + str(self.Thickness) + ")")
+ FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
return
diff --git a/src/Mod/Arch/ArchPipe.py b/src/Mod/Arch/ArchPipe.py
index 8d71e7be9..7a2e96547 100644
--- a/src/Mod/Arch/ArchPipe.py
+++ b/src/Mod/Arch/ArchPipe.py
@@ -117,12 +117,16 @@ class _CommandPipe:
if len(obj.Shape.Wires) == 1:
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Pipe"))
FreeCADGui.addModule("Arch")
- FreeCADGui.doCommand("Arch.makePipe(FreeCAD.ActiveDocument."+obj.Name+")")
+ FreeCADGui.doCommand("obj = Arch.makePipe(FreeCAD.ActiveDocument."+obj.Name+")")
+ FreeCADGui.addModule("Draft")
+ FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
else:
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Pipe"))
FreeCADGui.addModule("Arch")
- FreeCADGui.doCommand("Arch.makePipe()")
+ FreeCADGui.doCommand("obj = Arch.makePipe()")
+ FreeCADGui.addModule("Draft")
+ FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
@@ -159,7 +163,9 @@ class _CommandPipeConnector:
o += "]"
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Connector"))
FreeCADGui.addModule("Arch")
- FreeCADGui.doCommand("Arch.makePipeConnector("+o+")")
+ FreeCADGui.doCommand("obj = Arch.makePipeConnector("+o+")")
+ FreeCADGui.addModule("Draft")
+ FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
diff --git a/src/Mod/Arch/ArchRoof.py b/src/Mod/Arch/ArchRoof.py
index 195023c87..f2e3d677d 100644
--- a/src/Mod/Arch/ArchRoof.py
+++ b/src/Mod/Arch/ArchRoof.py
@@ -139,7 +139,9 @@ class _CommandRoof:
idx = int(sel.SubElementNames[0][4:])
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Roof"))
FreeCADGui.addModule("Arch")
- FreeCADGui.doCommand("Arch.makeRoof(FreeCAD.ActiveDocument."+obj.Name+","+str(idx)+")")
+ FreeCADGui.doCommand("obj = Arch.makeRoof(FreeCAD.ActiveDocument."+obj.Name+","+str(idx)+")")
+ FreeCADGui.addModule("Draft")
+ FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
return
@@ -147,7 +149,9 @@ class _CommandRoof:
if obj.Shape.Wires:
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Roof"))
FreeCADGui.addModule("Arch")
- FreeCADGui.doCommand("Arch.makeRoof(FreeCAD.ActiveDocument."+obj.Name+")")
+ FreeCADGui.doCommand("obj = Arch.makeRoof(FreeCAD.ActiveDocument."+obj.Name+")")
+ FreeCADGui.addModule("Draft")
+ FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
return
diff --git a/src/Mod/Arch/ArchSite.py b/src/Mod/Arch/ArchSite.py
index 567b4c432..02af353bc 100644
--- a/src/Mod/Arch/ArchSite.py
+++ b/src/Mod/Arch/ArchSite.py
@@ -290,7 +290,9 @@ Site creation aborted." )
ss += "]"
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Site"))
FreeCADGui.addModule("Arch")
- FreeCADGui.doCommand("Arch.makeSite("+ss+")")
+ FreeCADGui.doCommand("obj = Arch.makeSite("+ss+")")
+ FreeCADGui.addModule("Draft")
+ FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
diff --git a/src/Mod/Arch/ArchSpace.py b/src/Mod/Arch/ArchSpace.py
index 2247ebd2c..f4c28de43 100644
--- a/src/Mod/Arch/ArchSpace.py
+++ b/src/Mod/Arch/ArchSpace.py
@@ -229,9 +229,11 @@ class _CommandSpace:
if sel:
FreeCADGui.Control.closeDialog()
if len(sel) == 1:
- FreeCADGui.doCommand("Arch.makeSpace(FreeCADGui.Selection.getSelection())")
+ FreeCADGui.doCommand("obj = Arch.makeSpace(FreeCADGui.Selection.getSelection())")
else:
- FreeCADGui.doCommand("Arch.makeSpace(FreeCADGui.Selection.getSelectionEx())")
+ FreeCADGui.doCommand("obj = Arch.makeSpace(FreeCADGui.Selection.getSelectionEx())")
+ FreeCADGui.addModule("Draft")
+ FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
else:
diff --git a/src/Mod/Arch/ArchStairs.py b/src/Mod/Arch/ArchStairs.py
index 1cd192d3f..15f219670 100644
--- a/src/Mod/Arch/ArchStairs.py
+++ b/src/Mod/Arch/ArchStairs.py
@@ -91,9 +91,11 @@ class _CommandStairs:
FreeCADGui.addModule("Arch")
if len(FreeCADGui.Selection.getSelection()) == 1:
n = FreeCADGui.Selection.getSelection()[0].Name
- FreeCADGui.doCommand("Arch.makeStairs(baseobj=FreeCAD.ActiveDocument."+n+")")
+ FreeCADGui.doCommand("obj = Arch.makeStairs(baseobj=FreeCAD.ActiveDocument."+n+")")
else:
- FreeCADGui.doCommand("Arch.makeStairs(steps="+str(p.GetInt("StairsSteps",17))+")")
+ FreeCADGui.doCommand("obj = Arch.makeStairs(steps="+str(p.GetInt("StairsSteps",17))+")")
+ FreeCADGui.addModule("Draft")
+ FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
diff --git a/src/Mod/Arch/ArchStructure.py b/src/Mod/Arch/ArchStructure.py
index 2da8a4de8..38f474342 100644
--- a/src/Mod/Arch/ArchStructure.py
+++ b/src/Mod/Arch/ArchStructure.py
@@ -155,9 +155,11 @@ class _CommandStructure:
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Structural System")))
FreeCADGui.addModule("Arch")
if st:
- FreeCADGui.doCommand("Arch.makeStructuralSystem(" + ArchCommands.getStringList(st) + "," + ArchCommands.getStringList(ax) + ")")
+ FreeCADGui.doCommand("obj = Arch.makeStructuralSystem(" + ArchCommands.getStringList(st) + "," + ArchCommands.getStringList(ax) + ")")
else:
- FreeCADGui.doCommand("Arch.makeStructuralSystem(axes=" + ArchCommands.getStringList(ax) + ")")
+ FreeCADGui.doCommand("obj = Arch.makeStructuralSystem(axes=" + ArchCommands.getStringList(ax) + ")")
+ FreeCADGui.addModule("Draft")
+ FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
return
@@ -165,7 +167,9 @@ class _CommandStructure:
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Structure")))
FreeCADGui.addModule("Arch")
for obj in sel:
- FreeCADGui.doCommand("Arch.makeStructure(FreeCAD.ActiveDocument." + obj.Name + ")")
+ FreeCADGui.doCommand("obj = Arch.makeStructure(FreeCAD.ActiveDocument." + obj.Name + ")")
+ FreeCADGui.addModule("Draft")
+ FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
return
@@ -226,6 +230,8 @@ class _CommandStructure:
FreeCADGui.doCommand('s = Arch.makeStructure(length='+str(self.Length)+',width='+str(self.Width)+',height='+str(self.Height)+')')
FreeCADGui.doCommand('s.Placement.Base = '+DraftVecUtils.toString(point))
FreeCADGui.doCommand('s.Placement.Rotation=s.Placement.Rotation.multiply(FreeCAD.DraftWorkingPlane.getRotation().Rotation)')
+ FreeCADGui.addModule("Draft")
+ FreeCADGui.doCommand("Draft.autogroup(s)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
if self.continueCmd:
diff --git a/src/Mod/Arch/ArchWall.py b/src/Mod/Arch/ArchWall.py
index fad2577ea..a6d8efef2 100644
--- a/src/Mod/Arch/ArchWall.py
+++ b/src/Mod/Arch/ArchWall.py
@@ -198,12 +198,14 @@ class _CommandWall:
if selobj.HasSubObjects:
if "Face" in selobj.SubElementNames[0]:
idx = int(selobj.SubElementNames[0][4:])
- FreeCADGui.doCommand("Arch.makeWall(FreeCAD.ActiveDocument."+selobj.Object.Name+",face="+str(idx)+")")
+ FreeCADGui.doCommand("obj = Arch.makeWall(FreeCAD.ActiveDocument."+selobj.Object.Name+",face="+str(idx)+")")
spacedone = True
if not spacedone:
- FreeCADGui.doCommand('Arch.makeWall(FreeCAD.ActiveDocument.'+selobj.Object.Name+')')
+ FreeCADGui.doCommand('obj = Arch.makeWall(FreeCAD.ActiveDocument.'+selobj.Object.Name+')')
else:
- FreeCADGui.doCommand('Arch.makeWall(FreeCAD.ActiveDocument.'+selobj.Object.Name+')')
+ FreeCADGui.doCommand('obj = Arch.makeWall(FreeCAD.ActiveDocument.'+selobj.Object.Name+')')
+ FreeCADGui.addModule("Draft")
+ FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
done = True
@@ -273,6 +275,8 @@ class _CommandWall:
FreeCADGui.doCommand('base.addGeometry(trace)')
FreeCADGui.doCommand('wall = Arch.makeWall(base,width='+str(self.Width)+',height='+str(self.Height)+',align="'+str(self.Align)+'")')
FreeCADGui.doCommand('wall.Normal = FreeCAD.DraftWorkingPlane.axis')
+ FreeCADGui.addModule("Draft")
+ FreeCADGui.doCommand("Draft.autogroup(wall)")
def update(self,point,info):
"this function is called by the Snapper when the mouse is moved"
diff --git a/src/Mod/Arch/InitGui.py b/src/Mod/Arch/InitGui.py
index 9ea142e70..7e4937d2b 100644
--- a/src/Mod/Arch/InitGui.py
+++ b/src/Mod/Arch/InitGui.py
@@ -57,7 +57,7 @@ class ArchWorkbench(Workbench):
"Draft_Clone"]
self.draftextratools = ["Draft_WireToBSpline","Draft_AddPoint","Draft_DelPoint","Draft_ShapeString",
"Draft_PathArray","Draft_Mirror","Draft_Stretch"]
- self.draftcontexttools = ["Draft_ApplyStyle","Draft_ToggleDisplayMode","Draft_AddToGroup",
+ self.draftcontexttools = ["Draft_ApplyStyle","Draft_ToggleDisplayMode","Draft_AddToGroup","Draft_AutoGroup",
"Draft_SelectGroup","Draft_SelectPlane",
"Draft_ShowSnapBar","Draft_ToggleGrid","Draft_UndoLine",
"Draft_FinishLine","Draft_CloseLine"]
diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py
index 960885ac7..fac0c8188 100644
--- a/src/Mod/Draft/Draft.py
+++ b/src/Mod/Draft/Draft.py
@@ -233,7 +233,7 @@ def getGroupNames():
glist = []
doc = FreeCAD.ActiveDocument
for obj in doc.Objects:
- if obj.TypeId == "App::DocumentObjectGroup":
+ if obj.isDerivedFrom("App::DocumentObjectGroup") or (getType(obj) in ["Floor","Building","Site"]):
glist.append(obj.Name)
return glist
@@ -243,6 +243,23 @@ def ungroup(obj):
grp = FreeCAD.ActiveDocument.getObject(g)
if grp.hasObject(obj):
grp.removeObject(obj)
+
+def autogroup(obj):
+ "adds a given object to the autogroup, if applicable"
+ if FreeCAD.GuiUp:
+ if hasattr(FreeCADGui,"draftToolBar"):
+ if hasattr(FreeCADGui.draftToolBar,"autogroup") and (not FreeCADGui.draftToolBar.isConstructionMode()):
+ if FreeCADGui.draftToolBar.autogroup != None:
+ g = FreeCAD.ActiveDocument.getObject(FreeCADGui.draftToolBar.autogroup)
+ if g:
+ found = False
+ for o in g.Group:
+ if o.Name == obj.Name:
+ found = True
+ if not found:
+ gr = g.Group
+ gr.append(obj)
+ g.Group = gr
def dimSymbol(symbol=None,invert=False):
"returns the current dim symbol from the preferences as a pivy SoMarkerSet"
@@ -1168,6 +1185,7 @@ def extrude(obj,vector,solid=False):
if gui:
obj.ViewObject.Visibility = False
formatObject(newobj,obj)
+ select(newobj)
FreeCAD.ActiveDocument.recompute()
return newobj
@@ -1203,6 +1221,7 @@ def fuse(object1,object2):
object1.ViewObject.Visibility = False
object2.ViewObject.Visibility = False
formatObject(obj,object1)
+ select(obj)
FreeCAD.ActiveDocument.recompute()
return obj
@@ -1215,6 +1234,7 @@ def cut(object1,object2):
object1.ViewObject.Visibility = False
object2.ViewObject.Visibility = False
formatObject(obj,object1)
+ select(obj)
FreeCAD.ActiveDocument.recompute()
return obj
@@ -1282,7 +1302,7 @@ def move(objectslist,vector,copy=False):
if copy and getParam("selectBaseObjects",False):
select(objectslist)
else:
- select(newobjlist)
+ select(newobjlist)
if len(newobjlist) == 1: return newobjlist[0]
return newobjlist
@@ -1438,7 +1458,8 @@ def scale(objectslist,delta=Vector(1,1,1),center=Vector(0,0,0),copy=False,legacy
elif (obj.TypeId == "App::Annotation"):
factor = delta.x * delta.y * delta.z * obj.ViewObject.FontSize.Value
obj.ViewObject.Fontsize = factor
- if copy: formatObject(newobj,obj)
+ if copy:
+ formatObject(newobj,obj)
newobjlist.append(newobj)
if copy and getParam("selectBaseObjects",False):
select(objectslist)
@@ -2775,6 +2796,7 @@ def makePoint(X=0, Y=0, Z=0,color=None,name = "Point", point_size= 5):
obj.ViewObject.PointColor = (float(color[0]), float(color[1]), float(color[2]))
obj.ViewObject.PointSize = point_size
obj.ViewObject.Visibility = True
+ select(obj)
FreeCAD.ActiveDocument.recompute()
return obj
@@ -2968,6 +2990,7 @@ def makeFacebinder(selectionset,name="Facebinder"):
_ViewProviderFacebinder(fb.ViewObject)
faces = []
fb.Proxy.addSubobjects(fb,selectionset)
+ select(fb)
return fb
@@ -3330,7 +3353,6 @@ def upgrade(objects,delete=False,force=None):
deleteList = []
for n in names:
FreeCAD.ActiveDocument.removeObject(n)
-
return [addList,deleteList]
def downgrade(objects,delete=False,force=None):
@@ -3531,7 +3553,6 @@ def downgrade(objects,delete=False,force=None):
deleteList = []
for n in names:
FreeCAD.ActiveDocument.removeObject(n)
-
return [addList,deleteList]
diff --git a/src/Mod/Draft/DraftGui.py b/src/Mod/Draft/DraftGui.py
index 184220f1f..cfe9998d8 100644
--- a/src/Mod/Draft/DraftGui.py
+++ b/src/Mod/Draft/DraftGui.py
@@ -256,6 +256,7 @@ class DraftToolBar:
self.y = 0
self.z = 0
self.uiloader = FreeCADGui.UiLoader()
+ self.autogroup = None
if self.taskmode:
# add only a dummy widget, since widgets are created on demand
@@ -604,6 +605,8 @@ class DraftToolBar:
self.widthButton.setSuffix("px")
self.fontsizeButton = self._spinbox("fontsizeButton",self.bottomtray, val=self.fontsize,vmax=999, hide=False,double=True,size=(bsize * 3,bsize))
self.applyButton = self._pushbutton("applyButton", self.toptray, hide=False, icon='Draft_Apply',width=22)
+ self.autoGroupButton = self._pushbutton("autoGroup",self.bottomtray,icon="Draft_AutoGroup_off",hide=False,width=120)
+ self.autoGroupButton.setText("None")
QtCore.QObject.connect(self.wplabel,QtCore.SIGNAL("pressed()"),self.selectplane)
QtCore.QObject.connect(self.colorButton,QtCore.SIGNAL("pressed()"),self.getcol)
@@ -612,6 +615,7 @@ class DraftToolBar:
QtCore.QObject.connect(self.fontsizeButton,QtCore.SIGNAL("valueChanged(double)"),self.setfontsize)
QtCore.QObject.connect(self.applyButton,QtCore.SIGNAL("pressed()"),self.apply)
QtCore.QObject.connect(self.constrButton,QtCore.SIGNAL("toggled(bool)"),self.toggleConstrMode)
+ QtCore.QObject.connect(self.autoGroupButton,QtCore.SIGNAL("pressed()"),self.runAutoGroup)
def setupStyle(self):
style = "#constrButton:Checked {background-color: "
@@ -725,6 +729,7 @@ class DraftToolBar:
self.fontsizeButton.setToolTip(translate("draft", "Font Size"))
self.applyButton.setToolTip(translate("draft", "Apply to selected objects"))
self.constrButton.setToolTip(translate("draft", "Toggles Construction Mode"))
+ self.autoGroupButton.setToolTip(translate("draft", "Sets/unsets auto-grouping"))
#---------------------------------------------------------------------------
# Interface modes
@@ -1728,6 +1733,27 @@ class DraftToolBar:
self.radiusValue.setText(t)
self.radiusValue.setFocus()
+ def runAutoGroup(self):
+ FreeCADGui.runCommand("Draft_AutoGroup")
+
+ def setAutoGroup(self,value=None):
+ if value == None:
+ self.autogroup = None
+ self.autoGroupButton.setText("None")
+ self.autoGroupButton.setIcon(QtGui.QIcon(':/icons/Draft_AutoGroup_off.svg'))
+ self.autoGroupButton.setDown(False)
+ else:
+ obj = FreeCAD.ActiveDocument.getObject(value)
+ if obj:
+ self.autogroup = value
+ self.autoGroupButton.setText(obj.Label)
+ self.autoGroupButton.setIcon(QtGui.QIcon(':/icons/Draft_AutoGroup_on.svg'))
+ self.autoGroupButton.setDown(False)
+ else:
+ self.autogroup = None
+ self.autoGroupButton.setText("None")
+ self.autoGroupButton.setIcon(QtGui.QIcon(':/icons/Draft_AutoGroup_off.svg'))
+ self.autoGroupButton.setDown(False)
def show(self):
if not self.taskmode:
diff --git a/src/Mod/Draft/DraftTools.py b/src/Mod/Draft/DraftTools.py
index bf60ce109..a71f79369 100644
--- a/src/Mod/Draft/DraftTools.py
+++ b/src/Mod/Draft/DraftTools.py
@@ -475,14 +475,16 @@ class Line(Creator):
'line.Z1 = '+str(p1.z),
'line.X2 = '+str(p2.x),
'line.Y2 = '+str(p2.y),
- 'line.Z2 = '+str(p2.z)])
+ 'line.Z2 = '+str(p2.z),
+ 'Draft.autogroup(line)'])
else:
# building command string
rot,sup,pts,fil = self.getStrings()
FreeCADGui.addModule("Draft")
self.commit(translate("draft","Create DWire"),
['points='+pts,
- 'Draft.makeWire(points,closed='+str(closed)+',face='+fil+',support='+sup+')'])
+ 'line = Draft.makeWire(points,closed='+str(closed)+',face='+fil+',support='+sup+')',
+ 'Draft.autogroup(line)'])
Creator.finish(self)
if self.ui:
if self.ui.continueMode:
@@ -609,7 +611,7 @@ class Wire(Line):
rems = ["FreeCAD.ActiveDocument.removeObject(\""+o.Name+"\")" for o in FreeCADGui.Selection.getSelection()]
FreeCADGui.addModule("Draft")
todo.delayCommit([(translate("draft","Convert to Wire"),
- ['Draft.makeWire(['+pts+'])']+rems)])
+ ['wire = Draft.makeWire(['+pts+'])']+rems+['Draft.autogroup(wire)'])])
return
Line.Activated(self,name=translate("draft","DWire"))
@@ -703,8 +705,9 @@ class BSpline(Line):
rot,sup,pts,fil = self.getStrings()
FreeCADGui.addModule("Draft")
self.commit(translate("draft","Create BSpline"),
- ['points='+pts,
- 'Draft.makeBSpline(points,closed='+str(closed)+',face='+fil+',support='+sup+')'])
+ ['points = '+pts,
+ 'spline = Draft.makeBSpline(points,closed='+str(closed)+',face='+fil+',support='+sup+')',
+ 'Draft.autogroup(spline)'])
except:
print("Draft: error delaying commit")
Creator.finish(self)
@@ -806,8 +809,9 @@ class BezCurve(Line):
rot,sup,pts,fil = self.getStrings()
FreeCADGui.addModule("Draft")
self.commit(translate("draft","Create BezCurve"),
- ['points='+pts,
- 'Draft.makeBezCurve(points,closed='+str(closed)+',support='+sup+')'])
+ ['points = '+pts,
+ 'bez = Draft.makeBezCurve(points,closed='+str(closed)+',support='+sup+')',
+ 'Draft.autogroup(bez)'])
except:
print("Draft: error delaying commit")
Creator.finish(self)
@@ -935,14 +939,16 @@ class Rectangle(Creator):
'pl = FreeCAD.Placement()',
'pl.Rotation.Q='+rot,
'pl.Base = '+DraftVecUtils.toString(base),
- 'plane.Placement = pl'])
+ 'plane.Placement = pl',
+ 'Draft.autogroup(plane)'])
else:
FreeCADGui.addModule("Draft")
self.commit(translate("draft","Create Rectangle"),
['pl = FreeCAD.Placement()',
'pl.Rotation.Q = '+rot,
'pl.Base = '+DraftVecUtils.toString(base),
- 'Draft.makeRectangle(length='+str(length)+',height='+str(height)+',placement=pl,face='+fil+',support='+sup+')'])
+ 'rec = Draft.makeRectangle(length='+str(length)+',height='+str(height)+',placement=pl,face='+fil+',support='+sup+')',
+ 'Draft.autogroup(rec)'])
except:
print("Draft: error delaying commit")
self.finish(cont=True)
@@ -1193,7 +1199,8 @@ class Arc(Creator):
'pl = FreeCAD.Placement()',
'pl.Rotation.Q = '+rot,
'pl.Base = '+DraftVecUtils.toString(self.center),
- 'circle.Placement = pl'])
+ 'circle.Placement = pl',
+ 'Draft.autogroup(circle)'])
else:
# building command string
FreeCADGui.addModule("Draft")
@@ -1201,7 +1208,8 @@ class Arc(Creator):
['pl=FreeCAD.Placement()',
'pl.Rotation.Q='+rot,
'pl.Base='+DraftVecUtils.toString(self.center),
- 'Draft.makeCircle(radius='+str(self.rad)+',placement=pl,face='+fil+',support='+sup+')'])
+ 'circle = Draft.makeCircle(radius='+str(self.rad)+',placement=pl,face='+fil+',support='+sup+')',
+ 'Draft.autogroup(circle)'])
except:
print("Draft: error delaying commit")
else:
@@ -1226,7 +1234,8 @@ class Arc(Creator):
'pl = FreeCAD.Placement()',
'pl.Rotation.Q = '+rot,
'pl.Base = '+DraftVecUtils.toString(self.center),
- 'circle.Placement = pl'])
+ 'circle.Placement = pl',
+ 'Draft.autogroup(circle)'])
else:
# building command string
FreeCADGui.addModule("Draft")
@@ -1234,7 +1243,8 @@ class Arc(Creator):
['pl=FreeCAD.Placement()',
'pl.Rotation.Q='+rot,
'pl.Base='+DraftVecUtils.toString(self.center),
- 'Draft.makeCircle(radius='+str(self.rad)+',placement=pl,face='+fil+',startangle='+str(sta)+',endangle='+str(end)+',support='+sup+')'])
+ 'circle = Draft.makeCircle(radius='+str(self.rad)+',placement=pl,face='+fil+',startangle='+str(sta)+',endangle='+str(end)+',support='+sup+')',
+ 'Draft.autogroup(circle)'])
except:
print("Draft: error delaying commit")
self.finish(cont=True)
@@ -1449,15 +1459,17 @@ class Polygon(Creator):
'pol.Polygon = ' + str(self.ui.numFaces.value()),
'pol.Circumradius = ' + str(self.rad),
'pol.Placement = pl',
+ 'Draft.autogroup(pol)'
'FreeCAD.ActiveDocument.recompute()'])
else:
# building command string
FreeCADGui.addModule("Draft")
self.commit(translate("draft","Create Polygon"),
['pl=FreeCAD.Placement()',
- 'pl.Rotation.Q=' + rot,
- 'pl.Base=' + DraftVecUtils.toString(self.center),
- 'Draft.makePolygon(' + str(self.ui.numFaces.value()) + ',radius=' + str(self.rad) + ',inscribed=True,placement=pl,face=' + fil + ',support=' + sup + ')'])
+ 'pl.Rotation.Q = ' + rot,
+ 'pl.Base = ' + DraftVecUtils.toString(self.center),
+ 'pol = Draft.makePolygon(' + str(self.ui.numFaces.value()) + ',radius=' + str(self.rad) + ',inscribed=True,placement=pl,face=' + fil + ',support=' + sup + ')',
+ 'Draft.autogroup(pol)'])
FreeCAD.ActiveDocument.recompute()
self.finish(cont=True)
@@ -1553,14 +1565,16 @@ class Ellipse(Creator):
'pl = FreeCAD.Placement()',
'pl.Rotation.Q='+rot,
'pl.Base = '+DraftVecUtils.toString(center),
- 'ellipse.Placement = pl'])
+ 'ellipse.Placement = pl',
+ 'Draft.autogroup(ellipse)'])
else:
FreeCADGui.addModule("Draft")
self.commit(translate("draft","Create Ellipse"),
['pl = FreeCAD.Placement()',
- 'pl.Rotation.Q='+rot,
+ 'pl.Rotation.Q = '+rot,
'pl.Base = '+DraftVecUtils.toString(center),
- 'Draft.makeEllipse('+str(r1)+','+str(r2)+',placement=pl,face='+fil+',support='+sup+')'])
+ 'ellipse = Draft.makeEllipse('+str(r1)+','+str(r2)+',placement=pl,face='+fil+',support='+sup+')',
+ 'Draft.autogroup(ellipse)'])
except:
print("Draft: Error: Unable to create object.")
self.finish(cont=True)
@@ -1646,7 +1660,8 @@ class Text(Creator):
tx += ']'
FreeCADGui.addModule("Draft")
self.commit(translate("draft","Create Text"),
- ['Draft.makeText('+tx+',point='+DraftVecUtils.toString(self.node[0])+')'])
+ ['text = Draft.makeText('+tx+',point='+DraftVecUtils.toString(self.node[0])+')',
+ 'Draft.autogroup(text)'])
self.finish(cont=True)
@@ -1779,8 +1794,9 @@ class Dimension(Creator):
p3 = Vector(pt.point.getValues()[2].getValue())
FreeCADGui.addModule("Draft")
self.commit(translate("draft","Create Dimension"),
- ['Draft.makeDimension('+DraftVecUtils.toString(p1)+','+DraftVecUtils.toString(p2)+','+DraftVecUtils.toString(p3)+')',
- 'FreeCAD.ActiveDocument.removeObject("'+o.Name+'")'])
+ ['dim = Draft.makeDimension('+DraftVecUtils.toString(p1)+','+DraftVecUtils.toString(p2)+','+DraftVecUtils.toString(p3)+')',
+ 'FreeCAD.ActiveDocument.removeObject("'+o.Name+'")',
+ 'Draft.autogroup(dim)'])
def createObject(self):
"creates an object in the current doc"
@@ -1793,24 +1809,30 @@ class Dimension(Creator):
v2 = DraftGeomUtils.vec(self.edges[1])
normal = DraftVecUtils.toString((v1.cross(v2)).normalize())
self.commit(translate("draft","Create Dimension"),
- ['Draft.makeAngularDimension(center='+DraftVecUtils.toString(self.center)+',angles=['+str(self.angledata[0])+','+str(self.angledata[1])+'],p3='+DraftVecUtils.toString(self.node[-1])+',normal='+normal+')'])
+ ['dim = Draft.makeAngularDimension(center='+DraftVecUtils.toString(self.center)+',angles=['+str(self.angledata[0])+','+str(self.angledata[1])+'],p3='+DraftVecUtils.toString(self.node[-1])+',normal='+normal+')',
+ 'Draft.autogroup(dim)'])
elif self.link and (not self.arcmode):
ops = []
if self.force == 1:
self.commit(translate("draft","Create Dimension"),
- ['dim = Draft.makeDimension(FreeCAD.ActiveDocument.'+self.link[0].Name+','+str(self.link[1])+','+str(self.link[2])+','+DraftVecUtils.toString(self.node[2])+')','dim.Direction=FreeCAD.Vector(0,1,0)'])
+ ['dim = Draft.makeDimension(FreeCAD.ActiveDocument.'+self.link[0].Name+','+str(self.link[1])+','+str(self.link[2])+','+DraftVecUtils.toString(self.node[2])+')','dim.Direction=FreeCAD.Vector(0,1,0)',
+ 'Draft.autogroup(dim)'])
elif self.force == 2:
self.commit(translate("draft","Create Dimension"),
- ['dim = Draft.makeDimension(FreeCAD.ActiveDocument.'+self.link[0].Name+','+str(self.link[1])+','+str(self.link[2])+','+DraftVecUtils.toString(self.node[2])+')','dim.Direction=FreeCAD.Vector(1,0,0)'])
+ ['dim = Draft.makeDimension(FreeCAD.ActiveDocument.'+self.link[0].Name+','+str(self.link[1])+','+str(self.link[2])+','+DraftVecUtils.toString(self.node[2])+')','dim.Direction=FreeCAD.Vector(1,0,0)',
+ 'Draft.autogroup(dim)'])
else:
self.commit(translate("draft","Create Dimension"),
- ['Draft.makeDimension(FreeCAD.ActiveDocument.'+self.link[0].Name+','+str(self.link[1])+','+str(self.link[2])+','+DraftVecUtils.toString(self.node[2])+')'])
+ ['dim = Draft.makeDimension(FreeCAD.ActiveDocument.'+self.link[0].Name+','+str(self.link[1])+','+str(self.link[2])+','+DraftVecUtils.toString(self.node[2])+')',
+ 'Draft.autogroup(dim)'])
elif self.arcmode:
self.commit(translate("draft","Create Dimension"),
- ['Draft.makeDimension(FreeCAD.ActiveDocument.'+self.link[0].Name+','+str(self.link[1])+',"'+str(self.arcmode)+'",'+DraftVecUtils.toString(self.node[2])+')'])
+ ['dim = Draft.makeDimension(FreeCAD.ActiveDocument.'+self.link[0].Name+','+str(self.link[1])+',"'+str(self.arcmode)+'",'+DraftVecUtils.toString(self.node[2])+')',
+ 'Draft.autogroup(dim)'])
else:
self.commit(translate("draft","Create Dimension"),
- ['Draft.makeDimension('+DraftVecUtils.toString(self.node[0])+','+DraftVecUtils.toString(self.node[1])+','+DraftVecUtils.toString(self.node[2])+')'])
+ ['dim = Draft.makeDimension('+DraftVecUtils.toString(self.node[0])+','+DraftVecUtils.toString(self.node[1])+','+DraftVecUtils.toString(self.node[2])+')',
+ 'Draft.autogroup(dim)'])
if self.ui.continueMode:
self.cont = self.node[2]
if not self.dir:
@@ -2064,7 +2086,8 @@ class ShapeString(Creator):
'plm.Base='+DraftVecUtils.toString(self.ssBase),
'plm.Rotation.Q='+qr,
'ss.Placement=plm',
- 'ss.Support='+sup])
+ 'ss.Support='+sup,
+ 'Draft.autogroup(ss)'])
except Exception as e:
msg("Draft_ShapeString: error delaying commit", "error")
self.finish()
@@ -4609,16 +4632,18 @@ class Point(Creator):
commitlist = []
if Draft.getParam("UsePartPrimitives",False):
# using
- commitlist.append((translate("draft","Create Point"),
+ commitlist.append(translate("draft","Create Point"),
['point = FreeCAD.ActiveDocument.addObject("Part::Vertex","Point")',
'point.X = '+str(self.stack[0][0]),
'point.Y = '+str(self.stack[0][1]),
- 'point.Z = '+str(self.stack[0][2])]))
+ 'point.Z = '+str(self.stack[0][2]),
+ 'Draft.autogroup(point)'])
else:
# building command string
FreeCADGui.addModule("Draft")
- commitlist.append((translate("draft","Create Point"),
- ['Draft.makePoint('+str(self.stack[0][0])+','+str(self.stack[0][1])+','+str(self.stack[0][2])+')']))
+ commitlist.append(translate("draft","Create Point"),
+ ['point = Draft.makePoint('+str(self.stack[0][0])+','+str(self.stack[0][1])+','+str(self.stack[0][2])+')',
+ 'Draft.autogroup(point)'])
todo.delayCommit(commitlist)
FreeCADGui.Snapper.off()
self.finish()
@@ -4740,7 +4765,8 @@ class Draft_Facebinder(Creator):
FreeCAD.ActiveDocument.openTransaction("Facebinder")
FreeCADGui.addModule("Draft")
FreeCADGui.doCommand("s = FreeCADGui.Selection.getSelectionEx()")
- FreeCADGui.doCommand("Draft.makeFacebinder(s)")
+ FreeCADGui.doCommand("f = Draft.makeFacebinder(s)")
+ FreeCADGui.doCommand('Draft.autogroup(f)')
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
self.finish()
@@ -4772,11 +4798,13 @@ class VisGroup():
FreeCADGui.addModule("Draft")
if len(s) == 1:
if s[0].isDerivedFrom("App::DocumentObjectGroup"):
- FreeCADGui.doCommand("Draft.makeVisGroup(FreeCAD.ActiveDocument."+s[0].Name+")")
+ FreeCADGui.doCommand("v = Draft.makeVisGroup(FreeCAD.ActiveDocument."+s[0].Name+")")
+ FreeCADGui.doCommand('Draft.autogroup(v)')
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
return
- FreeCADGui.doCommand("Draft.makeVisGroup()")
+ FreeCADGui.doCommand("v = Draft.makeVisGroup()")
+ FreeCADGui.doCommand('Draft.autogroup(v)')
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
@@ -4957,6 +4985,51 @@ class Draft_Slope():
FreeCADGui.Control.closeDialog()
FreeCAD.ActiveDocument.recompute()
+
+class SetAutoGroup():
+ "The SetAutoGroup FreeCAD command definition"
+
+ def GetResources(self):
+ return {'Pixmap' : 'Draft_AutoGroup',
+ 'MenuText': QtCore.QT_TRANSLATE_NOOP("Draft_AutoGroup", "AutoGroup"),
+ 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Draft_AutoGroup", "Select a group to automatically add all Draft & Arch objects to")}
+
+ def IsActive(self):
+ if FreeCADGui.ActiveDocument:
+ return True
+ else:
+ return False
+
+ def Activated(self):
+ if hasattr(FreeCADGui,"draftToolBar"):
+ self.ui = FreeCADGui.draftToolBar
+ s = FreeCADGui.Selection.getSelection()
+ if len(s) == 1:
+ if s[0].isDerivedFrom("App::DocumentObjectGroup") or (Draft.getType(s[0]) in ["Site","Building","Floor"]):
+ self.ui.setAutoGroup(s[0].Name)
+ return
+ self.groups = ["None"]
+ gn = Draft.getGroupNames()
+ if gn:
+ self.groups.extend(gn)
+ self.labels = ["None"]
+ for g in gn:
+ o = FreeCAD.ActiveDocument.getObject(g)
+ if o:
+ self.labels.append(o.Label)
+ self.ui.sourceCmd = self
+ self.ui.popupMenu(self.labels)
+
+ def proceed(self,labelname):
+ self.ui.sourceCmd = None
+ if labelname == "None":
+ self.ui.setAutoGroup(None)
+ else:
+ if labelname in self.labels:
+ i = self.labels.index(labelname)
+ self.ui.setAutoGroup(self.groups[i])
+
+
#---------------------------------------------------------------------------
# Snap tools
#---------------------------------------------------------------------------
@@ -5198,6 +5271,7 @@ FreeCADGui.addCommand('Draft_Shape2DView',Shape2DView())
FreeCADGui.addCommand('Draft_ShowSnapBar',ShowSnapBar())
FreeCADGui.addCommand('Draft_ToggleGrid',ToggleGrid())
FreeCADGui.addCommand('Draft_FlipDimension',Draft_FlipDimension())
+FreeCADGui.addCommand('Draft_AutoGroup',SetAutoGroup())
# 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 c118df631..9052b25a5 100644
--- a/src/Mod/Draft/InitGui.py
+++ b/src/Mod/Draft/InitGui.py
@@ -79,7 +79,7 @@ class DraftWorkbench (Workbench):
"Draft_PathArray","Draft_Clone","Draft_Drawing","Draft_Mirror","Draft_Stretch"]
self.treecmdList = ["Draft_ApplyStyle","Draft_ToggleDisplayMode","Draft_AddToGroup",
"Draft_SelectGroup","Draft_SelectPlane",
- "Draft_ShowSnapBar","Draft_ToggleGrid"]
+ "Draft_ShowSnapBar","Draft_ToggleGrid","Draft_AutoGroup"]
self.lineList = ["Draft_UndoLine","Draft_FinishLine","Draft_CloseLine"]
self.utils = ["Draft_VisGroup","Draft_Heal","Draft_FlipDimension",
"Draft_ToggleConstructionMode","Draft_ToggleContinueMode","Draft_Edit",
diff --git a/src/Mod/Draft/Resources/Draft.qrc b/src/Mod/Draft/Resources/Draft.qrc
index 0bbac2fdb..6f079b619 100644
--- a/src/Mod/Draft/Resources/Draft.qrc
+++ b/src/Mod/Draft/Resources/Draft.qrc
@@ -72,6 +72,9 @@
icons/Draft_Slope.svg
icons/DraftWorkbench.svg
icons/Draft_Stretch.svg
+ icons/Draft_AutoGroup.svg
+ icons/Draft_AutoGroup_on.svg
+ icons/Draft_AutoGroup_off.svg
patterns/concrete.svg
patterns/cross.svg
patterns/line.svg
diff --git a/src/Mod/Draft/Resources/icons/Draft_AutoGroup.svg b/src/Mod/Draft/Resources/icons/Draft_AutoGroup.svg
new file mode 100644
index 000000000..7fa1ddd70
--- /dev/null
+++ b/src/Mod/Draft/Resources/icons/Draft_AutoGroup.svg
@@ -0,0 +1,453 @@
+
+
+
+
diff --git a/src/Mod/Draft/Resources/icons/Draft_AutoGroup_off.svg b/src/Mod/Draft/Resources/icons/Draft_AutoGroup_off.svg
new file mode 100644
index 000000000..76169e859
--- /dev/null
+++ b/src/Mod/Draft/Resources/icons/Draft_AutoGroup_off.svg
@@ -0,0 +1,464 @@
+
+
+
+
diff --git a/src/Mod/Draft/Resources/icons/Draft_AutoGroup_on.svg b/src/Mod/Draft/Resources/icons/Draft_AutoGroup_on.svg
new file mode 100644
index 000000000..ccd18bb84
--- /dev/null
+++ b/src/Mod/Draft/Resources/icons/Draft_AutoGroup_on.svg
@@ -0,0 +1,464 @@
+
+
+
+