PDA

View Full Version : Lisp won't work


BCrouse
2005-06-09, 06:08 PM
Can someone please tell me why this lisp will not work?



;; This routine creates or updates text style "DWGTITLES" "RMNAMES"
(defun C:fx3 (/ stylist X)
(setvar "cmdecho" 0)
(command "_.undo" "be")
(setq stylist '(("DWGTITLES" 12 1.2 0.09375) ; height, width factor, PS height
("RMNAMES" 9 0.9 nil)
("NOTES" 9 0.9 0.09375))
)
;; create or revise existing style
(command ".-style"
"DWGTITLES" ; name of text style 2
"Swiss.ttf" ; full font name 3
12 ; height of text 40
.125 ; width factor 41
0 ; obliquing angle 50
) ; * = bit flag
(while (>(getvar "CMDACTIVE")0) (command "") )

(command ".-style"
"RMNAMES" ; name of text style 2
"Swiss.ttf" ; full font name 3
.109375 ; height of text 40
0.9 ; width factor 41
0 ; obliquing angle 50
) ; * = bit flag
(while (>(getvar "CMDACTIVE")0) (command "") )

(foreach x stylist
(txtupdate x)
)

(command "_.regen")
(command "_.undo" "end")
(setvar "textstyle" "DWGTITLES")
(setvar "cmdecho" 1)
(princ)
)



(defun txtupdate (txtdata / ent ss ent_alst str)
(setq ss (ssget "X"
(list '(0 . "TEXT,MTEXT") (cons 7 (car txtdata)))
)
)
(while (and ss (> (sslength ss) 0))
(setq ent (ssname ss 0))
(setq ent_alst (entget ent))
(cond
((= (cdr (assoc 0 ent_alst)) "TEXT")
(if (and (nth 3 txtdata) (= (cdr (assoc 67 ent_alst)) 1)) ; Paper Space
(setq ent_alst (subst (cons 40 (nth 3 txtdata)) (assoc 40 ent_alst) ent_alst)
ent_alst (subst (cons 41 (nth 2 txtdata)) (assoc 41 ent_alst) ent_alst))
(setq ent_alst (subst (cons 41 (nth 2 txtdata)) (assoc 41 ent_alst) ent_alst))
)
)
((= (cdr (assoc 0 ent_alst)) "MTEXT")
(if (and (nth 3 txtdata) (= (cdr (assoc 67 ent_alst)) 1)) ; Paper Space
(setq ent_alst (subst (cons 40 (nth 3 txtdata)) (assoc 40 ent_alst) ent_alst)))
(setq str (cdr (assoc 1 ent_alst)))
(if (/= (vl-string-position (ascii ";") str) nil)
(progn
(setq
str (strcat
"{"
(substr str (+ (vl-string-position (ascii ";") str) 2))
)
)
(setq ent_alst (subst (cons 1 str) (assoc 1 ent_alst) ent_alst))
)
)
)
)
(entmod ent_alst)
(entupd ent)
(ssdel ent ss)
)
)



Thank you,

Brad

Opie
2005-06-09, 06:38 PM
Can someone please tell me why this lisp will not work?



;; This routine creates or updates text style "DWGTITLES" "RMNAMES"
(defun C:fx3 (/ stylist X)
(setvar "cmdecho" 0)
(command "_.undo" "be")
(setq stylist '(("DWGTITLES" 12 1.2 0.09375) ; height, width factor, PS height
("RMNAMES" 9 0.9 nil)
("NOTES" 9 0.9 0.09375))
)
;; create or revise existing style
(command ".-style"
"DWGTITLES" ; name of text style 2
"Swiss.ttf" ; full font name 3
12 ; height of text 40
0.125 ; width factor 41 Place a "0" in front of decimals
0 ; obliquing angle 50
) ; * = bit flag
(while (>(getvar "CMDACTIVE")0) (command "") )

(command ".-style"
"RMNAMES" ; name of text style 2
"Swiss.ttf" ; full font name 3
0.109375 ; height of text 40 Place a "0" in front of decimals
0.9 ; width factor 41
0 ; obliquing angle 50
) ; * = bit flag
(while (>(getvar "CMDACTIVE")0) (command "") )

(foreach x stylist
(txtupdate x)
)

(command "_.regen")
(command "_.undo" "end")
(setvar "textstyle" "DWGTITLES")
(setvar "cmdecho" 1)
(princ)
)



(defun txtupdate (txtdata / ent ss ent_alst str)
(setq ss (ssget "X"
(list '(0 . "TEXT,MTEXT") (cons 7 (car txtdata)))
)
)
(while (and ss (> (sslength ss) 0))
(setq ent (ssname ss 0))
(setq ent_alst (entget ent))
(cond
((= (cdr (assoc 0 ent_alst)) "TEXT")
(if (and (nth 3 txtdata) (= (cdr (assoc 67 ent_alst)) 1)) ; Paper Space
(setq ent_alst (subst (cons 40 (nth 3 txtdata)) (assoc 40 ent_alst) ent_alst)
ent_alst (subst (cons 41 (nth 2 txtdata)) (assoc 41 ent_alst) ent_alst))
(setq ent_alst (subst (cons 41 (nth 2 txtdata)) (assoc 41 ent_alst) ent_alst))
)
)
((= (cdr (assoc 0 ent_alst)) "MTEXT")
(if (and (nth 3 txtdata) (= (cdr (assoc 67 ent_alst)) 1)) ; Paper Space
(setq ent_alst (subst (cons 40 (nth 3 txtdata)) (assoc 40 ent_alst) ent_alst)))
(setq str (cdr (assoc 1 ent_alst)))
(if (/= (vl-string-position (ascii ";") str) nil)
(progn
(setq
str (strcat
"{"
(substr str (+ (vl-string-position (ascii ";") str) 2))
)
)
(setq ent_alst (subst (cons 1 str) (assoc 1 ent_alst) ent_alst))
)
)
)
)
(entmod ent_alst)
(entupd ent)
(ssdel ent ss)
)
)



Thank you,

Brad
You need to place a "0" (zero) in front of decimal numbers. I have not tested the code to see if it works now, but the VLIDE let me load the routine.

BCrouse
2005-06-13, 11:54 PM
You need to place a "0" (zero) in front of decimal numbers. I have not tested the code to see if it works now, but the VLIDE let me load the routine.


Thank you very much,

Brad