[Closed] node instances don't keep Custom Attributes instances ?
because
two instances of the same object can carry differents CA instances (therefore the CA is on the node and NOT on the baseobject)
Node A and C are the same geometry instance of a same object, so their baseobject are identical, if I’m not wrong.
However, I need them not be in two different “ca-groups”, therefore carrying two different CA instances.
If I put CA on the baseobject, as instances (object) means sharing the same baseobject, they will have both the same custom attributes, as it is linked on the baseobject. That’s exactly what I don’t want.
I hope it is clear enough…
I am very surprised that anybody have faced this kind of problem before.
Thanks for trying to help, Denis. I learn of your samples even when they don’t solve my case ;).
i don’t need to try it because i already see a big problems in your concept. as i understood you only want to mark some nodes by some mark which will make them a members of the same group, where every member of the group being cloned has to make the new member of its group. true?
as you already could see the coping of a node doesn’t automatically transfer the node’s custom attributes:
ca_test = attributes ca_test (;)
delete objects
b0 = box()
custattributes.add b0 ca_test baseobject:off
isproperty b0 #ca_test
b1 = copy b0
isproperty b1 #ca_test
b2 = instance b0
isproperty b2 #ca_test
so you have to use your own copy mechanics or do something using node events. and just trust me.
the second is not trivial but doable:
callbacks.removescripts id:#ca_identifier
ca_id = attributes ca_id attribID:#(0xCA,0x1D) (;)
fn replaceCAIdentifier =
(
data = callbacks.notificationParam()
for k=1 to data[1].count where (s = data[1][k].custattributes[#ca_id]) != undefined do
(
if (t = data[2][k].custattributes[#ca_id]) == undefined then append data[2][k].custattributes s else replaceinstances t s
)
)
callbacks.addscript #postNodesCloned "replaceCAIdentifier()" id:#ca_identifier
delete objects
(
b0 = box()
custattributes.add b0 ca_id baseobject:off
b1 = copy b0
format "(copy) > are ca instances: %
" (b0.ca_id == b1.ca_id)
b2 = instance b1
format "(instance) > are ca instances: %
" (b1.ca_id == b2.ca_id)
maxOps.CloneNodes b2 cloneType:#instance newNodes:&b3
format "(clone) > are ca instances: %
" (b2.ca_id == b3[1].ca_id)
)
Thank you Denis.
I think I have to go with the postNodesCloned event callback.
I saw before posting this thread it and would have wanted to avoid it and use only sceneNodeAdded callback to handle every node creation type (merging, cloning, undoing delete…).
I will go for a mix of #sceneNodeAdded for merging,/undoing delete and #postNodesCloned for cloning. It will cover any cases.
I hope it will help someone else another day.