Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AutoLisp Command Not Working

1 REPLY 1
Reply
Message 1 of 2
kzalec
486 Views, 1 Reply

AutoLisp Command Not Working

My VS.LSP isn't working with AutoCAD 2012

 

;VS.LSP        Viewport Scale     

;"viewport scale"

;Returns paperspace scale of current viewport for

;transparent use at prompt for scale in INSERT.

;Works similar to dim style option.

;To use with scale command, run VS first. ; 

(defun get_scale ()   

(setq cv (getvar "cvport"));get viewport number   

(setq cvh (getvar "viewsize")); get viewport height in ms units   

(setq ss (ssget "X" (list '(0 . "viewport") (cons 69 cv))))   

(setq enlist (entget (ssname SS 0)))   

(setq vsize (assoc 41 enlist));get viewport height in ps units   

(setq vsize (cdr vsize));get units    (setq ps (/ vsize cvh));get paperspace scale   

(setq ps (/ 1 ps))

);end defun (defun c:vs ()    (cond       

;then allow xp to run transparently      

;if insert is running          

((= (getvar "cmdnames") "INSERT")             

(get_scale))          

((= (getvar "cmdnames") "DDINSERT")             

(get_scale))      

;or if no command is running          

((= (getvar "cmdnames") "")             

(get_scale))      

;all others get cancelled          

(t (progn               

(princ "\nRun VS.LSP by itself.")               

(princ "\nCan only run transparently with INSERT or DDINSERT command.")            

);end progn          

); end t   

);end cond

);end defun

1 REPLY 1
Message 2 of 2
rkmcswain
in reply to: kzalec


@kzalec wrote:

My VS.LSP isn't working with AutoCAD 2012

 

;VS.LSP        Viewport Scale     

;"viewport scale"

;Returns paperspace scale of current viewport for

;transparent use at prompt for scale in INSERT.

;Works similar to dim style option.

;To use with scale command, run VS first. ; 

(defun get_scale ()   

(setq cv (getvar "cvport"));get viewport number   

(setq cvh (getvar "viewsize")); get viewport height in ms units   

(setq ss (ssget "X" (list '(0 . "viewport") (cons 69 cv))))   

(setq enlist (entget (ssname SS 0)))   

(setq vsize (assoc 41 enlist));get viewport height in ps units   

(setq vsize (cdr vsize));get units   

(setq ps (/ vsize cvh));get paperspace scale   

(setq ps (/ 1 ps))

);end defun

(defun c:vs ()    (cond       

;then allow xp to run transparently      

;if insert is running          

((= (getvar "cmdnames") "INSERT")             

(get_scale))          

((= (getvar "cmdnames") "DDINSERT")             

(get_scale))      

;or if no command is running          

((= (getvar "cmdnames") "")             

(get_scale))      

;all others get cancelled          

(t (progn               

(princ "\nRun VS.LSP by itself.")               

(princ "\nCan only run transparently with INSERT or DDINSERT command.")            

);end progn          

); end t   

);end cond

);end defun


 

Looks like you are missing a couple of returns in your code.

Once this is fixed, it works fine here.

R.K. McSwain     | CADpanacea | on twitter

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost