Message 1 of 2
BoundingBoxXYZ and CropBox problem

Not applicable
11-13-2012
05:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using Autodesk.Revit; using Autodesk.Revit.DB; using Autodesk.Revit.UI; using Autodesk.Revit.ApplicationServices; namespace ViewTest { [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)] [Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)] [Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)] public class Program : IExternalCommand { public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { // Quit if active document is null if (null == commandData.Application.ActiveUIDocument.Document) { message = "Active document is null."; return Result.Failed; } Autodesk.Revit.UI.UIApplication app = commandData.Application; Document document = commandData.Application.ActiveUIDocument.Document; ViewFamilyType vft = new FilteredElementCollector(document) .OfClass(typeof(ViewFamilyType)).Cast<ViewFamilyType>() .FirstOrDefault<ViewFamilyType>(x => ViewFamily.ThreeDimensional == x.ViewFamily); View3D view3d = null; FilteredElementCollector collector = new FilteredElementCollector(document); FilteredElementIterator itor = collector.OfClass(typeof(Autodesk.Revit.DB.View)).GetElementIterator(); itor.Reset(); while (itor.MoveNext()) { Autodesk.Revit.DB.View view = itor.Current as Autodesk.Revit.DB.View; // skip view templates because they're invisible in project browser if (null == view || view.IsTemplate) { continue; } else { if (view.Name == "Aerial") { view3d = view as View3D; } } } Transaction transaction = new Transaction(document, "xx"); transaction.Start(); BoundingBoxXYZ bounding = view3d.CropBox; view3d.CropBox = bounding; view3d.CropBoxActive = true; view3d.CropBoxVisible = true; transaction.Commit(); return Autodesk.Revit.UI.Result.Succeeded; } } //end of class } //end of namespace
As above code , the result is strange, the view turned to a blank view, seems that the direction of the camera/eyesight changed inverse. But the result is right is the view "Aerial" is an isolated Isometric View,
How it happens?