Rename Children of selected objects
-
With this script you can rename the children a null object, or any selection that has children inside, to match the parent's name + an incremental number, use in python scripts inside cinema. You can select any number of objects and it will rename the objects inside each parent to it's parent's name.
This is very useful when importing AI layers that have many paths inside.
import c4d def main(): # Get the active objects active_objects = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_CHILDREN) # Loop through each active object for obj in active_objects: # Get the name of the object base_name = obj.GetName() # Get the children of the object children = obj.GetChildren() # Loop through each child for i, child in enumerate(children): # Rename the child with the base name and an incremental number child.SetName(f"{base_name}_{i+1}") # Update the Cinema 4D scene c4d.EventAdd() # Execute main() if __name__=='__main__': main()
-
Hi truth-dream,
The idea of this forum is about the content provided by Maxon.
Please check programming suggestions or questions in the Developer-Café.
https://plugincafe.maxon.net/
This is the correct place for it.I feel somewhat uncomfortable having code here, in general, for various reasons.
The moderator of the Plugin Café is better suited for this.All the best