Python : Returning cameras in scene graph Tree

   2397   3   1
User Avatar
Member
19 posts
Joined: 12月 2018
Offline
Hi everyone,

Having a hard time to make python work with lop, looking especially to get a list of the camera present in scene graph tree. LopSelectionRule sounds like a good candidate for that, tried to understand better with these example[/url, especially the one that look for lights but would get errors like

AttributeError: 'LopNetwork' object has no attribute 'editableStage'

Not sure why though, would appreciate any insights
[www.sidefx.com]
User Avatar
スタッフ
455 posts
Joined: 6月 2020
Offline
Hi Adrien,

Can you elaborate a bit more on the context in which you're running Python? Is it in a Python LOP? A Python pane?

If you're in a Python LOP, then `stage = node.editableStage()` should work. If you're in some other context (e.g., a Python pane), then:

1 - make sure you're trying to query the stage from a node (`/stage/some_node`) not the LOP network (`/stage`)
2 - consider `node.stage()` instead of `node.editableStage()` for querying

- Rob
User Avatar
Member
112 posts
Joined: 10月 2011
Offline
editableStage only works within a python lop. when testing in the python shell use node.stage()

this should work:

stage=mynode.stage()
for p in stage.TraverseAll():
    if p.GetTypeName() == "Camera":
        print p
Edited by simon_o - 2021年2月1日 10:35:53
Pipeline @ RISE Visual Effects Studios
User Avatar
Member
19 posts
Joined: 12月 2018
Offline
Oh I see my mistake was trying to run in external editor. That makes more sense now ! Thank you guys you are legends
  • Quick Links