Light Source with ElementIntersectsFilter

Light Source with ElementIntersectsFilter

AnatolyCEL
Enthusiast Enthusiast
1,359 Views
7 Replies
Message 1 of 8

Light Source with ElementIntersectsFilter

AnatolyCEL
Enthusiast
Enthusiast

Hello,

 

I found incorrect behavior of ElementIntersectsElementFilter and ElementIntersectsSolidFilter. Lighting Fixture derived from family that has Light Source component, if the Light Source component intersects with another element only, then whole Lighting Fixture elements consider by the filters, as intersection.

 

Light Source.png

 

Lighting Fixtures.png

 

In attacment  example of Revit project. Macro: IntersectFilter.Example

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

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Anatoly,

 

Thank you for your query and very clear sample material.

 

I logged the issue REVIT-90948 [ElementIntersectsElementFilter and ElementIntersectsSolidFilter error with Light Source component -- 11765548] with our development team for this on your behalf as it requires further exploration and possibly a modification to our software. Please make a note of this number for future reference.

 

You are welcome to request an update on the status of this issue or to provide additional information on it at any time quoting this change request number.

 

This issue is important to me. What can I do to help?

 

This issue needs to be assessed by our engineering team, and prioritised against all of the other outstanding change requests. Any information that you can provide to influence this assessment will help. Please provide the following where possible:

 

  • Impact on your application and/or your development.
  • The number of users affected.
  • The potential revenue impact to you.
  • The potential revenue impact to Autodesk.
  • Realistic timescale over which a fix would help you.
  • In the case of a request for a new feature or a feature enhancement, please also provide detailed Use cases for the workflows that this change would address.

 

This information is extremely important. Our engineering team have limited resources, and so must focus their efforts on the highest impact items. We do understand that this will cause you delays and affect your development planning, and we appreciate your cooperation and patience.

 

I hope this helps.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 8

EKey
Advocate
Advocate

Hi Jeremy,

 

My name is Evgeny. We work together with Anatoly for developing Revit apps.

 

Thank you for your attention for the problem. We would like to see it fixed, but for now we have a workaround: with our clash detection application we consider every solid for interferences excluding the light source. As so, it doesn't make a critical impact for our company.

 

 

Here are the answers for your questionary:

  • Impact on your application and/or your development.

The app development requires using more sophisticated algorithms to overcome the problem. We want to see the problem solved as we can make our application more reliable and faster.

 

 

  • The number of users affected.

There are approximately 50 users in our company using the app.

 

 

  • The potential revenue impact to you.

As workaround exists, the impact is not critical.

 

 

  • The potential revenue impact to Autodesk.

N/A

 

 

  • Realistic timescale over which a fix would help you.

2 months.

 

 

  • In the case of a request for a new feature or a feature enhancement, please also provide detailed Use cases for the workflows that this change would address.

What we would like to see for the ElementIntersect method:

  • Take elements from linked model. Currently we break down the linked elements for solids.
  • It would be nice to have an option to consider an element with all nested Families as one single piece.

 

 

Thanks again for you attention and help.

 

 

Best Regards,

Evgeny.

 

 

 

 

0 Likes
Message 4 of 8

AnatolyCEL
Enthusiast
Enthusiast

Hello Jeremy,

 

In addition to Evgeny post.

 

Find in attachment our workaround for temporary resolving the problem. Macro: IntersectFilter.Example

 

Thanks,

Anatoly.

0 Likes
Message 5 of 8

jeremytammik
Autodesk
Autodesk

Dear Anatoly and Evgeny,

 

Thank you very much for your updates, business case and new sample.

 

I added them as notes to the issue REVIT-90948 [ElementIntersectsElementFilter and ElementIntersectsSolidFilter error with Light Source component -- 11765548] that I raised with our development team for you.

 

Can you maybe also provide a verbal description of the principles of your workaround?

 

If you think it might be helpful for others as well, I can promote this to a main blog post on The Building Coder.

 

Thank you!

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 6 of 8

AnatolyCEL
Enthusiast
Enthusiast

Hello Jeremy,

 

This is me example with comments:

 

