Display full version of the post: Add Region using .NET and late binding...

LittleOleMeDesi
22.03.2010, 15:02
I am trying to create a Region with .NET.  I am using late binding since I have to program to 3 different version of AutoCAD.The following code works: [CODE] Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click        Dim V_Region As Object        ' declare variables        Const PI = 3.14159265358979        Dim line1 As Object        Dim line2 As Object        Dim line3 As Object        Dim arc1 As Object        Dim center1(2) As Double        Dim point1(0 To 2) As Double        Dim point2(0 To 2) As Double        Dim point3(0 To 2) As Double        Dim point4(0 To 2) As Double        point1(0) = 10 : point1(1) = 10 : point1(2) = 0        point2(0) = 50 : point2(1) = 10 : point2(2) = 0        point3(0) = 50 : point3(1) = 20 : point3(2) = 0        point4(0) = 10 : point4(1) = 20 : point4(2) = 0        line1 = V_AutoCad.ActiveDocument.ModelSpace.AddLine(point1, point2)        line2 = V_AutoCad.ActiveDocument.ModelSpace.AddLine(point3, point4)        line3 = V_AutoCad.ActiveDocument.ModelSpace.AddLine(point4, point1)        center1(0) = line1.EndPoint(0) : center1(1) = line1.EndPoint(1) + 5        center1(2) = 0        arc1 = V_AutoCad.ActiveDocument.ModelSpace.AddArc(center1, 5, 3 / 2 * PI, 1 / 2 * PI)        ' make array for region        Dim arrayobj(3) As AcadEntity        arrayobj(0) = line1        arrayobj(1) = arc1        arrayobj(2) = line2        arrayobj(3) = line3        ' make the region from the array        V_Region = V_AutoCad.ActiveDocument.ModelSpace.AddRegion(arrayobj)           End Sub[/CODE]But when I change this line:      Dim arrayobj(3) As AcadEntityTo:      Dim arrayobj(3) As ObjectI get "Invalid Object Array" on the AddRegion line.Does anyone know how to fix this and stay as a late binding program???