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

Reading XData

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
1503 Views, 5 Replies

Reading XData


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
5 REPLIES 5
Message 2 of 6
Mikko
in reply to: Anonymous

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
Message 3 of 6
Anonymous
in reply to: Anonymous


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
Message 4 of 6
Mikko
in reply to: Anonymous

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.
Message 5 of 6
Anonymous
in reply to: Anonymous


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.
Message 6 of 6
xilandar
in reply to: Anonymous

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

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