Jump to content

Change drawing no. and title via script


badogblue

Recommended Posts

Here is a quick cut and paste change the yourblockname

 

; changes to issued for construction

(vl-load-com)
(setq oldtag1 "BDR_JOBTITLE1") ;attribute tag name
(setq newstr1 "Job title 1")
(setq oldtag2 "BDR_JOBTITLE1")  ;attribute tag name
(setq newstr2 "Job title 2")
(setq x 1) ; sheet 1
(setq ss1 (ssget "x"  '((0 . "INSERT") (2 . "Yourblockname"))))
(setq inc (sslength ss1)) ; this is the total number of sheets +1
(repeat inc      
(foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 (setq inc (1- inc)) )) 'getattributes)
(if (= oldtag1 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr1) 
) ; end if
(if (= oldtag2 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr2) 
) ; end if
(if (= oldtag3 (strcase (vla-get-tagstring att)))
(vla-put-textstring att x) 
) ; end if
) ; end for
(setq x (+ x 1))
) ;end repeat
(setq ss1 nil)
; (setq ss2 nil)
(princ)

 

Thanks again BIGAL, updated the above lisp as follows.

 

 
; changes to issued for construction
(vl-load-com)
(setq oldtag1 "BDR_DWGTITLE2") ;attribute tag name
(setq newstr1 "Sheet x of 181")
(setq oldtag2 "BDR_DWGNO") ;attribute tag name
(setq newstr2 "100_00x")
(setq x 1) ; sheet 1
(setq ss1 (ssget "x" '((0 . "INSERT") (2 . "Text_r2010"))))
(setq inc (sslength ss1)) ; this is the total number of sheets +1
(repeat inc 
(foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 (setq inc (1- inc)) )) 'getattributes)
(if (= oldtag1 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr1) 
) ; end if
(if (= oldtag2 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr2) 
) ; end if
(if (= oldtag3 (strcase (vla-get-tagstring att)))
(vla-put-textstring att x) 
) ; end if
) ; end for
(setq x (+ x 1))
) ;end repeat
(setq ss1 nil)
; (setq ss2 nil)
(princ) 

The above lisp changes the "drawing no" and "sheet no" to what is in the quotes, but the iterative process does nothing. Any advice, do i need to change something else?

 

Also, forgot to say that each drawing is a seperate .dwg with only 1 layout.

 

Thanks.

Edited by badogblue
Link to comment
Share on other sites

  • Replies 24
  • Created
  • Last Reply

Top Posters In This Topic

  • badogblue

    9

  • BIGAL

    6

  • dbroada

    2

  • mikekmx

    2

You will need to run a script that opens each dwg runs the lisp and then closes again something like

 

open dwg1 (setq sheetnum "1")(load "myblockupdate") close Y
open dwg2 (setq sheetnum "2")(load "myblockupdate") close Y
open dwg3 (setq sheetnum "3")(load "myblockupdate") close Y

Link to comment
Share on other sites

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