How to truncate beginning portion of file path name with fields or rtext

How to truncate beginning portion of file path name with fields or rtext

trel.molliermangarin
Contributor Contributor
1,017 Views
9 Replies
Message 1 of 10

How to truncate beginning portion of file path name with fields or rtext

trel.molliermangarin
Contributor
Contributor

Our file path name is too long on the title block and extends beyond the printable limits of the sheet. Is there a way to remove the username at the beginning of the file path in fields or rtext as shown in the screenshot? 

 

trelmolliermangarin_0-1636504447467.png

 

0 Likes
Accepted solutions (1)
1,018 Views
9 Replies
Replies (9)
Message 2 of 10

Valentin_CAD
Mentor
Mentor

@trel.molliermangarin 

 

Consider the suggestions from this link:

https://forums.autodesk.com/t5/autocad-forum/retrieve-partial-filename/td-p/9441494

 



Select the "Mark as Solution" if my post solves your issue or answers your question.

Seleccione "Marcar como solución" si mi publicación resuelve o responde a su pregunta.


Emilio Valentin

0 Likes
Message 3 of 10

trel.molliermangarin
Contributor
Contributor

Thank you Emilio. I have a better idea of how to manipulate the field/diesel expression with the link you provided. However, I still can't figure out how to set up an expression to start a Filename without the drive and username at the beginning. Any idea how to remove the username from the filename as shown in the screen shot?

 

trelmolliermangarin_0-1636566894832.png

 

0 Likes
Message 4 of 10

Valentin_CAD
Mentor
Mentor

@trel.molliermangarin ,

 

Why not add DIRECTORY ... in front of the "Filename only" field?

ValentinWSP_0-1636567603310.png

 

A Diesel Expression would resolve your issue.

Try asking the users on Visual LISP, AutoLISP and General Customization.

See other examples:

 



Select the "Mark as Solution" if my post solves your issue or answers your question.

Seleccione "Marcar como solución" si mi publicación resuelve o responde a su pregunta.


Emilio Valentin

Message 5 of 10

trel.molliermangarin
Contributor
Contributor

Not a bad idea. However, there are a few folders in the file path string prior to the file name.

0 Likes
Message 6 of 10

Valentin_CAD
Mentor
Mentor

@trel.molliermangarin ,

 

Another suggestion would be to add a MTEXT (blank) with a background mask.

Then use the DRAWORDER "bring to front" (to cover the C:USER....).

ValentinWSP_0-1636570105681.png

 



Select the "Mark as Solution" if my post solves your issue or answers your question.

Seleccione "Marcar como solución" si mi publicación resuelve o responde a su pregunta.


Emilio Valentin

0 Likes
Message 7 of 10

user181
Mentor
Mentor
Accepted solution

Hi @trel.molliermangarin try this diesel expression:

 

Use it in a field - Category Other - Field Name DieselExpression

This will work if the drawing is in C:\users\username\

If you save the drawing somewhere else you may not get the desired results

 

 

$(upper, $(substr, $(getvar, dwgprefix), $(+, $(strlen,$(getvar,loginname)), 11)) $(getvar,dwgname))

 

 

EESignature


Message 8 of 10

trel.molliermangarin
Contributor
Contributor

Thank you very much! This did the trick. What was your code logic on this? Did you count the string length of the login name and start the file path after (i.e. subtracted all characters prior to last character of login name)?

0 Likes
Message 9 of 10

user181
Mentor
Mentor

It adds the length of the login name plus 11 characters for c:\users and other slashes (I may have counted wrong) to omit from the path.  You can adjust the 11 to see more or less characters if needed at the beginning 

EESignature


0 Likes
Message 10 of 10

trel.molliermangarin
Contributor
Contributor

Understood. Thank you!

0 Likes