Testing python Gui.doCommand with the Draft Line tool

This commit is contained in:
Yorik van Havre 2012-05-28 16:02:56 -03:00
parent 4f91a5a71b
commit d9aa2712bb
2 changed files with 20 additions and 3 deletions

View File

@ -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, ")"

View File

@ -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()