can't get control of a camera!


https://forum.reallusion.com/Topic490740.aspx
Print Topic | Close Window

By videodv - Last Year
The output of the print comand prints to the consol log you find this under scripts/Consol Log incase you have not seen it.
This has always worked for me so not sure why its not working for you.
Chris.
By mono11 - Last Year
thanks  chris and gordryd!
yes, it is exactly the RL sample! The camera is in the scene, I double checked the name and it is set to "camera1". In fact, I get the output "camera is available" from the script.
Anyway, I removed the camera and created a new one, leaving its name to the default one ("Camera") and changed the string in FindObject accordingly, and now it works Smile

Btw, do you know where I can see the outputs of "print" commands? They do not show up in the Console log (this is why I had to set a label in the qtwidget to debug...)
By mono11 - Last Year
Hello,

I am trying to move a camera in iClone (named "camera1"). Running the following script:

    camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "camera1")
    if not camera.IsValid():
        log_label.setText("camera is not available")
    else:
        log_label.setText("camera is available")

    control = camera.GetControl("Transform")
    transform = RLPy.RTransform.IDENTITY
    transform.T().x = -75.0
    transform.T().y = -150.0
    transform.T().z = 250.0
    time = RLPy.RTime(0)
    control.SetValue(time, transform)
    # update after adding a key
    camera.Update()

gives me the following error:

control.SetValue(time, transform)
AttributeError
'NoneType' object has no attribute 'SetValue'

What am I doing wrong?
Also, can I create a camera directly from the python script?
Tnx!
By videodv - Last Year
I tried this out and if you remove the "if else statment" and make sure camera1 is in the scene then it works fine.

import RLPy

camera = RLPy.RScene.FindObject(RLPy.EObjectType_Camera, "camera1")

# if not camera.IsValid():
    # log_label.setText("camera is not available")
# else:
    # log_label.setText("camera is available")

control = camera.GetControl("Transform")
transform = RLPy.RTransform.IDENTITY
transform.T().x = -75.0
transform.T().y = -150.0
transform.T().z = 250.0
time = RLPy.RTime(0)
control.SetValue(time, transform)
# update after adding a key
camera.Update()

Chris.
By gordryd - Last Year
This code looks exactly like the sample provided by RL in the wiki (except for the if-else section).  What does the console log look like?  Is "camera1" 'available'?  Also, the indentation looks off for the first line (maybe a result of copy/paste to the forum)