I’m trying to delete all instances and then the actual definition of a custom attribute set. But for some reason, I run into trouble. I think there are some references dangling behind somewhere, but I can’t figure out how and why.
Here’s a bit of test code that does work:
testCA = attributes testCA attribID:#(0x42a4cdb9, 0x13c71b46) ( )
(
s = sphere()
custattributes.add s testCA;
custattributes.delete s testCA;
custattributes.deleteDef testCA;
)
But then to make it a bit more useful, I try to get all instances of the CA definition and delete them:
testCA = attributes testCA attribID:#(0x42a4cdb9, 0x13c71b46) ( )
(
s = sphere()
custattributes.add s testCA;
local instances = custAttributes.getDefInstances testCA;
for i in instances do (
local owner = custAttributes.getOwner i;
custAttributes.delete owner testCA;
)
custAttributes.deleteDef testCA;
)
The last line always throws a runtime exception:
custAttributes.deleteDef - Cannot delete, objects still using this definition: <AttributeDef:testCA>
When I run getDefInstances after it again, I get 1 instance, but trying to get the owner of it returns undefined… I’ve tried doing a garbage collect before deleting the definition, but this does not help.
Also, I noticed that the getOwner does not seem to return a valid node, but some other kind of object. For example I can’t query the name, and (isValidNode owner) returns false…
Any ideas what I’m doing wrong here?