Note assigning image textures to materials in Maya python

background

I want to script material settings in Maya.

procedure

Applying a Texture in Python https://forums.cgsociety.org/t/applying-a-texture-in-python/1573565/7

Assigning a Material using Pymel https://discourse.techart.online/t/assigning-a-material-using-pymel/1240

Assuming to use maya.cmds

import maya.cmds as mc

Create a File shader and set the texture file path.

Create a shader node and connect the attribute (e.g. color) of the shader to which you want to assign the texture to file.outColor.

It seems that shaders cannot be assigned directly to objects (mesh), so via a shadingGroup node (a node that collects surface shader, volume shader, etc.).

Connect the .surfaceShader of the shadingGroup node to the .outColor of the file shader.

Assign shadingGroup to an object. There seem to be many ways, but maya.cmds makes sets easier?

mc.sets("geo", edit=True, forceElement="sg1")

The structure is as follows (I wonder if it is easier to understand if you check with Maya Node editor)

object(mesh) <- shadingGroup node (.surfaceShader) <- (.outColor) File shader (.fileTextureName) <- Texture filename

development

If you want to assign it as volume shader or displacement shader, you can change the attribute connected to shadingGroup.

Recommended Posts

Note assigning image textures to materials in Maya python
How to adjust image contrast in Python
How to use Python Image Library in python3 series
Python Note: When assigning a value to a string
mayapy --Python in Maya
Image format in Python
Note to daemonize python
Convert the image in .zip to PDF with Python
Things to note when initializing a list in Python
How to create an image uploader in Bottle (Python)
Python OpenCV tried to display the image in text.
Python Note: The mystery of assigning a variable to a variable
[Note] How to write QR code and description in the same image with python
Login to website in Python
Python Input Note in AtCoder
Tweet with image in Python
Speech to speech in python [text to speech]
Image Processing Collection in Python
How to develop in Python
Post to Slack in Python
Exploring image filter parameters with blackbox optimization in Python Note
[Python] How to do PCA in Python
Implemented image segmentation in python (Union-Find)
[Note] Project Euler in Python (Problem 1-22)
Convert markdown to PDF in Python
How to collect images in Python
How to use SQLite in Python
Workflow to convert formula (image) to python
In the python command python points to python3.8
Try to calculate Trace in Python
How to use Mysql in python
How to wrap C in Python
How to use ChemSpider in Python
6 ways to string objects in Python
Foreign Key in Python SQLite [Note]
How to use PubChem in Python
Introduction to image analysis opencv python
How to handle Japanese in Python
An alternative to `pause` in Python
How to send a visualization image of data created in Python to Typetalk
Note: [Python3] Convert datetime to a string in any format you like
A note I looked up to make a command line tool in Python
I tried to implement PLSA in Python
[Introduction to Python] How to use class in Python?
Try logging in to qiita with Python
Install Pyaudio to play wave in python
How to access environment variables in Python
I tried to implement permutation in Python
Method to build Python environment in Xcode 6
How to dynamically define variables in Python
How to do R chartr () in Python
Pin current directory to script directory in Python
[Itertools.permutations] How to put permutations in Python
PUT gzip directly to S3 in Python
Introduction to Python Image Inflating Image inflating with ImageDataGenerator
Send email to multiple recipients in Python (Python 3)
Convert psd file to png in Python
Sample script to trap signals in Python
I tried to implement PLSA in Python 2
To set default encoding to utf-8 in python
Decorator to avoid UnicodeEncodeError in Python 3 print ()