Scripting_Create a batch Material importer from a texture list?

Started by twinch, October 26, 2022, 11:21:24 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


Hello everyone

I am working on a large project where I need to create a material that is derived from existing texture files.  I don't have any experience with Keyshot Scripting/python so I'm kind of shooting in the dark here.

The importer would need to create a material from the cloth default material, grab a texture in a folder and place in the diffuse channel, change the UV scaling to DPI and use the dpi of the texture image and then save the file as the same name as the texture name in the same folder.

Is this even possible?



Yes, this is possible.  I only know enough about Python to be dangerous.  Using the following functions may provide you with what you want.

Imports materials from MTL file into material library. Note: It is required that resource libraries are loaded once per session - the operation blocks while loading.
file = MTL File path to import materials from. *
folder = The existing sub material library folder to add the materials to, i.e. 'Glass/Basic' (default = '.', which is the root materials folder).

Gets all textures of the library. Note: It is required that resource libraries are loaded once per session - the operation blocks while loading.
filter = Filter by relative path in library, e.g. 'Textures/Wood'.

Find nodes in the subtree of this node by searching part names and material names. If no names or materials are given then it will find everything.
name = Part name to search for (string/tuple/list).
mat = Material name to search for (string/tuple/list).
all = Match all part names or all material names (default = false).
types = Filter results to match types (int/tuple/list) which can be the following the values: lux.NODE_TYPE_GROUP, lux.NODE_TYPE_OBJECT, lux.NODE_TYPE_ANIMATION, lux.NODE_TYPE_MODEL_SET, and lux.NODE_TYPE_MODEL default = all types).
depth = The amount of levels to go down the tree. A value of 1 means to only match the direct children of this node etc. (default = -1 = all)

Applies a material to an object in the scene.
mat = Material name to apply. *
obj = Object ID to apply to. *

Set material of a node. If applying to a group then it will apply to all sub nodes.
mat = The name of the material or multi-material to apply. It can also be an instance of lux.MultiMaterial.

Set concrete value of shader parameter. Cannot be called on pure parameters.
value = The supported input types depend on the shader parameter type. *

Applies a material mapping.
dict = Dictionary of object IDs to material names. *