Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Elevation view - determine if family is visible

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
aricke59
973 Views, 8 Replies

Elevation view - determine if family is visible

I am trying to automate tagging of families in elevation views and have it all working correctly except for the fact that items hidden by a wall ( or some other item) are also tagged. Because the item is visible in wire frame mode the geometry can be retrieved and therefore I cannot determine if the family is visible in the view and therefore whether the item should be tagged.

 

Is there any way of determining if the item is visible and therefore should be tagged?

 

I have also looked at the Custom Exporter - IExportContext however this only works for 3D views.

 

Heopfully there is some really simple option I am missing.Book Case behind wall

8 REPLIES 8
Message 2 of 9
Joe.Ye
in reply to: aricke59

 

Revit didn't  expose the straightforward API to check if an object is in the back of another element in a given view.

Fortunately, Revit exposed the ReferenceIntersector class to analysis the elements' spatial relationship. ReferenceIntersector..::..Find() method can

project a ray from the origin along the given direction, and returns all references from intersected elements which match the ReferenceIntersector’s criteria.
 
So you can use Find() method , set the origin to the family's location, and direction is from the family instance to the view's direction to get if walls in the ray.
 
Hope this helps.

 

 

 



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
Message 3 of 9
jeremytammik
in reply to: Joe.Ye

Dear Aricke,

 

I just discovered that you already submitted the same issue to ADN in case 10128426 [Elevations - Determine if an item is hidden by other items - Advice required].

When you submit issues repeatedly and there is a chance that an ADN advisor might answer, please let us know of the other related cases. That will save us effort and enable us to provide better support to you and other developers.

 

Here is my previous answer to the related case, for others to see as well:

 

The Revit API offers several powerful methods to determine occlusion of objects.

 

The two that spring to mind are the ray tracing and extrusion analysis functionality provided by the ReferenceIntersector and ExtrusionAnalyzer classes.

 

ReferenceIntersector -- http://lmgtfy.com/?q=revit+api+ReferenceIntersector

 

ExtrusionAnalyzer -- http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.29

 

Shadow Calculation -- http://thebuildingcoder.typepad.com/blog/2013/06/sun-direction-shadow-calculation-and-wizard-update....

 

I hope this helps.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 4 of 9
aricke59
in reply to: jeremytammik

Hi Jeremy,



Sorry for the doubling up of requests. I didn't get much response to the
request on the forum so used the more direct ADN approach which was handled
much faster.



It does still strike me as curious that there is no simple property / method
that reports on whether an item displays any geometry in a view.



The referenceintersector relies on a 3D view which is really not useful when
dealing with a 2D view. Duplicating the 2D view to 3D with all the
visibility override possibilities is likely to display / not display things
that should be shown / not shown. Certainly transferring all the vis
settings correctly is likely to require a great deal of coding.



The extrusion analyser and shadow calculation approaches would also fail for
families that often do not have 3D geometry, eg. A Nurse call button, gas
outlets, power outlets. These items are quite visible in an elevation but
without 3D geometry the two methods would fail. These items could also be
mounted on a desk (furniture) modesty panel. I haven't tried it, however
with the way furniture is handled I would have some doubts about the
referenceintersector hitting the geometry of the desk correctly. The power
outlet may actually be enclosed within the furniture bounding box yet may be
visible or hidden by the modesty panel.



Perhaps something for the API wishlist.



Thanks again for your assistance.



Kind regards,



Andreas Ricke - Director



ARSS-Logo-Full-email


ARSoftwareSolutions

45 Stirling Rd Croydon Vic 3136

E: mailto:info@arsoftwaresolutions.com.au| T: +6 13 9724 9341 | M:
0421214274 | W: www.arsoftwaresolutions.com.au
Message 5 of 9
Anonymous
in reply to: aricke59

 
Message 6 of 9
jeremytammik
in reply to: aricke59

Dear Andreas,

 

No problem at all. I was just wondering a bit where I recently heard or saw something similar and then it took a little while to hunt down. Sorry for my terrible memory 🙂

 

Please feel free to formulate a wishlist item for the 2D occlusion determination and submit a new case for that.

 

However, I would imagine that if you reduce it to 2D, it has so little to do with reality and there is so much left open to interpretation that it would end up being easier toimplement it yourself than even just try to formulate exactly what it is you need in a way that would also make it useful for others.

 

For the 2D case, all you need to do is collect lines, determine which ones you consider are hiding which others, and see whether a straight line can be drawn from A to B without hitting any obscuring line in between.

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 7 of 9
Anonymous
in reply to: aricke59

If you only wanted to handle the case of items obscured by a wall found in the view you could grab the location line of the wall and use it to create a vertical plane. With that plane you could implement a signed point distance to plane method to test each element for its location in front of or behind the wall.

 

Signed point distance to plane is one of my most used methods, it is quite useful for sorting lists of points relative to an arbitrary axis.

 

Here's my implementation:

 

public static Double SignedPointDistanceToPlane(XYZ point, Plane plane)
{
    return point.Subtract(plane.Origin).DotProduct(plane.Normal);
}

 

 

 

Message 8 of 9
aricke59
in reply to: jeremytammik

Hi Jeremy,

 

your comment about this routine unlikely to be useful to others surprises me. I have come across various items on your blog about determining if items are visible or not in a view. With the possibility of an item being hidden, its category being hidden, it's workset not open, the workset in a linked item not being open, or the item simply hidden in part or fully behind another item.

 

With all these possibilities it becomes almost impossible to be certain of whether an item actually results in some part of that item being "drawn" in the view. Clearly this is handled by Revit whenever it "draws" a view. A simple (on the face of it) routine such as "IsDrawnInView" would be helpful in tagging routines and would probably have other uses.

 

At present I do not think any of the proposed solutions would correctly identify if an item is or is not visible.

Message 9 of 9
aricke59
in reply to: Anonymous

Thanks Scott, I love the succinct function you use. I have to admit my understanding of matrices disappeared quite some time ago. I would love to see Revit / Autodesk provide a good reference on manipulating points and planes. Does anyone have a good reference for such operations?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community