Introducing sQuery - a jQuery-like library for Houdini

   3600   4   2
User Avatar
Member
3 posts
Joined: Jan. 2015
Offline
Hey guys! Meet sQuery, a jQuery-like library I have been developing for easy scene queries and modifications in Houdini. You can download and read more about it on github:

https://github.com/hibernationTheory/sQuery [github.com]

sQuery provides an easy-to-interface to perform complex scene queries and modifications over your scene. Better to show an example than to try to explain:

After importing the module, you would initialize it for a context.
sq = sQuery.sQuery(“obj”)
Here is a simple example:
sq.children(“*house*”).filter(“t#instance”).children(“t#alembic”).replaceAttrValue(“filename, ”v002“, ”v003")
# for all the children of the object context that has the word “house” in it filters those that are of type ‘instance’, gets the alembic nodes inside them and replaces the v002 in their filename attr value to v003.

Here is a more complex example:
sq.children(“*geo*”).remove(“*HOUSE*).filter(”t#instanc*“).children(”t#alembic “).replaceAttrValue(”filename“, ”v002“, ”v003“)
.setUserData(”is_altered“, ”true“).addToBundle(”alembics_inside_instances“).layout().next(”t#switch“).createNodeAfter(”delete“, {”group“:”*_arms_“}).toggle(”affectnumber“).select().setColor(”red").move(-10, -10)

“”“
gets all the children in obj context with name that matches to the *geo* pattern, from that removes those that have the word *HOUSE* in it, from the result filters those whose type name matches to the *instanc* pattern, chooses the alembic type children of the result for which the filename value contains the word ”main“ in it. replaces the ‘v002’ on the alembic nodes filename parameter with ‘v003’, creates a user data on them called ”is_altered“ with the value ”true“ and adds those alembics to the bundle ”alembics_inside_instances“, lays them out (layoutChildren on the nodes) and selects the next node if it is of type switch and creates a delete node after them with the ‘group’ parameter set to ‘*_arms_*’, toggles the affectnumber parameter on this delete nodes (meaning if it is on, makes it off or vice versa) and then sets a viewport selection on these ‘delete’ nodes that were created, also sets their color to red and moves them to -10 at x and -10 y. All in a single line.
”“”


Let me know what you think of it.
Thanks!
User Avatar
Member
459 posts
Joined: Oct. 2011
Offline
This is great! Having done quite a lot of jQuery, this looks very easy.

Cheers
Bonsak
http://www.racecar.no [www.racecar.no]
User Avatar
Member
3 posts
Joined: Jan. 2015
Offline
I am glad you liked it! I am trying to keep the API pretty similar to jQuery. All the selection methods like sibling, next, find, filter… pretty much works similar to their jQuery equivalents.

If you can think of any method that is there which would be good to have in here please let me know.

Thanks,
Engin
User Avatar
Member
183 posts
Joined: Nov. 2008
Offline
That's interesting, thx for sharing.
Aleksei Rusev
Sr. Graphics Tools Engineer @ Nvidia
User Avatar
Member
3 posts
Joined: Jan. 2015
Offline
no worries, @Stalkerx777, let me know if you think of a cool method to have in there and I can try to implement it.

Thanks!
  • Quick Links