Does Lop Import not support primitive path patterns?

   1849   4   2
User Avatar
Member
78 posts
Joined: May 2018
Offline
I'm trying to dynamically select a camera that I know will exist somewhere in the USD tree (under /cameras/**) but I do not know its exact location or name. I was hoping that I could use the expression `/cameras/** & %type:Camera` but that only seems to work on the primitive paths in Solaris, not on OBJ level nodes like LopImportCamera.

Any suggestions for alternate ways to do this sort of fuzzy primitive lookup in the OBJ context?
User Avatar
Member
276 posts
Joined: Nov. 2013
Offline
LopImportCamera can only represent a single camera and a fuzzy lookup might match multiple. In lops you could try creating a reference to the first camera found under /cameras, that then gives you a fixed/known name to use in the obj node. Something like this in python lop might work.

node = hou.pwd()
stage = node.editableStage()
cameras = stage.GetPrimAtPath('/cameras')
for prim in Usd.PrimRange(cameras):
    if UsdGeom.Camera(prim):
        stage.DefinePrim('/obj_cam').GetReferences().AddInternalReference(prim.GetPath())
        break

and then point the LopImportCamera node at /obj_cam
Edited by antc - June 17, 2022 17:04:22
User Avatar
Member
78 posts
Joined: May 2018
Offline
Yeah, I figured it was probably due to something like that. I was just hoping that there might be a way to limit the result to the first match returned or something.

Still, using an internal reference is an interesting idea. Do you know if that would cause issues with the USD structure? Would that reference then show up in exported .usd files?
User Avatar
Member
276 posts
Joined: Nov. 2013
Offline
Ashen
Would that reference then show up in exported .usd files?
It depends what branch you export. The LopImportCamera requires a lop node so you could have the node that's adding the reference live outside the branch you plan to export. You could also use a context option to switch off these kinds of extras during export.

One thing to watch for is if you have a more complex transform hierarchy above the camera. Referencing just the camera prim won't magically bring along the parent transforms (or any other inherited attributes) so make sure to reference the appropriate parent prim if needed.
Edited by antc - June 17, 2022 20:30:50
User Avatar
Staff
733 posts
Joined: Oct. 2012
Offline
Using a primitive pattern will be supported for the LOP Import Camera node in the next major release.
(If there are multiple matches, a warning will be issued and one of the primitives will be chosen)
  • Quick Links