Try to export Lights Geometry without its light source geometry (bulb or cone)

Try to export Lights Geometry without its light source geometry (bulb or cone)

pbobz
Contributor Contributor
1,522 Views
7 Replies
Message 1 of 8

Try to export Lights Geometry without its light source geometry (bulb or cone)

pbobz
Contributor
Contributor

 

Hi Fellow Programmers of the Revit API,

 

Any one knows how to not export the "light source" geometry.

 

I read somewhere on the forum that you can skip geometry based on solids face matrerial if it's name is "Default Light Source". However, in my case Face.MaterialID is always -1.

 

And don't see any way to export the light geometry without its light bulb/cone.

 

Any suggestion ? 🙂

 

 

0 Likes
Accepted solutions (2)
1,523 Views
7 Replies
Replies (7)
Message 2 of 8

Revitalizer
Advisor
Advisor
Accepted solution

Hi,

 

GraphicsStyle graphicsStyle = doc.GetElement(solid.GraphicsStyleId) as GraphicsStyle;

if (graphicsStyle != null)
{
    if (graphicsStyle.GraphicsStyleCategory.Id.IntegerValue == (int)(BuiltInCategory.OST_LightingFixtureSource))
    {
        // light sources geometry
    }
}

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 3 of 8

pbobz
Contributor
Contributor

 

 

Thanks,

 

I tried something similar :

 

if (gStyle.GraphicsStyleCategory.Name == "Light Source")
       continue;

 

but without any success.

Hope your BuiltInCategory way will work 🙂

 

Be right back to tell you,

0 Likes
Message 4 of 8

Revitalizer
Advisor
Advisor

Hi,

 

whenever possible, you should use the language independent approach.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 5 of 8

Revitalizer
Advisor
Advisor

Hi,

 

supposing you have a French Revit, the Category's name will be translated (by Revit) into its French equivalent (if it is a top level Category).

Thus, "Light Source" won't work, except you translate it into French...

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 6 of 8

pbobz
Contributor
Contributor

 

Nop, same effect. I keep exporting light source geometries even when I skip those based on graphicstyle.

 

 foreach (GeometryObject obj in geoElement)
{
                GeometryInstance geoInstance = obj as GeometryInstance;
                GraphicsStyle gStyle = doc.GetElement(obj.GraphicsStyleId) as GraphicsStyle;
                if (gStyle != null)
                {
                    if (gStyle.GraphicsStyleCategory.Id.IntegerValue == (int)(BuiltInCategory.OST_LightingFixtureSource))
                        continue;
                }

                    ExtractSolid(doc, VRobj, solid, color);
}
0 Likes
Message 7 of 8

Revitalizer
Advisor
Advisor
Accepted solution

Hi,

 

the GeometryInstance contains futher sets of geometry, it is a container.

 

Use the approach on Solid level, not on GeometryInstance level.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 8 of 8

pbobz
Contributor
Contributor

Excellent !

 

Thanks for pointing that to me.

 

It's working like a charm. Thanks for all the advices.

 

Regards

0 Likes