eengebruiker Posted January 1, 2020 Posted January 1, 2020 Hello, I just read about Dictionaries and Xrecords. I think I understand how to work with them but I am missing something. I would like to work easily with key/value-pairs and it looks like that is not possible, unless I am overlooking something. let me explain. When digging into Xrecords I can find values by using assoc. If I store my values using the proper DXF-codes for strings, layernames (also strings), integers, reals etc. I can easily find the values. But what if I want to store 2, 3, 4 or more strings. Each with a meaning to my application. It looks like I can only find them by using the order in which they are stored. I can not look them up using there names, e.g. "txtA", "txtB", "txtC", etc. The only solution I can think of is to use a Xrecord per key/value pair, but it feels like it is not supposed to be used that way. Or . . . am I wrong. Is this the way to do it? In fact, what I would like to do in an easy way, is storing data in the form of key/value pairs in a drawing. Something like (example): ("Name" . "Sample") ("Width" . 376.4) ("Height" . 123.1) ("Order" . 3) Etc. My code knows what type a value has, so I don't need a type value. In fact I am using this sometimes in my own code when passing data from and to (sub)routines. I group parameters this way in one sigle entity (basically a list with key-value pairs). It works but I want to be able to simply store them in the drawing. It looks like I can only do that in more complicated ways, but not as simple as I explained. I hope someone feels the same needs and exchange some lines about this or (better) has a good solution for me. Regards, André Quote
BIGAL Posted January 2, 2020 Posted January 2, 2020 (edited) Maybe, pretty easy to split using a "," "name,sample" "width,123.45" "height,123.45" Edited January 2, 2020 by BIGAL Quote
eengebruiker Posted January 2, 2020 Author Posted January 2, 2020 @BIGAL. Sure this could work, but all of my values will be strings then. But . . . . wouldn't you be happy with good support for my simple idea? Couldn't you think of applications if the possibilities where there? Regards, André Quote
Roy_043 Posted January 2, 2020 Posted January 2, 2020 You can look at Lee Mac's Xdata example and do something similar for Xrecords. 1 Quote
tombu Posted January 2, 2020 Posted January 2, 2020 You could simply use Custom Drawing Properties. The can be added with the PROPULATE (Express Tool) https://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-Core/files/GUID-BD03320F-3430-4C2F-80A3-AAC1167AF019-htm.html Many of us add and modify them with lisp. User access already familiar to most users and they're easily referenced even with fields. Quote
eengebruiker Posted January 3, 2020 Author Posted January 3, 2020 Thanks to all that replied. I will take time to evaluate your tips and I will use it if it works for me. 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.