After using GetSplitCurves(), you could test if any segment intersects with both cutting point to get the exact segment.
[CommandMethod("splitpoly")]
public void Test()
{
Document acDoc = AcadApp.DocumentManager.MdiActiveDocument;
Database acDb = acDoc.Database;
Editor ed = acDoc.Editor;
using(Transaction acTrans = acDoc.TransactionManager.StartTransaction())
{
// Get blocktable and blocltablerecord
BlockTable acBlkTbl = acTrans.GetObject(acDb.BlockTableId,OpenMode.ForRead) as BlockTable;
BlockTableRecord acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],OpenMode.ForWrite) as BlockTableRecord;
// Get polyline
PromptEntityResult plRet = ed.GetEntity("Please pick a polyline\n");
if (plRet.Status != PromptStatus.OK)
{
return;
}
Polyline pl = acTrans.GetObject(plRet.ObjectId, OpenMode.ForWrite) as Polyline;
if(pl == null)
{
return;
}
// Get cutting point
PromptPointResult pt1Ret = ed.GetPoint("Please pick the first split point on previous selected polyline.\n");
if (pt1Ret.Status != PromptStatus.OK)
{
return;
}
Point3d pt1 = pt1Ret.Value;
PromptPointResult pt2Ret = ed.GetPoint("Please pick the second split point on previous selected polyline.\n");
if (pt2Ret.Status != PromptStatus.OK)
{
return;
}
Point3d pt2 = pt2Ret.Value;
// Get cutting point collection
Point3dCollection ptColl = new Point3dCollection();
ptColl.Add(pt1);
ptColl.Add(pt2);
// Split the polyline with point collection
DBObjectCollection dbColl = pl.GetSplitCurves(ptColl);
// If any segment of the polyline intersects with both two cutting points, add it to database.
foreach (DBObject obj in dbColl)
{
Polyline subPl = obj as Polyline;
Point3d startPt = subPl.StartPoint;
Point3d endPt = subPl.EndPoint;
if((pt1 == startPt && pt2 == endPt) || (pt1 == endPt && pt2 == startPt))
{
subPl.ConstantWidth = 2;
acBlkTblRec.AppendEntity(subPl);
acTrans.AddNewlyCreatedDBObject(subPl,true);
}
}
acTrans.Commit();
}
}