Author Topic: 2015 | Autoloader RegistryEntries, SystemVariables, and EnvironmentVariables  (Read 4355 times)

0 Members and 1 Guest are viewing this topic.

BlackBox

  • King Gator
  • Posts: 3770
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.  

...
"How we think determines what we do, and what we do determines what we get."

cadtag

  • Swamp Rat
  • Posts: 1152
so, one can create new setvars instead of being limited to the USER* system variables?

The only thing more dangerous to the liberty of a free people than big government is big business

BlackBox

  • King Gator
  • Posts: 3770
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
"How we think determines what we do, and what we do determines what we get."

BlackBox

  • King Gator
  • Posts: 3770
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"
"How we think determines what we do, and what we do determines what we get."

MexicanCustard

  • Swamp Rat
  • Posts: 705
Nice! I've been doing this the hard way and just updating the registry directly. Thanks BlackBox.
Revit 2019, AMEP 2019 64bit Win 10

BlackBox

  • King Gator
  • Posts: 3770
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, instead of reading about it in an ADN email announcement, or even on DevBlog.

:-D

Cheers
« Last Edit: September 16, 2014, 08:22:59 AM by BlackBox »
"How we think determines what we do, and what we do determines what we get."

BlackBox

  • King Gator
  • Posts: 3770

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, 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 may also be of interest.

Cheers
"How we think determines what we do, and what we do determines what we get."

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
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.

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

BlackBox

  • King Gator
  • Posts: 3770
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.
"How we think determines what we do, and what we do determines what we get."