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_activeI see the same behaviour with native tools if I use this.Example:
Open a group with a cube
Push-Pull a face
Typemodel.close_activeinto 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_activethere 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_operationblock 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.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement