The Global Archicad Community

Stay informed. Get help. Share your knowledge.

Discussions about using GRAPHISOFT's tools (Archicad API, BIMx API, BIMcloud API) for independent software developers

Moderators: ejrolon, Barry Kelly, Karl Ottenstein, LaszloNagy, Gordana Radonic, nbalogh, gkmethy, mnguyen, Viktor Kovacs, Mihály Palenik, Tibor Lorántfy, rmasaki, MOREH Tamas, Akos Somorjai, Ed Brown

By drjustice
#327752
Hi. I'm confused about how to treat lights. I use the ModelerAPI.

From the model, I can get a list of all elements (walls, stairs, windows, doors, handrails, etc) and get their GUIDs. There is also an element of type LightElement, so that's great.

From a ModelerAPI::Model instance, I can enumerate lights by index, and it returns instances of ModelerAPI:Light classes (containing color, spot direction, range, etc).

I can also enumerate lights by index from a ModelerAPI::Element, same as from a ModelerAPI::Model.

I'm confused about what these ModelerAPI::Light instances refer to.

I can see 4 possibilities for what it means to enumerate lights by index from the model or an element. Either:

(1) A ceiling or wall element has lights attached to it and we can enumerate such lights. So for example, if there was a ceiling with 12 embedded pot lights, I could enumerate lights from the ceiling element, and I would get those 12 pot lights. (That could make sense)

(2) enumerating lights from an element only returns lights when the element is actually of type LightElement. In this case, enumerating (possibly multiple) lights means something like a light fixture with multiple light bulbs. (Might make sense too)

(3) there are, somehow, lights in the model that aren't actually Elements and aren't identifiable with a GUID. (God I hope not)

(4) refers to the list of lights that participate in the illumination of this element. (Doesn't make much sense to me)

So, which one is it?

If it's case (1), how would I find, only armed with an index and/or a ModelerAPI::Light instance, the GUID of the corresponding light element ? The ModelerAPI::Light class only contains data like color, spot direction, falloff, but nothing about the element it comes from.
By drjustice
#328847
Replying to my own question here.

It appears that the lights at the element level are lights that are part of the element.

For example, if you have a lamp with one light bulb, then you'll have 1 light for this element. The bulb's position will be located at the place in the lamp where light should be emitted.

As another example, if you have an overhead ceiling light with 3 neon tubes in the light fixture, then the element will have 3 lights.

Enumerating the lights at the model level gives global lights.