Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Changing drawing number in multiple sheets

17 REPLIES 17
Reply
Message 1 of 18
pillaisg
1060 Views, 17 Replies

Changing drawing number in multiple sheets

I am having some 500 sheets in which I have to change the Drawing Numbers. The format of the drawing Number is as follows SGP-5-1000-001-R2-A1-0. In which SGP is the area code,5 is the discipline code, 1000 is the drawing number,R2 is the project code A1 is the sheet size and 0 is the revision.
I need to change the area code (SGP) and Drawing NUmber (1000) in all the 500 sheets. This drawing number is in an attribute format.
Thanks in advance
17 REPLIES 17
Message 2 of 18
jimmy.dhondt
in reply to: pillaisg

What version are you working on (acad 2008)? Do you have a list with the new drawing numbers and codes? Do you have an example drawing (attribute names, block name)?

Jimmy
Message 3 of 18
pillaisg
in reply to: pillaisg

ya i am using auto cad 2004, The attribute contains tags for Area code, discipline number,drawing number sheet number project code, sheet size, revision. (SGP-5-1000-001-R1-A1-0) respectively
Message 4 of 18
jimmy.dhondt
in reply to: pillaisg

Do you have an example drawing?

Jimmy
Message 5 of 18
EC-CAD
in reply to: pillaisg

Can you post a sample drawing, showing what is
there (circle it).. and what you need there .. in red.
Or tell us what the 'blockname' and attribute 'tagname'
are.
Also,
You say change Area code.. I assume that's just a different
(3) character string portion..
And, you say, change Drawing Number.. is that just another
'constant' such as 2000 .. or do you need to preserve the
previous Drawing Number.. and increment / decrement it ?

Bob
Message 6 of 18
Anonymous
in reply to: pillaisg

If you aren't worried about losing the thumbnails, you can do it with ObjectDBX. I wrote
a find/replace function that worked with a drawing and its nested xrefs. Shoud be easy to
convert to working with a folder of drawings.


wrote in message news:5800073@discussion.autodesk.com...
I am having some 500 sheets in which I have to change the Drawing Numbers. The format of
the drawing Number is as follows SGP-5-1000-001-R2-A1-0. In which SGP is the area code,5
is the discipline code, 1000 is the drawing number,R2 is the project code A1 is the sheet
size and 0 is the revision.
I need to change the area code (SGP) and Drawing NUmber (1000) in all the 500 sheets.
This drawing number is in an attribute format.
Thanks in advance
Message 7 of 18
EC-CAD
in reply to: pillaisg

Here's a sample Lisp that can do the job.
You will have to batch the drawings, loading the Lisp.

;; Change_title_block_attributes.lsp
(vl-load-com)
;;
(setq blockname "your_block_name")
(setq tag_name "your_attribute_tagname")
(setq AREA_CODE "XXX")
(setq DWG_NUMBER "2000")
;;
(defun make_new_value_for_attribute ( val ); Target = SGP-5-1000-001-R2-A1-0
(setq token1 (substr val 4 3)); get "-5-"
(setq token2 (substr val 11 (strlen val))); get all after dwg_number
(setq new_val (strcat AREA_CODE token1 DWG_NUMBER token2)); make up new value
); function
;;
(setq ss nil)
(setq ss (ssget "_X" (list (cons 0 "INSERT")(cons 2 blockname)(cons 66 1))))
(if ss
(progn
(setq x 0)
(repeat (sslength ss)
(setq blk (vlax-ename->vla-object (ssname ss x)))
(if (safearray-value (setq atts (vlax-variant-value (vla-getattributes blk))))
(progn
(setq atts (vlax-safearray->list (vlax-variant-value (vla-getattributes blk))))
(foreach att atts
(setq tagname (strcase (vla-get-tagstring att))); tagname
(setq old_val (vla-get-textstring att)); old value
(if (= tagname tag_name)
(progn
(make_new_value_for_attribute old_val); returns 'new_val'
(vla-put-textstring att new_val)
); progn
); if
); foreach
); progn
); if
(setq x (+ x 1))
); repeat length ss
); progn
); if
(princ)

Bob
Message 8 of 18
pillaisg
in reply to: pillaisg

How can i check the lisp which you have posted. Please guide me.
thanks for your reply
Message 9 of 18
pillaisg
in reply to: pillaisg

This is the drawing . In the title block I want to change this title block with different area code drawing number and project code as mentioned in the drawing. I wish to convert it as a batch
Message 10 of 18
pillaisg
in reply to: pillaisg

This is the drawing in which i have mentioned. What i require. Like this there are multiple sheets where i need to change only the mentioned information. Please guide me if somebody knows the solution.
thanks
pillai
Message 11 of 18
jimmy.dhondt
in reply to: pillaisg

