How to evaluate stage from hython

   222   3   2
User Avatar
Member
16 posts
Joined: 2月 2016
オフライン
Hi, we would like to run a validate function we have on a write node on the incoming lop input. The problem we have is that the stage doesn't seem to be callable from a hython process. I found this post, but I found it incomplete. Instead of necro bumping the original post, could someone explain why we can't cook or cook(force=True) the stage node despite the method being available?
https://www.sidefx.com/forum/topic/76888/ [www.sidefx.com]

In my last test I took a fresh scene, set the manual mode up and then loaded a pighead and I tried to evaluate stage. While I am using the UI for this, I would normally be using only a hython process for the task cited before. The manual mode is just to test with different cases while assuming the issue is the same in hython. Train of thought being if it still doesn't work in manual mode, it wouldn't work either in hython.
User Avatar
Member
16 posts
Joined: 2月 2016
オフライン
From https://www.sidefx.com/forum/topic/76888/#post-328394 [www.sidefx.com]

mtucker
Ah! That is an important piece of information

You can write a function like this:
def getstage(lop):
  hou.setUpdateMode(hou.updateMode.AutoUpdate)
  stage = lop.stage()
  hou.setUpdateMode(hou.updateMode.Manual)
  return stage

Since this whole function gets run on the main thread, the UI will have no reason to update between the two setUpdateMode calls, and this should have minimal impact on the Houdini session, other than to cook the specified LOP node.

This "issue" isn't specific to LOPs either. All node types will behave this same way in "Manual" mode, refusing to cook no matter how nicely or forcefully you ask. You must (at least temporarily) exit Manual mode to get anything to cook.

It is said by staff that this ain't a LOP issue, but if I look at a geometry object in sop, I can access the geometry without switching mode by simply calling `node.geometry()`
User Avatar
スタッフ
4574 posts
Joined: 7月 2005
オフライン
I believe you are mistaken about the behavior of node.geometry(). It will not cook the SOP. If the SOP has already been cooked, then yes, it will return the geometry generated by this SOP the last time it cooked. But if the SOP has not been cooked, the geometry returned by node.geometry() will be empty.

LOPs is a little different from SOPs in regards to returning the last cooked result. This is because every SOP node keeps its own copy of the geometry it generated last time it cooked. LOPs do not keep a full USD stage for each LOP node. LOP nodes in a chain will generally share a USD stage, and edit and recompose this stage when you look at the cooked stage from one node then another in a chain. In Manual mode, even this recomposing is avoided, so the stage you get back from node.stage() may not be the same stage last cooked by that node. It may be the state of that shared stage as understood by some other node in the chain of LOP nodes.
User Avatar
Member
16 posts
Joined: 2月 2016
オフライン
What would be possible to do if we want to evaluate the stage from a said node in lops? One idea we had was to try and force a write of the stage to disk, then look at it using the api to be able to view the stage from said input. Would there be better ways to get the stage in a non auto update mode?
  • Quick Links