Profile Picture

can't get control of a camera!

Posted By mono11 3 Years Ago
You don't have permission to rate!
Author
Message
mono11
mono11
Posted 3 Years Ago
View Quick Profile
Junior Member

Junior Member (105 reputation)Junior Member (105 reputation)Junior Member (105 reputation)Junior Member (105 reputation)Junior Member (105 reputation)Junior Member (105 reputation)Junior Member (105 reputation)Junior Member (105 reputation)Junior Member (105 reputation)

Group: Forum Members
Last Active: 3 Years 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 3 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (4.6K reputation)Distinguished Member (4.6K reputation)Distinguished Member (4.6K reputation)Distinguished Member (4.6K reputation)Distinguished Member (4.6K reputation)Distinguished Member (4.6K reputation)Distinguished Member (4.6K reputation)Distinguished Member (4.6K reputation)Distinguished Member (4.6K reputation)

Group: Forum Members
Last Active: Last Week
Posts: 711, Visits: 7.6K
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: G-Tools Plug-Ins


videodv
videodv
Posted 3 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)

Group: Forum Members
Last Active: Last Year
Posts: 342, Visits: 12.0K
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 3 Years Ago
View Quick Profile
Junior Member

Junior Member (105 reputation)Junior Member (105 reputation)Junior Member (105 reputation)Junior Member (105 reputation)Junior Member (105 reputation)Junior Member (105 reputation)Junior Member (105 reputation)Junior Member (105 reputation)Junior Member (105 reputation)

Group: Forum Members
Last Active: 3 Years 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 3 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)

Group: Forum Members
Last Active: Last Year
Posts: 342, Visits: 12.0K
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