6
$\begingroup$

Is it possible to get a value such as the dimensions (object.dimensions) of an object in the material node editor, without referencing a specific object?

In other words, I want to get the dimensions of whatever object is using the material. How can I do this?

$\endgroup$

2 Answers 2

2
$\begingroup$

A driver is the only way I can think to access the object dimensions from a material.

Using a simple material example -

enter image description here

Add a driver to the field in a value node. Either right-click and select Add Driver or press D while the cursor is over the field. Setup the driver as -

enter image description here

Driver settings are shown in the properties panel of the Graph Editor when Drivers is selected in the header. This then mixes between the two diffuse nodes based on the dimension[0] value.

enter image description hereenter image description here

Note that auto-run python scripts needs to be enabled for drivers to work.

Obviously that is also rather rigid to the dimensions of one object. The Expr: of the driver can be any valid python, not sure of the path but there should be a way to go from the node with the driver to the parent object to choose the dimension value, which would be a more flexible way to use one material on multiple objects. I haven't had any luck accessing active_object in a driver.

$\endgroup$
3
  • $\begingroup$ Thanks, that's what I was afraid of. I want to be able to access the dimensions of the object with the material, hopefully without having to create drivers for each object.. $\endgroup$
    – gandalf3
    Commented Mar 5, 2014 at 21:10
  • $\begingroup$ Might there be a Python expression that could determine the current object referring to the material (instead of var)? $\endgroup$
    – Chuck
    Commented Feb 6, 2015 at 22:38
  • $\begingroup$ @Chuck No, but JerryNo has come up with a way around this - see his answer here. $\endgroup$
    – sambler
    Commented Feb 7, 2015 at 12:17
1
$\begingroup$

Perhaps it's easier than you think.

  1. Add INPUT->ATTRIBUTE in the shader editor.
  2. Switch Type to OBJECT.
  3. Insert Name YOUR CUSTOM PROPERTY
$\endgroup$

You must log in to answer this question.

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