getParameters not reflecting newly added data

   2153   2   0
User Avatar
Member
2 posts
Joined: Sept. 2022
Offline
Hello,

I'm trying to write some Python to explore HAPI in depth (for example be sure of which parmType is any node)
I have written some Python code into a Python Script node directly in Houdini and using an inprocess session to connect.

I'm retrieving a specfic node from a path and listing the infos by using hapi.getParameters on the node in question.
I have defined a multiparmList in the node. When I add multiparm instances it is not reflected in the listing.
Same thing if I edit the parameter interface. I can only get the new parameters if I restart Houdini altogether.

example :

Session : <hapi.Session: type=sessionType.Inprocess, id=0>
Session is already Initialized
Node to query : /obj/test/
NodeId : 2
()
NodeName : test
Type : nodeType.Obj
TotalCookCount : 6
Valid : True
Number of params: 40
>>=================
Multiparmlist ===
MultiParmList : <hapi.ParmInfo: id=37, type=parmType.Multiparmlist>
Number of multiparm childs : 2
=== Child ===
float1 : <hapi.ParmInfo: id=38, type=parmType.FloatStart>
TemplateName : float#
=== Child ===
Int1_ : <hapi.ParmInfo: id=39, type=parmType.IntStart>
TemplateName : Int#_

Here is a reduced version of the script I am currently using :
import hapi 

session = hapi.createInProcessSession()

try:
    hapi.isInitialized(session)
    print("Session is already Initialized")
except:
    print("Session not Initialized, initializing")
    cook_options = hapi.CookOptions()
    hapi.initialize(session, cook_options, use_cooking_thread = False) 

def stringFromSH(nameSH):
    str_len = hapi.getStringBufLength(session, nameSH)
    name = hapi.getString(session, nameSH, str_len)
    return name

nodeToQuery = hou.chsop("/obj/HAPI_Explorer/inputNode")
node = hapi.getNodeFromPath(session, -1, nodeToQuery)

nodeInfos = hapi.getNodeInfo(session, node)
parmInfos = hapi.getParameters(session, node, 0, nodeInfos.parmCount)

for p in parmInfos:
    print(stringFromSH(p.nameSH) + " : " + str(p))
Edited by anthony_rey - Oct. 4, 2022 10:44:57
User Avatar
Member
122 posts
Joined: June 2019
Offline
Interesting. I've never used inprocess sessions and also never used python API.
I'm usually using thrift sessions and enabling session sync from client application. With this approach I don't see this behavior.

In your example I get correct result only if I set any parameter from client. Even if I just set it to the current value. So the possible workaround is just setting any parameter on the node to its value.

...

node = hapi.getNodeFromPath(session, -1, nodeToQuery)

v = hapi.getParmIntValue(session, node, "some_int_parm", 0)
hapi.setParmIntValue(session, node, "some_int_parm", 0, v)
hapi.cookNode(session, node, None) # it's also important to cook the node on the client

nodeInfos = hapi.getNodeInfo(session, node)

...

I'm not sure why it's working like that and also not sure if it's intended to use hengine like that inside houdini itself.
User Avatar
Member
2 posts
Joined: Sept. 2022
Offline
Hello,

It's consistent with what I have seen when using thrift sessions and session sync, I guess I'll have to keep doing that instead of doing it directly inside Houdini !

Thanks !
  • Quick Links