2
$\begingroup$

I have scripted texture offset through script for blender internal material enter image description here

loc = bpy.data.objects["RigName"].pose.bones["BoneName"].location.x
bpy.data.materials["MaterialName"].texture_slots[7].offset[0] = loc

What is the syntax to access texture mapping location in Cycles Material

I have the idea of setting up drivers but as i have already scripted it like above showed example for many of the characters so it will help to know the syntax in speeding change to cycles

$\endgroup$

1 Answer 1

3
$\begingroup$

Let's assume Mapping is the unique name/identifier for the Mapping node in question. To find the unique node name, select the node and view the Side panel (N key).

enter image description here

The code to access the Location vector for Mapping is:

>>> bpy.data.materials['Material'].node_tree.nodes['Mapping'].translation
Vector((0.0, 0.0, 0.0))

or more structured

mat = bpy.data.materials['Material']
nodes = mat.node_tree.nodes
mapping = nodes['Mapping']
mapping.translation = 1.0, 0, 0   # accepts tuple

Hover over the properties and the tooltip will give a hint as to where to find most properties. But for materials, the path is via data.materials and not data.node_groups as the tooltip suggests.

$\endgroup$
2
  • $\begingroup$ Thanks great help. Please add clarification saying 'mapping' is node-name. And in case of many textures mapped to same material like in my case, one needs to refer to the appropriate node-name of that particular mapping node. Please add screenshot of where to find the node-name. Please correct me if wrong. $\endgroup$
    – ashwin
    May 24, 2015 at 11:49
  • 1
    $\begingroup$ I think finding the unique node name would have been an excellent separate question, as it will be generic and apply to many many other cases. Whereas now, someone might still ask that question, not knowing that the answer is also in this question. messy. $\endgroup$
    – zeffii
    May 24, 2015 at 12:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .