Setting a drawing scale to a view

Setting a drawing scale to a view

Anonymous
Not applicable
1,763 Views
5 Replies
Message 1 of 6

Setting a drawing scale to a view

Anonymous
Not applicable

Hi,

 

I am trying to create a view in the revitapi (c#, 2019) and cannot set the drawing scale to it.

 

Any suggestions?

 

 

0 Likes
Accepted solutions (1)
1,764 Views
5 Replies
Replies (5)
Message 2 of 6

aignatovich
Advisor
Advisor

View has "Scale" property. Usually it is enough to set a value. The only problem could be if this value is controlled by view template.

 

0 Likes
Message 3 of 6

Anonymous
Not applicable
ViewPlan viewPlan = ViewPlan.Create(currentDoc, viewFamilyType.Id, levelId);

Is the code I've used to create the view, how do I see the view template?

0 Likes
Message 4 of 6

aignatovich
Advisor
Advisor

There are several options:

1) check viewFamilyType.DefaultTemplateId property

2) check viewPlan.ViewTemplateId property after a view plan was created

 

 

0 Likes
Message 5 of 6

Anonymous
Not applicable

viewPlan.ViewTemplateId  - null

viewFamilyType.DefaultTemplateId - gives me an ID

 

How do I change the drawing scale knowing this? 

 

Edit:

When i do try and set it, it says the parameter is read only.

0 Likes
Message 6 of 6

aignatovich
Advisor
Advisor
Accepted solution

if viewPlan.ViewTemplateId == ElementId.InvalidElementId just set viewPlan.Scale = 100 (for example)

 

In other cases, get view from ViewTemplateId:

var templateView = (View)doc.GetElement(viewPlan.ViewTemplateId);

then check this expression:

templateView.GetNonControlledTemplateParameterIds().Contains(ElementId(BuiltInParameter.VIEW_SCALE))

if is is true then you can set viewPlan.Scale = 100 otherwise you can't set it, because it is controlled by template

0 Likes