Author Topic: windows environment variables  (Read 5290 times)

0 Members and 1 Guest are viewing this topic.

pmvliet

  • Guest
windows environment variables
« on: October 11, 2004, 10:05:24 AM »
I am not sure if this is possible or which type of code would work to do this.

I would like to be able to set Window's Environment variables from within AutoCad. If it could be from a menu pull-down or a dialog box I am not that picky.

This is what I want to do and I will use the search path for colortables as my example. I have various colortables for different clients. I would like to set the search path in AutoCad to look at a windows environment variable. Then when AutoCad is started or when you want to plot, you start this application that would prompt you for the client which would then set the correct search path for that particular client.

Any help would be appreciated.

Thanks,
Pieter

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
windows environment variables
« Reply #1 on: October 11, 2004, 10:25:53 AM »
You can do just that with the lisp commands (getenv "VAR" ) and (setenv "VAR" "VALUE")
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

pmvliet

  • Guest
windows environment variables
« Reply #2 on: October 11, 2004, 01:21:01 PM »
so if I type in
Code: [Select]

(setenv "Plotters" "c:\plotters")


I will create a environment variable named Plotters
if I type in
Code: [Select]

(getenv "plotters")

it will return c:\plotters as the variable.

For my path of AutoCad plotters, I put in the value of %plotters%
but I don't get anything to come out. I am obviously missing something.
The backslashes need to be \\ for the lisp's correct?

Do I also need to create the environement variable outside of AutoCad?

Thanks Keith. I think you are showing me a new light. I had a person tell me it would be all this complex code and BS.

Pieter

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
windows environment variables
« Reply #3 on: October 11, 2004, 02:42:32 PM »
Since the advent of protected memory environments, most programs run in their own environment under windows. As a result, many times (depending upon the program), the environment variables, if they are set outside of the program after windows has started, they will not be available to all programs.

You can set "global" environmental variables in the autoexec.bat in the root folder of your boot drive .. the call, if you remember your DOS commands is:

Code: [Select]

set variable=value


This will then be available to all programs.

For AutoCAD I would suggest creating your environment variables at runtime by use of a lisp, then you can reference them at anytime from lisp.

As for your issue with %plotters% I am not sure that will return the correct info, and yes, the doubel backslashes are required for all lisp commands, or you may use a single forward slash.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
windows environment variables
« Reply #4 on: October 11, 2004, 03:15:37 PM »
Quote from: Keith
You can set "global" environmental variables in the autoexec.bat in the root folder of your boot drive .. the call, if you remember your DOS commands is:

Code: [Select]

set variable=value


This will then be available to all programs.

For AutoCAD I would suggest creating your environment variables at runtime by use of a lisp, then you can reference them at anytime from lisp.


Sorry for hijacking...Keith, could setting up these global variables help me with my question in THIS post?

pmvliet

  • Guest
windows environment variables
« Reply #5 on: October 11, 2004, 03:41:58 PM »
I like your idea of just setting it via lisp and then it is there for AutoCad and won't affect the OS.

I will dig more into the %variable% option aand see how to get the search path to look at a variable.

Thanks for the insight, you always have an answer or idea.

Pieter