RTEXT DRAWING NAME

RTEXT DRAWING NAME

Anonymous
Not applicable
2,075 Views
8 Replies
Message 1 of 9

RTEXT DRAWING NAME

Anonymous
Not applicable

Good day,

 

Can anyone help me to remove the file name extension when I use $(getvar,dwgname)?

My file names are written like this: "M-03 AIRCONDITIONING SYSTEM LAYOUT"

 

when I use the $(getvar,dwgname) the text appearing was like this

"M-03 AIRCONDITIONING SYSTEM LAYOUT.dwg"

 

I want to remove the file name extension (.dwg)

But I don't know what code to use.. Please help me..

 

Thanks

0 Likes
Accepted solutions (1)
2,076 Views
8 Replies
Replies (8)
Message 2 of 9

cadffm
Consultant
Consultant
Accepted solution

use SUBSTR to cut the string from the 1 to the 'length of string - 4 characters)

 

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

 

 

$(substr, ; cut

$(getvar,DWGNAME), ; dwgname+ext

1, ; from 1 character to

$(-,$(strlen,$(getvar,DWGNAME)), 4) ; length of dwgname+ext, minus 4

)

 

But sind 2005 i would never use RTEXT for this, use a FIELD

Sebastian

Message 3 of 9

Anonymous
Not applicable

The command you have provided was effective.. Thank you very much! 🙂

 

But in addition, can I have another code for the same subject matter but this time, I want to substract also the first 5 characters of the file name..

 

my file name was "M-03 AIRCONDITIONING SYSTEM LAYOUT"

my output should be "AIRCONDITIONING SYSTEM LAYOUT" only..

 

everytime I try editing the code you have provided, it always appear as getvar error..

0 Likes
Message 4 of 9

cadffm
Consultant
Consultant
0 Likes
Message 5 of 9

dpalmerVQ54W
Enthusiast
Enthusiast

@cadffm 

 

I hope you don't mind I tried using your string in order to have the filename displayed on our drawing border in Layout.

 

Our filenames are in the style 12345-AX-A.dwg. I used your string in FIELDS and manged to edit it to remove the last 6 characters (the -A is an issue letter which we don't want displaying on our drawing number as the issue letter is displayed elsewhere) so it read 12345-AX. It's important that the characters are removed from the right as the filename could be longer (eg 12345-XX-AX-A)

 

Going back to the issue letter, the -A part of the filename, is it possible to create a DIESEL string that will only show the letter ie A. I would like to be able to make our issue letter a FIELD so that when the filename becomes, say 12345-AX-B.dwg the Issue letter only is displayed as B.

 

Thanks in advance.

David P
AutoCAD 2021; AutoCAD 2026; Navisworks Manage & Freedom
0 Likes
Message 6 of 9

Kent1Cooper
Consultant
Consultant

Put the drawing name without path or extension into a variable:

(setq str (vl-filename-base (getvar 'dwgname)))

 

To get the parts you're after, use the fact that the (vl-string-position) function lets you search from the end, so you can find the position of the last  hyphen, no matter how many hyphens there are.  So if that drawing name is "12345-AX-A":

 

For everything except  the hyphen and issue letter at the end:

(substr str 1 (vl-string-position 45 str 1 T))

returns
"12345-AX"

 

[45 is the ASCII character number for a hyphen.]

 

For the issue letter at the end only:
(substr str (+ (vl-string-position 45 str 1 T) 2))
returns

"A"

Kent Cooper, AIA
Message 7 of 9

dpalmerVQ54W
Enthusiast
Enthusiast
Thanks Kent. I'll give it a try and report back.
David P
AutoCAD 2021; AutoCAD 2026; Navisworks Manage & Freedom
0 Likes
Message 8 of 9

SPARKSURESH_G
Community Visitor
Community Visitor

Hi

I need 2 spaces for each letter of file name. Is it possible? our dwg No. are in separate boxes. so...

0 Likes
Message 9 of 9

Sea-Haven
Mentor
Mentor

Need a sample of the file name before and after else just guessing what you want.

0 Likes