How to Disregard Pipes that are Vertical

How to Disregard Pipes that are Vertical

aciavardini
Participant Participant
610 Views
3 Replies
Message 1 of 4

How to Disregard Pipes that are Vertical

aciavardini
Participant
Participant

Hello,

 

I currently have a FilteredElementCollector finding all pipes in the model. I would like to disregarded pipes that are vertical/have a slope equal to "Not Computed". What is the best way to achieve this?

public Result Execute(ExternalCommandData edata, ref string message, ElementSet elements)
        {
            UIDocument uidoc = edata.Application.ActiveUIDocument;
            Document doc = uidoc.Document;

            Transaction t = new Transaction(doc, "Auto Trench");
            t.Start();

            // Find all Pipes in Model
            FilteredElementCollector pipes = new FilteredElementCollector(uidoc.Document);
            List<Pipe> pipeList = pipes.OfClass(typeof(Pipe)).OfType<Pipe>().ToList();

aciavardini_1-1666065572953.png

 

Thanks.

 

0 Likes
Accepted solutions (1)
611 Views
3 Replies
Replies (3)
Message 2 of 4

Moustafa_K
Advisor
Advisor

All pipes are driven from a Linework. if you extracted the line from the pipe and checked its Z direction against 1, then you will be able to filter that out ... see the below code if does help

 

foreach (Pipe pipe in pipeList)
{
    var pipeCurve = pipe.Location as LocationCurve;
    var pipeLine = pipeCurve.Curve as Line;
    if (pipeLine.Direction.Z == 1) continue;

    //do my stuff to not 100% vertical Pipes
}
Moustafa Khalil
Cropped-Sharp-Bim-500x125-Autodesk-1
0 Likes
Message 3 of 4

jeremy_tammik
Alumni
Alumni

Thanks to Mostafa for one initial approach.

  

If you choose to follow that suggestion, I would definitely add some fuzz, i.e., compare the Z direction to be almost equal to 1.0, not exactly equal.

  

https://thebuildingcoder.typepad.com/blog/2022/08/instances-in-room-and-need-for-fuzz.html#3

 

This kind of comparison requires post-processing of the filtered element collector results.

 

If you can check the verticality or the slope not computed property up front using existing properties or parameters on the pipe elements, you might be able to replace the post-processing by significantly faster quick or slow filters:

 

http://thebuildingcoder.typepad.com/blog/2015/12/quick-slow-and-linq-element-filtering.html

  

However, depending on your requirements, the post-processing might be perfectly acceptable, and it is probably the easiest approach.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 4 of 4

rtg.dev015A9H9
Participant
Participant
Accepted solution

Hi @aciavardini ,
This is another approach, maybe more performant:

Parameter slopeParam = pipe.get_Parameter(BuiltInParameter.RBS_PIPE_SLOPE);
if (slopeParam.HasValue)  
{
	//Do something 
}
else
{
	//Do another thing on pipes with parameter slope "Not Computed"
}

 I did a few tests and it appears that "Not computed" pipes always have this parameter property set to false.

@aciavardini 

0 Likes