houdini pattern matched attributes with HOM

   7442   10   1
User Avatar
Member
380 posts
Joined: July 2005
Offline
wondering if its possible to get a filtered list of attributes
obtained via HOM using houdinis pattern matching syntax.
we currently filter with python regex, but a user wants
to be able to work with houdinis pattern matching syntax:

attrs = hou.node('/obj/geo/blah').geometry().primAttribs()

filter with houdini pattern matching syntax

* Matches any string.
? Matches any single character.


Matches any of the characters between the square brackets. This does not support character ranges using a hyphen (you cannot do ).
^pattern Removes strings matching pattern from the previous match.
User Avatar
Member
380 posts
Joined: July 2005
Offline
still not having much luck… a node can glob paths this way..
but im looking to basically filter an arbitary list of strings
(no invocation on the node) using houdinis pattern matching
logic … i know theres code in the hdk to do this, but i wondered
if some script gurus could point me in a direction before i attempt
to implement a custom hom dso. maybe thats the only way?
User Avatar
Member
1906 posts
Joined: Nov. 2006
Offline
I'm afraid there isn't really really anything available for pattern matching with Houdini's pattern syntax other than the things you've mentioned.

I'm not sure if it's been RFE'd though. I can see both pattern matching for attribute searching, as well as more general matching on a list of strings as good RFE ideas though.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
401 posts
Joined:
Offline
use fnmatch to filter the point attribute list.
this is not a science fair.
User Avatar
Member
380 posts
Joined: July 2005
Offline
fnmatch? wheres that from?
houdini expert in vancouver?
awesome.. where at?
User Avatar
Member
1906 posts
Joined: Nov. 2006
Offline
Ah yes, I forgot about the fnmatch module. So many useful modules to keep track of these days.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
380 posts
Joined: July 2005
Offline
fantastic. thanks!
User Avatar
Member
380 posts
Joined: July 2005
Offline
hmm, fnmatch is a native python module.
i was hoping there would be an entry point
to some houdini pattern matchin logic. for
instance,

>>> hou.hmatch(,“* ^life* ^d*”)



ie. match everything except those that match life and those that match d.
User Avatar
Staff
809 posts
Joined: July 2006
Offline
Well, it's a little ugly (and slow), but you can access the strmatch hscript function through hou.hscriptExpression.

So something like:

attrs = hou.node('/obj/geo/blah').geometry().primAttribs()
pattern = “* ^life* ^d”
filtered =
User Avatar
Member
401 posts
Joined:
Offline
True, fnmatch wouldn't match houdini's syntax.
For more complex queries you could use regex, though.
this is not a science fair.
User Avatar
Member
380 posts
Joined: July 2005
Offline
Thanks Johner! I've been playing around with
extending the hou module to use the hdk to
do houdini pattern matching, but so far i can
only figure out how to do pretty much the
same thing.

Anyone know whats happening under the hood
in the Attribute Sops' | Delete Attributes field?
This is exactly what i want.. any ideas where
to look in the hdk for this implementation?
at some level there has to be some string matching
happening.. I would just be surprised to discover
if its simply UT_String::matchPattern
  • Quick Links