Python Shelf tool - get stage prim names

   2028   3   1
User Avatar
Member
385 posts
Joined: July 2018
Offline
Seems like stage.editableStage() is not working inside the shelf tool but it does work in the python script LOP.
i am trying to get all my stage prims that are Meshes and just print their names


import hou

path = hou.ui.selectNode(node_type_filter=hou.nodeTypeFilter.Lop)

node = hou.node(path)

m = hou.LopSelectionRule()
m.setPathPattern('{ usd_istype(0, @primpath, "Mesh") }')
paths = m.expandedPaths(node)


stage = node.editableStage()
for path in paths:
    prim = stage.GetPrimAtPath(path)
    print(prim)

i get this error
"Traceback (most recent call last):
File "my_tool", line 18, in <module>
AttributeError: 'NoneType' object has no attribute 'GetPrimAtPath'"
Edited by papsphilip - June 25, 2022 16:27:17
User Avatar
Staff
4462 posts
Joined: July 2005
Offline
Use node.stage() to get a read-only version of the stage. editableStage is only for use within a python LOP where you are actually allowed to edit the stage.
User Avatar
Member
385 posts
Joined: July 2018
Offline
mtucker
Use node.stage() to get a read-only version of the stage. editableStage is only for use within a python LOP where you are actually allowed to edit the stage.
where can i look in the documentation for all available python LOPs functions?
Edited by papsphilip - June 26, 2022 15:17:07
User Avatar
Member
288 posts
Joined: Nov. 2013
Offline
papsphilip
where can i look in the documentation for all available python LOPs functions?

www.sidefx.com/docs/houdini/hom/hou/LopNode.html
  • Quick Links