Jump to content

trying to automatically create a materialbuilder based on primAttrib(name)


zetavfx

Recommended Posts

Hi, let me explain the best way I can.

1.- I have multiple objects in an alembic

2.- They have name attr

3.- I want to create a material (pxrmaterialbuilder) with that name attr and have it assigned to that object with a material node

 

I am trying to do it with a python node written like this (not like this, this does´t work)

node = hou.pwd()
geo = node.geometry()

# Add code to modify contents of geo.
# Use drop down menu to select examples.
import hou
import itertools

# Define geometry node name
geometryName = 'name'

# Get scene root node
sceneRoot = hou.node('/obj/Ship/matnet1/')
# Check if "MY_GEO" exists
if hou.node('/obj/{}'.format(geometryName)) == None:
    # Create empty geometry node in scene root
    geometry = sceneRoot.createNode('pxrmaterialbuilder', run_init_scripts=False)
    # Set geometry node name
    geometry.setName(geometryName)
    # Display creation message
    hou.ui.displayMessage('{} node created!'.format(geometryName))
else:
    # Display fail message
    hou.ui.displayMessage('{} already exists in the scene'.format(geometryName))

 

Here are my questions:

 

1.- How do I pass the attr name to the pxr node?

2.- Is this the way to go?

 

thanks.

 

Z.-

 

image.thumb.png.b8296645f2c762c7aae037db0bb0130c.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...