From d9aa2712bb87d900e7b1c7b5109805ea39b6e35c Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Mon, 28 May 2012 16:02:56 -0300 Subject: [PATCH] Testing python Gui.doCommand with the Draft Line tool --- src/Mod/Draft/DraftGui.py | 6 +++++- src/Mod/Draft/DraftTools.py | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/Mod/Draft/DraftGui.py b/src/Mod/Draft/DraftGui.py index 13517f478..7e651a698 100644 --- a/src/Mod/Draft/DraftGui.py +++ b/src/Mod/Draft/DraftGui.py @@ -78,7 +78,11 @@ class todo: try: name = str(name) FreeCAD.ActiveDocument.openTransaction(name) - func() + if isinstance(func,list): + for l in func: + FreeCADGui.doCommand(l) + else: + func() FreeCAD.ActiveDocument.commitTransaction() except: wrn = "[Draft.todo.commit] Unexpected error:", sys.exc_info()[0], "in ", f, "(", arg, ")" diff --git a/src/Mod/Draft/DraftTools.py b/src/Mod/Draft/DraftTools.py index 885e781c6..81d1bc05d 100644 --- a/src/Mod/Draft/DraftTools.py +++ b/src/Mod/Draft/DraftTools.py @@ -415,13 +415,26 @@ class Line(Creator): def finish(self,closed=False,cont=False): "terminates the operation and closes the poly if asked" if self.obj: + # remove temporary object, if any old = self.obj.Name todo.delay(self.doc.removeObject,old) self.obj = None if (len(self.node) > 1): + # building command string + if self.support: + sup = 'FreeCAD.ActiveDocument.getObject("' + self.support.Name + '")' + else: + sup = 'None' + points='[' + for n in self.node: + if len(points) > 1: + points += ',' + points += 'FreeCAD.Vector('+str(n.x) + ',' + str(n.y) + ',' + str(n.z) + ')' + points += ']' self.commit(translate("draft","Create DWire"), - partial(Draft.makeWire,self.node,closed, - face=self.ui.fillmode,support=self.support)) + ['import Draft', + 'points='+points, + 'Draft.makeWire(points,closed='+str(closed)+',face='+str(bool(self.ui.fillmode))+',support='+sup+')']) if self.ui: self.linetrack.finalize() self.constraintrack.finalize()