ReferenceIntersector.FindNearest does not intersect with Curtain Walls

ReferenceIntersector.FindNearest does not intersect with Curtain Walls

Anonymous
Not applicable
3,275 Views
8 Replies
Message 1 of 9

ReferenceIntersector.FindNearest does not intersect with Curtain Walls

Anonymous
Not applicable

When I use ReferenceIntersector.FindNearest, it will find a wall, but it doesn't find a curtain wall.

 

My code is:

 

var view3d = RUtils.Get3dView(doc);

ReferenceIntersector refIntersector = new ReferenceIntersector(
        new ElementCategoryFilter(BuiltInCategory.OST_Walls),
        FindReferenceTarget.Element,
        view3d
);

var x = refIntersector.FindNearest(stairBase, baseDirection);

and after executing this, the `x` is `null`.

I know the base point and direction are fine because when I change the type of wall in the UI to be, say "Interior - Partition" instead of "SH_Curtain wall" and rerun the code, then it does find it.  I expect it to intersect the curtain wall also since using the Revit Lookup tool, the curtain wall has BuiltinCategory of "OST_Walls" (just like the partition wall).

 

BTW, the function for getting the 3d view is:

 

        public static View3D Get3dView(Document doc, bool createIfNull=true)
        {
            FilteredElementCollector collector = new FilteredElementCollector(doc).OfClass(typeof(View3D));

            foreach (var elem in collector) {
                var view = (View3D) elem;
                if (view.IsTemplate || view.IsPerspective) {
                    continue;
                }

                if (view.IsSectionBoxActive) {
                    var trans = new Transaction(doc);
                    trans.Start("disable section box");
                    view.IsSectionBoxActive = false;
                    doc.Regenerate();
                    trans.Commit();
                
                    return view;
                }
            }

            return createIfNull ? create3dView(doc) : null;
        }


How can I have it intersect the curtain wall also?

0 Likes
Accepted solutions (2)
3,276 Views
8 Replies
Replies (8)
Message 2 of 9

RPTHOMAS108
Mentor
Mentor

Reference intersector will only work if item is visible in view you use. So you should not be picking at random because view discipline, manual hide, category hide etc. all affect what is visible in an existing view.

 

Either create a new view with what you are aiming at visible or use one which you know the visibility settings of. The issue may be something else but it is usually this.

0 Likes
Message 3 of 9

Anonymous
Not applicable

Thanks @RPTHOMAS108, that's good to know about creating a new 3D view.  I will keep that in mind.

 

In this case, that appears not to be the issue.  I replaced my call to get the 3D view to be:

 

var view3d = RUtils.create3dView(doc);

and that function looks like:

 

public static View3D create3dView(Document doc) {
    ViewFamilyType vft = new FilteredElementCollector(doc)
            .OfClass(typeof(ViewFamilyType))
            .Cast<ViewFamilyType>()
            .FirstOrDefault(x => ViewFamily.ThreeDimensional == x.ViewFamily);
    using (var trans = new Transaction(doc)) {
        trans.Start("Create 3D View");
        var view3D = View3D.CreateIsometric(doc, vft.Id);
        trans.Commit();
        return view3D;
    }
}

But it still does not find the curtain wall.  I've also confirmed the curtain wall is

 

I've drawn a model line for debugging purposes to show the line from the intersection (or no line if no intersection is found).  If I keep the wall as "Interior - Partition", then it intersects it (see attachment).  If curtain wall, it does not intersect...

Any other ideas?

 

 

0 Likes
Message 4 of 9

Anonymous
Not applicable

In case it's helpful, here's another example of the result. Notice it goes straight through the curtain wall, but stops at the wall.  This is the sample project that ships with Revit 2018.

0 Likes
Message 5 of 9

so-chong
Advocate
Advocate

hi, try to replace:

 

var x = refIntersector.FindNearest(stairBase, baseDirection);

with:

 

ReferenceWithContext x = refIntersector.FindNearest(stairBase, baseDirection);

FindNearest Method:

http://www.revitapidocs.com/2017.1/866e1f2b-c79a-4d9f-1db1-9e386dd42941.htm

 

i'm not sure if this helps, is this a code snippet?

 

it will help to post your code completely where things might go wrong.

0 Likes
Message 6 of 9

RPTHOMAS108
Mentor
Mentor
Accepted solution

Perhaps you need to use a logical or filter for the component categories of the curtain wall element i.e.

 

OST_CurtainWallPanels

OST_CurtainWallMullions

OST_Walls (Also include normal wall category for other non curtain walls)

 

etc.

 

When you select the wall it highlights the wall container which then has visible geometry reported to the lookup tool. Ordinarily geometry is invisible, so there is no geometry to find in the OST_Walls element. This is my theory.

Message 7 of 9

Anonymous
Not applicable

Awesome, including `OST_CurtainWallPanels` and `OST_CurtainWallMullions` indeed solved it.  Thanks!

I'm wondering how, in the future, I'll be able to know the relevant component categories, so I can answer my own question next time.  I think I can do it with Loadable Families since I can edit the family and see its different components, but for a system family like walls I don't know how to do that.  Is there a way to see the component categories?  Somewhere in the Revit Lookup tool perhaps?

 

@so-chong, thanks for your answer also.  I don't think that was the issue.  Since FindNearest already returns a ReferenceWithContext object, I reckon leaving it as `var` is equivalent to explicitly declaring the type.

0 Likes
Message 8 of 9

RPTHOMAS108
Mentor
Mentor
Accepted solution

Yes, you can select the subcomponent by hovering over with the mouse and then pressing tab repeatedly to cycle through items.

 

Lookup tool then lists the category as below.

 

Can also extract the values and names from the BuiltInCategory enum and look for likely items there.

 

Capture0303.PNG

Message 9 of 9

Anonymous
Not applicable

Awesome, thanks!

0 Likes