Home › Forums › General Questions › Loading / Cloning same Object with Children into Scene multiple times
- This topic has 18 replies, 2 voices, and was last updated 4 days, 5 hours ago by
kdv.
-
AuthorPosts
-
2025-03-26 at 12:34 pm #80904
Thomas Fabini
CustomerI’ve hit a wall when trying to dynamically clone (or append) objects to an existing scene:
As far as I understand, when cloning, none of the parent – child relationship are retained in the cloned objects as they always reference the former children.
Un- or re-parenting the clones isn’t even remotely an option because I am using a complex structure of parent-child relationships (and a rig) so I would assume that rebuilding of the structure would go down to every last bone in that rig.When appending that structure as a scene, with an unique id in the “as” slot, does that mean that for each appended scene individual objects are created? If so, how can the individual elements be referenced through puzzles?
On API-level this shouldn’t be a problem at all, since many apps load complete rigs and reference them (or elements, properties within) individually. But on the puzzle level using getObjectByName won’t really do, since there might be different uuids for the object but identical names.
I really hope there is a solution to this, else last resort would be to loading objects through the API and passing the references to the puzzles which I personally don’t feel would be best approach.
As always – any insights hints or solutions are greatly appreciated…
2025-03-26 at 12:57 pm #80905kdv
ParticipantIf so, how can the individual elements be referenced through puzzles?
you should rename all objects in appended scenes. every object should have a unique name if you want to interact with it via puzzles.
Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2025-03-26 at 1:04 pm #80906Thomas Fabini
Customeryou should rename all objects in appended scenes
Hi kdv, thanks for your reply.
Do you mean renaming objects in the original files which are loaded (which would defeat the purpose of dynamically loading and reusing a scene) – or – do you mean dynamically renaming objects when loading a scene?2025-03-26 at 1:05 pm #80907kdv
Participantdynamically renaming objects when loading a scene?
yeap. append/clone -> rename.
Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2025-03-26 at 1:14 pm #80908Thomas Fabini
Customeryeap. append/clone -> rename.
Is there a ‘rename’ puzzle I don’t know about?
I maybe could feed “all objects” from the loaded scene to a method, parse through for each and add an index to (the name property of) each element and return the references back in an object, dictionary. This is the only thing that comes to mind right now. (Don’t know it that works).-
This reply was modified 6 days, 4 hours ago by
Thomas Fabini.
2025-03-26 at 1:31 pm #80910kdv
ParticipantIs there a ‘rename’ puzzle I don’t know about?
Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2025-03-26 at 1:59 pm #80912Thomas Fabini
CustomerThat explains why I haven’t found it yet… I was going for something like (profoundly un-tested) …and profoundly wrong, too. here’s the update:
/// Built-in variables: app, v3d, puzzles, VARS, PROC const objects = VARS.scene_objects; const index = VARS.scene_index; const scene_objs_renamed = []; for ( const object of objects ) { obj = app.scene.getObjectByName(object); obj.name = obj.name+"_"+index; scene_objs_renamed.push(obj.name); } VARS.scene_objs_renamed = scene_objs_renamed;
-
This reply was modified 6 days, 3 hours ago by
Thomas Fabini.
2025-03-26 at 3:26 pm #80916Thomas Fabini
CustomerThanks very much for explaining this and for the solution kdv
so it means when appending a scene several times all object id’s are unique, but the names still remain the same, thus getObjectByName() would return always only the first instance it finds when traversing the scene children. So they can’t be manipulated by the classical puzzle selector.
When renaming all children in an appended scene it seems to work, the parenting and structure remains intact and individual elements can be manipulated through puzzles then.
2025-03-26 at 9:21 pm #80917kdv
Participantall object id’s are unique, but the names still remain the same, thus getObjectByName() would return always only the first instance it finds when traversing the scene children. So they can’t be manipulated by the classical puzzle selector.
yeap, that’s how it works. in puzzles you can find some object only by its unique name.
Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2025-03-27 at 7:45 am #80930Thomas Fabini
CustomerHi kdv,
one more question if I may:
Before you said loading _and_ cloning. When loading, the parent-child structure or the rig remains intact, all I have to do is to rename all objects within the loaded scene.But when cloning I am only able to clone a single object (without its children). If I’m not mistaken here.
Even if I would iterate through all objects when cloning (and renaming), would the parent-child relations of the clones be correct?
From other posts I understood that clones always reference back to their original children.Do you think it is possible to clone a complex parent-child structure or a rig with parent-child dependencies intact?
2025-03-27 at 12:23 pm #80932kdv
ParticipantDo you think it is possible to clone a complex parent-child structure
why not? easy.
Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2025-03-27 at 12:53 pm #80934Thomas Fabini
Customerwhy not? easy.
Thank you, then at least there’s hope it will work with cloning instead of loading, too.
But in that specific example you are cloning the whole scene… doesn’t this dramatically change when cloning a particular rig?Btw., I found your thread regarding cloning animations, it helped me rename the animation clips on the cloned, and renamed, rigs – without, there wasn’t any animation available for the new rigs which could be played – thanks for those examples, too.
2025-03-27 at 12:58 pm #80935kdv
ParticipantBut in that specific example you are cloning the whole scene
because that’s the most complex object. the left farmer is rigged, the animation of the right one is based on shape keys.
Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2025-03-27 at 1:02 pm #80936Thomas Fabini
CustomerDoes this mean it would work, too if the rig is parented to an empty which you clone?
2025-03-27 at 1:05 pm #80937kdv
ParticipantScene
is an empty object.Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
-
This reply was modified 6 days, 4 hours ago by
-
AuthorPosts
- You must be logged in to reply to this topic.