Print Page | Close Window

Field Expression in file name counting from the en

Printed From: CAD Forum
Category: EN
Forum Name: AutoCAD
Forum Description: Discussion about AutoCAD and AutoCAD LT, viewers, DWG and DXF formats, Design Review, AutoCAD web, Drive, add-ons
URL: https://www.cadforum.cz/forum_en/forum_posts.asp?TID=7131
Printed Date: 03.Jul.2026 at 23:24


Topic: Field Expression in file name counting from the en
Posted By: LGDB
Subject: Field Expression in file name counting from the en
Date Posted: 06.Jan.2012 at 00:14
Hello all. Happy 2012! Tongue
 
I'm looking for a 'field expression' to get just part of the file name. I found something here: 'CAD tip # 7003'
( http://www.cadforum.cz/cadforum_en/modified-drawing-name-as-an-automatic-field-tip7003 - http://www.cadforum.cz/cadforum_en/modified-drawing-name-as-an-automatic-field-tip7003 )
 
I made some tests using the examples given. All work fine, but what I need is that the expression to count from the end to the beggining of the file name, as they have different number of characters. 
Eg:
The end of the files name are like this: "....... (01).dwg". I'd like to get just the '01'.
 
Two reasons I'd like to build it that way: 
1) This field expression would be part of the sheet set, so all drawing will have the same expression in title block.
2) The file names may change time to time, but the last bit: (01).dwg. 
 
Any ideas? Big%20smile
 
Thank you very much!



Replies:
Posted By: LGDB
Date Posted: 12.Jan.2012 at 07:54

For now I'm using this expression:

$(substr,$(getvar,DWGNAME),3,$(-,$(strlen,$(getvar,DWGNAME)),9))

Sorry I understanding absolutely nothing about this issue, but I think it works like this, please correct me if I am wrong:

Suppose my file name is 'abcdef.ghi'
1) It picks the 3o. character (letter 'c') of the file name,
2) It starting counting from the end to the beginning starting on 3 (equals letter 'i') up to 9 and trims on letter 'd', leaving just the letter 'c', which it is what I'm looking for.

Is that right?
 
I'd like to find a way to trim after the letter 'c', using the example above, as the file names change the number of characters. If that thought is possible, I wouldn't have to change the last number for each drawing, which defeats the purpose of being something dynamic.

Does anyone know if this is possible?

Thank you!




Print Page | Close Window