Attributes from drawing name?

Attributes from drawing name?

DC-MWA
Collaborator Collaborator
2,940 Views
27 Replies
Message 1 of 28

Attributes from drawing name?

DC-MWA
Collaborator
Collaborator

I'm trying to find a way to use to attributes to name and number our sheets from the drawing name. Unfortunately, my autolisp skills are limited to basic layer manipulation, commands and variable settings etc. Ultimately it would be great to have a program autoload or part of our acaddoc that checks for the block and if it exists, fills in the attributes using the drawing name as desribed below.

We use a block called "MWA-SHEET". It contains two attributes, "SHEETNUMBER" and "SHEETTILE".

Sample file name: "A1.00-Sheet Title.dwg"

I need to use the "A1.00" for the "SHEETNUMBER" attribute and "Sheet Title" for the "SHEETTITLE" attribute.

I have included a sample drawing containing the "MWA-SHEET" block.

Thank you in advance for your time and input.

0 Likes
Accepted solutions (2)
2,941 Views
27 Replies
Replies (27)
Message 2 of 28

Moshe-A
Mentor
Mentor

@DC-MWA,

 

Excuse me but AutoCAD provides us with beautiful tools like DIESEL to do such tasks, there is also fields which more sophisticated and recent but long before that we had RTEXT (from express tools) that can use DIESEL

so why not use it?

 

sending back your fixed dwg.

 

moshe

 

0 Likes
Message 3 of 28

DC-MWA
Collaborator
Collaborator

I have no idea how either of those items function. Can i automate the proces with one those methods?

I tend to lean towards autolisp and acaddoc usage because of the success ive had and the control it gives me to manage.

0 Likes
Message 4 of 28

dlanorh
Advisor
Advisor
Can you please re-post drawing in AutoCAD 2010 format.

I am not one of the robots you're looking for

0 Likes
Message 5 of 28

DC-MWA
Collaborator
Collaborator

sample drawing 2010 attached...

0 Likes
Message 6 of 28

dlanorh
Advisor
Advisor
I notice that the layout tab name reflects the drawing name format.

Is this set seperately?
If so, do you want the title block attributes and layout tab name both set at the same time?

I am not one of the robots you're looking for

0 Likes
Message 7 of 28

DC-MWA
Collaborator
Collaborator

That would be great!

0 Likes
Message 8 of 28

dlanorh
Advisor
Advisor
Should have something in 3 hours. I have to pick someone up from the airport in about 40 mins.

I am not one of the robots you're looking for

0 Likes
Message 9 of 28

DC-MWA
Collaborator
Collaborator

I truly appreciate your time and assistance.

0 Likes
Message 10 of 28

Moshe-A
Mentor
Mentor

the answer is yes

have you looked at the fix drawing I send you?

this is the place to learn AutoCAD Customization and that's includes macros, rtext,diesel, fields and AutoLISP.

I likes very much autolisp but there are cases where other tools can give you more simple solutions then autolisp coding so why not learn? if you go over diesel reference you'll find that it has many basic functions of autolisp.

 

  

 

 

 

 

0 Likes
Message 11 of 28

maratovich
Advisor
Advisor

You need to consider a different filename: 

A021.150 - SAMPLE SHEET 000-500 (2)

It is necessary to clarify with the author whether there will be a change of name.

 

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
0 Likes
Message 12 of 28

DC-MWA
Collaborator
Collaborator

Sample file name: "A1.00-Sheet Title.dwg"

the naming before the dash changes and the information after the dash changes..

Examples..

"A1.00-Site Plan.dwg"

"A2.00-Floor Plan.dwg"

"A3.00-Enlarged Plans.dwg"

"A10.00-Architectural details.dwg"

0 Likes
Message 13 of 28

dlanorh
Advisor
Advisor
Accepted solution

Attached is :

 

1. a modified drawing to allow a test. The single layout has been renamed "layout1". It's basically the drawing you sent me.

2. The lisp file

 

This has been minimally tested and has minimal error checking. If the drawing name is not in the format "Sheet No - Sheet Title" the lisp will exit without running. This is to prevent a nill return when searching for the "-" in the drawing name. This is used as the point to split the string.

 

