<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: retrieve xdata in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/retrieve-xdata/m-p/5331067#M10258</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&lt;EM&gt;&amp;gt;&amp;gt; I got it returning the first character in each xdata record&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Look to that lines:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-family: courier new,courier; color: #000080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; For Each typeVal As TypedValue In rb&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-family: courier new,courier; color: #000080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox(typeVal.Value(i)).ToString()&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There you start of a loop that already handles each item of the resultbuffer (&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&lt;SPAN style="color: #000080;"&gt;For Each ...&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;)&lt;/P&gt;
&lt;P&gt;And within that loop you should take the value (&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&lt;SPAN style="color: #000080;"&gt;typeVal.Value&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;) and that's it&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With your syntax &lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&lt;SPAN style="color: #000080;"&gt;typeVal.Value(i)&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; you don't take the full string, you just take the element i in the array ... for a string that means you take the character at position i out of the array of characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH, - alfred -&lt;/P&gt;</description>
    <pubDate>Sat, 11 Oct 2014 08:07:50 GMT</pubDate>
    <dc:creator>Alfred.NESWADBA</dc:creator>
    <dc:date>2014-10-11T08:07:50Z</dc:date>
    <item>
      <title>retrieve xdata</title>
      <link>https://forums.autodesk.com/t5/vba-forum/retrieve-xdata/m-p/5318279#M10254</link>
      <description>&lt;P&gt;&amp;nbsp;This porting VBA to ,net is a pain. I have attatched a number of xdata to an object in one function. I need to retrieve specific xdata in another. I cant seem to find where to put the index value to get to item 5 in the xdata. I can read all of the xdata just fine&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks Mike&lt;/P&gt;</description>
      <pubDate>Mon, 06 Oct 2014 00:09:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/retrieve-xdata/m-p/5318279#M10254</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-10-06T00:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: retrieve xdata</title>
      <link>https://forums.autodesk.com/t5/vba-forum/retrieve-xdata/m-p/5330713#M10255</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please upload either a drawing with one element in modelspace with your EED/XDATA or show your code so we see what you wrote/how you did it.&lt;/P&gt;
