ElementIntersectsElementFilter with linked docs

ElementIntersectsElementFilter with linked docs

Anonymous
Not applicable
1,204 Views
7 Replies
Message 1 of 8

ElementIntersectsElementFilter with linked docs

Anonymous
Not applicable

Hi,

 

How do I make ElementIntersectsElementFilter work with linked docs.

 

Thanks & Regards

Sanjay Pandey

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

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Sanjay Pandey,

 

I am not sure whether ElementIntersectsElementFilter works directly with linked docs. I'll check for you.

 

Here is one possible approach to determine the location of the linked elements in the host document:

 

http://thebuildingcoder.typepad.com/blog/2013/11/determining-host-document-location-of-a-linked-elem...

 

You could use that as part of your solution.

 

Cheers,

 

Jeremy



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

0 Likes
Message 3 of 8

Anonymous
Not applicable

Hi,

 

Thanks for the help.

 

I got it working.

 

Thanks & Regards

Sanjay Pandey

0 Likes
Message 4 of 8

jeremytammik
Autodesk
Autodesk

Dear Sanjay Pandey,

 

Congratulations!

 

That was very quick indeed!

 

How, please?

 

I am sure this is of great interest to others as well.

 

Thank you for sharing!

 

Cheers,

 

Jeremy



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

0 Likes
Message 5 of 8

Anonymous
Not applicable
Accepted solution

 

ElementIntersectsElementFilter does not work with lilnked docs

 

but we can always loop the linked docs and use ElementIntersectsElementFilter with each linked doc.

 

Thanks & Regards

Sanjay Pandey

0 Likes
Message 6 of 8

Anonymous
Not applicable

Hi Sanjay,

 

How exactly did you make it to work? I'm in a similar situation and for me it is not working.

I have an element from a linked doc and another one from current doc and ElementIntersectsElementFilter fail to see the intersaction.

 

This is what I'm doing:

 

FilteredElementCollector collector = new FilteredElementCollector(element.Document, new List<ElementId> { element.Id });
collector.WherePasses(new ElementIntersectsElementFilter(elementFromLink));

 

and collector.GetElementCount() return 0

 

Thank you,

Claudiu

 

 

0 Likes
Message 7 of 8

Anonymous
Not applicable

Here it goes:

foreach (Document linkedDoc in doc.Application.Documents)
                {
                    FilteredElementCollector collectorn = new FilteredElementCollector(linkedDoc);
                    collectorn.WherePasses(new ElementMulticategoryFilter(builtInCats));
                    ElementIntersectsElementFilter testElementIntersectsElementFilter = new ElementIntersectsElementFilter(intersect);
                    collectorn.WherePasses(testElementIntersectsElementFilter);
                    foreach (Element elm in collectorn)
                    {
                        //string gt = elm.Id.ToString();
                        //TaskDialog.Show("IIPL", gt + "source " + intersect.Id.ToString());
                        got = true;
                        break;
                    }
                    if (got == true)
                    {
                        break;
                    }
                }

Thanks & Regards

Sanjay Pandey

0 Likes
Message 8 of 8

Anonymous
Not applicable

This filter only work when your linkrevitinstance do not have transform to the current project.

You can check by the method RevitLinkInstance.GetTransform().

 

I feel annoying about this limitation now.