- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
Recently I had a glance at Archicad and I noticed the way you could switch between floor plans while the size and position of the view remained the same. This way it's really easy to compare floor plans to each other. So I thought I would make a little add-in for Revit that can align all open views to the active view (obviously only works for floor/ceiling plans).
I found this post on the building coder: http://thebuildingcoder.typepad.com/blog/2012/06/uiview-and-windows-device-coordinates.html and came up with this small piece of code myself:
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { m_app = commandData.Application; Application app = m_app.Application; m_doc = m_app.ActiveUIDocument.Document; UIDocument uidoc = m_app.ActiveUIDocument; try { View aview = uidoc.ActiveView; IList<UIView> uiviews = uidoc.GetOpenUIViews(); UIView uiview = null; IList<XYZ> rect = new List<XYZ>(); foreach (UIView uv in uiviews) { if (uv.ViewId.Equals(aview.Id)) { uiview = uv; } } rect = uiview.GetZoomCorners(); foreach (UIView view in uiviews) { view.ZoomAndCenterRectangle(rect[0], rect[1]); } return Result.Succeeded; } catch (Exception) { return Result.Failed; }
I retrieve the model coordinates with the GetZoomCorners method and the apply those same coordinates to the ZoomAndCenterRectangle method. What happens is that all views except the active view get aligned to each other, but on a slightly off position from the active view. Is there anyone who knows the underlying workings of either of the above methods? Maybe it has something to do with the size of the property/project browser window?
Any advice would be welcome.
-Taco
Solved! Go to Solution.