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

Linking CAD File Names into Title block, but only using some of the name.

8 REPLIES 8
Reply
Message 1 of 9
Anonymous
985 Views, 8 Replies

Linking CAD File Names into Title block, but only using some of the name.

Hi All,

 

I have a problem that I'd like some help on if I can.

 

We are using a title block and it has an attribute field that links to the file name. Now one of our projects is adding the revision to the CAD file name, but it messes up our drawing sheets.

 

i.e. It was fine when the CAD file name was 111-A222-ZZ-X-123456.dwg and this would display the complete 111-A222-ZZ-X-123456 in the drawing title.

 

Now we need to do this, the CAD file name, 111-A222-ZZ-X-123456-001002-A1.dwg and we still need to just show 111-A222-ZZ-X-123456 in the title block, striping away the 001002-A1.

 

Is this possible? It would make my life so simple if it can be done.

 

Thanks

 

Tim D

8 REPLIES 8
Message 2 of 9
Lee_Mac
in reply to: Anonymous

You could use a DIESEL expression to remove a specific number of characters from the end of the string, something like:

 

$(substr,$(getvar,DWGNAME),1,$(-,$(strlen,$(getvar,DWGNAME)),14))

 Here I am removing the four characters: ".dwg" and the 10 characters "-001002-A1"

Message 3 of 9
Shneuph
in reply to: Lee_Mac

Hi Lee,

  I thought you could do this with Diesel too but I messed with it for awhile and can't get the diesel to work within the field... shouldn't somethign like:

 

%<\$(substr,$(getvar,DWGNAME),1,$(-,$(strlen,$(getvar,DWGNAME)),4))>%

 

work if you paste it into mtext editor???

Mine returns "####" as a field.

 

Probably the something to do with the %$<\ characters yah?

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
Message 4 of 9
Shneuph
in reply to: Shneuph


@Shneuph wrote:

%<\$(substr,$(getvar,DWGNAME),1,$(-,$(strlen,$(getvar,DWGNAME)),4))>%

 

Probably the something to do with the %$<\ characters yah?



got it...

 

 

%<$(substr,$(getvar,DWGNAME),1,$(-,$(strlen,$(getvar,DWGNAME)),4))>%

 

worked...

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
Message 5 of 9
Lee_Mac
in reply to: Shneuph

Or:

 

%<\\AcDiesel $(substr,$(getvar,DWGNAME),1,$(-,$(strlen,$(getvar,DWGNAME)),4))>%

 

But if you just want the filename, its easier to use:

 

%<\\AcVar Filename \\f \"%fn2\">%

 

Message 6 of 9
Anonymous
in reply to: Lee_Mac

Thank guys. I'll try this out once I'm back at work in the morning.

Is it possible to use any part of the dwg file name in files using those codes. What it I wanted to havecanother field and just show the A1 in that one?

Also, are there any good books on this?

Thanks
Tim
Message 7 of 9
Lee_Mac
in reply to: Anonymous


@Anonymous wrote:

Is it possible to use any part of the dwg file name in files using those codes. What it I wanted to havecanother field and just show the A1 in that one?

 

Yes, but note that the solutions provided are obtaining a substring with a known number of characters - hence the field in my first post will always trim 14 characters, whatever the filename.

 


@Anonymous wrote:

Also, are there any good books on this?

 

For DIESEL, I mostly use this reference.

Message 8 of 9
Anonymous
in reply to: Lee_Mac

Good Morning All,

 

Back onto this subjuct today. I've ran into a problem with what we did in these drawing sheets using the CAD file name as above.

 

Sometimes the revision on these drawings goes from A1, A2, A3, then back down to A ro be released to another contractor that just has alpha codes foer their revision status.

 

This cause the autofields do display the wrong drawing number, sheet number and total number of sheets.

 

I have redone those to just use this expression to cut off the length of string 

 

$(substr,$(getvar,DWGNAME),1, 20)

 

etc,

 

But the problem I am now having is how to define the length to the revision in the files name and to substract the ".dwg" off the end i was hoping this would do it

 

$(substr,$(getvar,DWGNAME),29, 2,$(-,$(strlen,$(getvar,DWGNAME)),31))

 

But this doesnt work.

 

For reference the drawing files names are like this

421-F100-DF-Y-00GF10-001020-A1.dwg

421-F100-DF-Y-00GF10-001020-A2.dwg

421-F100-DF-Y-00GF10-001020-A3.dwg

421-F100-DF-Y-00GF10-001020-B.dwg

 

Any help would be greatly recieved.

 

Thanks.

Tim

 

Message 9 of 9
devitg
in reply to: Anonymous

You can use a VL function From the VLIDE help (VL-LOAD-COM) ;_ load all VL functions (setq dwgname (VL-FILENAME-BASE (GETVAR "dwgname"))) Returns the name of a file, after stripping out the directory path and extension

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

Post to forums  

Autodesk Design & Make Report

”Boost