Aftertouch Posted March 3, 2017 Posted March 3, 2017 Hello eveybody, I would like to store about 40 custom variables in a drawing. They are all Yes/No (0/1) variables. Now i know about the USERI and USERR variables, but they only go up to 5. Also i need to be able to call these variables with a DIESEL function for my ribbon, so i can toggle buttons with it. $(getvar, customvar1) I've read about using custom dictionaries to store information. But i doubt that this information can be read out using a DIESEL function? So my question... Where should i start with this??? Quote
rkmcswain Posted March 3, 2017 Posted March 3, 2017 (edited) To confirm, store them in the drawing itself? Have you seen these two ideas? http://developer.nanocad.com/blog/2014/09/16/multicad-net-api-saving-non-graphical-data-in-dwg-drawings/ http://adndevblog.typepad.com/autocad/2012/05/how-can-i-store-my-custom-information-in-a-dwg-file.html Edited March 3, 2017 by rkmcswain add URL Quote
tombu Posted March 3, 2017 Posted March 3, 2017 Hello eveybody,I would like to store about 40 custom variables in a drawing. They are all Yes/No (0/1) variables. Now i know about the USERI and USERR variables, but they only go up to 5. Also i need to be able to call these variables with a DIESEL function for my ribbon, so i can toggle buttons with it. $(getvar, customvar1) I've read about using custom dictionaries to store information. But i doubt that this information can be read out using a DIESEL function? So my question... Where should i start with this??? Since they are all Yes/No (0/1) variables you can store a lot of them in one USERI variable as bitcodes which you can access with DIESEL functions. Good reference: http://www.crlf.de/Dokumente/Diesel/Diesel.html Quote
Aftertouch Posted March 9, 2017 Author Posted March 9, 2017 Hmm.... both suggestions dont seem to fit my needs. Or i just dont understand how to use them. :-( Quote
tombu Posted March 9, 2017 Posted March 9, 2017 Take the OSMODE (System Variable). The setting is stored as a bitcode using the sum of the values for each osnap that is turned on. Using the logand lisp function (if(logand (getvar "osmode") 1)(princ "\nEndpoint On")(princ "\nEndpoint Off"))(princ) lets you know if Endpoint osnap is on or off. You could check 16 different osnap settings stored in that one integer system variable. This can be done with lisp or DIESEL functions using USERI variables in the same way. Quote
Roy_043 Posted March 9, 2017 Posted March 9, 2017 Integers in Autolisp are 32 bit. So you can store 32 on/off settings. Quote
BIGAL Posted March 10, 2017 Posted March 10, 2017 Users1 which is is a string will handle 40 0&1 no need to worry about how bitcodes work. Use "substr". users1 Enter new value for USERS1, or . for none : 1234567890123456789012345678901234567890 useri1 is limited to +-32767 So you have 5 users so could have 200 0&1 probably more dont know the string limit for usersx. Quote
Aftertouch Posted March 10, 2017 Author Posted March 10, 2017 Thanks for all the replies. @BIGAL and Roy_043, Your suggestions also crossed my mind. Where the UserI is limited to about 12 characters or or, the UserS can store many many many more... BUT.... UserS variables are not saved in the drawing... Now there is my next problem... Quote
BIGAL Posted March 10, 2017 Posted March 10, 2017 I have used userI etc did not know USERS is not saved. You may have to create your own Dictionary its not hard, you can store anything you like. I have a global style example, but I did do a save individual variables as a test at one stage for some private software, will try to find code. You could do all 40 as variables rather than just 1 string a bit easier as you can change just 1. Without going into it you would save "Text" & "Textstring" variables. If you google will find examples. Quote
tombu Posted March 11, 2017 Posted March 11, 2017 look into this I've learned a lot from Peter Jamtgaard starting on the old AUGI Guilds, to the WAUN Guilds him and a group of coders started when that went away. He's still active with AUGI as well. Biggest advantage for using Ldata is that USERI variables may likely be modified by other code you may be using. Peter figured out that by attaching ldata to layer 0 it was possible to delete if it ever became necessary. This is great code. Quote
Snownut Posted March 11, 2017 Posted March 11, 2017 If you want to permanently store the variables in whatever form they may be (text, reals, intergers, pairs etc..) the only way to reliably do this is with xdata dictionaries. See https://www.theswamp.org/index.php?topic=5003.msg60453#msg60453 for reference. Quote
Recommended Posts
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.