Dictionaries and Xrecords

Dictionaries and Xrecords

Anonymous
Not applicable
337 Views
5 Replies
Message 1 of 6

Dictionaries and Xrecords

Anonymous
Not applicable
I'm new to this whole XRECORD concept so please bear with me... I've got a dictionary (MY_LAYERS) set up that Within that dictionary is an XRECORD (MY_LAYER_STATES) which contains the current layers within the drawing. I'm able to write everything to the dictionary and xrecord no problem! The problem I'm running into is this: How can I now read the contents of the xrecord?? The number of entries within the xrecord will vary from one drawing to another. Thanks in advance! -- I support two teams: the Red Sox and whoever beats the Yankees.
0 Likes
338 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Matt, Find the upper bounds of the record.... For I = 0 to UBound(XrecordData) Nice game last night...Go Bronson...Bring on the Yanks.... Paul "Matt W" wrote in message news:4166f123$1_1@newsprd01... > I'm new to this whole XRECORD concept so please bear with me... > > I've got a dictionary (MY_LAYERS) set up that Within that dictionary is an > XRECORD (MY_LAYER_STATES) which contains the current layers within the > drawing. > I'm able to write everything to the dictionary and xrecord no problem! > > The problem I'm running into is this: How can I now read the contents of the > xrecord?? The number of entries within the xrecord will vary from one > drawing to another. > > Thanks in advance! > > > -- > I support two teams: the Red Sox and whoever beats the Yankees. > > >
0 Likes
Message 3 of 6

Anonymous
Not applicable
Matt, You could also add LBounds... For I = LBound(XrecordData) _ to UBound(XrecordData) Paul "Paul Richardson" wrote in message news:4167c7b2_2@newsprd01... > Matt, Find the upper bounds of the record.... > > For I = 0 to UBound(XrecordData) > > Nice game last night...Go Bronson...Bring > on the Yanks.... > > Paul > > > "Matt W" wrote in message > news:4166f123$1_1@newsprd01... > > I'm new to this whole XRECORD concept so please bear with me... > > > > I've got a dictionary (MY_LAYERS) set up that Within that dictionary is an > > XRECORD (MY_LAYER_STATES) which contains the current layers within the > > drawing. > > I'm able to write everything to the dictionary and xrecord no problem! > > > > The problem I'm running into is this: How can I now read the contents of > the > > xrecord?? The number of entries within the xrecord will vary from one > > drawing to another. > > > > Thanks in advance! > > > > > > -- > > I support two teams: the Red Sox and whoever beats the Yankees. > > > > > > > >
0 Likes
Message 4 of 6

Anonymous
Not applicable
Thanks, Paul but... I can't seem to get this thing straight. I *know* it's something simple, but I just can't put my finger on it. Here's the code I've got so far... [code] Option Explicit Public Sub CreateXrecord() Dim oXrec As AcadXRecord Dim oDict As AcadDictionary Dim oLayer As AcadLayer Dim vType() As Integer Dim vData() As Variant Dim i As Integer ReDim Preserve vData(0 To i) ReDim Preserve vType(0 To i) Set oDict = ThisDrawing.Dictionaries.Add("MY_LAYERS") For Each oLayer In ThisDrawing.Layers vType(i) = 1 vData(i) = oLayer.Name Set oXrec = oDict.AddXRecord("MY_LAYER_STATES") oXrec.SetXRecordData vType, vData i = i + 1 ReDim Preserve vData(0 To i) ReDim Preserve vType(0 To i) Next Set oXrec = Nothing End Sub Public Sub ReadXrecord() Dim oXrec As AcadXRecord Dim oDict As AcadDictionary Dim vType() As Integer Dim vData() As Variant Dim i As Integer Set oDict = ThisDrawing.Dictionaries("MY_LAYERS") ' This is where I'm lost. ' What's the syntax to read the contents of the dictionaries xrecords? For i = LBound(oXrec) To UBound(oXrec) Next Set oXrec = Nothing Set oDict = Nothing End Sub [/code] It's shaping up to be a good world series! Now if I could only find a place that sells the "Yankee Hater" hats I'll be all set. -- I support two teams: the Red Sox and whoever beats the Yankees. "Paul Richardson" wrote in message news:4167d027$1_3@newsprd01... | Matt, You could also add LBounds... | | For I = LBound(XrecordData) _ | to UBound(XrecordData) | | Paul | | "Paul Richardson" wrote in message | news:4167c7b2_2@newsprd01... | > Matt, Find the upper bounds of the record.... | > | > For I = 0 to UBound(XrecordData) | > | > Nice game last night...Go Bronson...Bring | > on the Yanks.... | > | > Paul | > | > | > "Matt W" wrote in message | > news:4166f123$1_1@newsprd01... | > > I'm new to this whole XRECORD concept so please bear with me... | > > | > > I've got a dictionary (MY_LAYERS) set up that Within that dictionary is | an | > > XRECORD (MY_LAYER_STATES) which contains the current layers within the | > > drawing. | > > I'm able to write everything to the dictionary and xrecord no problem! | > > | > > The problem I'm running into is this: How can I now read the contents of | > the | > > xrecord?? The number of entries within the xrecord will vary from one | > > drawing to another. | > > | > > Thanks in advance! | > > | > > | > > -- | > > I support two teams: the Red Sox and whoever beats the Yankees. | > > | > > | > > | > | > | |
0 Likes
Message 5 of 6

