Jump to content

Change DWGPREFIX with if-function


Manuel_Kunde

Recommended Posts

Hi, I want to change the beginning of my path (the workingfolder) if the path starts with "P:\" (marked red) and replace it with the path marked green. (with an if - function). 

 

(The destination location is the same, but the access is through a different network).

Is it possible to change the beginning with an If - function and change the Path this way?

 

(strcat (substr (getvar "DWGPREFIX") 1 2) "\\company.lan\center")

 

 

image.thumb.png.792f4da82c91af82b7ea932163697653.png

 

 

 

 

Link to comment
Share on other sites

5 minutes ago, marko_ribar said:

Don't you mean :

 


(strcat "\\company.lan\center" (substr (getvar "DWGPREFIX") 1 2))

 

Yes, exactly. Do you know of an If function that will only execute the Stract command if "P:" is at the beginning of the path?

Link to comment
Share on other sites

(if (vl-string-search "P:\\" (getvar "DWGPREFIX"))
 (strcat "\\\\company.lan\\center" (substr (getvar "DWGPREFIX") 3 (strlen (getvar "DWGPREFIX"))))
)

 

 

Edited by confutatis
Link to comment
Share on other sites

(if (= (substr (getvar 'dwgprefix) 1 2) "P:")
  (strcat "\\company.lan\center" (substr (getvar "DWGPREFIX") 3))
)

Not sure, though...

Link to comment
Share on other sites

On 7/6/2021 at 6:49 AM, Manuel_Kunde said:

Yes, exactly. Do you know of an If function that will only execute the Stract command if "P:" is at the beginning of the path?

Sounds like you have people accessing files through UNC ? If so perhaps:

(if (wcmatch (setq dp (getvar "DWGPREFIX")) "P:*")
  (strcat "\\\\company.lan\\center" (substr dp 3))
  dp
)

*EDIT Changed (substr dp 1 2) to (substr dp 3)

Edited by ronjonp
  • Like 1
Link to comment
Share on other sites

8 hours ago, ronjonp said:

Sounds like you have people accessing files through UNC ? If so perhaps:


(if (wcmatch (setq dp (getvar "DWGPREFIX")) "P:*")
  (strcat "\\\\company.lan\\center" (substr dp 1 2))
  dp
)

 

 

It works, thank you so far.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...