I have some objects that have tags and I would like to copy these objects and assign new tags directly to them, but I don’t know how to override the Sketchup.send_action(CMP_PASTE) action.
For example I have my table with tag t1 after copying it I want the new table (copy-table) to be tag t2.
There is no API for that.
There’s also not really a notion within SketchUp to know when something is being copied. It just knows that things are created/deleted.
I guess you could monitor the active_entities with an entities observer and catch new entities being created. If your object (I assume a group or component instance) stored an attribute to ID it you could check that and reassign tags as needed. For instance, if you added an attribute with the PID of the original object, then the copy would also get that attribute copied, but it’d have a new PID. You could then check that the attribute ID matched the PID and assume that’s a copy.
ok, I’ll try to make my own copy function
Group#copymethod is a convenience wrapper for the above. Ie, it is the same as:
group2 = entities.add_instance(group1.definition, group1.transformation)
This means that
group2would be superimposed over
group1and would need to be moved to a new location.
After your new instances exist, create new tag(s) then assign the new instance(s) to use them.