I'll keep that commandline class handy, but there is no reason i see to use it.
I draw plines all the time from line and arc data.
I guess you will have to go through the part of matching up endpoints to other enpoints, since you don't necessarily know the order of segments if just objectids.
I think the pline join in acad is just an interface to gather data to feed into a new entity, so you must do the same.
Here is my code for reference, but you will have to substitute various portions to your needs, because I use objects not provided here, but you can see whats going on.
public static bool DrawPl(this CE.Glist glist, string layer, int color, out object objectId)
{
objectId = null;
//Add the pline object
AcDb.Polyline pline = new Polyline();
pline.Closed = false;
//add verticies
for (int i = 0; i < glist.Segments.Count; i++) {
//Segments is an arraylist, so test for object type
if (glist.Segments[i] is CE.Line) {
CE.Line line = (CE.Line)glist.Segments[i];
if (i == 0)
pline.AddVertexAt(0, new Point2d(line.StartPt.X, line.StartPt.Y), 0.0, 0.0, 0.0);
pline.AddVertexAt(i + 1, new Point2d(line.EndPt.X, line.EndPt.Y), 0.0, 0.0, 0.0);
}
else {
CE.Arc arc = (CE.Arc)glist.Segments[i];
CE.Point stpt;
CE.Point endpt;
if (arc.Direction == "CCW") {
stpt = CEG.Polar(arc.CenPt, arc.StartAng, arc.Radius);
endpt = CEG.Polar(arc.CenPt, arc.EndAng, arc.Radius);
}
else {
stpt = CEG.Polar(arc.CenPt, arc.EndAng, arc.Radius);
endpt = CEG.Polar(arc.CenPt, arc.StartAng, arc.Radius);
}
double bulge;
if (arc.Delta <= 0.0000000001) {
bulge = 0.0;
}
else {
bulge = (arc.Radius - (SM.Cos(arc.Delta / 2.0) * arc.Radius)) / (CEG.Distance(stpt, endpt) / 2.0);
if (arc.Direction == "CW") bulge = bulge * -1.0;
}
if (i == 0)
pline.AddVertexAt(0, new Point2d(stpt.X, stpt.Y), 0.0, 0.0, 0.0);
pline.AddVertexAt(i + 1, new Point2d(endpt.X, endpt.Y), 0.0, 0.0, 0.0);
pline.SetBulgeAt(i, bulge);
}
}
//set color
pline.Color = AcCo.Color.FromColorIndex(AcCo.ColorMethod.ByAci, Convert.ToInt16(color));
ObjectId id;
bool ret = HADR.AddEntityToDB(pline, layer, out id);
objectId = (object)id;
return ret;
}