Get the scalelist in Revit document

Get the scalelist in Revit document

daniel
Enthusiast Enthusiast
2,030 Views
5 Replies
Message 1 of 6

Get the scalelist in Revit document

daniel
Enthusiast
Enthusiast

Hi, 

A hopefull easy question botering me.. 

 

I have a lot of dialoges in my add-in, whic deals with scales of views from Revit. 

 

This list is populated by me creating a list, similar to the list in Revit. 

 

Is there av way of getting hold of the scale list that Revit uses?

I can only finde the selected scale of objects, my aim is to get hold of the class or enum that holds the whole list. 

 

This would save med som maintaing of new cusom scales and so on.. 

 

 

tnx 

 

Daniel 

0 Likes
2,031 Views
5 Replies
Replies (5)
Message 2 of 6

jeremytammik
Autodesk
Autodesk

Dear Daniel,

 

I this case, I can say nothing that you cannot discover for yourself as well.

 

All I can do is search the Revit API help file RevitAPI.chm for 'scale' and see what I find.

 

I did in fact find the View.Scale property that corresponds to the numbers you are after:


"The scale is the ratio of true model size to paper size. This property is meaningless for perspective views. When setting the scale if the scale corresponds to a predefined scale, the predefined item will be applied. Otherwise, a custom scale will be applied."

 

Here is a sample command making use of it:

 

http://thebuildingcoder.typepad.com/blog/2014/10/new-text-note-and-text-width-calculation.html

 

The view also comes equipped with a method IsValidViewScale to check whether a given view scale candidate is in the allowable range, i.e., an integer in the range 1 to 24,000.

 

Beyond that, I found nothing that looks useful for you.

 

Please let us know how you end up solving this.

 

Thank you!

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 6

daniel
Enthusiast
Enthusiast

I have had a look at the chm and search around.. 

 

The View.Scale returns an Integer, as the selected scale.

 

The aim for me is to get the whole list, which populates the dropdown list of scales. 

 

 

0 Likes
Message 4 of 6

ChengboZhang
Enthusiast
Enthusiast

How to get the whole list  ,not one view ' s current scale. 

thanks !

0 Likes
Message 5 of 6

RPTHOMAS108
Mentor
Mentor

I don't think you could get the whole list baring a time consuming iteration over all the views.

 

I would just create a list by copying those currently in the dropdown in the UI, noting that a view can be set to any scale when custom is used.

0 Likes
Message 6 of 6

Kevin_Zurro
Participant
Participant

The only solution I found to get out of it is to create a list and manually add the scales that are in metric units.

 

List<int> lista = new List<int>();

lista.Add(1);
lista.Add(2);
lista.Add(5);
lista.Add(10);
lista.Add(20);
lista.Add(25);
lista.Add(50);
lista.Add(100);
lista.Add(200);
lista.Add(500);
lista.Add(1000);
lista.Add(2000);
lista.Add(5000);

 

This way it will look like the Scale1 image. But when the project is in imperial units, the scalelist will NOT be displayed as the Scale2 image.

0 Likes