Jump to content

Environment Variables


cadman6735

Recommended Posts

I stumbled across environment variables.

 

(getenv) (setenv)

 

I was able to find a list of environment variables from HyperPics and AfraLisp, where can I find the environment variables in the Developer Guide (Help Menu) of AutoCAD itself?

 

I want to find an up to date list that comes with AutoCAD 2012.

 

Thanks

Link to comment
Share on other sites

Uhmm ... do you mean the system variables: http://docs.autodesk.com/ACD/2011/ENU/filesACR/WSfacf1429558a55de6d0beb1006696e53b-6076.htm

 

If you mean the lisp functions: http://docs.autodesk.com/ACD/2011/ENU/filesALR/WSfacf1429558a55de1a7524c1004e616f8b-5913.htm

 

If you mean the environment variables, you can see them all in the registry. Open RegEdit (type RegEdit into the search box on Vist/Win7's start menu, or type RegEdit into XP's Run.. dialog). Then browse to the registry key: HKEY_CURRENT_USER\Software\Autodesk\AutoCAD ... under which would be listed all the versions installed on your PC (including Verticals). E.g. my ACA 2011's is: HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R18.1\ACAD-9004:409, while my Vanilla 2011 is HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R18.1\ACAD-9001:409. For 2012 it would be under the R18.2 folder and then a similar code for the vertical.

 

Under this, most of the standard environment variables are contained in: HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R18.1\ACAD-9001:409\Profiles\>\General

 

There are some others under: HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R18.1\ACAD-9001:409\FixedProfile\General. Which is also where any custome environment variables you create will get saved. E.g. issuing this at AutoCad's command line:

(setenv "MyOwn\\EnvSet" "testing setenv")

Will create a new folder under the FixedProfile folder named MyOwn and a value in there named EnvSet with its contents as "testing setenv". See this screen capture:

capture_07262011_092717.jpg

 

As a sample (the one most commonly used): (getenv "ACAD") gets the support folders. This is actually the ACAD value under: HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R18.1\ACAD-9001:409\Profiles\>\General

Link to comment
Share on other sites

Irneb,

Thank you very much for your detailed post the regedit was the part I was after (getenv "ACAD")

 

Thank you :D

Link to comment
Share on other sites

There are some others under: HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R18.1\ ACAD-9001:409\FixedProfile\General. Which is also where any custome environment variables you create will get saved. E.g. issuing this at AutoCad's command line:

 

Code:

 

(setenv "MyOwn\\EnvSet" "testing setenv")

 

What is an example I can do with this? I can make my own folder, what would I put there and use it for?

Link to comment
Share on other sites

What is an example I can do with this? I can make my own folder, what would I put there and use it for?

 

Saving program settings between drawing sessions?

 

But I prefer to save such settings to a txt/ini/cfg file as these are easier/safer for the user to remove.

Link to comment
Share on other sites

Anything you'd like. It's a "quick" way to save settings for your own addons to acad, so it remembers those even after acad closes.

 

Useful when you've got some command which has default values for user entry. Same as with the Offset command, but say you want to have acad remember that same offset tomorrow as well (not just for this one drawing in this one session) ... you'd need to save it either to a file to be opened and read each time, or you'd save it to the registry using vl-registry-write and have a specific folder for yourself, or just use the setenv to have such value saved under acad's registry entries.

 

Say you've got several of these commands, you'd like to group them into one folder so you can more easily export them. That's why you'd want a folder of your own instead of simply mixed in between acad's normal settings.

 

Edit: But as Lee's pointed out, using a file is the most "portable" method. It's a bit difficult to get registry stuff moved between PC's and/or other versions of ACad. My seeing of this is everything which changes quite often (such as these default values) should be set in registry as it's generally more efficient to read & write to them than opening and closing files. Things which only change seldom (like settings) are better left for files, since these you'd probably want to copy to other PC's / Versions as well.

Link to comment
Share on other sites

I see. it is mainly local to one machine vs. a file that can be sent to many machines.

 

I read a post on afralisp where he was using an example of how to modify a profile for users out side of his local office with a lisp routine that modified the "ACAD" env to append profile settings to the users current profile. Got me curiouse.

 

http://www.afralisp.net/archive/vl/acadset.htm

 

I understand the regestry is a dangours place to play but it is better to play with education than with ignorance, thanks guy.

Link to comment
Share on other sites

You've got the idea about files! The registry shouldn't be a "dangerous place" it's meant to be used for settings (that's why Microsoft put it there). Prior to the registry each program in Win3 (and before) had to save all it's settings into various INI files. The registry is basically like a common INI file for everything.

 

It's just that some programs (and even portions of Windows itself) relies on some values therein - their own settings. So you must be careful in deleting / modifying existing values. Officially you should make your own folder under the HK**/Software folder to store all your settings. That's why it would be preferable to use the vl-registry-* functions instead of setenv/getenv with some custom keyname/folder - it can be very easy to overwrite some setting in ACad inadvertently with that.

 

The setenv is like a lazy-man's registry function. Say you have a setting only for one version of acad, but it needs to be different for another. If you go the recommended route of using the vl-registry-write, you'll need to somehow account for what version the setting is meant for (e.g. create sub-folders for each version). But with the setenv it's saved direct to that acad's version without you needing to even find out any info about it.

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...