帮助排除Autolisp故障
程序中用于转换多行文字和属性的部分有问题,因此可以将其作为文本输出到文件中。如果有人愿意帮助我解决程序故障,我将不胜感激。;define program - listing your variable names here
; resets them to nil after the program finishes
;;;--- Main Application
(defun C:ESBTEXT2(/ lts ernote filen fil eset en enlist cntr et ne ned)
(setq rep (getint "Please enter the number of times the wire number should output: "))
;;;--- Setup three list to hold the data
(setq TBNOList(list) WIRENOList (list) DEVIDList(list))
;turn echo off
(setvar "cmdecho" 0)
;get ltscale (Note: ltscale should always equal dimscale)
(setq lts(getvar "ltscale"))
;set the exit note to successful
(setq ernote "\n....ESBTEXT Complete.")
;if ssget returns a valid selection set
(if
(setq eset
(ssget "X"
'(
(-4 . "<OR")
(8 . "TBNO")
(8 . "WIRENO")
(8 . "DEVID")
(-4 . "OR>")
)
)
)
;progn necessary for multiple statements inside an if statement
(progn
;set the entity counter to zero
(setq cntr 0)
;step through each entity in the selection set
(while (< cntr (sslength eset))
;get the entity name indexed by cntr
(setq en(ssname eset cntr))
;get the DXF group codes for the entity
(setq enlist(entget en)
et (cdr (assoc 0 enlist))
)
;check the group code 0 to see if entity type = TEXT
(if (cond ((= et "TEXT")(setq str (cdr (assoc 1 enlist))))
((= et "MTEXT")
;COMBINE GROUP 3's AND GROUP 1's INTO ONE STRING
(setq str (vl-remove-if-not '(lambda (q)(or (= (car q) 3)(= (car q) 1))) enlist)
str (apply 'strcat (mapcar 'cdr cs))
)
)
((and (= et "INSERT")(= (cdr (assoc 66 enlist)) 1))
(setq ne (entnext en))
(while (and ne (= (cdr (assoc 0 (setq ned (entget ne)))) "ATTRIB"))
(setq str (cdr (assoc 1 ned))
ne (entnext ne)
)
(cond
((= (cdr(assoc 8 enlist)) "TBNO") (setq TBNOList (append TBNOList (list str))))
((= (cdr(assoc 8 enlist)) "WIRENO")(setq WIRENOList(append WIRENOList (list str))))
((= (cdr(assoc 8 enlist)) "DEVID") (setq DEVIDList(append DEVIDList (list str))))
)
)
nil
)
)
;progn necessary for multiple statements inside an if statement
(progn
;;;--- Add it to the appropriate list
(cond
((= (cdr(assoc 8 enlist)) "TBNO") (setq TBNOList (append TBNOList (list str))))
((= (cdr(assoc 8 enlist)) "WIRENO")(setq WIRENOList(append WIRENOList (list str))))
((= (cdr(assoc 8 enlist)) "DEVID") (setq DEVIDList(append DEVIDList (list str))))
)
) ;close the if progn
) ;close the if statement
;increment the counter to get the next entity
(setq cntr(+ cntr 1))
) ;close the while loop
;;;--- Sort the list
(setq TBNOList (srtAN TBNOList))
(setq WIRENOList (srtAN WIRENOList))
(setq DEVIDList (srtAN DEVIDList))
;;;--- Print the list (parameters =
(prinFile "TBNO_" TBNOList 1)
(prinFile "WIRENO_" WIRENOList Rep)
(prinFile "DEVID_" DEVIDList 1)
);progn
);if
;turn the command echo back on
(setvar "cmdecho" 1)
;clear the command line
(princ "\n")
;supress last echo
(princ)
)
非常感谢。
布拉德·梅斯纳
页:
[1]