Undo Deleted Entities
-
So, apparently if you Undo a deleted entity, you don't get back exactly the same entity?
entity;#<Sketchup;;Face;0x422be20> entityID;27 # Delete and Undo the Face entity;#<Sketchup;;Face;0x3ed63c8> entityID;27
I get the same entityID, but not exactly the same Face? I guess I can manage them through the entityID, right? I'll just need to search the entities for the entityID.
-
Jim,
Yes, expected behavior - particularly with GC-ed languages. But also because the Ruby objects are just proxies of the 'real' objects buried inside SU proper, so I think the wrapper can change at any time, while the value is persistent for the lifetime of the underlying object.
You have to tread very carefully when matching Entities. Even comparing EntityID isn't enough sometime - well thats what I found anyway. In LightUp I ended up just hashing the entity, which works great.
Adam
-
agree with Adam - using entityID sometimes makes you chase dead horses. better using hashes even if there is a slight time penalty.
hope there will be a fix in future SU versions -
I know what a Hash is in Ruby, but are you guys talking about the same "hash"? It's not clear how I could use a Ruby hash without running into the same problem; needing to search Entities for the matching ID.
I wanted one of my plugins to handle selections in undo and redo operations, so I wrote a Selection Manager to handle it. It appears to work just fine using the entityID of each selected entity stored in an array of arrays; and stepping back and forth thru the stack.
Second issue, there appears to be a que-ing, or scheduler in Sketchup? If I call Sketchup.undo followed immediately by my undo, the entities have not been "undone" in time for my undo to find them. I hacked it up using...
Sketchup.undo UI.start_timer(0.1) { my_undo}
Any alternative?
Advertisement