BoundingBoxXYZ and CropBox problem

BoundingBoxXYZ and CropBox problem

Anonymous
Not applicable
696 Views
1 Reply
Message 1 of 2

BoundingBoxXYZ and CropBox problem

Anonymous
Not applicable


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? 

0 Likes
697 Views
1 Reply
Reply (1)
Message 2 of 2

grahamcook
Advocate
Advocate

zhao

 

I had a similar issue when modifying the cropbox of an elevation view and also experienced the inverse effect.  See following post:

 

http://forums.autodesk.com/t5/Autodesk-Revit-API/Modify-CropBox-of-Elevation-View/td-p/3604982

 

Joe.Ye was going to feed this back to the delopment team.

 

Graham

 

 

0 Likes