Lee Mac Posted March 3, 2010 Posted March 3, 2010 Have you made sure that the settings at the top of the LISP code are correct? Quote
woodman78 Posted March 3, 2010 Author Posted March 3, 2010 yeah i chnged them to suit the block i created but still no joy. The dialog loads but when I select something and click ok nothing changes. Quote
Lee Mac Posted March 3, 2010 Posted March 3, 2010 yeah i chnged them to suit the block i created but still no joy. The dialog loads but when I select something and click ok nothing changes. All seems fine for me ~ did you do a regen? Quote
woodman78 Posted March 4, 2010 Author Posted March 4, 2010 Yeah LeeMac that worked fine when I saved the drawing first. It updated then no problem. I have been try to modify it so that the first word on the line in the text file is extracted and used to fill another attribute in the same block. I made a bit of a mess of it. I tried using the (setq ** (car **)) to do it but I an having problems with how to update the attribute. Can you have a look and give em some guidance?? Thanks. change_att.lsp Quote
Lee Mac Posted March 4, 2010 Posted March 4, 2010 It doesn't look like you've modified it.. How would it function? The user is selecting a string to populate an attribute - where does this other attribute come in? and where is the string to populate it? Quote
woodman78 Posted March 4, 2010 Author Posted March 4, 2010 Sorry I attached the wrong version. change_att.lsp Quote
Lee Mac Posted March 4, 2010 Posted March 4, 2010 You cannot use 'car' on a string. The 'car' function is for use on lists, and retrieves the first item in the list. Perhaps it might've been easier if this was explained earlier in the thread. Quote
woodman78 Posted March 5, 2010 Author Posted March 5, 2010 Would you be able to code this LeeMac? Thanks. Quote
Lee Mac Posted March 5, 2010 Posted March 5, 2010 Would you be able to code this LeeMac? Thanks. I thought you wanted to learn... Quote
Lee Mac Posted March 5, 2010 Posted March 5, 2010 Study how I have approached it: (defun c:Change_Att (/ *error* _read BLOCKNAME DCFILENAME DCFLAG DCTAG ELST ENT I POS PTR SS STR STRFILENAME STRLST TAGSTRING TAGSTRING1 TAGSTRING2 ) (vl-load-com) ;; Lee Mac ~ 01.03.10 (setq dcfilename "Change_Att.dcl" ;; DCL Filename Strfilename "Change_Att.txt" ;; Data Filename BlockName "Project_Names" ;; Block Name TagString1 "TAG1" ;; Tag String TagString2 "TAG2" ;; Tag String ) (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 "attchange" dcTag)) (princ "\n** Dialog Could not be Loaded **")) (t (start_list "lst") (mapcar (function add_list) StrLst) (end_list) (setq ptr (set_tile "lst" "0")) (action_tile "lst" "(setq ptr $value)") (setq dcFlag (start_dialog)) (setq dcTag (unload_dialog dcTag) TagString1 (strcase TagString1) TagString2 (strcase TagString2) Str (nth (atoi ptr) 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)))))))) (cond ( (eq TagString1 (cdr (assoc 2 eLst))) (entupd (cdr (assoc -1 (entmod (subst (cons 1 Str) (assoc 1 eLst) eLst)))))) ( (and (eq TagString2 (cdr (assoc 2 eLst))) (setq pos (vl-string-position 32 Str))) (entupd (cdr (assoc -1 (entmod (subst (cons 1 (substr str 1 pos)) (assoc 1 eLst) eLst))))))))) (princ "\n*Cancel*")))) (princ)) Quote
woodman78 Posted March 8, 2010 Author Posted March 8, 2010 Thanks LeeMac, I modified another a copy of the lisp for my drawing types so that it does the following: Text file line: AD Accident Data Tag1: Accident Data Tag2: AD Quote
Lee Mac Posted March 8, 2010 Posted March 8, 2010 I'm glad it works for you, but as I say - look at how I have written the LISP so that you may learn from it Quote
woodman78 Posted April 6, 2010 Author Posted April 6, 2010 LeeMac, I have been using the above lisp for a while now but it was pointed out to me that the lisp doesn't change all instances of a block in a drawing. It changes the first layout ok but on the second layout it only puts in the first letter of the string. Any ideas? Quote
woodman78 Posted April 7, 2010 Author Posted April 7, 2010 I checked out the two versions of the lisp I have: the one that you created and the one I modified for the drawing type. The one that you created, Project_names, updates the project title in many sheets in the one drawing. My version, drawing_type will update the first sheet and partially update the second sheet and subsequent sheets. Could you have a look at the code and see what I've messed up with them?? drawing_type.lsp project_names.lsp Quote
Lee Mac Posted April 7, 2010 Posted April 7, 2010 Firstly, if you modify a code, it is common courtesy to mark on the code where you have modified it, and who has made the modification. As for the problem, bear in mind at which point the 'pos' variable is initiated. Quote
woodman78 Posted April 7, 2010 Author Posted April 7, 2010 LeeMac, I have been trying to get this to work. I'm struggling with it. I set the TagString1 Pos to start at character 4 in this case. And this works for the first layout. I am missing how it works for the first one and not the others. (while (setq ent (ssname ss (setq i (1+ i)))) (while (not (eq "SEQEND" (cdr (assoc 0 (setq eLst (entget (setq ent (entnext ent)))))))) (cond ( (eq TagString1 (cdr (assoc 2 eLst))) (entupd (cdr (assoc -1 (entmod (subst (cons 1 (substr Str 4 pos)) ;;;;;;;; BD (assoc 1 eLst) eLst)))))) ( (and (eq TagString2 (cdr (assoc 2 eLst))) (setq pos (vl-string-position 32 Str))) (entupd (cdr (assoc -1 (entmod (subst (cons 1 (substr str 1 pos)) (assoc 1 eLst) eLst))))))))) (princ "\n*Cancel*")))) Quote
Lee Mac Posted April 7, 2010 Posted April 7, 2010 pos is nil in the first condition - it does not get set until the second. Quote
woodman78 Posted April 7, 2010 Author Posted April 7, 2010 Thanks LeeMac, got it. it's working now. 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.