Get info about current SNAPANG value - error 'bad argument type: FILE'

Get info about current SNAPANG value - error 'bad argument type: FILE'

Anonymous
Not applicable
478 Views
2 Replies
Message 1 of 3

Get info about current SNAPANG value - error 'bad argument type: FILE'

Anonymous
Not applicable

Hello,

recently I worked a lo about lisps based on SNAPANG command

(see here:

http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisps-whichs-base-is-snapang-quot-joi...

)

 

and I wrote a lisp which inform in the CommandLine about the current SNAPANG value (it is NGINF1). But it failed to work properly. So I modified it and get NGINF2.

So I did in the case of HNGINF here:

http://forums.autodesk.com/t5/autocad-2010-2011-2012/why-instead-of-hpang-a-number-between-0-and-1-i...

- I also converted the angle in radians to degrees.

 

But this time, in the case of NGINF2, it doesn't work.

 

There is error in CommandLine - how looks prompt about this error like, is in the lisp code below.

 

 

;Command: NGINFRAD
;; error: bad argument type: FILE 0.611994
; gives result in Radians
(defun c:NGINF1
  (/ CurAng)
  (setq CurAng (getvar "SNAPANG"))
  (princ "\nCurrent SNAPANG value is equal to: " CurAng)
)
;---
;Command: NGINF
;; error: bad argument type: FILE
; gives good result in decimal Degrees
(defun c:NGINF2
  (/ CurAngRad CurAng)
  (setq CurAngRad (getvar "SNAPANG"))
  (setq CurAng (* (/ 180 PI) CurAngRad))
  (princ "\nCurrent SNAPANG value is equal to: " CurAng)
)

 

Could you please tell me what is wrong? What should I change?

0 Likes
479 Views
2 Replies
Replies (2)
Message 2 of 3

Ajilal.Vijayan
Advisor
Advisor

You need to use strcat and rtos.

So the princ line will be like this.

 

  (princ (strcat "\nCurrent SNAPANG value is equal to: " (rtos CurAng 2 3)))

 

 

0 Likes
Message 3 of 3

Anonymous
Not applicable

Thank you. This tip was useful.

 

But after I used lisp with your correction:

 

(defun c:NGINFok
  (/ CurAngRad CurAng)
  (setq CurAngRad (getvar "SNAPANG"))
  (setq CurAng (* (/ 180 PI) CurAngRad))
;  (princ "\nCurrent SNAPANG value is equal to: " CurAng); it gives error
(princ (strcat "\nCurrent SNAPANG value is equal to: " (rtos CurAng 2 3))); it is correct
)

 In the CommandLine there was doubled prompt:

"Command: NGINFOK
Current SNAPANG value is equal to: 0"\nCurrent SNAPANG value is equal to: 0""

 

So I had soon the knowledge what to do in order to have not doubled prompt, because I had such situation and on this forum someone helped me.

 

So I added "(princ)" nad now it works perfect.

And this is our lisp:

 

; Works properly

; NGINFOK
(defun c:NGINF
  (/ CurAngRad CurAng)
  (setq CurAngRad (getvar "SNAPANG"))
  (setq CurAng (* (/ 180 PI) CurAngRad))
;  (princ "\nCurrent SNAPANG value is equal to: " CurAng); it gives error
(princ (strcat "\nCurrent SNAPANG value is equal to: " (rtos CurAng 2 3))); it is correct
(princ)
)

 

Thanks for your help.

 

 

 

 

 

 

0 Likes