woodman78 Posted August 19, 2010 Posted August 19, 2010 I have been playing around with a LISP routine that I got from LeeMac to update block attributes. I have been trying to set one up that will update attributes for Designed,Drawn,Checked and Approved in our title block. I have run into trouble in that I can get the txt file to populate the first 2 drop down boxes but not the second and I can get the first attribute to update but no more. Can someone tell me where I go from here? Am I even going down the right route? Names.dwg I have also seen LeeMac's sk routine for reading attirbute values and I was wondering how I could incorporate this so that when the LISP starts it reads the attributes values and sets them in the dialog box? (defun c:Names (/ *error* _read BLOCKNAME DCFILENAME DCFLAG DCTAG ELST ENT I PTR PTR1 SS STR STR1 STRFILENAME STRLST TAGSTRING TAGSTRING1) ;; Lee Mac ~ 01.03.10 (setq dcfilename "Names.dcl" ;; DCL Filename Strfilename "Names.txt" ;; Data Filename BlockName "Names" ;; Block Name TagString "Design" ;; Tag String Tagstring1 "Drawn" ;; TagString1 Tagstring2 "Check" ;; TagString2 Tagstring3 "Approve" ;; TagString3 ) (defun *error* (msg) (and dcTag (unload_dialog dcTag)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ)) (defun _read (file / ofile lst nl) (cond ( (setq ofile (open file "r")) (while (setq nl (read-line ofile)) (setq lst (cons nl lst))) (close ofile))) (reverse lst)) (cond ( (not (setq i -1 ss (ssget "_X" (list (cons 0 "INSERT") (cons 2 BlockName) (cons 66 1))))) (princ (strcat "\n** No Blocks with Name: " BlockName " Found **"))) ( (not (setq Strfilename (findfile Strfilename))) (princ "\n** Data File not Found **")) ( (not (setq StrLst (_read Strfilename))) (princ "\n** Data File Empty **")) ( (<= (setq dcTag (load_dialog dcfilename)) 0) (princ "\n** Dialog Definition Not Found **")) ( (not (new_dialog "Names" dcTag)) (princ "\n** Dialog Could not be Loaded **")) (t ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (start_list "lst") (mapcar (function add_list) StrLst) (end_list) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (start_list "lst1") (mapcar (function add_list) StrLst) (end_list) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (start_list "lst2") (mapcar (function add_list) StrLst) (end_list) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (start_list "lst3") (mapcar (function add_list) StrLst) (end_list) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq ptr (set_tile "lst" "0") ptr1 (set_tile "lst1" "0") ptr2 (set_tile "lst2" "0") ptr3 (set_tile "lst3" "0")) (action_tile "lst" "(setq ptr $value)" "lst1" "(setq ptr1 $value)" "lst2" "(setq ptr2 $value)" "lst3" "(setq ptr3 $value)") (setq dcFlag (start_dialog)) (setq dcTag (unload_dialog dcTag) TagString (strcase TagString) TagString1 (strcase TagString1) Str (nth (atoi ptr) StrLst) Str1 (nth (atoi ptr1) StrLst)) (if (= 1 dcFlag) (while (setq ent (ssname ss (setq i (1+ i)))) (while (not (eq "SEQEND" (cdr (assoc 0 (setq eLst (entget (setq ent (entnext ent)))))))) (if (eq TagString (cdr (assoc 2 eLst))) (entupd (cdr (assoc -1 (entmod (subst (cons 1 Str) (assoc 1 eLst) eLst))))) (if (eq TagString1 (cdr (assoc 2 eLst))) (entupd (cdr (assoc -1 (entmod (subst (cons 1 Str1) (assoc 1 eLst) eLst))))))) (princ)) Names : dialog { //*dialog name label = "Names"; //*give it a label : row { //*define row : paragraph { //*define paragraph : text_part { //*define more text label = "Title Block Names"; //*some more text } //*end text : text_part { //*define more text label = " "; //*some more text } //*end text } //*end paragraph } //*end row : row { //*define row : boxed_column { //*define boxex_column label = "Designed"; //*give it a label : popup_list { //*define popup_list key = "lst"; //*give it a name label = "Type"; //*give it a label edit_width=8; //*edit_width alignment = right; //*alignment } //*end popup_list : spacer { //*define spacer height = 0; //*height } //*end spacer } //*end column } //*end row : row { //*define row : boxed_column { //*define boxex_column label = "Drawn"; //*give it a label : popup_list { //*define popup_list key = "lst1"; //*give it a name label = "Size"; //*give it a label edit_width=8; //*edit_width alignment = right; //*alignment } //*end popup_list : spacer { //*define spacer height = 0; //*height } //*end spacer } //*end boxed_column } //*end row : row { //*define row : boxed_column { //*define boxex_column label = "Checked"; //*give it a label : popup_list { //*define popup_list key = "lst2"; //*give it a name label = "Type"; //*give it a label edit_width=8; //*edit_width alignment = right; //*alignment } //*end popup_list : spacer { //*define spacer height = 0; //*height } //*end spacer } //*end column } //*end row : row { //*define row : boxed_column { //*define boxex_column label = "Approved"; //*give it a label : popup_list { //*define popup_list key = "lst3"; //*give it a name label = "Type"; //*give it a label edit_width=8; //*edit_width alignment = right; //*alignment } //*end popup_list : spacer { //*define spacer height = 0; //*height } //*end spacer } //*end column } //*end row : row { //*define row : column { //*define column ok_cancel ; //*predifined OK/Cancel : paragraph { //*define paragraph : text_part { //*define more text label = "CCC NNRDO v1.0.24.07.2009"; //*some more text } //*end text } //*end paragraph } //*end column } //*end row } //*end dialog Text File to populate lists BD JL KOR MOS DOS DM Quote
Lee Mac Posted August 19, 2010 Posted August 19, 2010 Woodman, I would point out that it is good coding conduct to mark the parts that you have altered so that incorrect modifications do not reflect on the original author. Quote
woodman78 Posted August 20, 2010 Author Posted August 20, 2010 Sorry about that LeeMac. I have a tendency to get carried away and forget about that. The code updated with my changes indicated. And the dcl above is entirely different to the one you wrote for the original lisp. (defun c:Names (/ *error* _read BLOCKNAME DCFILENAME DCFLAG DCTAG ELST ENT I PTR PTR1 SS STR STR1 STRFILENAME STRLST TAGSTRING TAGSTRING1) ;; Lee Mac ~ 01.03.10 (setq dcfilename "Names.dcl" ;; DCL Filename Strfilename "Names.txt" ;; Data Filename BlockName "Names" ;; Block Name TagString "Design" ;; Tag String Tagstring1 "Drawn" ;; TagString----------------BD Tagstring2 "Check" ;; TagString2----------------BD Tagstring3 "Approve" ;; TagString3----------------BD ) (defun *error* (msg) (and dcTag (unload_dialog dcTag)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ)) (defun _read (file / ofile lst nl) (cond ( (setq ofile (open file "r")) (while (setq nl (read-line ofile)) (setq lst (cons nl lst))) (close ofile))) (reverse lst)) (cond ( (not (setq i -1 ss (ssget "_X" (list (cons 0 "INSERT") (cons 2 BlockName) (cons 66 1))))) (princ (strcat "\n** No Blocks with Name: " BlockName " Found **"))) ( (not (setq Strfilename (findfile Strfilename))) (princ "\n** Data File not Found **")) ( (not (setq StrLst (_read Strfilename))) (princ "\n** Data File Empty **")) ( (<= (setq dcTag (load_dialog dcfilename)) 0) (princ "\n** Dialog Definition Not Found **")) ( (not (new_dialog "Names" dcTag)) (princ "\n** Dialog Could not be Loaded **")) (t ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;----------------BD (start_list "lst") ;----------------BD (mapcar (function add_list) StrLst) ;----------------BD (end_list) ;----------------BD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;----------------BD (start_list "lst1") ;----------------BD (mapcar (function add_list) StrLst) ;----------------BD (end_list) ;----------------BD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;----------------BD (start_list "lst2") ;----------------BD (mapcar (function add_list) StrLst) ;----------------BD (end_list) ;----------------BD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;----------------BD (start_list "lst3") ;----------------BD (mapcar (function add_list) StrLst) ;----------------BD (end_list) ;----------------BD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;----------------BD (setq ptr (set_tile "lst" "0") ptr1 (set_tile "lst1" "0") ;----------------BD ptr2 (set_tile "lst2" "0") ;----------------BD ptr3 (set_tile "lst3" "0")) ;----------------BD (action_tile "lst" "(setq ptr $value)" "lst1" "(setq ptr1 $value)" ;----------------BD "lst2" "(setq ptr2 $value)" ;----------------BD "lst3" "(setq ptr3 $value)") ;----------------BD (setq dcFlag (start_dialog)) (setq dcTag (unload_dialog dcTag) TagString (strcase TagString) TagString1 (strcase TagString1) Str (nth (atoi ptr) StrLst) Str1 (nth (atoi ptr1) StrLst)) ;----------------BD (if (= 1 dcFlag) (while (setq ent (ssname ss (setq i (1+ i)))) (while (not (eq "SEQEND" (cdr (assoc 0 (setq eLst (entget (setq ent (entnext ent)))))))) (if (eq TagString (cdr (assoc 2 eLst))) (entupd (cdr (assoc -1 (entmod (subst (cons 1 Str) (assoc 1 eLst) eLst))))) (if (eq TagString1 (cdr (assoc 2 eLst))) (entupd (cdr (assoc -1 (entmod (subst (cons 1 Str1) (assoc 1 eLst) eLst))))))) (princ)) Quote
woodman78 Posted August 23, 2010 Author Posted August 23, 2010 Does anyone have any pointers on where to go with this? Thanks Quote
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.