[Closed] delete invalid (fucked up) custom attributes instances
Hello,
Somehow, I have a scene where some custom attributes instances have no owner. It tells me that their owner is undefined. Here is the code I used to perse these fucked up instances :
local CAinstances = custAttributes.getDefInstances MyCADef
for i=CAinstances.count to 1 by -1 where (custAttributes.getOwner CAinstances[i] == undefined) do
(
delete CAinstances[i] -- crash here
)
So there are twisted CA definition instances in the scene. I can spot them but I can’t find a way to delete them once for all. Any idea ?
look again… you have a valid CA definition… correct? you have valid instances of this definition. but this instances don’t have an owner. well. it’s definitely possible. you can’t destroy this instances. but you can delete the definition from scene if you want. deleting a CA instance means remove it from its owner ca list.
do you know an object that this CA was applied to?
if so, you can delete it using (deleteitem <node>.custattributes <index>)
Yes I know, Denis.
But the crazy thing here is that it executes the “delete” line. That means that it found some defInstances have undefined owner.
So I cannot do deleteitem undefined.custattributes <index>
That is why I need to delete the instance itself instead of using custAttributes methods (which use a owner to get the attribute)
i’ve asked you: “do you know a node what the CA was added to?” if you know you can delete the missing CA from this node ca list.
Thanks for trying to help, Denis.
look again… you have a valid CA definition… correct? you have valid instances of this definition. but this instances don’t have an owner. well. it’s definitely possible. you can’t destroy this instances. but you can delete the definition from scene if you want. deleting a CA instance means remove it from its owner ca list.
I think I have overreacted on this one…
The so-called “fucked up” ca instances are actually some instances which were added to objects earlier in the max session, then removed from these objects.
Apparently, 3dsmax keeps them in memory (until the next garbage collector ?). I was confused by the fact that the gc() did not remove them.
Anyway, when I restart 3dsmax, the fucked up instances are gone.
These instances were only remains from previously attached ca instances…
At least, if someone ask himself the same question, the answer is that everything is ok with these undefined owned ca instances. They will be garbage collected and will not pollute your scene.
they will never be garbage collected… they will stay in memory for all max session. but of course they will not be saved with a scene.