Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is it possible to replace a drive by an environment variable?

5 REPLIES 5
Reply
Message 1 of 6
Maxime_37
321 Views, 5 Replies

Is it possible to replace a drive by an environment variable?

I want to know if it's possible to replace a drive by an environment variable in a search path in the profile. For example:

to replace C:\Program Files\Autodesk\AutoCAD Mechanical 2012\Acadm by %LOCAL DRIVE%\Program Files\Autodesk\AutoCAD Mechanical 2012\Acadm. 

5 REPLIES 5
Message 2 of 6
dbroad
in reply to: Maxime_37

If you are doing batch file processing (files with a bat extension) or entering commands in the command shell, then the only way I know of to access those features are to use the lisp expression:

 

(getenv "homedrive")

 

getenv will allow you to access any system environmental variable.  You can strcat that together with your path when using findfile.

Architect, Registered NC, VA, SC, & GA.
Message 3 of 6
Maxime_37
in reply to: Maxime_37

Thank you for the answer but I'm not really familiar with what you said. Can you explain in detail how to do it. Because I'm just starting in the lisp environment and programming.

 

Thank you in advance, Maxime

Message 4 of 6
dbroad
in reply to: Maxime_37

Give me some context for your need and we can discuss further.

 

(findfile (strcat (getenv "homedrive") "\\" "mydrawing.dwg"))  ;one example would find mydrawing.dwg in the root folder of the c: drive if c: was the homedrive.  If you had an environmental variable set for localdrive, then you could reference that instead of homedrive.

Architect, Registered NC, VA, SC, & GA.
Message 5 of 6
Maxime_37
in reply to: dbroad

We have to create a standard profile that will work every where in the world so I'll tell you our configuration. We will install autocad mechanical 2012 locally on each computer in each country, our custom file like the .cuix, or template will be on a different network for each country. My problem is that we will have some path in the profile that will be link locally and some on a network but the letter of the disk can be different from one country to another. In fact, I want to have 2 or 3 variables instead of 3 disk letters in my search path of the profile. For example, in my country the variable %localdisk% can be equal to "C:" and in an other country it would be equal to "D:" So the other country would just have to set the good letter of the disk associated to the good variable. I hope my intentions are clear enough, if something is unclear just tell me.

 

Thank you, Maxime

Message 6 of 6
dbroad
in reply to: Maxime_37

I have no expertise in changing profiles programmatically.  I also have no way to verify that %localdisk% system variable is accepted automcatically by an operating system.  My OS is Windows XP and it does not by default have that system variable.

 

Profiles are saved in the registry and you should be able to export a registry as an arg file and either change its extension to reg and run it as a shell batch process.  If using batch files for installation, you should be able to use the reg or arg file as an input stream and replace your instances of %localdisk% in that file with the batch program as a replaceable parameter sending the changed stream to another file.  After the reg or arg file is modified by batch, it should be acceptable as input to regedit or as a profile import in the options command.

 

While it is possible to access and to set most all of the profile parameters programmatically with lisp, that would require additional effort of starting Autocad and launching the lisp.

 

By examining the arg files created by exporting profiles, it does support environmental variables in the saved paths.

Architect, Registered NC, VA, SC, & GA.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost