Setting Trusted Locations (trustedpath)

Setting Trusted Locations (trustedpath)

JeffPaulsen
Collaborator Collaborator
2,616 Views
8 Replies
Message 1 of 9

Setting Trusted Locations (trustedpath)

JeffPaulsen
Collaborator
Collaborator

How can I set the trusted locations path using VBA?

 

My experience with VBA is limited to updating macros that other people have written so be kind.

 

I have a VBA macro that I use to setup new installs. It sets support paths, creates folders, copies files & edits the PGP among other things.

 

The support path is set using acadPrefFile but I don't see the trusted path as one of the options.

 

FYI I am updating the macro for C3D 2016.

 

Jeff Paulsen
Civil 3D 2020.4 | Win 10 Pro N 64-bit
Xeon W-2223 @ 3.60GHz, 32GB Ram | NVidia Quadro P2200
0 Likes
Accepted solutions (1)
2,617 Views
8 Replies
Replies (8)
Message 2 of 9

Alfred.NESWADBA
Consultant
Consultant
Accepted solution

Hi,

 

you can use

 

ThisDrawing.GetVariable("TRUSTEDPATHS")

to get the list of current trusted paths (string with semicolon as seperator), add your path if it's not already part of it, and then use

 

Call ThisDrawing.SetVariable("TRUSTEDPATHS", tNewPaths)

to store the new setting.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 3 of 9

JeffPaulsen
Collaborator
Collaborator

I added the following lines to the macro and quickly realized I was missing something.

 

 

ThisDrawing.GetVariable ("TRUSTEDPATHS")
Call ThisDrawing.SetVariable("TRUSTEDPATHS", "Z:\Autodesk 2016\")

 

This set TRUSTEDPATHS to "Z:\Autodesk 2016\".

 

I realized that I needed to append "Z:\Autodesk 2016\" to the value returned by ThisDrawing.GetVariable ("TRUSTEDPATHS"). It took an hour or so to do what most you guys probably would do in 3 minutes but I got it to work with the code below.

 

Dim strOLDTPath As String
Dim strTPath As String
strOLDTPath = ThisDrawing.GetVariable("TRUSTEDPATHS")
strTPath = strOLDTPath & ";Z:\Autodesk 2016\"
Call ThisDrawing.SetVariable("TRUSTEDPATHS", strTPath)

Is this an efficient method to accomplish my goal or is there a better way?

Jeff Paulsen
Civil 3D 2020.4 | Win 10 Pro N 64-bit
Xeon W-2223 @ 3.60GHz, 32GB Ram | NVidia Quadro P2200
0 Likes
Message 4 of 9

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

you should first verify if the new path is alread part of trusted paths. Just to add the same path again and again will make troubles in case the path's string is too long.

But at least that is how it works, folders separated with delimiter ;

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 5 of 9

JeffPaulsen
Collaborator
Collaborator

That's a good idea but I am not sure how to accomplish that. I noticed it was duplicating my path prior to seeing your post so I took a different approach. I just set the path each time ignoring what was set prior to running the macro (see below). I don't anticipate users changing this setting very often if at all.

 

Call ThisDrawing.SetVariable("TRUSTEDPATHS", "C:\Users\" & strLogin & "\appdata\roaming\autodesk\c3d 2016\enu\support\;C:\programdata\autodesk\c3d 2016\enu\data\reports\net;Z:\Autodesk 2016\JRSupport;Z:\Autodesk 2016\JRLisp")

 

Jeff Paulsen
Civil 3D 2020.4 | Win 10 Pro N 64-bit
Xeon W-2223 @ 3.60GHz, 32GB Ram | NVidia Quadro P2200
0 Likes
Message 6 of 9

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

>> but I am not sure how to accomplish that

Does that help?

 

Dim strOLDTPath As String
Dim strTPath As String
strOLDTPath = ThisDrawing.GetVariable("TRUSTEDPATHS")

Dim tAddPathStr as String
tAddPathStr = "Z:\Autodesk 2016\"   'be careful with the backslash at the end, maybe AutoCAD removes it
'then the check below has to be updated. if (";" & ucase(strOLDPATH) & ";") like ("*;" & ucase(tAddPathStr) & ";*") then 'well, path already added else 'path has to be added Call ThisDrawing.SetVariable("TRUSTEDPATHS", strOLDPATH & ";" & tAddPathStr ) endif

(just typed, not tested)

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 7 of 9

JeffPaulsen
Collaborator
Collaborator

Thanks. I will try it later today.

 

A backslash in the TRUSTEDPATHS variable tells AutoCAD the subfolders are also trusted. Hopefully it doesn't remove it.

Jeff Paulsen
Civil 3D 2020.4 | Win 10 Pro N 64-bit
Xeon W-2223 @ 3.60GHz, 32GB Ram | NVidia Quadro P2200
0 Likes
Message 8 of 9

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

>> A backslash in the TRUSTEDPATHS variable tells AutoCAD the subfolders are also trusted.

Sorry no, not correct.

What you mean is a backslash followed by 3 points has the meaning to trust subfolders too.

 

So this example:

   C:\Program Files\ISHAcadAppsBaseNET\...

means the folder itself is trusted and all the subfolders too

 

   C:\Program Files\ISHAcadAppsBaseNET\

means the folder itself is trusted, but not the subfolders

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 9 of 9

JeffPaulsen
Collaborator
Collaborator
Thanks. You are correct. I double checked what I read in the help file and the 3 dots are required.
Jeff Paulsen
Civil 3D 2020.4 | Win 10 Pro N 64-bit
Xeon W-2223 @ 3.60GHz, 32GB Ram | NVidia Quadro P2200
0 Likes