revit三维转到俯视图并缩放匹配选定元素

根据需要转到特定角度的三维视图,首先查找需要转到三维视图的up Direction 和Right Direction 并据此算出forwardDirection。 

            UIDocument uidoc = commandData.Application.ActiveUIDocument;
            Document doc = uidoc.Document;
            UIApplication uiapp = commandData.Application;
            Application app = uiapp.Application;
            View3D v3 = uidoc.ActiveView as View3D;
            ICollection ids = uidoc.Selection.GetElementIds();
            if (!(uidoc.ActiveView is View3D))
            {
                return Result.Cancelled;
            }
            v3.SetOrientation(new ViewOrientation3D(new XYZ(), new XYZ(0, 1, 0), new XYZ(0, 0, -1)));
            //如果不缩放匹配需要刷新下三维视图
            //uidoc.RefreshActiveView();
            if (ids.Count!=0)
            {
                uidoc.ShowElements(ids);
            }

 

你可能感兴趣的:(revit二次开发)