AutoCAD 2010/2011/2012

AutoCAD 2010/2011/2012

Reply
Active Contributor
dbyrnes
Posts: 33
Registered: ‎03-26-2009
Message 1 of 11 (1,917 Views)

Edit field codes in AutoCAD?

1917 Views, 10 Replies
10-11-2012 12:01 PM

We are currently fielding the drawing number in our title blocks from the file name. Typical format would be 123456-SR-100-40-1001.dwg for the drawing name which would appear the same in the title block. We then had a separate field for the tab number.


What we want to do in the title block is replace the last two digits of the filename with the tab number, We would change the filename to 123456-SR-100-40-10XX, the tab names would be numbered 01, 02, 03 etc, and the drawing number in the title block would appear as 123456-SR-100-40-1001, 123456-SR-100-40-1002, 123456-SR-100-40-1003 etc.


Can this be done by manipulating the filename field expression? Or would we have to use a different (custom) field expression? Can we even do this with fields?

Valued Contributor
Rick-K
Posts: 88
Registered: ‎07-25-2012
Message 2 of 11 (1,906 Views)

Re: Edit field codes in AutoCAD?

10-11-2012 01:56 PM in reply to: dbyrnes

Like this?

 

See attached.

 

Rick

Active Contributor
dbyrnes
Posts: 33
Registered: ‎03-26-2009
Message 3 of 11 (1,901 Views)

Re: Edit field codes in AutoCAD?

10-11-2012 02:04 PM in reply to: Rick-K

Yes, except everything up to the ctab field in your dwg also has to be a field linked to the filename minus the last two characters.

*Expert Elite*
leothebuilder
Posts: 481
Registered: ‎07-05-2010
Message 4 of 11 (1,898 Views)

Re: Edit field codes in AutoCAD?

10-11-2012 02:11 PM in reply to: dbyrnes

If you are trying to have the file name as a field, with the last 2 digits as the layout tab number I don't think you can do this as a field.

 

You can use the file name as field (leave off the last two digits) so your file name would be 123456-SR-100-40-10

and append this with Rtext using a diesel expression $(getvar, "ctab")

 

If you number multiple layout tabs in your drawing simply as 01, 02, 03 etc. this diesel expression will return those values.

Distinguished Mentor
steven-g
Posts: 637
Registered: ‎05-11-2009
Message 5 of 11 (1,884 Views)

Re: Edit field codes in AutoCAD?

10-11-2012 10:11 PM in reply to: dbyrnes

Does this do it

Regards Steven Gray
Setting Out (Joinery Manufacturing)
Autocad 2013LT
Windows 7 professional
Active Contributor
dbyrnes
Posts: 33
Registered: ‎03-26-2009
Message 6 of 11 (1,867 Views)

Re: Edit field codes in AutoCAD?

10-12-2012 09:25 AM in reply to: steven-g

That's beautiful! It's very close. We can't use ctab because we're also generating drawing indexes from here, and ctab only reports whatever tab was current when the drawing was last saved. I thought of saving the active tab as a variable that stayed constant - can that be done in diesel?

*Expert Elite*
leothebuilder
Posts: 481
Registered: ‎07-05-2010
Message 7 of 11 (1,860 Views)

Re: Edit field codes in AutoCAD?

10-12-2012 09:53 AM in reply to: dbyrnes

The diesel expression stays constant, unless you change the tab number.

 

How do you generate your drawing index?

Active Contributor
dbyrnes
Posts: 33
Registered: ‎03-26-2009
Message 8 of 11 (1,856 Views)

Re: Edit field codes in AutoCAD?

10-12-2012 10:12 AM in reply to: leothebuilder

I'll have to take a closer look at the ctab issue - I had it on hearsay so never tried it myself. What you've done is very close to what we're after though - so thanks!

 

We use EATTEXT to spit out the drawing list into a table object.

Active Contributor
dbyrnes
Posts: 33
Registered: ‎03-26-2009
Message 9 of 11 (1,849 Views)

Re: Edit field codes in AutoCAD?

10-12-2012 10:58 AM in reply to: leothebuilder

Okay, I made a test file with five tabs numbered 01 through 05. I inserted your diesel into each, and in the title block, the numbers appear perfectly because ctab is pulling the name of the current tab. Then I changed to model space and closed the drawing. I ran EATTEXT in a new drawing and got what you see in the attached. I think CTAB always returns the current tab (the model tab in this case), and I'm looking for a way to make the tab number stick. (Obviously, the list should read 2101, 2102, 2103 etc, as it does in the title blocks themselves.

 

I know nothing about diesel and next to nothing of autolisp, but is there a way to do something like (setq tabno (getvar "ctab")) in the second expression? I believe (could be wrong!) that would make a sticky value in that field.

Distinguished Mentor
steven-g
Posts: 637
Registered: ‎05-11-2009
Message 10 of 11 (1,828 Views)

Re: Edit field codes in AutoCAD?

10-12-2012 01:42 PM in reply to: dbyrnes

There is nothing like moving the goal posts, your original post only asked for a field within the drawing title, unfortunately there is no other way to get tab information that I know of, someone with Lisp experience may be able to help you further.

Regards Steven Gray
Setting Out (Joinery Manufacturing)
Autocad 2013LT
Windows 7 professional
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.