Refer here for corrected code:
http://thebuildingcoder.typepad.com/blog/2013/10/set-view-section-box-to-match-scope-box-for-revit-2...
this is code to create a new view:
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) {
Autodesk.Revit.DB.Document doc = commandData.Application.ActiveUIDocument.Document;
UIDocument uidoc = commandData.Application.ActiveUIDocument;
ISelectionFilter iselfilterScopeBox = new ScopeBoxesSelectionFilter();
Element eScopeBox = doc.GetElement(uidoc.Selection.PickObject(ObjectType.Element, iselfilterScopeBox, "Please select a Section Box"));
View3D view3DCurrent = doc.ActiveView as View3D;
if (view3DCurrent == null) {
TaskDialog.Show("XXX", "Please use this command in a 3D view.");
return Result.Failed;
}
BoundingBoxXYZ bbXYZScopeBox = GetSectionBoundingBoxFromScopeBox(eScopeBox, view3DCurrent.ViewDirection);
ViewOrientation3D vieworientation3D = view3DCurrent.GetOrientation();
using (Transaction t = new Transaction(doc, "Create View")) {
t.Start();
ViewFamilyType viewFamilyType = (from v in new FilteredElementCollector(doc).OfClass(typeof(ViewFamilyType)).Cast<ViewFamilyType>()
where v.ViewFamily == ViewFamily.ThreeDimensional
select v).First();
View3D view3DNew = View3D.CreateIsometric(doc, viewFamilyType.Id);
view3DNew.SetOrientation(vieworientation3D);
view3DNew.SetSectionBox(bbXYZScopeBox);
t.Commit();
uidoc.ActiveView = view3DNew;
}
return Result.Succeeded;
}