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
$\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.

|improve this answer|||||
$\endgroup$
  • $\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 Mar 5 '14 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 Feb 6 '15 at 22:38
  • $\begingroup$ @Chuck No, but JerryNo has come up with a way around this - see his answer here. $\endgroup$ – sambler Feb 7 '15 at 12:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.