# Relative reference to object property in material driver?

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?

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

Using a simple material example -

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 -

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.

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.

• 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.. – gandalf3 Mar 5 '14 at 21:10
• Might there be a Python expression that could determine the current object referring to the material (instead of var)? – Chuck Feb 6 '15 at 22:38
• @Chuck No, but JerryNo has come up with a way around this - see his answer here. – sambler Feb 7 '15 at 12:17