Jump to content

Recommended Posts

Posted

Have you made sure that the settings at the top of the LISP code are correct?

  • Replies 38
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    19

  • woodman78

    18

  • alanjt

    1

  • BearDyugin

    1

Top Posters In This Topic

Posted Images

Posted

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.

Posted
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?

Posted

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

Posted

It doesn't look like you've modified it.. :huh:

 

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?

Posted

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.

Posted

Would you be able to code this LeeMac?

 

Thanks.

Posted
Would you be able to code this LeeMac?

 

Thanks.

 

I thought you wanted to learn... o:)

Posted

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))

Posted

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

Posted

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 :)

  • 4 weeks later...
Posted

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?

Posted

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

Posted

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.

Posted

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*"))))

Posted

pos is nil in the first condition - it does not get set until the second.

Posted

Thanks LeeMac, got it. it's working now.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...