Hello, does anyone know of a command or does anyone have a lisp I could use which would zoom my viewport outwards to the nearest available scale value
I generally use 1:25,50,100,250,500 and 1000
Currently I have a lisp which zooms everything in, but it doesn't zoom to the nearest scale value afterwards.
Thank you for anyone who helps.
Solved! Go to Solution.
Solved by ВeekeeCZ. Go to Solution.
This is the current lisp I have, I didn't make it but I am trying to learn it
Try and see.
(defun c:ZoomViewportOut (/ oldcmdecho vplist curcvport nr vpss ms en x scales cs ns) (setq oldcmdecho (getvar "cmdecho")) (setvar "cmdecho" 0) (setq vplist (mapcar 'car (vports))) (setq curcvport (getvar "cvport")) (setq scales '(0.04 0.02 0.01 0.004 0.002 0.001 0.0005 0.0002)) (if (= (getvar "tilemode") 0) (progn (if (= (setq ms (getvar "cvport")) 1)(command "._mspace")) (setq nr 0 vpss (ssget "_x" (list '(-4 . "<AND") '(0 . "VIEWPORT")(cons 410 (getvar "ctab")) '(-4 . "<NOT") '(69 . 1) '(-4 . "NOT>") '(-4 . "AND>")))) (if vpss (repeat (sslength vpss) (setq en (entget (setq e (ssname vpss nr)))) (if (and (= 0 (logand 1 (cdr (assoc 90 en)))) (< 0 (cdr (assoc 68 en))) (/= 16384 (logand 16384 (cdr (assoc 90 en))))) (progn (setq cs (getpropertyvalue e "CustomScale")) (if (setq ns (cond ((cadr (member cs (vl-sort (cons cs scales) '>)))) (cs))) (setpropertyvalue e "CustomScale" ns)))) (setq nr (+ 1 nr)) ) ) (if (= ms 1) (command "._pspace")) ) (foreach x vplist (setvar "cvport" x) (command "._zoom" "_e")) ) (setq vpss nil)(setvar "cvport" curcvport)(setvar "cmdecho" oldcmdecho) (princ) )
@kieran.leadbetter wrote:
Wow... that works genuinely perfect, thank you
can you explain some of that lisp or where I could learn to write things like that
I understand the quotations and bracket functions and things
Its more the setq, sslength, vpss, etc.
Different command line prompts I think they're called?
Type VLIDE into the command line. Create a new and copy/paste the code in there to see something like this:
Blue are functions, black are variables. Green are integers, dark green reals. Strings are in magenta. And red... parentheses...
There is a simple way to set a scale in a viewport no code, if your metric, turn on the toolbar viewports, it has a current scale box so for metre units just put a number in the box and it will zoom to that scale.
The number is a simple 1000/scale so 250=4, 100=10, 500=2.
View not right just change number again and yes lock viewport when happy.
Here's the IF func...
(vl-load-com) (defun C:ViewportScaleImportNWG ( / scales) (command "-SCALELISTEDIT" "D" "*" "E") (setq scales (mapcar '(lambda (x) (cdr (assoc 300 (entget (cdr x))))) (vl-remove-if '(lambda (x) (/= (car x) 350)) (dictsearch (namedobjdict) "ACAD_SCALELIST")))) (if (vl-position "1:25" scales) (it exists) (it's not) )
First of all, I don't really understand what you wanted to do by this:
(command "-SCALELISTEDIT" "A" "1:25" "N" "1:25" "E")
it's You: Add 1:25, then ACAD: Hey, it exists. Redefine? You: No, then 1:25... what?!
(vl-load-com) (defun C:ViewportScaleImportNWG ( / scales) (command "-SCALELISTEDIT" "D" "*" "E") (setq scales (mapcar '(lambda (x) (cdr (assoc 300 (entget (cdr x))))) (vl-remove-if '(lambda (x) (/= (car x) 350)) (dictsearch (namedobjdict) "ACAD_SCALELIST")))) (if (not (vl-position "1:25" scales)) (command "-SCALELISTEDIT" "A" "1:25" "1:25" "E")) ; create new ; ELSE: do nothing is already exists ;; or (if (not (vl-position "1:25" scales)) (command "-SCALELISTEDIT" "A" "1:25" "1:25" "E") ; create new (command "-SCALELISTEDIT" "A" "1:25" "_Y" "1:25" "E")) ; redefine ;; accordingly all the next (if (not (vl-position "1:50" scales)) (command "-SCALELISTEDIT" "A" "1:50" "1:50" "E")) ; create new (princ) ;clean exit )
Can't find what you're looking for? Ask the community or share your knowledge.