Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
English is not my native language and there may be quite a few mistakes,
Thank you for your understanding。
Here's the test code
var per1 = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.GetEntity("\nPick Polyline");
if (per1.Status != PromptStatus.OK) return;
var ptr = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.GetPoint("\nPick a Point");
if (ptr.Status != PromptStatus.OK) return;
using (Transaction tr = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)tr.GetObject(Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.BlockTableId, OpenMode.ForRead, false);
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false);
var pl = per1.ObjectId.GetObject(OpenMode.ForRead) as Curve;
//Geometry Curve3d
var geoC = pl.GetGeCurve();
// splited Curve3d
var scs = geoC.GetSplitCurves(geoC.GetParameterOf(geoC.GetClosestPointTo(ptr.Value).Point));
foreach (Curve3d subC in scs)
{
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("\nGeo Curve3d's startpoint and endpoint \t" + subC.StartPoint.ToString() + "\t" + subC.EndPoint.ToString());
// database Curve
var dbc = Curve.CreateFromGeCurve(subC);
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("\ndbbase Curve's startpoint and endpoint\t" + dbc.StartPoint.ToString() + "\t" + dbc.EndPoint.ToString());
btr.AppendEntity(dbc);
tr.AddNewlyCreatedDBObject(dbc, true);
}
tr.Commit();
}
I need split Curve3d into segments,
and then Create database Curve,
when I select a Line or a Arc,
the result is right,
But when I select a ployline,
the result is wrong,
the "sub polyline" is as long as the source polyline。
Who can help test the above code,
Find out where my error is。
Thank you so much!
王磊
您认为此帖子是否有用?欢迎为此帖点赞。
您的问题是否已得到解答?请点击“接受解答”按钮。
Solved! Go to Solution.