Author Topic: API for obtaining Viewport Scale  (Read 2569 times)

0 Members and 1 Guest are viewing this topic.

Keith Brown

  • Swamp Rat
  • Posts: 601
API for obtaining Viewport Scale
« on: June 18, 2015, 09:42:30 AM »
I am working with automatically generating viewports on a sheet based on drawing views and I am calculating the viewport scale.  Currently I have one scale hard coded (1/4" = 1') into the program along with its viewport scale factor of 48.  My question is that given the AutoCAD .NET API enumeration of StandardScaleType.Scale1To4inchAnd1ft is there anything in the API to return 48?  Do I need to calculate the viewport scale factor for each enumeration?  It is not hard to do and I have all the values already calculated and written down but before I write the class to generate this I thought that there might already be something in the API.


Thanks.
Keith Brown | AutoCAD MEP Blog | RSS Feed
AutoCAD MEP 2014 / Revit MEP 2014 / EastCoast CAD/CAM addon / Visual Studio 2013

Jeff H

  • Needs a day job
  • Posts: 6144
Re: API for obtaining Viewport Scale
« Reply #1 on: June 18, 2015, 11:38:51 AM »
CustomScale property if I remember correctly.


Keith Brown

  • Swamp Rat
  • Posts: 601
Re: API for obtaining Viewport Scale
« Reply #2 on: June 18, 2015, 12:33:13 PM »
Yes,  that is it.  Thank you.
Keith Brown | AutoCAD MEP Blog | RSS Feed
AutoCAD MEP 2014 / Revit MEP 2014 / EastCoast CAD/CAM addon / Visual Studio 2013

Keith Brown

  • Swamp Rat
  • Posts: 601
Re: API for obtaining Viewport Scale
« Reply #3 on: June 18, 2015, 06:01:13 PM »
I had issues implementing the API version of this.  I believe it had to do with setting the standard scale, the height, and the width of the viewport and the order in which you set them.  To make it easy on myself i just went ahead and created a quick method to return the scale factor that I was expecting.


I probably would not have had to do this if there was halfway decent documentation on the API.
Keith Brown | AutoCAD MEP Blog | RSS Feed
AutoCAD MEP 2014 / Revit MEP 2014 / EastCoast CAD/CAM addon / Visual Studio 2013

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: API for obtaining Viewport Scale
« Reply #4 on: June 18, 2015, 06:05:49 PM »

I probably would not have had to do this if there was halfway decent documentation on the API.

It's a pity someone from AutoDesk who could do something about this didn't visit these forums.
#IsThereAnybodyOutThereWhoCares
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: API for obtaining Viewport Scale
« Reply #5 on: June 18, 2015, 06:08:29 PM »
afterthought added:
They're too busy playing with stuff that is going to make the world a better place ... oh, wait ....
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Keith Brown

  • Swamp Rat
  • Posts: 601
Re: API for obtaining Viewport Scale
« Reply #6 on: June 18, 2015, 06:10:00 PM »
It's a pity someone from AutoDesk who could do something about this didn't visit these forums.
#IsThereAnybodyOutThereWhoCares


+1
Keith Brown | AutoCAD MEP Blog | RSS Feed
AutoCAD MEP 2014 / Revit MEP 2014 / EastCoast CAD/CAM addon / Visual Studio 2013

Keith Brown

  • Swamp Rat
  • Posts: 601
Re: API for obtaining Viewport Scale
« Reply #7 on: July 13, 2015, 09:03:46 AM »
For anyone else finding this thread and wondering what to do the Autocad .net help file does touch upon the subject.


Quote
The StandardScale and CustomScale properties are used to specify the scale for a viewport. The StandardScale property accepts a value based on the StandardScaleType enum; whereas the CustomScale property accepts a real number which represents the ratio of units between Model and Paper space. For example, the real value equal to 1:4 is 0.25.


You can read the whole article here.
Keith Brown | AutoCAD MEP Blog | RSS Feed
AutoCAD MEP 2014 / Revit MEP 2014 / EastCoast CAD/CAM addon / Visual Studio 2013