[Sidefx-houdini-list] OperationFailled exception when comparing two node tupes in HOM

Graham Thompson captainhammy at gmail.com
Fri Oct 30 17:11:02 EDT 2009

Unfortunately as you have encountered hou.HDADefinition.nodeType() will
always throw an exception when attempting to call it on an instance of
hou.HDADefinition from a file that is not installed.  Having an existing
hou.NodeType means that Houdini has that operator loaded and it can create
one.    In this case all you can do is compare nodeTypeName strings and
nodeTypeCategories to make sure they are the same.

if assetDef.nodeTypeName()  == definition.nodeTypeName() and
assetDef.nodeTypeCategory() == definition.nodeTypeCateogry()

2009/10/30 Pablo Giménez <pablogipi at gmail.com>

> Hi, just a quick one about HOM.
> I have a snippet of code that basically goes through all the otls files in
> a
> location and check if a given definition exists in the otl.
> So I am getting the otls defintions with: hou.hda.definitionsInFile(otl)
> The I compare the node types, bascially this is what I am doing:
> def getDefinitionInOtl(definition, otl):
>    # Get definitions in the otl:
>    definitions =  hou.hda.definitionsInFile(otl)
>    if len(definitions) == 0:
>    raise st.TypeError('Given otl hasn`t any definition: \n' +
> otl.libraryFilePath())
>    for assetDef in definitions:
>    if assetDef.nodeType()  == definition.nodeType():
>        return assetDef
>    # Not found
>    raise st.ValueError("Definition cant be found in the otl:\n" +
> otl.libraryFilePath())
> Well to make it works I have to change:
> if assetDef.nodeType()  == definition.nodeType():
> by:
> if assetDef.nodeTypeName()  == definition.nodeTypeName():
> Sometimes I got an exception of type OperationFailled because the
> definition
> is not installed if I compare two hou.NodeType.
> A work around is t ocompare string instead, althoug is not perfect.
> My question is why I can compare and get the names of the node types but
> not
> compare both of them.
> thx
> --
> Un saludo
> Best Regards
> Pablo Giménez
> _______________________________________________
> Sidefx-houdini-list mailing list
> Sidefx-houdini-list at sidefx.com
> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list

More information about the Sidefx-houdini-list mailing list