TheSwamp

CAD Forums => CAD General => Topic started by: BlackBox on September 12, 2014, 10:01:11 AM

Title: 2015 | Autoloader RegistryEntries, SystemVariables, and EnvironmentVariables
Post by: BlackBox on September 12, 2014, 10:01:11 AM
http://knowledge.autodesk.com/support/autocad/downloads/caas/CloudHelp/cloudhelp/2015/ENU/AutoCAD-Customization/files/GUID-3C25E517-8660-4BB7-9447-2310462EF06F-htm.html

Quote
RegistryEntries Element - Supported in AutoCAD 2015-based products

The RegistryEntries element is optional, and can contain one or more RegistryEntry elements. A RegistryEntry element contains the definition of a registry entry that the plug-in should create or modify. Registry entries are stored in the Windows Registry or in a property list (PLIST) file on Mac OS.

Note: On Windows, registry entries are created under HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\ <release>\ACAD- <product>: <language>. It is not possible to create registry entries in other locations. The equivalent location is used in the PLIST files on Mac OS.

...

The following example creates the registry key MYREGKEY and adds the values STRING and NUMBER:

Code - XML: [Select]
  1. <RegistryEntries>
  2.     <RegistryEntry
  3.        Key="MYREGKEY"
  4.        Name="STRING"
  5.        Value="Example"
  6.        Type="REG_SZ"
  7.    />
  8.  
  9.     <RegistryEntry
  10.        Key="MYREGKEY"
  11.        Name="NUMBER"
  12.        Value="123"
  13.        Type="REG_DWORD"
  14.    />
  15. </RegistryEntries>
  16.  



SystemVariables Element - Supported in AutoCAD 2015-based products

The SystemVariables element is optional, and can contain one or more SystemVariables elements. A SystemVariable element contains the definition of a system variable that the plug-in should create or modify.

...

The following example creates a system variable named MYVARIABLE:

Code - XML: [Select]
  1. <SystemVariable
  2.    Name="MYVARIABLE"
  3.    PrimaryType="String"
  4.    StorageType="User"
  5.    Value="Example"
  6.    Owner=""
  7.    Flags="Create|DotIsEmpty|SpacesAllowed"
  8. />
  9.  

The following example changes the value of the CURSORSIZE system variable to 100 when the plug-in is loaded the first time:

Code - XML: [Select]
  1. <SystemVariable
  2.    Name="CURSORSIZE"
  3.    Value="100"
  4.    Flags="OpenOnce"
  5. />
  6.  



EnvironmentVariables Element - Supported in AutoCAD 2015-based products

The EnvironmentVariables element is optional, and can contain one or more EnvironmentVariable elements. A EnvironmentVariable element contains the definition of an environment variable that the plug-in should create or modify. Environment variables are stored in the Windows Registry or in a property list (PLIST) file on Mac OS.

Note: The value of an environment variable is always stored as a string, and the name of an environment variable is case sensitive.

...

The following is an example of creating two environment variables named MYNUMVAR and MYSTRVAR:

Code - XML: [Select]
  1. <EnvironmentVariables>
  2.     <EnvironmentVariable
  3.        Name="MYNUMVAR"
  4.        Value="123"
  5.    />
  6.  
  7.     <EnvironmentVariable
  8.        Name="MYSTRVAR"
  9.        Value="Example"
  10.    />
  11. </EnvironmentVariables>
  12.  

...
Title: Re: 2015 | Autoloader RegistryEntries, SystemVariables, and EnvironmentVariables
Post by: cadtag on September 12, 2014, 10:09:38 AM
so, one can create new setvars instead of being limited to the USER* system variables?

Title: Re: 2015 | Autoloader RegistryEntries, SystemVariables, and EnvironmentVariables
Post by: BlackBox on September 12, 2014, 10:19:18 AM
so, one can create new setvars instead of being limited to the USER* system variables?

See the SystemVariables table at the above link, StorageType category:

Quote
Storage location for the variable's value; when persisted. Optional when modifying an existing system variable.

Valid values are:
  • Database – Persisted in the drawing file the variable is created
  • Profile – Persisted as part of the current AutoCAD profile
  • Session – Not retained between sessions or in the drawing it is created
  • User – Persisted as part of the FixedProfile for AutoCAD
