.NET

Reply
*Maksim Sestic
Message 1 of 6 (469 Views)

Reading XData

469 Views, 5 Replies
08-10-2005 08:03 AM

Is there an example, preferrably in VB.NET, of
actually reading XData (not writing)? I get a ResultBuffer and don't know how to
read certain value at specified index.

 

Regards,

Maksim Sestic
Distinguished Contributor
Mikko
Posts: 212
Registered: ‎10-03-2003
Message 2 of 6 (469 Views)

Re: Reading XData

08-10-2005 08:27 AM in reply to: *Maksim Sestic
Dim idArray() As ObjectId
Try
Dim res As PromptSelectionResult = ed.GetSelection
If res.Status PromptStatus.OK Then
Exit Sub
End If
Dim SS As Autodesk.AutoCAD.EditorInput.SelectionSet = res.Value
idArray = SS.GetObjectIds()
Dim objId As ObjectId
For Each objId In idArray
Dim XDataEnt As Entity = CType(myT.GetObject(objId, OpenMode.ForRead), Entity)
If XDataEnt.GetType.Name.ToString() = "YourXDataEntity ex. CIRCLE LINE etc...." Then
Try
Dim myXdata As Array
myXdata = XDataEnt.XData.AsArray
var0 = myXdata.GetValue(0)
var1 = myXdata.GetValue(1)
Catch ex As Exception
ed.WriteMessage("Selected entity does not have any xdata attached to it." & vbCrLf & "Try Again!")
Exit Sub
End Try
End If
Next
myT.Commit()
Catch ex As Exception
ed.WriteMessage(ex.ToString)
Finally
myT.Dispose()
End Try
ed.WriteMessage(var0 & ", " & var1) null
*Maksim Sestic
Message 3 of 6 (469 Views)

Re: Reading XData

08-10-2005 11:26 PM in reply to: *Maksim Sestic

Mikko,

 

Thanks for the tip, but I'm still having problem
with this part of code you've sent:

 

...

Dim myXdata As
Array
myXdata = XDataEnt.XData.AsArray
...

 

The error reported: 
color=#808080>'AsArray' is not a member of
'Autodesk.AutoCAD.DatabaseServices.ResultBuffer'
,

and also: Value of type
'Autodesk.AutoCAD.DatabaseServices.ResultBuffer' cannot be converted to
'System.Array'
.

There is no
XData.AsArray method exposed (?!)... I'm using AutoCAD 2005.

 

Regards,

Maksim Sestic
Distinguished Contributor
Mikko
Posts: 212
Registered: ‎10-03-2003
Message 4 of 6 (469 Views)

Re: Reading XData

08-11-2005 04:10 AM in reply to: *Maksim Sestic
According to the 2006 Object Browser

Public Function AsArray() As Autodesk.AutoCAD.DatabaseServices.TypedValue()
Member of: Autodesk.AutoCAD.DatabaseServices.ResultBuffer

Must be new to 2006. Never used 2005 very much, the API was very incomplete. You can always use the COM Interop, still works just fine. Not the answer you wanted to hear. Maybe someone else has the remedy.
*Maksim Sestic
Message 5 of 6 (469 Views)

Re: Reading XData

08-11-2005 04:40 AM in reply to: *Maksim Sestic

Mikko,

 

Thanks anyway, I'm planning to switch to 2006
soon so I guess this is newly exposed functionality. Regarding ResultBuffer type
in 2005 - it's a simple List user needs to iterate (ForEach...Next) to get to
desired index and then get a Value property.

 

Regards,

Maksim Sestic

 

According to the 2006 Object
Browser

Public Function AsArray() As
Autodesk.AutoCAD.DatabaseServices.TypedValue()
    
Member of: Autodesk.AutoCAD.DatabaseServices.ResultBuffer

Must be new to
2006.  Never used 2005 very much, the API was very incomplete.  You
can always use the COM Interop, still works just fine.  Not the answer you
wanted to hear.  Maybe someone else has the remedy.
New Member
xilandar
Posts: 1
Registered: ‎08-24-2005
Message 6 of 6 (469 Views)

Re: Reading XData

08-24-2005 03:15 AM in reply to: *Maksim Sestic
DESI BRE KUME
MORAO SAM PO NETU DA TE TRAZIM
AJDE PISHI DESI I SHTA IMA NOVO
U BANGKOKU SAM VEC DUZE.....I TAKO SVE OK
PISHI
POZDRAV
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.