Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Change New Floor Plans Properties: Detail Level, Elevation, etc.

1 REPLY 1
Reply
Message 1 of 2
sam.z
1344 Views, 1 Reply

Change New Floor Plans Properties: Detail Level, Elevation, etc.

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?

 

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;
}

 

1 REPLY 1
Message 2 of 2
Felix_Seguin
in reply to: sam.z

I know it's an old question, but I stumbled upon the same problem and found a solution (at least for the View Range part) . In your code, you get the View Range with this:

PlanViewRange viewRange = floorPlan.GetViewRange();

 Which is fine, then you adjust the values with this:

viewRange.SetLevelId(PlanViewPlane.TopClipPlane, viewRange.Unlimited);
...
viewRange.SetOffset(PlanViewPlane.TopClipPlane, PLANE_VIEW_OFFSET);
...

 Which is again the way to go. But you never assigned the modified View Range to your view: 

floorPlan.SetViewRange(viewRange);

This should work.

 

I haven't checked for your Detail Level and Elevation problems, but at least this will get one of the three out of the way. Hope this helps.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community