meissnerb Posted June 23, 2011 Share Posted June 23, 2011 (edited) I am having trouble with the part of the program that is meant to convert the mtext and the attributes so that it can be output as text to the file. If someone would be willing to help me troubleshoot the program I would appreciate it. ;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 [the first entity in a set is 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 = [FileName Prefix] [Name of List] [Print Repeat] (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) ) Thank you, Brad Meissner Edited June 23, 2011 by rkmcswain added CODE tags Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.