.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Storing variable-length modifiable list in the drawing

2 REPLIES 2
Reply
Message 1 of 3
namin
348 Views, 2 Replies

Storing variable-length modifiable list in the drawing

I have a variable-length list of elements, which I would like to store in the drawing. The list might be modified by adding or deleting elements.

My plan is to use a dictionary keyed by "elD" where D is a unique index within the list. There would be an "Length" key to tell me how many Ds I have to look through (as some D's might be missing if an element is deleted). Then, the value at a certain key would just be the XRecord of an element.

My question is: Do you think that's a good way to store variable-length lists? Is there a simpler, perhaps more built-in approach?

Thanks.
2 REPLIES 2
Message 2 of 3
foruma000256
in reply to: namin

Dictionaries can hold dictionaries.

Just keep nesting dictionaries and items until you get the nested tree organization your after. I recommend naming your keys after your class ID object (such as a GUID.tostring) then you can find that key, and it will be unique.

jvj
Message 3 of 3
Anonymous
in reply to: namin

XRecords can hold any number of elements of any supported type, and you can include lists that are bounded by delimiters having groupcode 102 with the values "{", and "}". See the docs for XData for an explaination of list delimiters.

I wouldn't design your system to require an excessive number of dictionaries with each holding an XRecord that contains only one or a few elements, because that would be much less efficient than fewer dictionaries/xrecords that use list delimiters to holds many elements or lists.

The more imporant part is that you only need to locate individual XRecords once. Once you have found them, you can simply cache their ObjectIds in program memory, and use that to access them afterward, rather than having to do some sort of keyed/indexed lookup every time you need to access the data.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

wrote in message news:6033425@discussion.autodesk.com...
I have a variable-length list of elements, which I would like to store in the drawing. The list might be modified by adding or deleting elements.

My plan is to use a dictionary keyed by "elD" where D is a unique index within the list. There would be an "Length" key to tell me how many Ds I have to look through (as some D's might be missing if an element is deleted). Then, the value at a certain key would just be the XRecord of an element.

My question is: Do you think that's a good way to store variable-length lists? Is there a simpler, perhaps more built-in approach?

Thanks.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost