Results 1 to 7 of 7

Thread: Can anyone assist me please?

  1. #1
    Member
    Join Date
    2008-11
    Posts
    12
    Login to Give a bone
    0

    Question Can anyone assist me please?

    I have a project that is an exact copy of a building that was already done some time ago. So I wish to do the absolute minimal drafting required to keep profit up. I want to run a batch routine if possible to change part of the drawing file name, the project number to be exact. It is a slight bit trickier as only part of the line of text of a tag in an attributed block is required to be changed, see example below.

    Block Name: title
    Tag: NUMBER
    text: 22160-M-50-00-0100

    I want to change 22160-M-50-00-0100 to 22193-M-50-00-0100.
    I want to be able to do this via lisp and using runbatch if possible. Is anyone able to assist as i have 600 drawings and this would make life a hell of a lot easier.

  2. #2
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Iron Station, NC
    Posts
    3,198
    Login to Give a bone
    0

    Default Re: Can anyone assist me please?

    Quote Originally Posted by scoff View Post
    I have a project that is an exact copy of a building that was already done some time ago. So I wish to do the absolute minimal drafting required to keep profit up. I want to run a batch routine if possible to change part of the drawing file name, the project number to be exact. It is a slight bit trickier as only part of the line of text of a tag in an attributed block is required to be changed, see example below.

    Block Name: title
    Tag: NUMBER
    text: 22160-M-50-00-0100

    I want to change 22160-M-50-00-0100 to 22193-M-50-00-0100.
    I want to be able to do this via lisp and using runbatch if possible. Is anyone able to assist as i have 600 drawings and this would make life a hell of a lot easier.
    I dont have anything that can do this right off hand, I however do have some parts and pieces that can do what you ask. You need to have the program select a block, find the particular tag (it will work as long as you have unique tags throught the block), trim the left side of the string, and replace it with the proper text.
    Code:
    (setq ss (ssget "_X" '((0 . "insert")(2 . "TBLK NAME HERE"))))
    (if    (/= ss nil)
                  (progn
                (foreach itm2 lst
                  (setq    Ent    (ssname ss 0)
                    EntData    (entget Ent)
                  ) ;_ end of setq
                  (if
                    (not
                      (foreach Att
                           (vlax-invoke
                         (vlax-ename->vla-object Ent)
                         'GetAttributes
                           ) ;_ end of vlax-invoke
                    (if (= (vla-get-TagString Att)
                           "ATTRIBUTENAME HERE"
                        ) ;_ end of =
                      (setq    tmpList
                         (cons Att (vla-get-TextString Att))
                      ) ;_ end of setq
                    ) ;_ end of if
                      )        ;end foreach
                    )        ;END NOT
    
                     (vla-put-TextString
                       (car tmpList)
                       (strcat "NUMBER" (vl-string-left-trim "OLDNUMBER" (vla-get-TextString Att)))
                     ) ;_ end of vla-put-TextString
    
                     (vla-Update (car tmpList))
                  )        ;end if
    I have no idea if the above will work. maybe someone else can give a hand. I took one of our programs that does something similar and tried to modify it, but without your title block at hand, there is no way for me to test it.

  3. #3
    Member
    Join Date
    2008-11
    Posts
    12
    Login to Give a bone
    0

    Cool Re: Can anyone assist me please?

    Ok,
    I have started to progress with this though not very good and pretty lost.
    I have used bits from another routine i found and hope it makes sense what i am trying to do. Could someone please check it as I know it is not correct, i have commented on the obvious areas to me that are not correct.

    Code:
    (defun C:UpdateTB
    		    (/	      inspt    atts	acsp	 fname
    		     issuenum revnum   tddate	issuedfor
    		     amblk      adoc
    		    )
      (vl-load-com)
      (setvar "cmdecho" 0)
      (setq zero (list 0 0 0))
      (setq	adoc (vla-get-activedocument
    	       (vlax-get-acad-object)
    	     )
      )
      (if (and
    	(= (getvar "tilemode") 0)
    	(= (getvar "cvport") 1)
          )
        (setq acsp (vla-get-paperspace adoc))
        (setq acsp (vla-get-modelspace adoc))
      )
    
      (setq	fname
            "S:\\DSA CAD\\BLOCK'S\\Dynamic Blocks\\Set Up\\Attributes\\Ammendment Line.dwg"
      )									;;Enter the directory path and file name of ammendment tag to be inserted
      (setq atblk "title")							;;Sets the name of the title block attribute to be ammended
      (setq	revtag "[A]")							;;Sets the name of the REV tag to be ammended  (setq revnum (strcase (getstring "What REV is the drawing?.."))) to prompt user
      (setq datetag "26.11.08")						;;Sets the date of the ammendment tag, use (menucmd "M=$(edtime,$(getvar,date),DD.MO.yy)") to automate days date
      (setq	issuedfortag "Drawing Issued For .......")			;;Sets the what the drawing is to be issued for (setq	issuedfor (getstring T "Drawing Issued For .......")) from user prompts
      (setq drawntag (strcase "##"))					;;Sets the name of the DRAWN tag to be ammended  (setq drawntag (strcase (getstring "Who has DRAWN the drawing?..))) to prompt user
      (setq engineertag (strcase "##"))					;;Sets the name of the ENGINEER tag to be ammended  (setq engineertag (strcase (getstring "Which ENGINEER designed the drawing?.."))) to prompt user
      (setq checkedtag (strcase "##"))					;;Sets the name of the CHECKED tag to be ammended  (setq checkedtag (strcase (getstring "Who CHECKED the drawing?.."))) to prompt user
      (setq approvedtag (strcase "##"))					;;Sets the name of the APPROVED tag to be ammended  (setq approvedtag (strcase (getstring "Who APPROVED the drawing?.."))) to prompt user
    
      (vla-startundomark
        (vla-get-activedocument (vlax-get-acad-object))
      )
    
      (if (findfile ammendln)
        (setq amblk (vlax-invoke acsp 'Insertblock zero fname 1 1 1 0))
        (setq atts (vlax-invoke amblk 'GetAttributes))
        (foreach at	atts
          (cond
    	((eq "ISSUE" (vlax-get at 'TagString))
    	 (vlax-put at 'TextString issuenum)
    	)
    	((eq "REV" (vlax-get at 'TagString))
    	 (vlax-put at 'TextString revtag)
    	)
    	((eq "DATE" (vlax-get at 'TagString))
    	 (vlax-put at 'TextString datetag)
    	)
    	((eq "AMMENDMENT" (vlax-get at 'TagString))
    	 (vlax-put at 'TextString issuefortag)
    	)
          ) ;_cond
        ) ;_foreach
        (vla-update amblk)
        (alert
          "Ammendment Block Was Not Found\nCheck it is in the AutoCAD Search Path"
        )
      ) ;_if
    
    ;;; I think i have an error here. I am trying to search for the block and if found proceed.
    
      (if (= (tblsearch "block" atblk))								
        (setq atts (vlax-invoke atblk 'GetAttributes))
        (foreach at atts
          (cond
            ((eq "DRAWN" (vlax-get at 'TagString))
             (vlax-put at 'TextString drawntag)
             )
            ((eq "ENGINEER" (vlax-get at 'TagString))
             (vlax-put at 'TextString engineertag)
             )
            ((eq "CHECKED" (vlax-get at 'TagString))
             (vlax-put at 'TextString checkedtag)
             )
            ((eq "APPROVED" (vlax-get at 'TagString))
             (vlax-put at 'TextString approvedtag)
             )
            ((eq "DATE" (vlax-get at 'TagString))
             (vlax-put at 'TextString datetag)
             )
    ;;; This section here is of concern. I need to read the tag "NUMBER"and then trim the number (hence my first start of thread).
        To my understanding this will place the value of numbertag in the attributed tag.
    
            ((eq "NUMBER" (vlax-get at 'TagString))
             (vlax-put at 'TextString numbertag)
             )
            ((eq "AA" (vlax-get at 'TagString))
             (vlax-put at 'TextString revnum)
             )
          ) ;_cond
        ) ;_foreach
        (vla-update atblk)
        (alert
          "Title, Attributed Block Was Not Found\nCheck the block name is correct and in drawing"
        )
      ) ;_if
      (vla-regen adoc acactiveviewport)
      (vla-endundomark
        (vla-get-activedocument (vlax-get-acad-object))
      )
      (command "-layout" "rename" "" revnum)
    
      (princ)
    )

    If i could get this working I would be most appreciative.

    Stephen

    Last edited by Opie; 2008-11-25 at 04:08 PM. Reason: [code] tags added, please see Moderator Note

  4. #4
    Member
    Join Date
    2008-11
    Posts
    12
    Login to Give a bone
    0

    Cool Re: Can anyone assist me please?

    Sorry guys,
    How do I get the code inside the blue box formatted corectly like you have done above?

  5. #5
    Member
    Join Date
    2008-11
    Posts
    12
    Login to Give a bone
    0

    Cool Re: Can anyone assist me please?

    I have attached the lisp file, might make life easier?
    Attached Files Attached Files

  6. #6
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Iron Station, NC
    Posts
    3,198
    Login to Give a bone
    0

    Default Re: Can anyone assist me please?

    Quote Originally Posted by scoff View Post
    Sorry guys,
    How do I get the code inside the blue box formatted corectly like you have done above?
    code tags
    Code:
    looks something like this
    its the # sign in the post editor, or is CODE inside of [] at the beginning and /CODE inside [] at the end of the code

  7. #7
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Iron Station, NC
    Posts
    3,198
    Login to Give a bone
    0

    Default Re: Can anyone assist me please?

    Code:
    (defun C:UpdateTB
              (/        inspt    atts     acsp     fname
               issuenum revnum   tddate   issuedfor
               amblk    adoc
              )
      (vl-load-com)
      (setvar "cmdecho" 0)
      (setq zero (list 0 0 0))
      (setq    adoc (vla-get-activedocument
               (vlax-get-acad-object)
             ) ;_ end of vla-get-activedocument
      ) ;_ end of setq
      (if (and
        (= (getvar "tilemode") 0)
        (= (getvar "cvport") 1)
          ) ;_ end of and
        (setq acsp (vla-get-paperspace adoc))
        (setq acsp (vla-get-modelspace adoc))
      ) ;_ end of if
    
      (setq    fname
         "S:\\DSA CAD\\BLOCK'S\\Dynamic Blocks\\Set Up\\Attributes\\Ammendment Line.dwg"
      ) ;_ end of setq
      ;;Enter the directory path and file name of ammendment tag to be inserted
      (setq atblk "title")
      ;;Sets the name of the title block attribute to be ammended
      (setq revtag "[A]")
      ;;Sets the name of the REV tag to be ammended (setq revnum (strcase (getstring "What REV is the drawing?.."))) to prompt user
      (setq datetag "26.11.08")
      ;;Sets the date of the ammendment tag, use (menucmd "M=$(edtime,$(getvar,date),DD.MO.yy)") to automate days date
      (setq issuedfortag "Drawing Issued For .......")
      ;;Sets the what the drawing is to be issued for (setq issuedfor (getstring T "Drawing Issued For .......")) from user prompts
      (setq drawntag (strcase "##"))
      ;;Sets the name of the DRAWN tag to be ammended (setq drawntag (strcase (getstring "Who has DRAWN the drawing?..))) to prompt user
      (setq engineertag (strcase "##"))
      ;;Sets the name of the ENGINEER tag to be ammended (setq engineertag (strcase (getstring "Which ENGINEER designed the drawing?.."))) to prompt user
      (setq checkedtag (strcase "##"))
      ;;Sets the name of the CHECKED tag to be ammended (setq checkedtag (strcase (getstring "Who CHECKED the drawing?.."))) to prompt user
      (setq approvedtag (strcase "##"))
      ;;Sets the name of the APPROVED tag to be ammended (setq approvedtag (strcase (getstring "Who APPROVED the drawing?.."))) to prompt user
    
      (vla-startundomark
        (vla-get-activedocument (vlax-get-acad-object))
      ) ;_ end of vla-startundomark
    
      (if (findfile ammendln)
        (progn
          (setq amblk (vlax-invoke acsp 'Insertblock zero fname 1 1 1 0))
          (setq atts (vlax-invoke amblk 'GetAttributes))
          (foreach at atts
        (cond
          ((eq "ISSUE" (vlax-get at 'TagString))
           (vlax-put at 'TextString issuenum)
          )
          ((eq "REV" (vlax-get at 'TagString))
           (vlax-put at 'TextString revtag)
          )
          ((eq "DATE" (vlax-get at 'TagString))
           (vlax-put at 'TextString datetag)
          )
          ((eq "AMMENDMENT" (vlax-get at 'TagString))
           (vlax-put at 'TextString issuefortag)
          )
        ) ;_cond
          ) ;_foreach
          (vla-update amblk)
          (alert
        "Ammendment Block Was Not Found\nCheck it is in the AutoCAD Search Path"
          ) ;_ end of alert
        ) ;_ end of progn
      ) ;_if
    
    ;;; I think i have an error here. I am trying to search for the block and if found proceed.
    
      (if (= (tblsearch "block" atblk))
        (progn
          (setq atts (vlax-invoke atblk 'GetAttributes))
          (foreach at atts
        (cond
          ((eq "DRAWN" (vlax-get at 'TagString))
           (vlax-put at 'TextString drawntag)
          )
          ((eq "ENGINEER" (vlax-get at 'TagString))
           (vlax-put at 'TextString engineertag)
          )
          ((eq "CHECKED" (vlax-get at 'TagString))
           (vlax-put at 'TextString checkedtag)
          )
          ((eq "APPROVED" (vlax-get at 'TagString))
           (vlax-put at 'TextString approvedtag)
          )
          ((eq "DATE" (vlax-get at 'TagString))
           (vlax-put at 'TextString datetag)
          )
          ;| This section here is of concern. I need to read the tag "NUMBER"and then trim the number (hence my first start of thread).
        To
        my
        understanding
        this
        will
        place
        the
        value
        of
        numbertag
        in
        the
        attributed
        tag.|;
    
          ((eq "NUMBER" (vlax-get at 'TagString))
           (vlax-put at 'TextString numbertag)
          )
          ((eq "AA" (vlax-get at 'TagString))
           (vlax-put at 'TextString revnum)
          )
        ) ;_cond
          ) ;_foreach
          (vla-update atblk)
          (alert
        "Title, Attributed Block Was Not Found\nCheck the block name is correct and in drawing"
          ) ;_ end of alert
        ) ;_ end of progn
      ) ;_if
      (vla-regen adoc acactiveviewport)
      (vla-endundomark
        (vla-get-activedocument (vlax-get-acad-object))
      ) ;_ end of vla-endundomark
      (command "-layout" "rename" "" revnum)
    
      (princ)
    ) ;_ end of defun
    I took care of a couple of the errors with the too many arguments, when using an if statement, if you have more than one function that you want to run, you must use include the functions within (progn ... )

Similar Threads

  1. Can anyone assist, please?
    By stephen.coff in forum AutoLISP
    Replies: 7
    Last Post: 2008-11-16, 01:52 PM
  2. Can not get multiple block lookup working - please assist!?
    By cadman_meg in forum Dynamic Blocks - Technical
    Replies: 11
    Last Post: 2008-03-11, 02:06 PM
  3. Replies: 7
    Last Post: 2006-08-29, 03:22 AM
  4. Use plan regions to assist alignment of objects
    By Wes Macaulay in forum Revit Architecture - Tips & Tricks
    Replies: 14
    Last Post: 2005-02-23, 01:55 PM
  5. PDA or Laptop to assist on site?
    By Nic M. in forum Revit - In Practice
    Replies: 10
    Last Post: 2004-07-06, 08:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •