+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Full Member
    Using
    not specified
    Join Date
    Sep 2005
    Posts
    33

    Default Getting to know the Viewport scale

    Registered forum members do not see this ad.

    When one selects a viewport and runs a list command on it to find out the scale relative to paper space (amongst other things) it returns a decimal no. that reads like a.aaaaxp which then forces you to look it up in a calculator to convert into the fractional scale.

    It easy for simple metric scales like 1:100 (0.01xp) to do it mentally but for feet/inches scales a 1"=16'-0" returns 0.0052xp, so you must hunt for that calculator in the mess on your desk! :-)

    So my question: is there a lisp routine available which can return just the denominator on the command line (no bells and whistles needed)?

    I have zero lisp skills, other than doing cut&paste from from what I've seen here...

    Thanks

  2. #2
    Super Member
    Using
    AutoCAD 2007
    Join Date
    Aug 2003
    Location
    Livingston, Scotland
    Posts
    995

    Default

    you don't say why you want the value printed to the command line, so I'm guessing you just want to see what the actual value is, and not do anything with it... if that is the case, what's wrong with using the viewports toolbar ? as soon as you click on a viewport, it lists the scale
    ResourceCAD.... the Resource for your CAD Solutions

  3. #3
    Full Member
    Using
    not specified
    Join Date
    Sep 2005
    Posts
    33

    Default

    Hendie,

    Have already tried that, works fine with standard scales; 1:10, 1:200, 1"=8'-0" etc. But the window becomes greyed out if the viewport is not to a 'standard' scale (say 1"=2'-6", dont ask me why I need to use such scales!! :-)).

  4. #4
    Full Member
    Using
    not specified
    Join Date
    Sep 2005
    Posts
    33

    Default

    Hendie:

    Sorry for my last post.

    Your tip does work and the value too is shown, its just that the scale window in the toolbar becomes greyed, so I ended up thinking it as an error...

    Obviously with locked viewports this greying will happen!!

    Thanks..

  5. #5
    Senior Member
    Using
    AutoCAD 2005
    Join Date
    Dec 2005
    Location
    Brandon, Manitoba, Canada
    Posts
    166

    Default

    here is a quick lisp that will give you the xpscale

    Code:
    (defun c:viewscale(/ ss xpscale psheight msheight xpinvert)
      (princ "\nSelect Viewport...")
      ;Get selection set, allow only viewports
      (setq ss nil)
      (setq ss (ssget '((0 . "viewport"))))
      ;get the height of the viewport in paper space
      (setq psheight (cdr(assoc 41 (entget(ssname ss 0)))))
      ;get the height of the viewport in model space
      (setq msheight (cdr(assoc 45 (entget(ssname ss 0)))))
      ;divide to get the xp scale
      (setq xpscale (/ psheight msheight))
      ;find the invert of xpscale
      (setq xpinvert(/ 1 xpscale))
    you will still need to add some to get it to output the value in a format of your likeing.
    Thalon

  6. #6
    Full Member
    Using
    not specified
    Join Date
    Sep 2005
    Posts
    33

    Default

    Thanks thalon, but I have no lisp skills to 'add something to it to give me an output of my choice'...

    Tried using it the way it is, but it returns an error, I am guessing it needs an error fn. Till I scale up my lisp skills I'll have to rely on the viewport toolbar.

  7. #7
    Senior Member
    Using
    not specified
    Join Date
    Sep 2005
    Location
    Brisbane, Australia
    Posts
    318

    Default

    Registered forum members do not see this ad.

    try Periscope addon .. it has the ability to display viewport parameters in a text box that appears when you place the crosshairs over the viewport frame...
    http://manusoft.com/Software/Periscope/Index.stm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts