DIESEL Field for modified filename

DIESEL Field for modified filename

Anonymous
Not applicable
426 Views
3 Replies
Message 1 of 4

DIESEL Field for modified filename

Anonymous
Not applicable

Hi all,

 

I am trying to create an AutoCAD field that can extract the file name (without path name and file extension), and then also to modify it slightly replacing underscore with forward slash.  For example below:

 

XXX_XXX_XXXXX_XXXX_XXX.DWG

 

to

 

XXX/XXX/XXXXX/XXXX/XXX

 

How would I go about making a DIESEL field expression to do the above?

 

Thanks lots for the the hlep!

0 Likes
427 Views
3 Replies
Replies (3)
Message 2 of 4

hmsilva
Mentor
Mentor

@Anonymous wrote:

Hi all,

 

I am trying to create an AutoCAD field that can extract the file name (without path name and file extension), and then also to modify it slightly replacing underscore with forward slash.  For example below:

 

XXX_XXX_XXXXX_XXXX_XXX.DWG

 

to

 

XXX/XXX/XXXXX/XXXX/XXX

 

How would I go about making a DIESEL field expression to do the above?

 

Thanks lots for the the hlep!


Hi andy.tung,

DIESEL functions are quite limited, and probably it will not be possible to replace all underscores with forward slashes...

For the file name, perhaps something like this to do the trick

 

$(substr,$(getvar, "dwgname"),1,$(-,$(strlen,$(getvar, "dwgname")),4))

 

Hope this helps,
Henrique

EESignature

Message 3 of 4

m_badran
Advocate
Advocate

Try this.

$(substr,$(getvar,dwgname),1, 3)$(if,$(eq,$(substr,$(getvar,dwgname),4, 1),_),/)$(substr,$(getvar,dwgname),5, 3)$(if,$(eq,$(substr,$(getvar,dwgname),8, 1),_),/)$(substr,$(getvar,dwgname),9, 5)$(if,$(eq,$(substr,$(getvar,dwgname),14, 1),_),/)$(substr,$(getvar,dwgname),15, 4)$(if,$(eq,$(substr,$(getvar,dwgname),19,1),_),/)$(substr,$(getvar,dwgname),20, 3)

 

Message 4 of 4

Anonymous
Not applicable

Thanks mostafabadran

 

That bit of code is almost working, just gotta delete the extension "dwg"

0 Likes