Ok, there are actually a few different ways you can do it.
**** OPTION 1 ****
There is a little used function in lisp that allows you to set and retrieves configuration values. To use this function, use this syntax.
To save an individual value for each drawing:
(setq vname "variablename") (setq apname "put your program name here") (setcfg (strcat "AppData/" apname "/" vname) "any string value")
To retrieve that data:
(setq vname "variablename") (setq apname "put your program name here") (setq val (getcfg (strcat "AppData/" apname "/" vname)))
The value to save must be a string value, and the retrieved value is a string as well. We convert real numbers to a string then back again. This way will only hold the required value for the current workstation.
**** OPTION 2 ****
Another way to do this is a little less secure, but allows the value to be attached with the drawing.
Using a system variable USERRx the x represents a number from 1 to 5. USERIx stores integer values and USERSx stores string values.
To save the value: (setvar "USERR1" a)
To retrieve the value: (setq a (getvar "USERR1"))
**** OPTION 3 ****
Place a hidden attributed block in the drawing. Create a block that will be inserted by your program, or you could alternatively have the program create an anonymous one for you automatically if the value is not found.
**** OPTION 4 ****
Register your application with the lisp function REGAPP then attach an XDATA value to an object that will not be deleted, such as title block, in that XDATA, store the data.
**** OPTION 5 ****
Create a short VBA routine that sets configuration data, and retrieves it as well. In your lisp, have the USERxx variable set to your value, then on exit of the program, have a VBA command reactor retrieve the value and save it to the registry, similar to the following:
Private Sub SaveValue() RetVal = object.GetVariable ("USERxx")
If (RetVal <> 0) Then SaveSetting appname:="Your Program", section:="Drawingname", _ Key:="Value", setting:=RetVal
Of course if you don't already know VBA then this will be one of the most difficult ways.
**** OPTION 6 ****
Save the value to a program configuration file:
Retrieve the value here if it exists:
(setq fn (open "drawingname.cfg" "r")) (if fn (progn (setq a (read-line fn)) (close fn) ) ) Save it here:
Use the Visual Lisp functions VLAX-LDATA-PUT and VLAX-LDATA-GET to store and retrieve data that will be stored as an object in the drawing. Of course this only works with R14 with Visual Lisp addon or A2k and A2k2.
Load the Visual Lisp com object: (vl-load-com)
Put the value in:
(vlax-ldata-put "ThisObject" "ThisKey" a)
Retrieve the value:
If vl-load-com is already loaded then you do not need to reload it, otherwise:
(vl-load-com) (setq a (vlax-ldata-get "ThisObject" "ThisKey"))
I hope this clears up how to store data for use between drawing sessions.
Since the later 1980s, manufacturing companies have seen over 3 percent in labor output year on year, with most of this productivty enhancement occuring because of the optimization of repetitive tasks. Download Now