Message 1 of 3
connect texture to some selected lights by python

Not applicable
09-08-2021
06:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I have created some aiAreaLights and noisetexture("noise1").
I wanted to connect "noise1.outColor" to all "aiAreaLightShape.color" which I selected.
So I selected some lights and executed below one.
for root_obj in pm.selected():
target_list = root_obj.listRelatives(allDescendents=True)
target_list.append(root_obj)
for obj in target_list:
cmds.connectAttr("noise1.outColor","{}.color".format(obj))
But I could connect to only one light which I selected at first.
And also there was error.
# Error: RuntimeError: file <maya console> line 5: Maya command error #
Could anyone tell me how can I fix it to connect to all lights?