# Location of object in OSL

I'm running Blender 2.78

Using OSL, I am trying to find the location of an object. In the Node editor, I am in Shader Nodes for World. The object I'm trying to find is a UV sphere named 'MySun' and has an emitter material using cycles.

In the OSL script, I'm trying to get the location of MySun like this:

vector Sv;
getattribute("MySun","object:location", Sv);


When I run it, I get an EXCEPTION_ACCESS_VIOLATION error and Blender crashes. I've searched all over for the correct way to do this and have found people saying it couldn't be done, or that you can only get the location of the current object. What's the current object when you're working on "World"?

These were posts from several years ago, so I'm hoping that if there was a bug it's fixed by now, because the documentation certainly seems like getattribute is made to get the attributes of any object you name.

Is there another way I'm supposed to reference an object?

Thanks!

This functionality still not supported. And will not in the near future - see developers answer here https://developer.blender.org/T52154

But you can "Bake" scene objects into OSL script and query object parameters in material nodes later. There is even addon for that: https://github.com/IPv6/kristallum/blob/master/blender/addons/sceneFeatBaker_v01.py

It creates text block with OSL shader (or replace existing one), that can find object location, dimensions, orientation, etc during render by name and/or name prefix. For direct use in material nodes

Seems it still not possible... Filled bug report, hope this will be fixed at last

https://developer.blender.org/T52027