The lisp can be run from model space or paper space. No check is included for more than 1 layout tab. If there is more than 1 layout, the first layout is always changed. The lisp changes the layout (tab) name as well as filling the attributes. The Block name is hard coded into the lisp, as well as the two attribute "TAG" names. If there are more than two attributes in the block the others will be ignored.

I am not one of the robots you're looking for

0 Likes
Message 14 of 28

dbhunia
Advisor
Advisor

Hi,

 

Try this code.... (its tested in AutoCAD 2007, hope fully it will run in higher version.....)

 

(defun c:DEBA (/ Val_2 Val_1 Layout_Name)
(command "_.Tilemode" 0)
(setq Layout_Name (getvar "dwgname"))
(Setq selectionset (ssget "_A" '((2 . "MWA-SHEET"))))
(if (/= selectionset "nil")
(progn
(setq N (sslength selectionset))
(setq Data (ssname selectionset 0))
(setq Att_1 (entnext data))
(setq Att_Data_1 (entget Att_1))
(setq Att_2 (entnext (entnext data)))
(setq Att_Data_2 (entget Att_2))

(setq Layout_Name (split-at " " Layout_Name))
(setq No_Ent (length Layout_Name))
(setq Val_1 (nth 0 Layout_Name))
(setq No 2)
(setq Val_2 "")
(while (< No No_Ent)
(setq Val (nth No Layout_Name))
(setq Val_2 (strcat Val_2 Val " "))
(setq No (+ No 1))
)
(setq ff1(assoc 1 Att_Data_1))
(setq xx1 (cons 1 Val_1))
(entmod(subst xx1 ff1 Att_Data_1))
(setq val_2 (vl-string-subst " " ".dwg" Val_2))
(setq ff2(assoc 1 Att_Data_2))
(setq xx2 (cons 1 Val_2))
(entmod(subst xx2 ff2 Att_Data_2))
(command "regen")
))
)
(defun split-at (char str / pos )
(setq pos (vl-string-position (ascii char) str))
(cond
((or (null char) (null str)) nil)
((null pos) (list str))
(T (cons (substr str 1 pos)
(split-at char (substr str (+ 2 pos)))
)))
)

 

For auto loading you have to workout through "acad.lsp" file......

for your refference check this......

https://forums.autodesk.com/t5/autocad-land-desktop-read-only/auto-run-a-command-on-drawing-open/td-...

 


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

DC-MWA
Collaborator
Collaborator

This is perfect!!  I truly appreciate your time and effort.

If you're ever in Pismo Beach California I'd love to treat you to a big bowl of calm chowder, that's for sure!

You have helped me so much.

THANK YOU! THANK YOU! THANK YOU!

0 Likes
Message 16 of 28

DC-MWA
Collaborator
Collaborator

I just noticed that it gives a message about file naming if the file is named incorrectly. Thats perfect.

Is there a way to make it exit quietly with no message if the block is not present in drawing?

This way when we are working on files other than sheet files, se do not get hte message about file naming.

Is this possible?

0 Likes
Message 17 of 28

dbhunia
Advisor
Advisor

@DC-MWA wrote:

I just noticed that it gives a message about file naming if the file is named incorrectly. Thats perfect.

Is there a way to make it exit quietly with no message if the block is not present in drawing?

This way when we are working on files other than sheet files, se do not get hte message about file naming.

Is this possible?


Try the other code


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

DC-MWA
Collaborator
Collaborator

Other code crashes if block not present.

0 Likes
Message 19 of 28

DC-MWA
Collaborator
Collaborator

The TBLT.lsp perfect except for it gives the message about file naming when the block is not present.

If it looked for the block, if not found.. exited the program.

As I said before, when we work files other than sheets files, we will see that message a hundred times  a day. I like the message for sheet files as it makes the user name the file correctly though.

Again, thank you for you assist.

0 Likes
Message 20 of 28

dlanorh
Advisor
Advisor

@DC-MWA wrote:

I just noticed that it gives a message about file naming if the file is named incorrectly. Thats perfect.

Is there a way to make it exit quietly with no message if the block is not present in drawing?

This way when we are working on files other than sheet files, se do not get hte message about file naming.

Is this possible?


When the block is not present, the message appears because it exits through the local *error* function. I can add a silent exit for the block not being present.

I am not one of the robots you're looking for

0 Likes