// I found that solid's graphics style name is equal to category name of instance family components.
// So I can exclude unnessossory solids from consideration.
        public void Example()
        {
            // List of excluded category name
            List<string> excludedSolids = new List<string> { "Light Source" };
            
            // Take the Duct for our test
            FilteredElementCollector collector = new FilteredElementCollector(Document);
            collector.WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_DuctCurves);
            Element element = collector.FirstElement();
            collector.Dispose();
            
            List<Element> elements = new List<Element>();
            
            // Retrieve all solids from the duct, build ElementIntersectsSolidFilter for each excluding defained before in excluded list,
            // and get list of intersected elements
            IEnumerable<GeometryObject> solids = getSolids(element);
            foreach (Solid solid in solids)
            {
                if (solid.GraphicsStyleId != null && !solid.GraphicsStyleId.Equals(ElementId.InvalidElementId) &&
                    excludedSolids.Contains(Document.GetElement(solid.GraphicsStyleId).Name))
                    continue;
                
                ElementFilter intersectsFilter = new ElementIntersectsSolidFilter(solid);
                collector = new FilteredElementCollector(Document);
                IList<Element> intersected = collector.WhereElementIsNotElementType()
                                                      .Excluding(new List<ElementId> { element.Id })
                                                      .WherePasses(intersectsFilter).ToElements();
                collector.Dispose();
                foreach (Element intersect in intersected)
                    if (!elements.Exists(el => el.Id.Equals(intersect.Id)))
                        elements.Add(intersect);
            }

            // But found intersected elements in its turn can have excluded solids, so we have to do second check:
            // for each found element retrive solids, exclude defained before in excluded list, build ElementIntersectsSolidFilter for each
            // and check intersection with the source element (Duct in our test)
            List<ElementId> removingElements = new List<ElementId>();
            foreach (Element intersectedElement in elements)
            {
                solids = getSolids(intersectedElement);
                bool solidSecondChecked = false;
                foreach (Solid solid in solids)
                {
                    if (solid.GraphicsStyleId != null && !solid.GraphicsStyleId.Equals(ElementId.InvalidElementId) &&
                        excludedSolids.Contains(Document.GetElement(solid.GraphicsStyleId).Name))
                        continue;
                    
                    ElementFilter intersectsFilter = new ElementIntersectsSolidFilter(solid);
                    collector = new FilteredElementCollector(Document, new List<ElementId> { element.Id });
                    solidSecondChecked = collector.Excluding(new List<ElementId> { intersectedElement.Id })
                                                  .WherePasses(intersectsFilter).Any();
                    collector.Dispose();
                    if (solidSecondChecked)
                        break;
                }
                if (!solidSecondChecked)
                    removingElements.Add(intersectedElement.Id);
            }
            elements.RemoveAll(el => removingElements.Contains(el.Id));

            Selection.SetElementIds(elements.Select(el => el.Id).ToArray());
            TaskDialog.Show("Result""Duct intersects " + elements.Count + " element.");
        }
        // Finaly, we have correct list of intersected elements with the duct.
        
        private IEnumerable<GeometryObject> getSolids(Element checkingElement)
        {
            IEnumerable<GeometryObject> solids;
            GeometryElement geometryElement = checkingElement.get_Geometry(new Options { DetailLevel = ViewDetailLevel.Fine });
            solids = geometryElement.Where(geometry => geometry.GetType().Equals(typeof(Solid)));
            if (!solids.Any())
            {
                GeometryInstance geometryInstance = (GeometryInstance)geometryElement.FirstOrDefault(geometry => geometry.GetType().Equals(typeof(GeometryInstance)));
                if (geometryInstance != null && geometryInstance.Transform.IsConformal)
                {
                    geometryElement = geometryInstance.GetInstanceGeometry();
                    solids = geometryElement.Where(geometry => geometry.GetType().Equals(typeof(Solid)));
                }
            }
            return solids;
        }

 

Thanks,

Anatoly.

0 Likes
Message 7 of 8

AnatolyCEL
Enthusiast
Enthusiast

Find also in attachment the samle project

 

Anatoly.

0 Likes
Message 8 of 8

jeremytammik
Autodesk
Autodesk

Dear Anatoly,

 

Thank you very much for the additional explanation!

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes