Lisp Routine Help Please!!

Alfonso-R

Usenet Archive
Joined
Jan 15, 2004
Messages
3
Reaction score
0
The routine below is for labelling contours.
I have tried to run the program, but it keeps
coming up with an error after the "digitize a point
to the right" command. AutoCAD returns this message
"error: bad argument type: numberp: nil". Also,
is it possible to modify the program to be able to
automatically pick the z value of the pline in stead
of manually entering the text?? Any help would be greatly appreciated!!!

Al

;*******CONTOUR ELEVATION LABELING ROUTINE******
; ENT - Contour line being labeled
; IPT - Left insertion point of label
; ANG - Insertion angle of label
; DST - Distance to break contour line
; EL - Elevation of selected contour
;-----------------------------------------------
(defun C:CTEXT (/ ENT IPT ANG DST EL)
;-----INITILAIZE PROGRAM----
(setq VARLST (list "OSMODE" "CLAYER" "TEXTSTYLE"))
(start)
(setvar "OSMODE" 512)
(setvar "FLATLAND" 0)
(setq ENT (entsel "\nDigitize the left insertion point: ") IPT (cadr ENT) ENT (car ENT)) (setvar "OSMODE" 0) ;-----GET ANGLE & ELEVATION--------- (setq ANG (getangle IPT "\nDigitize a point to the right: ") EL (rtos (cadddr (assoc 10 (entget ENT))) 2 0)) ;----BREAK THE LINE---------------- (setq DST (* SF (* (strlen EL) 0.10))) (command "break" ENT IPT (polar IPT ANG DST)) ;-----------------INSERT THE TEXT------------------------ (command "layer" "m" "TXT100" "") (command "text" "s" "VLEROY" "m" (polar IPT ANG (/ DST 2)) (* SF 0.1) (angtos ANG 0 4) EL) (done)
)
 
In below sequence: The variable 'SF' is not being set.
(setq ENT (entsel "\nDigitize the left insertion point: ") IPT (cadr ENT) ENT (car ENT)) (setvar "OSMODE" 0) ;-----GET ANGLE & ELEVATION--------- (setq ANG (getangle IPT "\nDigitize a point to the right: ") EL (rtos (cadddr (assoc 10 (entget ENT))) 2 0)) ;----BREAK THE LINE---------------- (setq DST (* SF (* (strlen EL) 0.10)))

You may want to add:
(setq SF (getvar "DIMSCALE"))
Just after:
(setvar "OSMODE" 0)

Bob
 
What kind of object are you selecting at the "digitize a point to the right" prompt?
___
 
I don't know what (start) does, but SF is not set. That is causing the error. This version will pick the z value from the first point selected.

(defun C:CTEXT (/ ENT IPT ANG DST EL)
;-----INITILAIZE PROGRAM----
(setq VARLST (list "OSMODE" "CLAYER" "TEXTSTYLE"))
;(start)
(setvar "OSMODE" 512)
(setvar "FLATLAND" 0)
;(setq ENT (entsel "\nDigitize the left insertion point: ")) ;(setq IPT (cadr ENT)) (setq IPT (getpoint "\nDigitize the left insertion point: ") ENT (car (nentselp IPT)) ) (setvar "OSMODE" 0) ;-----GET ANGLE & ELEVATION--------- ;(setq SPT (getpoint "\nDigitize a point to the right: ")) (setq ANG (getangle IPT "\nDigitize a point to the right: ")) (setq EL (rtos (caddr IPT) 2 0)) ;----BREAK THE LINE---------------- (setq DST (* SF (* (strlen EL) 0.10))) (command "break" ENT IPT (polar IPT ANG DST)) ;-----------------INSERT THE TEXT------------------------ (command "layer" "m" "TXT100" "") (command "text" "s" "VLEROY" "m" (polar IPT ANG (/ DST 2)) (* SF 0.1) (angtos ANG 0 4) EL) ;(done)
)
 

Latest threads

Back
Top