Testing python Gui.doCommand with the Draft Line tool
This commit is contained in:
parent
4f91a5a71b
commit
d9aa2712bb
|
@ -78,6 +78,10 @@ class todo:
|
||||||
try:
|
try:
|
||||||
name = str(name)
|
name = str(name)
|
||||||
FreeCAD.ActiveDocument.openTransaction(name)
|
FreeCAD.ActiveDocument.openTransaction(name)
|
||||||
|
if isinstance(func,list):
|
||||||
|
for l in func:
|
||||||
|
FreeCADGui.doCommand(l)
|
||||||
|
else:
|
||||||
func()
|
func()
|
||||||
FreeCAD.ActiveDocument.commitTransaction()
|
FreeCAD.ActiveDocument.commitTransaction()
|
||||||
except:
|
except:
|
||||||
|
|
|
@ -415,13 +415,26 @@ class Line(Creator):
|
||||||
def finish(self,closed=False,cont=False):
|
def finish(self,closed=False,cont=False):
|
||||||
"terminates the operation and closes the poly if asked"
|
"terminates the operation and closes the poly if asked"
|
||||||
if self.obj:
|
if self.obj:
|
||||||
|
# remove temporary object, if any
|
||||||
old = self.obj.Name
|
old = self.obj.Name
|
||||||
todo.delay(self.doc.removeObject,old)
|
todo.delay(self.doc.removeObject,old)
|
||||||
self.obj = None
|
self.obj = None
|
||||||
if (len(self.node) > 1):
|
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"),
|
self.commit(translate("draft","Create DWire"),
|
||||||
partial(Draft.makeWire,self.node,closed,
|
['import Draft',
|
||||||
face=self.ui.fillmode,support=self.support))
|
'points='+points,
|
||||||
|
'Draft.makeWire(points,closed='+str(closed)+',face='+str(bool(self.ui.fillmode))+',support='+sup+')'])
|
||||||
if self.ui:
|
if self.ui:
|
||||||
self.linetrack.finalize()
|
self.linetrack.finalize()
|
||||||
self.constraintrack.finalize()
|
self.constraintrack.finalize()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user