Dim xdatatype(1) As Short
That should fix the problem. In VB6, which is what VBA in AutoCAD is based
on, the Integer type is a 16 bit signed integer. In .NET the Integer type
is a 32 bit signed integer. The 16 bit signed integer type in VB.NET, and
C# btw, is the Short type. Well, if you want to get real picky it's
System.Int16, but who's that anal :-)
--
Bobby C. Jones
"Matt Howland" wrote in message
news:27497870.1081859645404.JavaMail.jive@jiveforum1.autodesk.com...
> Thank you for the reply. I am attaching my code so that you can take a
look at it and let me know what you think. I am showing you both the VBA
code and the VB.net code. The VBA code worked without any problems.
>
> VBA Code:
>
> Sub xdata()
> Dim line As AcadLine
> Dim pt1(2) As Double
> Dim pt2(2) As Double
> pt2(0) = 100: pt2(1) = 100
> Dim xdatatype(0 To 1) As Integer
> Dim xdata(0 To 1) As Variant
> xdatatype(0) = 1001: xdatatype(1) = 1000
> xdata(0) = "LineData": xdata(1) = "Data"
> Set line = ThisDrawing.ModelSpace.AddLine(pt1, pt2)
> line.SetXData xdatatype, xdata
> Dim xdatatyperet As Variant
> Dim xdataret As Variant
> line.GetXData "LineData", xdatatyperet, xdataret
> Dim i
> For Each i In xdataret
> MsgBox (i)
> Next
> End Sub
>
>
> Here is the code in VB.net with minor changes to accomodate the
differences between the two. Directly below is the error message that I
received.
>
> "An unhandled exception of type
'System.Runtime.InteropServices.COMException' occurred in AutocadChanges.exe
>
> Additional information: Invalid argument type in SetXData method"
>
> VB.net Code:
>
> Sub xdata()
> Dim line As AutoCAD.AcadLine
> Dim pt1(2) As Double
> Dim pt2(2) As Double
> pt2(0) = 100 : pt2(1) = 100
> Dim xdatatype(1) As Integer
> Dim xdata(1) As Object
> xdatatype(0) = 1001 : xdatatype(1) = 1000
> xdata(0) = "LineData" : xdata(1) = "Data"
> line = acaddoc.ModelSpace.AddLine(pt1, pt2)
> line.SetXData(xdatatype, xdata)
> Dim xdatatyperet As Object
> Dim xdataret As Object
> line.GetXData("LineData", xdatatyperet, xdataret)
> Dim i
> For Each i In xdataret
> MsgBox(i)
> Next
> End Sub
>
> Any help you can give would be much appreciated. Thanks.