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

Adding Multiple Xrecords to a Named Object Dictionary

5 REPLIES 5
Reply
Message 1 of 6
jimmydee
2305 Views, 5 Replies

Adding Multiple Xrecords to a Named Object Dictionary

Attached is a text file containing two functions for creating an Xrecord in the NOD and reading the Xrecord back. That's working fine but I'm can't figure out how to add multiple Xrecords to my Dcitionary in the NOD.

 

Basically every time I use the ADDTASK function it seems to overwrite the previous Xrecord and I'm left with only one record.

 

Any help would be greatly appreciated.

 

Thank you,

Jim Dee

 

5 REPLIES 5
Message 2 of 6
jimmydee
in reply to: jimmydee

Am I just misunderstanding how xrecords in dictionaries are structured?

 

Is the following code from my previous post resulting in one xrecord entry or is each "New TypedValue" and xrecord?

 

                'create data as result buffer with data inside
                Dim data As ResultBuffer = New ResultBuffer(New TypedValue(DxfCode.Text, Now.ToString("G")), _
                                                            New TypedValue(DxfCode.Text, Action), _
                                                            New TypedValue(DxfCode.Text, task), _
                                                            New TypedValue(DxfCode.Text, Application.GetSystemVariable("loginname")))


I thought that I could add an xrecord which would hold several "fields" in each xrecord, but I keep overwriting the previous entry with the ADDTASK function.

 

Can someone please help steer me in the right direction? The documentation on this subject is almost nonexistent.

 

Thank you,

Jim Dee

Message 3 of 6
HomeBoyLV
in reply to: jimmydee

Sounds like the you are using the same name for the xrecord each time you write to the NOD.

 

Make sure you use unique values for the record name, like:

 

NOD.SetAt ("SomeUniqueName", MyXrecord)

 

HomeBoy Out

Message 4 of 6
jimmydee
in reply to: HomeBoyLV

Homeboy,

 

Thank you for the reply.

 

I might be more confused than I thought - isn't the "SomeUniqueName" string in your example the name of a dictionary within the NOD? I thought that I was adding a dictionary named "TaskData" to the NOD and then adding a xrecord to that dictionary and that xrecord has four strings as data within the it.

 

If "SomeUniqueName in NOD.SetAt ("SomeUniqueName", MyXrecord) is not the dictionary name then how do I add a dictionary to the NOD and why would xrecords have a unique name associated with them? Why wouldn't I be able to simply add records to the dictionary and then later loop thru each record to read the data.

 

I can only find week references in this discussion group that describe the creation of dictionaries and records the way that I described, but not enough to understand the structure and now I'm more confused about the structure of dictionaries and xrecords in the NOD.

 

Do you know where I can get more info? I feel like I'm just poking around in the dark.

 

Thank you,

Jim Dee

 

Message 5 of 6
HomeBoyLV
in reply to: jimmydee

I might be more confused than I thought - isn't the "SomeUniqueName" string in your example the name of a dictionary within the NOD?

 

No. The  "SomeUniqueName" is the key used to identify records in the dictionary.

 

 I thought that I was adding a dictionary named "TaskData" to the NOD and then adding a xrecord to that dictionary and that xrecord has four strings as data within the it.

 

You are adding a record to and existing dictionary (the Named ObjectDictionary), with a key value of "TaskData". Think of the four strings as cols of the record.

 

If "SomeUniqueName in NOD.SetAt ("SomeUniqueName", MyXrecord) is not the dictionary name then how do I add a dictionary to the NOD and why would xrecords have a unique name associated with them? Why wouldn't I be able to simply add records to the dictionary and then later loop thru each record to read the data.

 

You can add a dictionary to a dictionary, at least I did it in VBA. I think xrecords can have extention dictionary, so you could add your items to that. Each xrecord needs its own key to ID each record. dictionaries can have multipal xrecords in them, and the key is how you ID each one. you can add a record, each with its own ID, and roll through the dictionary.

 

I think the confusion is in the structure . Dictionaries hold xrecords, xrecords hold the data.

 

Hope that helps

 

HomeBoy Out

Message 6 of 6
dgorsman
in reply to: HomeBoyLV

I find it helps to think of a Dictionary as what it is - an indexed collection of items (XRecords and/or other Dictionaries).  Each item of that collection must have a unique ID, which applies to both Dictionaries and XRecords as the Name property.  XRecords are like a simplified Dictionary, in that they can hold a variety of data (including pointers to other Dictionaries or XRecords - not sure about actual objects), but that data doesn't have to have a unique ID.  The ordering is up to the program.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


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