Enable undo in creating assembly command
This commit is contained in:
parent
8f8cbea719
commit
3c8e211b49
13
assembly.py
13
assembly.py
|
@ -1235,14 +1235,25 @@ class Assembly(AsmGroup):
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def make(doc=None,name='Assembly'):
|
def make(doc=None,name='Assembly',undo=True):
|
||||||
if not doc:
|
if not doc:
|
||||||
doc = FreeCAD.ActiveDocument
|
doc = FreeCAD.ActiveDocument
|
||||||
|
if not doc:
|
||||||
|
raise RuntimeError('No active document')
|
||||||
|
if undo:
|
||||||
|
doc.openTransaction('Create assembly')
|
||||||
|
try:
|
||||||
obj = doc.addObject(
|
obj = doc.addObject(
|
||||||
"Part::FeaturePython",name,Assembly(),None,True)
|
"Part::FeaturePython",name,Assembly(),None,True)
|
||||||
ViewProviderAssembly(obj.ViewObject)
|
ViewProviderAssembly(obj.ViewObject)
|
||||||
obj.Visibility = True
|
obj.Visibility = True
|
||||||
obj.purgeTouched()
|
obj.purgeTouched()
|
||||||
|
if undo:
|
||||||
|
doc.commitTransaction()
|
||||||
|
except Exception:
|
||||||
|
if undo:
|
||||||
|
doc.abortTransaction()
|
||||||
|
raise
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
Info = namedtuple('AssemblyInfo',('Assembly','Object','Subname'))
|
Info = namedtuple('AssemblyInfo',('Assembly','Object','Subname'))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user