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
|
||||
|
||||
@staticmethod
|
||||
def make(doc=None,name='Assembly'):
|
||||
def make(doc=None,name='Assembly',undo=True):
|
||||
if not doc:
|
||||
doc = FreeCAD.ActiveDocument
|
||||
if not doc:
|
||||
raise RuntimeError('No active document')
|
||||
if undo:
|
||||
doc.openTransaction('Create assembly')
|
||||
try:
|
||||
obj = doc.addObject(
|
||||
"Part::FeaturePython",name,Assembly(),None,True)
|
||||
ViewProviderAssembly(obj.ViewObject)
|
||||
obj.Visibility = True
|
||||
obj.purgeTouched()
|
||||
if undo:
|
||||
doc.commitTransaction()
|
||||
except Exception:
|
||||
if undo:
|
||||
doc.abortTransaction()
|
||||
raise
|
||||
return obj
|
||||
|
||||
Info = namedtuple('AssemblyInfo',('Assembly','Object','Subname'))
|
||||
|
|
Loading…
Reference in New Issue
Block a user