Get animation cache frame range to a variable in Houdini (Python)

Example: You want to automate shot-based tasks and exports with python. To get the frame range data from the animated alembic cache to a variable you can use this method. 

Documentation on how to navigate data in info tree:

https://www.sidefx.com/docs/houdini/hom/hou/NodeInfoTree.html

The Alembic nodes info tree has a branch called “Alembic SOP Info” which contains rows: “Start Frame”, “End Frame”, “Frames/Second”, “Start Time”, and “End Time”. Each row is a tuple containing tuples of strings. 

For example: 

((‘Start Frame’, ‘0’), (‘End Frame’, ‘92’), (‘Frames/Second’, ‘24’), (‘Start Time’, ‘0’), (‘End Time’, 3.8333333’))

Access this data by storing the rows from the “Alembic SOP Info” branch to a variable and then loop through each item in this tuple. 

  • if the first item of the iterated tuple is “Start Frame”

    • store the second item of the iterated tuple to variable “fstart”

  • if the first item of the iterated tuple is “End Frame”

    • store the second item of the iterated tuple to variable “fend”

node = hou.node("/obj/alembic1/alembic1")

branches = node.infoTree().branches()

rows = branches["Alembic SOP Info"].rows()

for row in rows : 
	if row[0] == "Start Frame" :
		fstart = row[1]
	if row[0] == "End Frame" :
		fend = row[1]
Previous
Previous

Replace hairs that share root position (VEX)

Next
Next

Move hairs that are inside the geometry back to the surface (VEX)