Return Linked Walls In Active View from User Selections

Return Linked Walls In Active View from User Selections

Mark.Ackerley
Advocate Advocate
2,454 Views
5 Replies
Message 1 of 6

Return Linked Walls In Active View from User Selections

Mark.Ackerley
Advocate
Advocate

Hi,

 

Apologies for what must be a basic question... As part of a larger script, when the user selects a single linked wall, I would like to return all the linked walls in the active view.  Unfortunately, instead, all the walls in the current document active view are returned!

 

Any advice greatly appreciated 🙂

 

Mark

 

 

 

 

obt = ObjectType.LinkedElement
refElemsLinked = uidoc.Selection.PickObjects(obt, "Please pick an element in the linked model")
linkInst = doc.GetElement(refElemsLinked[0].ElementId)
transform = linkInst.GetTotalTransform()
elem = doc.GetElement(refElemsLinked[0].ElementId)
docLinked = elem.GetLinkDocument()
fec=ElementCategoryFilter(BuiltInCategory.OST_Walls)
collectedWalls = FilteredElementCollector(docLinked,doc.ActiveView.Id).WherePasses(fec).WhereElementIsNotElementType().ToElements()

 

 

 

 

0 Likes
Accepted solutions (2)
2,455 Views
5 Replies
Replies (5)
Message 2 of 6

Mark.Ackerley
Advocate
Advocate

Hah, my test file was just a duplicate of my test link file, so Revit got confused 🙂

0 Likes
Message 3 of 6

TripleM-Dev.net
Advisor
Advisor
Accepted solution

Hi,

 

You can't retrieve elements from a linked document using a host view (they don't exist in same context!)

You need to create a virtual solid from the views extends (3D) and use this in the linkdocument as a intersection tool to get the walls using WherePasses and ElementIntersectsSolidFilter.

 

examples should be in this forum, see: Collect elements from link document in view of host document 

Under the assumption no linked elements are hidden by user, filter, phase settings etc...

 

- Michel

0 Likes
Message 4 of 6

Mark.Ackerley
Advocate
Advocate

Hey,

 

Thanks for the response, it seems to work fine here? Perhaps you would be good enough to clarify? (I'm really no expert at this!)

 

Capture.JPG

 

Cheers,

 

Mark

0 Likes
Message 5 of 6

TripleM-Dev.net
Advisor
Advisor
Accepted solution

Not clear what this all is, some explanation about source and results.

Dynamo nodes with some settings and a view which seems to have ALL walls in view (this would work yes!)

Any walls outside view?

 

Maybe the DynamoNode does the same internally (custom node from a external dynamo library?)

 

A picture as below would be more clearly.

The red elements were "visible" in the view of the host and the id's were used to mark the elements in the linked document. 

 

Callout_result2.PNG

 

0 Likes
Message 6 of 6

Mark.Ackerley
Advocate
Advocate

Hi,

 

Oh yes, good spot, if i crop my view down, i still get all the walls in the link!

 

I'll have a look at the link you posted.

 

Cheers,

 

Mark

0 Likes