Do you have a list with the all the drawing filenames and the new information that has to be written to the drawings?

Jimmy
Message 12 of 18
pillaisg
in reply to: pillaisg

The drawing numbers are in a sequence only the drawing number changes and the sheet number remains the same .
THe area number will change it can be any 3 alphabets which represents the code of the area. The project code also will change which can be alphanumerical (2 digits/ 2 alphabets)
Message 13 of 18
jimmy.dhondt
in reply to: pillaisg

Pillai,

No mather wath kind of programming you're going to use (Objectdbx, lisp, vba), you will need to know for each drawing the correct data that has to be written to the attribute. E.g. drawing filename (or drawing number in the title) = "12345": new area number = "abc", new project code = "12", etc...
Without this information it is not possible to write a routine that will do what you're asking for.

Jimmy
Message 14 of 18
EC-CAD
in reply to: pillaisg

Save this attached Lisp in your AutoCad \ support folder.
.. Edit the lisp, put in your title-block name, and attribute tag-name in these lines:
(setq blockname "your_block_name")
(setq tag_name "your_attribute_tagname")

.. and place your area / project string in these
lines.
(setq AREA_CODE "XXX")
(setq DWG_NUMBER "2000")
.. save the file (in text format, using Notepad or Wordpad)

Then, using a batch process such as ScriptPro..
select the drawings, and this Lisp to be run on each.

Oh, I just took a look at the 'test' dwg. My routine would
only change (1) of the attributes. You'll need to check for
each 'tag' name.. within block 'ADN01', and place the
appropriate value into each attribute. Simple to do, with
expansion of what I posted. The question is..
For (all) the drawings to be processed, are the values for
a given 'tag' such as (serial) .. consistent ?
IF not, you will need to read-in the data from a text file, or
spread-sheet .. and associate each drawing.. with the data.
I.E.
Drawing1, BHN, 5, 9117, 000, V7, 3, 0
Drawing2, XXX, 5, 9118, 000, V8, 3, 1
.. etc.
This can be done by making up an Excel .xls, saving as a .csv,
then reading in that .csv .. with the Lisp.


Bob Message was edited by: ECCAD
Message 15 of 18
Anonymous
in reply to: pillaisg

This is an algorithm approximation that should work if coded properly. Choose your
language and code it.

let
area := get user input (string) eg. "804"
serial := get user input (string)
code := get user input (string)
rev := get user input (string)
changes := association list of changes in form: (...(tag . new value) ...) e.g. (...(cons
"AREA" area) ..) if using lisp

one possible choice of selecting drawings to process:
folders := get user inputs (strings)
dwgs := all drawings in folders

let doc be an opendbx document

foreach dwg in dwgs
open dwg as doc
foreach item in each layout.block in doc
if item.objectname = "AcDbBlockReference" and item.name="ADN01" then
foreach att in item.attributes
if change := (assoc att.tagstring changes)
att.textstring := (cdr change)
endif
end foreach
endif
end foreach
close doc and cleanup stuff



wrote in message news:5804993@discussion.autodesk.com...
This is the drawing in which i have mentioned. What i require. Like this there are
multiple sheets where i need to change only the mentioned information. Please guide me if
somebody knows the solution.
thanks
pillai
Message 16 of 18
jimmy.dhondt
in reply to: pillaisg

Assuming that he always wants the same area, serial, code and rev for all drawings...

Jimmy
Message 17 of 18
Anonymous
in reply to: pillaisg

Yes, otherwise let area := program/rule system for changing area, etc. instead of a single
value.

You could also manage the process from a table in autocad or an excel spreadsheet better
than by prompting. Then instead of blindly opening every drawing, you could look for
sheets only. Too bad the SSM API is such a pain to work with, otherwise you could do it
with that. But thinking about that, he could just start using sheet set properties and
fields in his attributes and cut out the programming altogether.

wrote in message news:5806786@discussion.autodesk.com...
Assuming that he always wants the same area, serial, code and rev for all drawings...

Jimmy
Message 18 of 18
EC-CAD
in reply to: pillaisg

Here's a Lisp to extract the ADNO1 attributes and make
an initial .csv file called....drawing_info.csv.
You will need to place a 'real' path (on your system), into:
(setq PATH "c:/ACAD/"); ******** Change to something you have on your system ********
.. save the Lisp in your AutoCAD\support folder, and batch
your existing drawings. The resultant .csv file.. will have
all the 'data' from your existing drawings.. in there.
Next, we'll give you a Lisp to 'read' back-in the data, and
place the values into your target drawings.
This routine has been tested on your 'test' drawing, and it
works just fine.

If you need a decent batch program, just give me an E-Mail
(see the address in the Lisp).

Bob

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost