Jump to content

Change drawing no. and title via script


badogblue

Recommended Posts

First off, I'm a total cad noob, never used a script before!

 

As the title says I need to edit the drawing number and drawing title in the title block of over 200 drawings.

 

The title in every drawing is "site clearance drawings", this needs changed to "site clearance".

 

For the drawing numbers, extra drawings where added to the series and so the drawing no. needs changed from "1 of 180", "2 of 180" etc. to "1 of 210" etc. Each drawing is in a separate dwg with the title "site_clearance_001" etc.

 

Would really appreciate your help!

Thanks in advance.

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

Are the title and the number attributes? If so, what are the names of the attributes?

 

Not sure, the drawings would probably be set up as industry standard, so depends if attributes are standard?

 

Don't have access to drawings now so can't check. I assume a script would only be possible if the title block uses attributes, so assume yes for now.

 

Thanks.

Link to comment
Share on other sites

as a lover of scripts I would say this is possible BUT if you are not using LT it would be far safer to use LISP. In effect, a script is just doing the typing for you and will keep typing irrespective of whether the output is correct or not. You can build a lot more error trapping into LISP.

 

Before you can start on either LISP of a script you will need to determine the names of the attributes to be changed. I would suggest you post an example of the drawing. If you cannopt post a whole drawing as a minimum you should post the block with a CLEAR description of what needs changing, and how the new information is obtained (spreadsheet?).

 

Having said all that, I don't have the time to work out a script for you or knowledge to write a LISP for you but hang around, somebody else should be along soon.

Link to comment
Share on other sites

Not sure, the drawings would probably be set up as industry standard, so depends if attributes are standard?

 

Don't have access to drawings now so can't check. I assume a script would only be possible if the title block uses attributes, so assume yes for now.

Thanks.

 

i suggest you find out or someone may be wasting their time

Link to comment
Share on other sites

i suggest you find out or someone may be wasting their time

 

Just phoned a college, all drawing title blocks are set up with attributes. Don't know their names but that shouldn't matter for now.

 

Would prefer a script as I understand it more.

 

Thanks for all the replies!

Link to comment
Share on other sites

Don't know their names but that shouldn't matter for now

 

Sorry but it does matter. The lisp programs are all done it just takes a bit of a hack of one to suit your dwg's we must have your dwg !!! or We need to know the title block name and the name of its attribute tags to be changed.

Link to comment
Share on other sites

Sorry but it does matter. The lisp programs are all done it just takes a bit of a hack of one to suit your dwg's we must have your dwg !!! or We need to know the title block name and the name of its attribute tags to be changed.

 

I know the names are needed, but if someone could post a script/lisp I could put the names in once I find them out. I was hoping to keep it general so that I could use it in the future for other changes to title block.

 

Even if someone could start me off, I would greatly appreciate it.

Thanks everyone.

Link to comment
Share on other sites

I still maintain that you do not want to do this as a script but anyway, here is a snippet to get you started.

 

OPEN
[color=red]filename[/color]
-ATTEDIT
N
N
[color=red]block_name[/color]
[color=red]attribute tag name[/color]
*
[color=red]current text[/color]
[color=red]new text[/color]

 

you will need to replace the red lines with your own data.

 

If any of your answers have spaces in them, you MUST put quote marks around the text.

 

If for any reason current text is not found (mis typed or simply blank) the script will fail but continue running. Sometimes the resultant confusion is minor, sometime major. ALWAYS keep backups when running long scripts.

Link to comment
Share on other sites

Here is a lisp example

 

; changes to issued for construction
: thanks to lee mac for original code
(vl-load-com)
; 1.  Get current date in mm/dd/yy format.
(defun ddmmyy (/ x today)
    (setvar "cmdecho" 0)
    (setq x (getvar "CDATE"))                 ; get current date
    (setq today ( rtos x 2 4))                    ; convert to a string
    (setq date (strcat (substr today 7 2) "."    (substr today 5 2) "." (substr today 3 2) ))
)

