Undo shifts geometry
-
I am currently writing a tool that generates geometry inside the currently open group. And when you open a group/component SU transforms the co-ordinates to global co-ordinates.
In order to ensure the geometry I generate starts at local 0,0,0 I transform all the 3d points I use to generate the mesh with
model.edit_transform
.And that works fine.
If I undo while inside the group everythings works fine.
But, if I undo after exiting the group - the geometry then gets offset from where it should be. The offset is the same as the offset from the groups' parent origin to the group.
How on earth can I avoid that?
-
hm... the issue appear to be related to using
model.close_active
I see the same behaviour with native tools if I use this.Example:
Open a group with a cube
Push-Pull a face
Typemodel.close_active
into the Ruby Console
UndoAs you undo the push-pulled face is shifted.
Also, normally when you edit a group it appears in the undo stack "Undo Close" - but when you use
model.close_active
there is no entry in the undo stack.From what I gather - using this method confuses the co-ordinates SU uses for undo/redo.
-
Aaaaaaarrggh!!!!
Is there any other way to close the current context? -
Rather than using 'undo'... I'd extend the tool's
onCancel()
anddeactivate()
methods so that they reset everything back as it was when you kicked off - e.g. inactivate()
you'd remember the objects' transformations and set them back to those as part of the 'undo', and/or keep a running array / hash of all new geometry [best kept grouped until it's finally 'committed
' because erasing the group will never affect the other geometry] and erase! it all on an 'undo'...
Wrapped in astart_/commit_operation
block it will all undo/redo after the commit - the main problem is breaking the tool's work with an <Esc> or starting another tool part way through - hence my suggestions above... See how I do it in WorkPlane.rb... -
No - I need to ensure that when the tool deactivated that the group is closed.
Advertisement