Jump to content

Rename materials according to a parameter


ben

Recommended Posts

I'm trying to do something similar. When you load a geometry file with the "`" key get a geometry node automatically named for the file sop's file string. I would like this to persist, so that choosing a different file will again rename the geometry node.

I've not done any python expressions or callbacks before, so thanks in advance for the guidance.

Link to comment
Share on other sites

I'm trying to do something similar. When you load a geometry file with the "`" key get a geometry node automatically named for the file sop's file string. I would like this to persist, so that choosing a different file will again rename the geometry node.

I've not done any python expressions or callbacks before, so thanks in advance for the guidance.

Seriously did not know that ` was a short cut for loading a file. Thanks :)

I don't think something like that is very hard. Add the following to the callback for a file parameter in your asset.

import os; kwargs["node"].setName(os.path.basename(kwargs["node"].evalParm("file")))

Where "file" is the parameter name that should be used to set the node's name.

EDIT: Make sure you set the callback to Python.

Edited by hopbin9
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...