Jump to content
Korhon

Create HDA using python

Recommended Posts

Hi! 

 

Anyone know how to create an .hda using pyton? Want a script to do the same as rightclick/Create Digital Asset does.

 

Thanks :)

Share this post


Link to post
Share on other sites

hou.Node.createDigitalAsset() + 10 other hou.Node's methods dealing with hda.

Share this post


Link to post
Share on other sites

This is the way I have done it in the past when creating a digital asset from a shelf tool:

# Create new digital using OBJ subnet as a base
temp_node = hou.node("/obj").createNode("subnet")

# Create new digital asset from temp node
hda_node = temp_node.createDigitalAsset(
  name = hda_name,
  hda_file_name = hdalib_directory + hda_name,
  description = "DESCRIPTION",
  min_num_inputs = 0,
  max_num_inputs = 0,
)

hda_node.setName("NAME")

# Get HDA definition
hda_def = hda_node.type().definition()

# --------------------------------------------
# Do whatever you need to do with the HDA here
# i.e. Creation, copying and organisation of children:

hou.moveNodesTo(tuple(other_premade_node), hda_node)
hda_node.layoutChildren()
# -------------------------------------------

# Update and save new HDA
hda_options = hda_def.options()
hda_options.setSaveInitialParmsAndContents(True)
hda_def.setOptions(hda_options)
hda_def.save(hda_def.libraryFilePath(), hda_node, hda_options)

 

  • Like 3

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×