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.
Solved! Go to Solution.
Solved by jeremytammik. Go to Solution.
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
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
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
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); }
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.