Anonymous
Not applicable
Matt dump the Record to a Var array and then you can read..Can't wait for tomorrow night...gl Paul Public Sub ReadXrecord() Dim oXrec As AcadXRecord Dim oDict As AcadDictionary Dim XrecType As Variant Dim XrecData As Variant Dim i As Integer Set oDict = ThisDrawing.Dictionaries("MY_LAYERS") Set oXrec = oDict.GetObject("MY_LAYER_STATES") oXrec.GetXRecordData XrecType, XrecData For i = LBound(XrecData) To UBound(XrecData) Debug.Print XrecData(i) Next Set oXrec = Nothing Set oDict = Nothing End Sub "Matt W" wrote in message news:416a8312$1_1@newsprd01... > Thanks, Paul but... > > I can't seem to get this thing straight. I *know* it's something simple, > but I just can't put my finger on it. > > Here's the code I've got so far... > > [code] > Option Explicit > > > Public Sub CreateXrecord() > Dim oXrec As AcadXRecord > Dim oDict As AcadDictionary > Dim oLayer As AcadLayer > Dim vType() As Integer > Dim vData() As Variant > Dim i As Integer > > ReDim Preserve vData(0 To i) > ReDim Preserve vType(0 To i) > > Set oDict = ThisDrawing.Dictionaries.Add("MY_LAYERS") > For Each oLayer In ThisDrawing.Layers > vType(i) = 1 > vData(i) = oLayer.Name > Set oXrec = oDict.AddXRecord("MY_LAYER_STATES") > oXrec.SetXRecordData vType, vData > i = i + 1 > ReDim Preserve vData(0 To i) > ReDim Preserve vType(0 To i) > Next > > Set oXrec = Nothing > End Sub > > Public Sub ReadXrecord() > Dim oXrec As AcadXRecord > Dim oDict As AcadDictionary > Dim vType() As Integer > Dim vData() As Variant > Dim i As Integer > > Set oDict = ThisDrawing.Dictionaries("MY_LAYERS") > > ' This is where I'm lost. > ' What's the syntax to read the contents of the dictionaries xrecords? > For i = LBound(oXrec) To UBound(oXrec) > > Next > > Set oXrec = Nothing > Set oDict = Nothing > End Sub > [/code] > > It's shaping up to be a good world series! > Now if I could only find a place that sells the "Yankee Hater" hats I'll be > all set. > > -- > I support two teams: the Red Sox and whoever beats the Yankees. > > > "Paul Richardson" wrote in message > news:4167d027$1_3@newsprd01... > | Matt, You could also add LBounds... > | > | For I = LBound(XrecordData) _ > | to UBound(XrecordData) > | > | Paul > | > | "Paul Richardson" wrote in message > | news:4167c7b2_2@newsprd01... > | > Matt, Find the upper bounds of the record.... > | > > | > For I = 0 to UBound(XrecordData) > | > > | > Nice game last night...Go Bronson...Bring > | > on the Yanks.... > | > > | > Paul > | > > | > > | > "Matt W" wrote in message > | > news:4166f123$1_1@newsprd01... > | > > I'm new to this whole XRECORD concept so please bear with me... > | > > > | > > I've got a dictionary (MY_LAYERS) set up that Within that dictionary > is > | an > | > > XRECORD (MY_LAYER_STATES) which contains the current layers within the > | > > drawing. > | > > I'm able to write everything to the dictionary and xrecord no problem! > | > > > | > > The problem I'm running into is this: How can I now read the contents > of > | > the > | > > xrecord?? The number of entries within the xrecord will vary from one > | > > drawing to another. > | > > > | > > Thanks in advance! > | > > > | > > > | > > -- > | > > I support two teams: the Red Sox and whoever beats the Yankees. > | > > > | > > > | > > > | > > | > > | > | > >
0 Likes
Message 6 of 6

Matt__W
Advisor
Advisor
Thanks, Paul.
I figured it out earlier this morning, but I've been to busy trying to get some as-built drawings completed!

Thanks for the reply.

I'm thinkin' the Sox in 5! I think they want it more than the Spankees (especially after last year).

Go Red Sox!!


Matt Wunch
Revit Subject Matter Expert/sUAS Pilot

Twitter | LinkedIn

AU2017 - Code Blue Dr Revit - How to Resuscitate Corrupt Revit Models

Was this answer helpful? If so, please click the ACCEPT AS SOLUTION or the KUDO button.

0 Likes