How to retrieve Rebar in link document

How to retrieve Rebar in link document

kiencent94
Enthusiast Enthusiast
861 Views
8 Replies
Message 1 of 9

How to retrieve Rebar in link document

kiencent94
Enthusiast
Enthusiast

Hello.

I m trying retrieving Rebar in Link Document. 

I create a solid from Cropt box of Active View (The second pic below) in Host Document. Then i used ElementIntersectsSolidFilter to retrieve Elements in Link Document which intersect with Active View 's Solid.

But when i watch instanceElementsInViewRvL in debugging mode, there were no Rebar, only Floor and FamilyInstance..

I need some helps to retrieve Rebar in Link Document.

 

 

 

var bbActiveView = ActiveView.get_BoundingBox(null);
var solidActivew = bbActiveView.CreateSolidFromBBox();
var solidIntersecFil = new Autodesk.Revit.DB.ElementIntersectsSolidFilter(solidActivew);
instanceElementsInViewRvL = new FilteredElementCollector(RevitLinkDocument)?.WhereElementIsNotElementType().WherePasses(solidIntersecFil);

1.png2.png

Thanks,

Kien

0 Likes
862 Views
8 Replies
Replies (8)
Message 2 of 9

kiencent94
Enthusiast
Enthusiast

Any help please

 

Thanks,

Kien

0 Likes
Message 3 of 9

BenoitE&A
Collaborator
Collaborator

Hi,

It looks like a very classical problem of Revit API, which is : you can not filter elements from a given view in a Linked document.

you can try the usual :

FilteredElementCollector collector = new FilteredElementCollector(linkedDocument, viewFromHostDocument);

And you will see Revit can not perform this. 

 

You should probably try another way. For example, filter all the Rebar of the linked document, find the one closer to a given location. Pay attention to the Transformation between Host and Linked document though.

Good luck !


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/
0 Likes
Message 4 of 9

kiencent94
Enthusiast
Enthusiast

I tried to find all instance element in Link Document, then i used ElementIntersectsSolidFilter to filter elements which intersects with a given solid (Solid from Cropt Box of ActiveView in Active Document).

As my code and 2 pictures i attached above, The solid of Active View in Active Document definitely intersects 3 element of Link Document (Rebars,Floor, Framing). But my code couldn't retrieve Rebar, just retrieve Floor and Framing

 

Thanks,

Kien

 

0 Likes
Message 5 of 9

BenoitE&A
Collaborator
Collaborator

My guess is: your intersection is between elements from different documents. I mean: either your box is from HostDocument; or the Floors and Framing are from Host and Rebar from LinkedDocument... 

Another point: usually in Revit you have an option when you use methods like ElementIntersectsSolidFilter to search elements from the LinkedDocument and not only in the Host. Did you check this?


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/
0 Likes
Message 6 of 9

kiencent94
Enthusiast
Enthusiast
Thank for your comments.
In my example , the box is from host document, Floor, FamilyInstance
(Framing), Rebars are from link document.
As my code ( first attached picture ) i used solid of Active View ( 2nd pic
) from Host Document to retrieve elements from Link Document (all element
in pic 2 are from Link Document) by ElementIntersectSolidFilter.
As u see in 1st pic, in debug mode, it just retrieved floor and framing,
not rebars...
Apologize for my english is not good.

Thanks,
Kien
0 Likes
Message 7 of 9

BenoitE&A
Collaborator
Collaborator

Hey,

Looks like you don't get it so I'll try to be clear : 

In this line you create a filter based on a view from your Host Document : 

var solidIntersecFil = new Autodesk.Revit.DB.ElementIntersectsSolidFilter(solidActivew);

 And here you use it hoping you can intersect elements from your Linked Document :

instanceElementsInViewRvL = new FilteredElementCollector(RevitLinkDocument)?.WhereElementIsNotElementType().WherePasses(solidIntersecFil);

Revit can not do this (filter stuff from a Linked Doc using a filter based on a view of the Host Doc).

So you have to find another way of thinking.


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/
Message 8 of 9

kiencent94
Enthusiast
Enthusiast

If Revit couldn't do the filter as u said, so why did i retrieve Floor and Framing, both of this from Link Document. U could see these in the 1st pic (debugging mode).

I think u are misunderstanding, i dont use the method that search and filter visible element in a View and a Document:

public FilteredElementCollector
	 ( Document document,
	ElementId viewId )

I use another that search and filter the set of elements in a Document:(Corresponding for my example is LinkDocument)

public FilteredElementCollector
	( Document document )

Thanks,

Kien

0 Likes
Message 9 of 9

BenoitE&A
Collaborator
Collaborator

Hi,

Indeed you must be right and I must be wrong. 

Your solidActiveView (creating a solid from the view) is pretty clever and might avoid the problem that I mentionned, so all in all you should retrieve your Rebar. 

I would add a filter on categories to ease the search for Revit (since you know you are searching for Rebar) but still, your problem looks... odd.

Another way of trying to do it is: 

Filter all the document on Rebar.

Localize your solidActiveView

Find the closest Rebar from the solidActiveView


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/
0 Likes