On 24/07/2018 at 11:05, xxxxxxxx wrote:
I'm still getting a handle on python basics so any help would be much appreciated. I'm trying to make a python tag that will select lights by name in my hierarchy and will then control certain parameters with user data. From all the examples I've seen, this code should be working....
def Lights() :
for i in doc.GetObjects() :
if (i.GetName() == 'v2' and 'v1') :
Lights = i
def main() :
Vol_On = op[c4d.ID_USERDATA,1]
Lights = c4d.BaseObject (5102) # Light
op[c4d.LIGHT_VLTYPE] = Vol_On
On 25/07/2018 at 02:51, xxxxxxxx wrote:
Thanks for writing to us. Please keep in mind tag is part of an object (is like adding an element to an object). So you are only allowed to modify the current object parameter, or the tag itself.
To select an object according to its name. A script executed by the script manager will be more suited.
The basic way to do this is to iterate over the scene, please read this blog Recursive hierarchy iteration, Then check for the name and use SetActiveObject to select your objects.
For the second part, to control certain parameters from user data, you are right, a tag is a good choice (but keep in mind tag, can only modify the current host object, he can read the user data from another object for sure if you respect priorities).
And your code, is somehow correct, except "op" currently represent the operator which mean, the python tag itself. If you want to get the host object, use op.GetObject().
light = op.GetObject()
lightUserData = light[c4d.ID_USERDATA,1]
light[c4d.LIGHT_VLTYPE] = lightUserData
If you have any question, please let me know.