Does Lop Import not support primitive path patterns?

   2543   4   2
User Avatar
Member
78 posts
Joined: 5月 2018
オフライン
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
354 posts
Joined: 11月 2013
オフライン
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 - 2022年6月17日 17:04:22
User Avatar
Member
78 posts
Joined: 5月 2018
オフライン
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
354 posts
Joined: 11月 2013
オフライン
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 - 2022年6月17日 20:30:50
User Avatar
スタッフ
793 posts
Joined: 10月 2012
オフライン
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