How to Access a Wall Sweep from a wall instance from Revit 2015?

How to Access a Wall Sweep from a wall instance from Revit 2015?

Anonymous
Not applicable
1,628 Views
4 Replies
Message 1 of 5

How to Access a Wall Sweep from a wall instance from Revit 2015?

Anonymous
Not applicable

I'm trying to quantify a list of stacked walls.

 

If I used the filtered ElementCollector there is no problem because I select all an the wall sweeps that are on the project.

var collector = new FilteredElementCollector(this.Document, view.Id).WhereElementIsNotElementType();

 

But if I pick a collection of Stacked walls like this.

UIDocument.Selection.GetElementIds()

 

Only the Stacked walls are selected, with the property GetStackedWallMemberIds() I can access the walls, Is there a way to access the element id of the wall sweeps with a property?

 

When you have a wall sweep you can access the wall with the GetHostIds() Something similar but from the wall object.

 

Thanks.

 

 

0 Likes
Accepted solutions (1)
1,629 Views
4 Replies
Replies (4)
Message 2 of 5

Aaron.Lu
Autodesk
Autodesk
Dear,
Seems there is no way to directly get WallSweep from Wall, the only workaround is to filter all WallSweep and use GetHostIds() to check with wall it belongs to.


Aaron Lu
Developer Technical Services
Autodesk Developer Network
0 Likes
Message 3 of 5

Anonymous
Not applicable

Thanks I thought it could be other way.

 

I'm going to test it and see if doesn't slow down.

 

 

0 Likes
Message 4 of 5

Aaron.Lu
Autodesk
Autodesk
cool, looking forward to see the result 🙂


Aaron Lu
Developer Technical Services
Autodesk Developer Network
0 Likes
Message 5 of 5

Anonymous
Not applicable
Accepted solution

I come up with this solution

 

From the current selection I gather the Walls and Stacked Walls

UIDocument UIDocument;

UIDocument.Selection.GetElementIds().Select<ElementId, Element>(x => Document.GetElement(x)).Where(x =>

new BuiltInCategory[]

{

BuiltInCategory.OST_Walls,

BuiltInCategory.OST_StackedWalls

}.Contains((BuiltInCategory)x.Category.Id.IntegerValue));

Next I collect the Walls ids

IEnumerable<int> wallIds = currSel.Where(x => !(x as Wall).IsStackedWall).Select<Element, int>(x => x.Id.IntegerValue);

And Search for the walls contained on the Stacked walls

currSel.Where(x => (x as Wall).IsStackedWall).OfType<Wall>().ToList().ForEach(x => wallIds = wallIds.Union(x.GetStackedWallMemberIds().Select<ElementId, int>(y => y.IntegerValue)));

Then I select all the Wall Sweeps on the current view with the Filter Element Collector

IEnumerable<WallSweep> wallSweeps;

Document doc;

var collector = new FilteredElementCollector(doc).OfClass(WallSweep).ToElements();

IEnumerable<Element> selResult = from element in collector select element;

wallSweeps= selResult.OfType<WallSweep>();

 

And Finally collect the intersected elements

IEnumerable<Element> wsInSelWalls = wallSweeps.Where(x => x.GetHostIds().Select<ElementId, int>(y => y.IntegerValue).Intersect(wallIds).Count() > 0);