Get an offset polyline

Get an offset polyline

youssefGC
Advocate Advocate
427 Views
2 Replies
Message 1 of 3

Get an offset polyline

youssefGC
Advocate
Advocate

Hi everyone,

I try to write the code below, in order to sweep and offset each segment in a given polyline (prompt by user). But when I execute them in the example (image), I found a "System.ArgumentOutOfRangeException"  in the second part.

 

 

for (int i = 0; i < nbrOfSegment; i++)
                {
                    // create a single pline
                    Polyline ProvisoirPline = new Polyline();
                    ProvisoirPline.AddVertexAt(ProvisoirPline.NumberOfVertices, OriginalPline.GetPoint2dAt(i), OriginalPline.GetBulgeAt(i), 0, 0);
                    ProvisoirPline.AddVertexAt(ProvisoirPline.NumberOfVertices, OriginalPline.GetPoint2dAt(i + 1), OriginalPline.GetBulgeAt(i + 1), 0, 0);

                    DBObjectCollection DBObj = ProvisoirPline.GetOffsetCurves(10);
                    Polyline NewOffsetSegment = (Polyline)dbo[0]; // Argument Out Of Range Exception 

                    /// code

                }

 

 

2023-03-02_132246.png

Thank you.

0 Likes
Accepted solutions (1)
428 Views
2 Replies
Replies (2)
Message 2 of 3

norman.yuan
Mentor
Mentor

Shouldn't this line

 

Polyline NewOffsetSegment = (Polyline)dbo[0];

 

be

 

Polyline NewOffsetSegment = (Polyline)DBObj[0];

 

?

 

it looks like variable "dbo" is declared before the showed code and is an empty collection of something.

 

 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 3

youssefGC
Advocate
Advocate
Accepted solution

Thanks for your reply.

Yes I fall into an error, the variable "dbo" should be "DBObj".

I found the origin of the problem : the offset value is greater than the diameter of the arc (when the offset direction was inside the polyline), but when I reduce the value of the offset the code march perfectly.

0 Likes