Cannot get AddRegion to work with late binding

Cannot get AddRegion to work with late binding

nrjdjjs
Explorer Explorer
415 Views
1 Reply
Message 1 of 2

Cannot get AddRegion to work with late binding

nrjdjjs
Explorer
Explorer

I am trying to generate a 3D solid of an octagon shape created using polylines. Because this code is to be supported on many versions of AutoCAD, I am using late binding. Here is the code written in C#:

 

//create polylines from vertices of an octagon - vertices below represent the octagon vertices

var octagonPolylines = new dynamic[8];

k = 0;
for (int i = 0; i <= 7; i++)
{
           double[] startPoint = new double[] { vertices[k], vertices[k + 1], vertices[k + 2] };
           double[] endPoint = new double[] { vertices[k + 3], vertices[k + 4], vertices[k + 5] };
           octagonPolylines[i] = acModelSpace.AddLine(startPoint, endPoint);
           k += 3;
}

 

//create a region from the polylines

object[] octagonRegion = acModelSpace.AddRegion(octagonPolylines);

 

// create an extruded solid from the region

foreach (dynamic obj in octagonRegion)
{
       dynamic octagon3DSolid = acModelSpace.AddExtrudedSolid(obj, height, taperAngle);
}

 

I get an "Invalid Object Array" exception at the line where the method AddRegion is used.

 

I have tried many different approaches but cannot get this to work. Is there another or better way to generate an octagonal 3D solid using late binding? Any help in this matter would be sincerely appreciated.

 

Thank you

0 Likes
416 Views
1 Reply
Reply (1)
Message 2 of 2

Moshe-A
Mentor
Mentor

@nrjdjjs  hi,

 

move this thread to >> dot net forum <<

 

moshe

 

0 Likes