Title: Re: 2015 | Autoloader RegistryEntries, SystemVariables, and EnvironmentVariables
Post by: BlackBox on September 12, 2014, 11:04:23 AM
At the risk of being redundant (discussing this elsewhere)... I've just tested Autoloader's new SystemVariable functionality successfully using the following as PackageContents.xml:

Code - XML: [Select]
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <ApplicationPackage AppVersion="1.0.0" Author="BlackBox" Description="Custom, drawing saved, system variable example." HelpFile=" " Icon=" " Name="BlackBox Custom System Variables Sample for AutoCAD®" ProductType="Application" ProductCode="{65B474D6-3190-4CF2-9B73-E1A19C453FA0}" SchemaVersion="1.0" UpgradeCode="{5CC83E23-3A25-42FE-A67F-CDBEFB6A6E7D}" >
  3.         <Components>
  4.                 <RuntimeRequirements OS="Win32|Win64" Platform="AutoCAD*" SeriesMax="R20.0" SeriesMin="R20.0" />
  5.                 <SystemVariables>
  6.                         <SystemVariable Flags="Create|OpenOnce|SpacesAllowed|Chatty" Name="PROP1" Owner="" PrimaryType="String" StorageType="Database" Value="OFF" />
  7.                 </SystemVariables>
  8.         </Components>
  9. </ApplicationPackage>
  10.  

Example from Command Line:

Code: [Select]
Command: (getvar 'prop1)
"OFF"
Command: (setvar 'prop1 "on")
"on"
Command: (getvar 'prop1)
"on"
Title: Re: 2015 | Autoloader RegistryEntries, SystemVariables, and EnvironmentVariables
Post by: MexicanCustard on September 12, 2014, 01:46:28 PM
Nice! I've been doing this the hard way and just updating the registry directly. Thanks BlackBox.
Title: Re: 2015 | Autoloader RegistryEntries, SystemVariables, and EnvironmentVariables
Post by: BlackBox on September 12, 2014, 01:54:25 PM
Nice! I've been doing this the hard way and just updating the registry directly. Thanks BlackBox.

You're welcome, MC.

The utter irony (I shouldn't have been surprised by), is that I happened to stumble upon it, searching Google for some old posts that demonstrate adding custom system variables via .NET Variables class to help here (http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-a-custom-drawing-variable-yes-or-no-0-or-1/td-p/5269543), instead of reading about it in an ADN email announcement, or even on DevBlog.

:-D

Cheers
Title: Re: 2015 | Autoloader RegistryEntries, SystemVariables, and EnvironmentVariables
Post by: BlackBox on September 16, 2014, 08:22:45 AM

The utter irony (I shouldn't have been surprised by), is that I happened to stumble upon it, searching Google for some old posts that demonstrate adding custom system variables via .NET Variables class to help here (http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-a-custom-drawing-variable-yes-or-no-0-or-1/td-p/5269543), instead of reading about it in an ADN email announcement, or even on DevBlog.

I did inquire about this topic with ADN, and Stephen kindly educated me that this was covered at a recent Developer Days event... Documentation can be found on extranet under 'events' section, and a public presentation on web here (https://www.youtube.com/watch?v=J_IGTohbgtM) may also be of interest.

Cheers
Title: Re: 2015 | Autoloader RegistryEntries, SystemVariables, and EnvironmentVariables
Post by: Kerry on September 16, 2014, 05:42:42 PM
Quote from:  From over there
BlackBox_ wrote:
** Note to self - Add poor code format available options (i.e., Lisp, .NET, XML, etc.) to list of new forum feedback. Grr.

Good luck with that.

Title: Re: 2015 | Autoloader RegistryEntries, SystemVariables, and EnvironmentVariables
Post by: BlackBox on September 16, 2014, 06:58:00 PM
Quote from:  From over there
BlackBox_ wrote:
** Note to self - Add poor code format available options (i.e., Lisp, .NET, XML, etc.) to list of new forum feedback. Grr.

Good luck with that.

 :-D... What else can I say, TheSwamp has waaay better code tag options.