Show Element Relative to Model in View3D
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I’m having trouble finding a way to adjust a perspective 3D view to show the region that is already showing as well as a specific element. I have this working for 2D because all I have to do is make a new BoundingBoxXYZ that includes both the current CropBox and the BoundingBoxXYZ of my element, then set view.CropBox = newBox. I've attached pictures to show this operation in a 2D view.
I want to mimic this behavior with 3D views. My ideas was to orient the view facing down then do the same crop box union but set the eye of the view to the center of the XY plane of the new box and at a Z value high enough to see everything.
The problem I’m running into is that I can’t find a good way to get or set the corners of the crop box as it is projected onto a specific plane (such as the plane defined by the height of the element). From what I can tell from this source: https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2017/ENU/Revit-API/files/GUID-... the CropBox of a perspective view basically just gives corners of the front clipping plane and the distance to the back clipping plane. I’m not sure how to tell what region is currently visible, or how to predict what region will be made visible by setting the CropBox to a new BoundingBoxXYZ.
I’m also not sure how to figure out what Z value to place the eye at since I can’t find a field of view angle or anything else to find the relationship between the dimensions of the projection plane and the distance from the plane to the eye.
I’m wondering if I’ve missed anything that already exists to do this, or if anyone has any ideas. I’ve been stuck on this for a while now and it is entirely possible that I’ve been staring at my code too long to see the obvious solution. I would also appreciate any alternative suggestions if someone has a different, hopefully less complicated way to show the element in relation to the model.
For context, I’m making an add-in that includes a visual representation of a particular point in 3D, such as the base point, the survey point, or any other point the user wants to be able to reference easily. I place a family instance of the "Diagnostic Tripod-1 point" at the reference point. Right now I can use UIDocument.ShowElement but that doesn’t give any context for where the point is relative to the rest of the model. If I have a survey point 700 ft. from a building and I zoom in and show just that point then it can be difficult to find the rest of the model again, which usually defeats the purpose of showing the point in the first place.
Thanks for your time!