&lt;P&gt;The element with index 5 of an array is normally readable by&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-family: courier new,courier; color: #000080;"&gt;&amp;nbsp;&amp;nbsp; myArrData(5)&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But as there might be more than just one application that needs to assign EED to an object you have 2 options to get your data&amp;amp;colon;&lt;/P&gt;
&lt;P&gt;a) take all XDATA from the object (as array), then scan it for your appname and that is the index where you start now, add + 5 to get your value&lt;/P&gt;
&lt;P&gt;b) use the function DBObj&lt;STRONG&gt;&lt;SPAN style="color: #000080;"&gt;.GetXDataForApplication&lt;/SPAN&gt;&lt;/STRONG&gt; ==&amp;gt; that gives you only your EED as resultbuffer&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH, - alfred -&lt;/P&gt;</description>
      <pubDate>Fri, 10 Oct 2014 20:58:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/retrieve-xdata/m-p/5330713#M10255</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2014-10-10T20:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: retrieve xdata</title>
      <link>https://forums.autodesk.com/t5/vba-forum/retrieve-xdata/m-p/5330925#M10256</link>
      <description>&lt;P&gt;Here is the code i have. I got it returning the first character in each&lt;BR /&gt;xdata record:&lt;BR /&gt;&lt;BR /&gt;Public Sub ViewXData()&lt;BR /&gt;' Get the current database and start a transaction&lt;BR /&gt;Dim acCurDb As Autodesk.AutoCAD.DatabaseServices.Database&lt;BR /&gt;acCurDb = Application.DocumentManager.MdiActiveDocument.Database&lt;BR /&gt;&lt;BR /&gt;Dim acDoc As Document =&lt;BR /&gt;Application.DocumentManager.MdiActiveDocument&lt;BR /&gt;&lt;BR /&gt;Dim appName As String = "mikeC"&lt;BR /&gt;Dim msgstr As String = ""&lt;BR /&gt;Dim objColection As ObjectIdCollection = New ObjectIdCollection()&lt;BR /&gt;Using acTrans As Transaction =&lt;BR /&gt;acCurDb.TransactionManager.StartTransaction()&lt;BR /&gt;&lt;BR /&gt;' Request objects to be selected in the drawing area&lt;BR /&gt;Dim acSSPrompt As PromptSelectionResult =&lt;BR /&gt;acDoc.Editor.GetSelection()&lt;BR /&gt;&lt;BR /&gt;' If the prompt status is OK, objects were selected&lt;BR /&gt;If acSSPrompt.Status = PromptStatus.OK Then&lt;BR /&gt;Dim i As Integer&lt;BR /&gt;i = 0&lt;BR /&gt;Dim acSSet As SelectionSet = acSSPrompt.Value&lt;BR /&gt;'' add more objects&lt;BR /&gt;objColection = New ObjectIdCollection(acSSet.GetObjectIds())&lt;BR /&gt;' Step through the objects in the selection set&lt;BR /&gt;For Each acSSObj As SelectedObject In acSSet&lt;BR /&gt;' Open the selected object for read&lt;BR /&gt;Dim acEnt As Object =&lt;BR /&gt;acTrans.GetObject(acSSObj.ObjectId, _&lt;BR /&gt;&lt;BR /&gt;OpenMode.ForRead)&lt;BR /&gt;&lt;BR /&gt;' Get the extended data attached to each object for&lt;BR /&gt;mikeC&lt;BR /&gt;Dim rb As ResultBuffer =&lt;BR /&gt;acEnt.GetXDataForApplication(appName)&lt;BR /&gt;&lt;BR /&gt;' Make sure the Xdata is not empty&lt;BR /&gt;If Not IsNothing(rb) Then&lt;BR /&gt;' Get the values in the xdata&lt;BR /&gt;For Each typeVal As TypedValue In rb&lt;BR /&gt;MsgBox(typeVal.Value(i)).ToString()&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;msgstr = msgstr &amp;amp; vbCrLf &amp;amp;&lt;BR /&gt;typeVal.TypeCode.ToString() &amp;amp; ":" &amp;amp; typeVal.Value&lt;BR /&gt;&lt;BR /&gt;Next&lt;BR /&gt;Else&lt;BR /&gt;msgstr = "NONE"&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;' Display the values returned&lt;BR /&gt;MsgBox(appName &amp;amp; " xdata on " &amp;amp;&lt;BR /&gt;VarType(acEnt).ToString() &amp;amp; ":" &amp;amp; vbCrLf &amp;amp; msgstr)&lt;BR /&gt;&lt;BR /&gt;msgstr = ""&lt;BR /&gt;Next&lt;BR /&gt;i = i + 1&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;' Ends the transaction and ensures any changes made are ignored&lt;BR /&gt;acTrans.Abort()&lt;BR /&gt;&lt;BR /&gt;' Dispose of the transaction&lt;BR /&gt;End Using&lt;BR /&gt;End Sub&lt;/P&gt;</description>
      <pubDate>Sat, 11 Oct 2014 00:33:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/retrieve-xdata/m-p/5330925#M10256</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-10-11T00:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: retrieve xdata</title>
      <link>https://forums.autodesk.com/t5/vba-forum/retrieve-xdata/m-p/5331067#M10258</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&lt;EM&gt;&amp;gt;&amp;gt; I got it returning the first character in each xdata record&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Look to that lines:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-family: courier new,courier; color: #000080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; For Each typeVal As TypedValue In rb&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-family: courier new,courier; color: #000080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox(typeVal.Value(i)).ToString()&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There you start of a loop that already handles each item of the resultbuffer (&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&lt;SPAN style="color: #000080;"&gt;For Each ...&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;)&lt;/P&gt;
&lt;P&gt;And within that loop you should take the value (&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&lt;SPAN style="color: #000080;"&gt;typeVal.Value&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;) and that's it&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With your syntax &lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&lt;SPAN style="color: #000080;"&gt;typeVal.Value(i)&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; you don't take the full string, you just take the element i in the array ... for a string that means you take the character at position i out of the array of characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH, - alfred -&lt;/P&gt;</description>
      <pubDate>Sat, 11 Oct 2014 08:07:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/retrieve-xdata/m-p/5331067#M10258</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2014-10-11T08:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: retrieve xdata</title>
      <link>https://forums.autodesk.com/t5/vba-forum/retrieve-xdata/m-p/5344665#M10259</link>
      <description>&lt;P&gt;Also, don't forget that the arrays are 0 based so element 5 is going to be located at position 4...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Fri, 17 Oct 2014 14:49:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/retrieve-xdata/m-p/5344665#M10259</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-10-17T14:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: retrieve xdata</title>
      <link>https://forums.autodesk.com/t5/vba-forum/retrieve-xdata/m-p/5347861#M10260</link>
      <description>&lt;P&gt;I don't know if this the correct way to do this but here is what worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;My above Code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If rb IsNot Nothing Then&lt;BR /&gt;' Get the values in the xdata&lt;BR /&gt;Dim XdataOut As TypedValue() = rb.AsArray()&lt;BR /&gt;&lt;BR /&gt;Dim xdata4&amp;nbsp;As Double = XdataOut.ElementAt(4).Value&lt;BR /&gt;Dim xdata5&amp;nbsp;As Double = XdataOut.ElementAt(5).Value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks Mike&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Oct 2014 11:48:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/retrieve-xdata/m-p/5347861#M10260</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-10-20T11:48:57Z</dc:date>
    </item>
  </channel>
</rss>

