Show messages: All
1-3
4-6
From: Michael Gibson
Hi andrew,
> Ok great, that's good to know that commands automatically get undo support :) This one definitely
> needs it since it is quite an intrusive operation, so I'll switch it to being a command instead.
Actually I should clarify that a bit - commands automatically get undo support for all added and removed geometry. Changing just an attribute like the object name will not be covered by that current system. You could do something like clone the object, change the name on the cloned object, remove the old object from the geometry database and add in the renamed object into the geometry database in a command and then that would be undoable. The undo record will consist of the entire old object though.
> Do commands have access to any extra java script libs?
No, they have the same stuff available as inline script, but the command launcher does some various set up and tear down tasks like setting up undo records for added and removed geometry, loading the command's UI file, canceling any currently running command, clearing previous picked points, clearing any selection transition or selection lock, etc...
> Something like string.js
http://stringjs.com/ would be really useful!
You can probably use it if you want, try copying the .js file to the commands folder and then in your command put #include "string.js".
- Michael
From: andrewsimper
I implemented the script as a command and came to post here to complain that it wouldn't undo, but you have beaten me to it :)
Copying all of the geometry by a clone is a very heavyweight operation for a simple re-name. Is it possible to add the name field to your undo system?
edit: how does the current system work when I click on the top left name field and type in a new name? I can undo that operation, is this also a completely clone of all geometry that is being renamed?
From: Michael Gibson
Hi andrew,
> edit: how does the current system work when I click on the top left name field and type
> in a new name? I can undo that operation, is this also a completely clone of all geometry
> that is being renamed?
I had to look it up, I had forgotten about this.
When you use the regular UI to edit the name it does set up a special undo unit that just contains object state (including name, style assignment, hidden and locked states), and just the geometry's ID number as a reference to it, rather than storing a clone of the actual geometry.
But currently the creation of these particular undo units is baked in to some specific functions like the property panel's name edit function (which includes showing the dialog as part of it), there isn't any way to trigger it by itself from script right now.
- Michael
Show messages: All
1-3
4-6