Please let me know if I'm able to save some variables into current DWG?
I would like to provide availability for user to save some data which is different for each DWG file.
Solved! Go to Solution.
Lookup Xrecords / Xdata and Dictionary
Further to arcticad's reply, you'd typically store global data on the Named Objects Dictionary, and data related to a particular entity as xdata on that entity or as an xrecord in its extension dictionary.
But if you're storing 'variables' (sysvars), then you migh prefer to use the Autodesk.AutoCAD.Runtime.Variable class. You can specify whether the variable is per session, per user, per profile or per database.
I don't seem to find any information on how to use Autodesk.AutoCAD.Runtime.Variable
Can you point me in the direction.
I used LispVariable to store data in file so user could use them in Text Field.
Here are examples how to get and set Lisp Variables I used.
You can see this thread about custom Variables.
IMO, the main issue with Autodesk.AutoCAD.Runtim.Variable is the variable has to be registered in HKLM which most often requires administrator user account.
Use DBDictionary to save data (XRecord) in file.
Try to search for NamedObjectsDictionary (NOD) you should find many examples in this forum.
If you want to go the Xdata route without selecting an entity, you can set your Xdata on any DBObject (i.e. layer "0", model space BlockTableRecord) but, IMO, you'd rather use a DBDictionary and Xrecord.
Start with some of our most frequented solutions to get help installing your software.