Profile Picture

can't get control of a camera!

Posted By mono11 4 Months Ago
You don't have permission to rate!
Author
Message
mono11
mono11
Posted 4 Months Ago
View Quick Profile
New Member

New Member (47 reputation)New Member (47 reputation)New Member (47 reputation)New Member (47 reputation)New Member (47 reputation)New Member (47 reputation)New Member (47 reputation)New Member (47 reputation)New Member (47 reputation)

Group: Forum Members
Last Active: 3 Months Ago
Posts: 3, Visits: 6
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!
gordryd
gordryd
Posted 4 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)

Group: Forum Members
Last Active: 23 minutes ago
Posts: 537, Visits: 6.0K
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)

Reallusion Certified Director / Reallusion Best Visual Award / Reallusion Certified Content Developer
See all the G-Tools Plug-Ins available for iClone here: https://marketplace.reallusion.com/store/G-Tools
videodv
videodv
Posted 4 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (2.3K reputation)Distinguished Member (2.3K reputation)Distinguished Member (2.3K reputation)Distinguished Member (2.3K reputation)Distinguished Member (2.3K reputation)Distinguished Member (2.3K reputation)Distinguished Member (2.3K reputation)Distinguished Member (2.3K reputation)Distinguished Member (2.3K reputation)

Group: Forum Members
Last Active: 2 hours ago
Posts: 338, Visits: 9.8K
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.
mono11
mono11
Posted 4 Months Ago
View Quick Profile
New Member

New Member (47 reputation)New Member (47 reputation)New Member (47 reputation)New Member (47 reputation)New Member (47 reputation)New Member (47 reputation)New Member (47 reputation)New Member (47 reputation)New Member (47 reputation)

Group: Forum Members
Last Active: 3 Months Ago
Posts: 3, Visits: 6
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...)
videodv
videodv
Posted 4 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (2.3K reputation)Distinguished Member (2.3K reputation)Distinguished Member (2.3K reputation)Distinguished Member (2.3K reputation)Distinguished Member (2.3K reputation)Distinguished Member (2.3K reputation)Distinguished Member (2.3K reputation)Distinguished Member (2.3K reputation)Distinguished Member (2.3K reputation)

Group: Forum Members
Last Active: 2 hours ago
Posts: 338, Visits: 9.8K
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.



Reading This Topic