Home › Forums › Programming › Is there a way to name children of clones
Tagged: bz
- This topic has 3 replies, 2 voices, and was last updated 1 year, 1 month ago by
kvdml.
-
AuthorPosts
-
2024-11-12 at 1:15 pm #78605
kvdml
CustomerHi,
verge 4.71
I appended a scene, panel.glb, which consists of an empty, ‘panel’, and two child geometries: ‘panel_frame’ and ‘panel_glass’.
Like this:
* panel
->panel_frame
->panel_glassWhen I make clones of panel, the two children are cloned as well. But only panel receives a new name:
[“panel”, “panel_frame”, “panel_glass”]
[“panel2”, “panel_frame”, “panel_glass”]
[“panel3”, “panel_frame”, “panel_glass”]My question:
A. is there a way to rename panel_frame to ‘panel frame_2″ & “panel frame_3”, because I can not target these objects with setObjTransform or setMorphFactor like thisB. If I can’t rename the objects, is there a way I can target these? Like panel2.panel_frame?
C. Or is it better to make separate clones of panel_frame and panel_glass and parent to a new parent?
thx
2024-11-12 at 1:39 pm #78606Brameister
ParticipantMaybe you could use a short function in an exec script puzzle to rename the children, something like this:
Attachments:
2024-11-12 at 4:39 pm #78616kvdml
Customerthx,
had to rework it a bit, but I got it working like this:function renameChildrenOfClone(clonedObjectName) {
// Retrieve the cloned object from the scene using its name
const clonedObject = app.scene.getObjectByName(clonedObjectName);// Extract the index number from the parent object’s name
const indexMatch = clonedObjectName.match(/\d+$/);
const index = indexMatch ? indexMatch[0] : ”;for (let i = 0; i < clonedObject.children.length; i++) {
const child = clonedObject.children;if (child.name.startsWith(‘panel_frame’)) {
child.name = panel_frame${index};
} else if (child.name.startsWith(‘panel_glass’)) {
child.name = panel_glass${index};
}
}
}2024-11-12 at 4:40 pm #78617kvdml
Customerthis is my clone object before and after the rename function
[‘panel2’, ‘panel_frame’, ‘panel_glass’]
[‘panel2’, ‘panel_frame2’, ‘panel_glass2’][‘panel3’, ‘panel_frame’, ‘panel_glass’]
[‘panel3’, ‘panel_frame3’, ‘panel_glass3’] -
AuthorPosts
- You must be logged in to reply to this topic.

