using Autodesk.Revit.DB; using System; namespace HYJig { public class ViewAssist { public static bool ViewValidating(Document doc, View activeView) { bool flag; if (activeView.GetType() == typeof(ViewPlan)) { ViewPlan viewPlan = activeView as ViewPlan; if (viewPlan.SketchPlane == null) { Plane plane = Plane.CreateByOriginAndBasis(viewPlan.Origin, viewPlan.RightDirection, viewPlan.UpDirection); Transaction transaction = new Transaction(doc); transaction.Start("new sketchPlane"); activeView.SketchPlane = SketchPlane.Create(doc, plane); transaction.Commit(); } flag = true; } else if (activeView.GetType() == typeof(ViewSection)) { ViewSection viewSection = activeView as ViewSection; if (viewSection.SketchPlane == null) { Plane plane2 = Plane.CreateByOriginAndBasis(viewSection.Origin, viewSection.RightDirection, viewSection.UpDirection); Transaction transaction2 = new Transaction(doc); transaction2.Start("new sketchPlane"); activeView.SketchPlane = SketchPlane.Create(doc, plane2); transaction2.Commit(); } flag = true; } else { flag = false; } return flag; } } }