(setq oldtag1 "DRAWING_STATUS") ;attribute tag name
(setq newstr1 "ISSUED FOR CONSTRUCTION")
(setq oldtag2 "REV_NO")  ;attribute tag name
(setq newstr2 "0")
(setq ss1 (ssget "x"  '((0 . "INSERT") (2 . "DA1DRTXT"))))
(setq inc (sslength ss1))
(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
) ; end for
) ;end repeat
(setq oldtag1 "REV-NO")
(setq newstr1 "0")
(ddmmyy)
(setq oldtag2 "DATE")
(setq newstr2 date)
(setq oldtag3 "AMENDMENT")
(setq newstr3 "ISSUED FOR CONSTRUCTION")
(setq ss2 (ssget "x"  '((0 . "INSERT") (2 . "REVTABLE"))))
(setq inc (sslength ss2))
(repeat inc
(foreach att (vlax-invoke (vlax-ename->vla-object (ssname ss2 (setq inc (1- inc)))) 'getattributes)
(if (= oldtag1 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr1) 
)
(if (= oldtag2 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr2) 
)
(if (= oldtag3 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr3) 
)
)
)
(setq ss1 nil)
; (setq ss2 nil)
(princ)

Link to comment
Share on other sites

we use a nice little script called "bfind"

 

This doesn't seem to do incremental numbering which is needed for sheet numbers. I downloaded the Batch Attribute editor from lee-mac which seems perfect but it doesn't seem to work.

 

I select the drawings and the attribute to be changed but on clicking "run", nothing happens! It come up with on the command line: "do you want to discard all changes". Selecting yes or no results in the file open window opening. I think it's because my cad comes installed with cadtools which is preventing the attribute editor from connecting to the title block. It also comes with oasysis which might also be a problem.

 

Any advice, please?

Link to comment
Share on other sites

If you post a sample drawing, I would be happy to try writing a LISP routine for you.

 

Thanks for the offer, unfortunately I'm not off liberty to post a drawing online. If you could post a general lisp for changing sheet numbers incrementally I could add in the title block name and attribute name later. If its not too much trouble.

I really appreciate all the help, thanks!

Link to comment
Share on other sites

Thanks for the offer, unfortunately I'm not off liberty to post a drawing online. If you could post a general lisp for changing sheet numbers incrementally I could add in the title block name and attribute name later. If its not too much trouble.

I really appreciate all the help, thanks!

 

it only need be the titleblock

Link to comment
Share on other sites

The method is all there in the code I posted but you need a variation in that it iterates through the layouts and changes the correct variable being the sheet number.

 

Here is different lisp that does do that plus a couple of other things it uses the layout name which has a number on the end which matches the sheet number.

 

; change the 410 to layout name
;;-------------------=={ Parse Numbers }==--------------------;;
;;                                                            ;;
;;  Parses a list of numerical values from a supplied string. ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright © 2011 - [url="http://www.lee-mac.com"]www.lee-mac.com[/url]       ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  s - String to process                                     ;;
;;------------------------------------------------------------;;
;;  Returns:  List of numerical values found in string.       ;;
;;------------------------------------------------------------;;
(defun LM:ParseNumbers ( s )
 (
   (lambda ( l )
     (read
       (strcat "("
         (vl-list->string
           (mapcar
             (function
               (lambda ( a b c )
                 (if
                   (or
                     (< 47 b 58)
                     (and (= 45 b) (< 47 c 58) (not (< 47 a 58)))
                     (and (= 46 b) (< 47 a 58) (< 47 c 58))
                   )
                   b 32
                 )
               )
             )
             (cons nil l) l (append (cdr l) (list nil))
           )
         )
         ")"
       )
     )
   )
   (vl-string->list s)
 )
)
;(defun ah:sheetupdate1 (ss1 lay plotabs tabname dwgname)
(defun ah:sheetupdate1 ()
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for lay (vla-get-Layouts doc)
 (setq plotabs (cons (vla-get-name lay) plotabs))
)
(setq title "Please enter dwg number")
(setq width "   edit_width = 12;")
(setq limit "     edit_limit = 9;")
(ah:getval title width limit)
(setq dwgname item)
(setq title "Please enter version for all sheets <Cr> no change")
(setq width "   edit_width = 8;")
(setq limit "     edit_limit = 5;")
(ah:getval title width limit)  
(setq newstr4 item)

(princ "0")
(setq len (length plotabs))
(setq x 0)
(setq bname "DA1DRTXT")
(repeat len
 (setq tabname (nth x plotabs))
 (if (/= tabname "Model")
   (progn
     (setvar "ctab" tabname)
     (setq ss1 (ssget "x"  (list (cons 0 "INSERT") (cons 2 bname)(cons 410 tabname))))
     (setq dwgnum (Lm:parsenumbers tabname))
     (setq sheetnum (car dwgnum))
     (setq oldtag1 "SHT_NO") ;attribute tag name
     (setq newstr1 (rtos sheetnum 2 0))
     (setq oldtag2 "DRG_NO") ;attribute tag name
     (setq oldtag3 "PROJ_NO") ;attribute tag name
     (setq newstr3 dwgname)
     (setq oldtag4 "REV_NO") ;attribute tag name
; if less than 10
(if (< (car dwgnum) 10.0) 
     (setq newstr2 (strcat dwgname "-D0"  (rtos sheetnum 2 0)))
     (setq newstr2 (strcat dwgname "-D"  (rtos sheetnum 2 0)))
)
     (foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 0 )) '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 newstr3) 
       ) ; end if
       (if (and (/= newstr4 nil) (= oldtag4 (strcase (vla-get-tagstring att))) )
       (vla-put-textstring att newstr4) 
       ) ; end if 
      ) ; end foreach
   ) ; end progn
) ; end if
(setq x (+ x 1))
) ; end repeat
(setq ss1 nil)  
) ; end defun ah

(ah:sheetupdate1)
(princ)

Link to comment
Share on other sites

Sorry for the slow reply, have been quite busy.

 

Thanks Bigal for the lisp, unfortunately couldn't get it to work. Have been given several hundred more drawings to renumber so am desperate to get a script/lisp to automate this.

 

In summary: I need to change the Sheet No. and Drawing No. on the whole drawing series so that it is in ascending order.

 

Eg: For sheet no: "Sheet 1 of 200", "Sheet 2 of 200", etc.

For Drawing no: "xxxx_xxxx_100_001", "xxxx_xxxx_100_002" etc.

 

Here is a sample script which is used to change values in the title block:

 

;Script to change drawing details

;Enter attribute tag in first quote marks and value in second quote marks

;

(OASYSATTRIBUTECHANGE "BDR_DWGTITLE2" "DWGTitle 2 (Sheet 1 of 200)")

 

;End script

 

Here is a picture of the title block, including all attribute tags.

 

Title_Block_zpsfdc3bbd9.jpg

 

Thanks in advance!

Link to comment
Share on other sites

The off the shelf does not exist as every block has different names and different attribute TAG names.

 

So first you have to change the block name in the code above here it is DA1DRTXT

 

The attribute tags need to be changed "DRG_NO") ;attribute tag name, to yours BDR_DWGTITLE1 and so on then your well on the way.

 

Again post your title block and its a 5 min job

Link to comment
Share on other sites

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)

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