Hello
I am creating a new Floor Plan view/level. And my code sets the new views' elevation, detail level and view range offsets.
My Problem: Whilst my code sets the views' elevation, detail level and view range offsets. When I run my addin and inspect the new view. The elevation, detail level and view range offsets haven't changed at all? The elevation, detail level and view range offsets have their default values.
Note: the view and level is created successfully but its elevation, detail level and view range offsets values dont change/get set. Also my code is executing within a transaction that is committed, so thats not a cause.
Any idea what I am doing wrong and how I can set the elevation, detail level and view range offsets?
I am creating a new Floor Plan view/level. And my code sets the new views' elevation, detail level and view range offsets.
My Problem: Whilst my code sets the views' elevation, detail level and view range offsets. When I run my addin and inspect the new view. The elevation, detail level and view range offsets haven't changed at all? The elevation, detail level and view range offsets have their default values.
Note: the view and level is created successfully but its elevation, detail level and view range offsets values dont change/get set. Also my code is executing within a transaction that is committed, so thats not a cause.
Any idea what I am doing wrong and how I can set the elevation, detail level and view range offsets?
Code:
public static Level createPlanLevel(Document doc, string name="", double elev=0.00) { Level level = doc.Create.NewLevel(0); level.Name = name; ElementId nid = level.Id; IEnumerable<ViewFamilyType> viewFamilyTypes = null; ViewPlan floorPlan = null; // Try to create floor plan level try { viewFamilyTypes = from elem in new FilteredElementCollector(doc).OfClass(typeof(ViewFamilyType)) let type = elem as ViewFamilyType where type.ViewFamily == ViewFamily.FloorPlan // .StructuralPlan // select type; floorPlan = ViewPlan.Create(doc, viewFamilyTypes.First().Id, nid); } // If user is in a structural project (users who use Revit Structural can only create one type of project) catch (Exception e) { viewFamilyTypes = from elem in new FilteredElementCollector(doc).OfClass(typeof(ViewFamilyType)) let type = elem as ViewFamilyType where type.ViewFamily == ViewFamily.StructuralPlan select type; floorPlan = ViewPlan.Create(doc, viewFamilyTypes.First().Id, nid); } // Problems Here: The created view's/level's elevation, detail level and offsets dont ever change! level.Elevation = elev; floorPlan.DetailLevel = ViewDetailLevel.Fine; floorPlan.CropBoxActive = false; PlanViewRange viewRange = floorPlan.GetViewRange(); viewRange.SetLevelId(PlanViewPlane.TopClipPlane, viewRange.Unlimited); viewRange.SetLevelId(PlanViewPlane.BottomClipPlane, viewRange.Unlimited); viewRange.SetLevelId(PlanViewPlane.ViewDepthPlane, viewRange.Unlimited); viewRange.SetLevelId(PlanViewPlane.CutPlane, viewRange.Unlimited); viewRange.SetLevelId(PlanViewPlane.UnderlayBottom, viewRange.Unlimited); viewRange.SetOffset(PlanViewPlane.TopClipPlane, PLANE_VIEW_OFFSET); viewRange.SetOffset(PlanViewPlane.CutPlane, PLANE_VIEW_OFFSET); viewRange.SetOffset(PlanViewPlane.BottomClipPlane, -1 * PLANE_VIEW_OFFSET); viewRange.SetOffset(PlanViewPlane.ViewDepthPlane, -1 * PLANE_VIEW_OFFSET); //viewRange.SetOffset(PlanViewPlane.UnderlayBottom, viewRange.Unlimited); return level; }