viewport scale

Discussion in 'AutoCAD' started by Elise Moss, Jun 14, 2004.

  1. Elise Moss

    Elise Moss Guest

    I want to be able to get the scale of a viewport, using entsel, but I can't
    see the dxf code that corresponds to the viewport scale..and I am thinking
    it might need some converstion?

    Thanks,

    Elise Moss
    www.mossdesigns.com
     
    Elise Moss, Jun 14, 2004
    #1
  2. Elise Moss

    Rudy Tovar Guest

    2004?
     
    Rudy Tovar, Jun 14, 2004
    #2
  3. Elise Moss

    R.K. McSwain Guest


    http://tinyurl.com/2m9ga
     
    R.K. McSwain, Jun 14, 2004
    #3
  4. Elise Moss

    Elise Moss Guest

    Yep, that works.

    Then I can create a basic text list to match the different values.

    How do I create a text value that includes quotes, i.e 3/32" = 1'?

    Thanks,

    Elise Moss


    group_41 / group_45 (or pspace_height / mspace_height).
     
    Elise Moss, Jun 14, 2004
    #4
  5. Elise Moss

    T.Willey Guest

    This is a quick little one, only tested on one vport
    Code:
    (defun c:VS(/ ent1 ent2 eq1 eq2 eq3 tx1)
    
    (while (not (setq ent1 (entsel "\nSelect viewport:")))
    )
    (if ent1
    (progn
    (setq ent2 (entget (car ent1)))
    (if (= (cdr (assoc 0 ent2)) "VIEWPORT")
    (progn
    (setq eq1 (/ (cdr (assoc 41 ent2)) (cdr (assoc 45 ent2))))
    (setq eq2 (* 12 eq1))
    (setq eq3 (rtos eq2 4 5))
    (setq tx1 (strcat "\n"eq3" per 1'-0\""))
    (prompt tx1)
    )
    (setq ent1 nil)
    )
    )
    )
    (princ)
    )
    
    Tim
     
    T.Willey, Jun 14, 2004
    #5
  6. Elise Moss

    T.Willey Guest

    Code:
    (defun c:VS(/ ent1 ent2 eq1 eq2 eq3 tx1)
    
    (setvar "errno" 0)
    (if (/= (getvar "cvport") 1)
    (alert "\nCommand can only be done in paper space.")
    (progn
    (while
    (and
    (not (setq ent1 (entsel "\nSelect viewport:")))
    (/= (getvar "errno") 52)
    )
    )
    (if ent1
    (progn
    (setq ent2 (entget (car ent1)))
    (if (= (cdr (assoc 0 ent2)) "VIEWPORT")
    (progn
    (setq eq1 (/ (cdr (assoc 41 ent2)) (cdr (assoc 45 ent2))))
    (setq eq2 (* 12 eq1))
    (setq eq3 (rtos eq2 4 5))
    (prompt (setq tx1 (strcat "\n"eq3"=1'-0\"")))
    )
    (progn
    (setq ent1 nil)
    (prompt "\nNo viewport selected.")
    )
    )
    )
    )
    )
    )
    (princ)
    )
    
    Tweaked it a little, I think it works better now. At least it can give you a start. I wanted one for myself just never got around to writing it, but since you asked I got around to it. So thanks for asking.

    Tim
     
    T.Willey, Jun 14, 2004
    #6
  7. Elise Moss

    ffejgreb Guest

    Don't know if this matters, but your routine doesn't work with
    non-rectangular viewports. Just in case you (and Elise) needed that
    functionality as well.
     
    ffejgreb, Jun 14, 2004
    #7
  8. Elise Moss

    T.Willey Guest

    That is a really good point, I didn't even think about that. The only way I see to get it in that case is to use (ssget) with a filter for viewports. Is there some other way that anyone knows so that you could just pick it? I rather have it just one at a time so that if I wanted to later I could use that information grabbed and returned to put it into an attribute later for the scale factor.

    Thanks in advance.
    Tim
     
    T.Willey, Jun 14, 2004
    #8
  9. Elise Moss

    T.Willey Guest

    Ok, did a little checking and got this to work with objects made into viewports. If anyone knows a better way please post.

    Code:
    (defun c:VS(/ ent1 ent2 eq1 eq2 eq3 tx1)
    
    
    (setvar "errno" 0)
    (setq tx1 nil)
    (if (/= (getvar "cvport") 1)
    (alert "\nCommand can only be done in paper space.")
    (progn
    (while
    (and
    (not (setq ent1 (entsel "\nSelect viewport:")))
    (/= (getvar "errno") 52)
    )
    )
    (if ent1
    (progn
    (setq ent2 (entget (car ent1)))
    (cond
    ((= (cdr (assoc 0 ent2)) "VIEWPORT")
    (GetVPScale)
    )
    ((= (cdr (assoc 102 ent2)) "{ACAD_REACTORS")
    (setq ent2 (entget (cdr (assoc 330 ent2))))
    (if (= (cdr (assoc 0 ent2)) "VIEWPORT")
    (GetVPScale)
    )
    )
    )
    )
    (if (not tx1)
    (prompt "\nNo viewport selected.")
    )
    )
    )
    )
    (princ)
    )
    
    (defun GetVPScale()
    
    (setq eq1 (/ (cdr (assoc 41 ent2)) (cdr (assoc 45 ent2))))
    (setq eq2 (* 12 eq1))
    (setq eq3 (rtos eq2 4 5))
    (prompt (setq tx1 (strcat "\n"eq3"=1'-0\"")))
    )
    
    Tim
     
    T.Willey, Jun 15, 2004
    #9
  10. Elise Moss

    Laura Guest

    I like this one very much, but I use the metric system
    (like scale: 1 centimeter = 100 centimeters)
    What do I have to change in the lisp for that?

    Laura



    viewports. If anyone knows a better way please post.
     
    Laura, Jun 15, 2004
    #10
  11. Elise Moss

    T.Willey Guest

    See if this works for you. Now the "units" have to be set to what you want the viewport to be calculated in.

    Code:
    (defun c:VS(/ ent1 ent2 eq1 eq2 eq3 tx1)
    
    
    (setvar "errno" 0)
    (setq tx1 nil)
    (setq ut1 (getvar "insunits"))
    (if (= ut1 0)
    (alert "Units are set to none,
    calculating as if drawing in inches.")
    )
    (if (/= (getvar "cvport") 1)
    (alert "\nCommand can only be done in paper space.")
    (progn
    (while
    (and
    (not (setq ent1 (entsel "\nSelect viewport:")))
    (/= (getvar "errno") 52)
    )
    )
    (if ent1
    (progn
    (setq ent2 (entget (car ent1)))
    (cond
    ((= (cdr (assoc 0 ent2)) "VIEWPORT")
    (GetVPScale)
    )
    ((= (cdr (assoc 102 ent2)) "{ACAD_REACTORS")
    (setq ent2 (entget (cdr (assoc 330 ent2))))
    (if (= (cdr (assoc 0 ent2)) "VIEWPORT")
    (GetVPScale)
    )
    )
    )
    )
    (if (not tx1)
    (prompt "\nNo viewport selected.")
    )
    )
    )
    )
    (princ)
    )
    
    (defun GetVPScale()
    
    (setq eq1 (/ (cdr (assoc 41 ent2)) (cdr (assoc 45 ent2))))
    
    (cond
    ((or (= ut1 0) (= ut1 1))
    (setq eq2 (* 12 eq1))
    (setq eq3 (rtos eq2 4 5))
    (setq tx1 (strcat "\n"eq3 "= 1'-0\""))
    )
    ((= ut1 2)
    (setq eq2 (/ 1 eq1))
    (setq eq3 (rtos eq2 5))
    (setq tx1 (strcat "\n1\" = "eq3"\'-0\""))
    )
    ((or (= ut1 4) (= ut1 5) (= ut1 6) (= ut1 7) (= ut1 12) (= ut1 14) (= ut1 15) (= ut1 16) (= ut1 17))
    (cond
    ((= ut1 4)
    (setq tx2 "MILLIMETERS")
    )
    ((= ut1 5)
    (setq tx2 "CENTIMETERS")
    )
    ((= ut1 6)
    (setq tx2 "METERS")
    )
    ((= ut1 7)
    (setq tx2 "KILOMETERS")
    )
    ((= ut1 12)
    (setq tx2 "NANOMETERS")
    )
    ((= ut1 14)
    (setq tx2 "DECIMETERS")
    )
    ((= ut1 15)
    (setq tx2 "DECAMETERS")
    )
    ((= ut1 16)
    (setq tx2 "HECTOMETERS")
    )
    ((= ut1 17)
    (setq tx2 "GIGAMETERS")
    )
    )
    (setq eq2 (/ 1 eq1))
    (setq eq3 (rtos eq2 5))
    (setq tx1 (strcat "\n1 = "eq3" "tx2))
    )
    
    )
    
    (prompt tx1)
    )
    
    Tim
     
    T.Willey, Jun 15, 2004
    #11
  12. Elise Moss

    Laura Guest

    Thank you Tim,

    I get:
    1 = 0 METERS that should be 1 = 20 METERS
    1 = 1/16 METERS that should be 1 = 50 METERS
    1 = 1/8 METERS that should be 1 = 100 METERS

    But I've no idea how to change that
    The insunits I use is 6 (Meters).

    laura


    want the viewport to be calculated in.
     
    Laura, Jun 16, 2004
    #12
  13. Elise Moss

    T.Willey Guest

    Laura,

    Can you post your drawing. I don't work in metrics that often, and I don't have one right now that I can just use to test, but if you post yours I can see where it is messing up.

    Tim
     
    T.Willey, Jun 16, 2004
    #13
  14. Elise Moss

    Laura Guest

    Hi Jürg,

    This one turns the scales around, first modelspace and than paperspace.
    But that is something to get used to.
    And it just calculates the "normal" vports, not the polygonal vports.

    Thank you,

    Laura
     
    Laura, Jun 17, 2004
    #14
  15. Elise Moss

    Laura Guest

    Thanks for all the trouble I've put you in.
    This lipsroutine is coming very close.
    The european (i think it's european) standard is puting the scale in cm.
    We draw in meters and the paperspace is in mm.

    so:

    1 unit in paperspace is 0.05 units in modelspace

    1 mm in paperspace = 0.05 m in modelspace
    1 mm in paperspace = 50 mm in modelspace
    (1 cm in paperspace = 50 cm in modelspace)

    We call that "scale 1 : 50"

    I hope this is not confusing. I think it is.....

    laura
     
    Laura, Jun 18, 2004
    #15
  16. Elise Moss

    Laura Guest

    This is it!
    Thank you for all your trouble helping me!

    laura


    non metric support, but because I'm not familiar with the non metric system
    the code may be improved. If someone has the patience to do it, please let
    me know.
     
    Laura, Jun 21, 2004
    #16
  17. Elise Moss

    Jürg Menzi Guest

    Hi Laura

    Welcome...:cool:

    Cheers
     
    Jürg Menzi, Jun 21, 2004
    #17
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.