Please Help! Populate attributes by excel -LISP

Please Help! Populate attributes by excel -LISP

ryan_carey
Contributor Contributor
1,898 Views
6 Replies
Message 1 of 7

Please Help! Populate attributes by excel -LISP

ryan_carey
Contributor
Contributor

I have read and read, and i know each lisp is unique.  I am stumped and seeking help!  I had a SCR file and TXT file halfway working but got frustrated when i couldnt get any further and it seems like LISP is a better option.

 

Background:

We are turned over drawing packages from Vendors that contain hundreds of drawings.   Each drawing has to be put on its own DWG file and assigned with our own Title, File/Drawing number, etc.  I am looking a more efficient way than what we are currently doing and from what i have read and researched through the forums it can be done - i just cant figure it out.

 

I have attached the title block and an excel file for what i am looking to do.  If you open the drawing you will see the title lines 1 - 3, file no, and revision description is populated.  ( i want to create a lisp to do that later, but for starters ,want to start here).  These drawing sets are printed, and physically signed and then the names have to be manually typed into the title block.  Since there are hundreds of drawings, i am looking to have a file do this for me instead of having to open hundreds individually and type the names in each block (drawn by / date, engineer / date, quality, date, etc. )  . For each block the name is the same for each set.  I am looking for something in this order

 

Open drawing

**it reads excel populated info (row 2)  to fill in attributes on the drawing that are listed in the excel column names of row 1

zoom extents

save

close

open next drawing and do the same, etc, etc. 

 

Please tell me this is feasible and help would be greatly appreciated!  I hope i have provided enough information and it makes sense.

0 Likes
Accepted solutions (1)
1,899 Views
6 Replies
Replies (6)
Message 2 of 7

CodeDing
Advisor
Advisor

@ryan_carey,

 

To clarify...

- Will the "Row 2" in your Excel file ALWAYS populate the 6 attributes for that title block?

(Ex: 100 dwgs & 1 set of attributes)

 

- OR will "Row 2" populate 1 file, then "Row 3" the next file, "Row 4" the next.. etc..

(Ex: 100 dwgs & 100 sets of attributes)

 

Best,

~DD

0 Likes
Message 3 of 7

ryan_carey
Contributor
Contributor

@CodeDing Thanks for the reply!  Row 2 will always populate the same 6 attributes.  So 100 drawings will have the same attribute set added to the title block.

0 Likes
Message 4 of 7

dbhunia
Advisor
Advisor

Hi,

 

Try this........

 

First put all the drawings in a single folder & run the code it will ask to select the Folder Containing the drawings you just select the folder & move forward......Code will work itself on all the drawings in side that folder.....

 

But before running the Lisp make sure about two things-

       1. There is only one Drawing is open (other than any drawing which one you want to edit), otherwise SDI Variable can not be reset.

       2. Wait for complete execution of the command, otherwise SDI Variable will not restored back.

 

First save your Excel file as *.csv file format........

(i have considered these attribute tag names...."DRAWNBYDATE" "ENGDATE" "QUALITYDATE" "LINE_1_DRAWN_BY" "LINE_1_ENGINEER" "QUALITY1" from your attached drawing  ..........  "Row 2 will always populate the same 6 attributes"(means all title blocks would be updated from a single *.csv file).......... The title block name is identical....... and there is only one layout named "Layout1")

 

 


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
Message 5 of 7

ryan_carey
Contributor
Contributor

@dbhunia

 

That worked Great!  So, if i change the attribute tag name in the lisp file to match a different tag in another drawing...  That should work too correct?

 

For example, say on a D size title block, the Attribute tag name is named ENGINEER_DATE where as in a B Size, the Tag name is ENGDATE.  

 

As long as i change that tag name in the lisp file, and the tag name on the CSV file, to be the same,  it should work...correct?


(I know i could just change the Tag name on the files to match, but i was asking in case i wanted to fill in titles, or anything else i could do a replace at both locations, and it would read it correctly)

 

Thanks a ton for the help

0 Likes
Message 6 of 7

dbhunia
Advisor
Advisor
Accepted solution

Yes you can change the Attribute tag name in the Lisp file..........But no need to change the tag name in in the *.csv file.......

only you have to follow the order only........Like in the given Lisp the order is....

 

"DRAWNBYDATE" "ENGDATE" "QUALITYDATE" "LINE_1_DRAWN_BY" "LINE_1_ENGINEER" "QUALITY1"

 

And the corresponding *.csv Flie the order is....what I followed.....only thing the values should be placed in 2nd row....

 

Capture.PNG

 

If you want you can add the Attribute tag name here......(list "DRAWNBYDATE" "ENGDATE" "QUALITYDATE" "LINE_1_DRAWN_BY" "LINE_1_ENGINEER" "QUALITY1")...... in this pattern (each separated by inverted comma and within the parenthesis)........ But for that you have to add corresponding value in *.csv file.......

 

And the last main thing you have to add lines........here.....(This all for this particular Title Block named "A$C3AA00204").

 

.....................
(foreach att (vlax-invoke Obj 'GetAttributes)
	(if (= (vla-get-Tagstring att) (nth 0 tag_str)) (vla-put-textstring att (nth 0 (nth 1 Data_csv))))
	(if (= (vla-get-Tagstring att) (nth 1 tag_str)) (vla-put-textstring att (nth 1 (nth 1 Data_csv))))
	(if (= (vla-get-Tagstring att) (nth 2 tag_str)) (vla-put-textstring att (nth 2 (nth 1 Data_csv))))
	(if (= (vla-get-Tagstring att) (nth 3 tag_str)) (vla-put-textstring att (nth 3 (nth 1 Data_csv))))
	(if (= (vla-get-Tagstring att) (nth 4 tag_str)) (vla-put-textstring att (nth 4 (nth 1 Data_csv))))
	(if (= (vla-get-Tagstring att) (nth 5 tag_str)) (vla-put-textstring att (nth 5 (nth 1 Data_csv))))
..................;here add lines corresponding each Attribute tag name );foreach ........................

 


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
Message 7 of 7

ryan_carey
Contributor
Contributor

@dbhunia

 

Perfect, Thanks for the help.

0 Likes