-
- 经测试没有大问题,只是画完多段线后原有线段不能完全删除,希望高手给予修改意见,如有BUG请回复!
- public class mycommand
- {
- //本代码由书写,仅供学习用,引用请注明出处.............
- //联系本人请Q:584457142
- [CommandMethod("my")]//将首尾相连的线段或多段线连成多段线
- public void my()
- {
- Document acDoc = Application.DocumentManager.MdiActiveDocument;
- Database acCurDb = acDoc.Database;
- Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
- try
- {
- using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
- {
- BlockTable acBlkTbl;
- acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable;
- BlockTableRecord acBlkTblRec;
- acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
- OpenMode.ForWrite) as BlockTableRecord;
- PromptSelectionOptions pso=new PromptSelectionOptions();
- PromptSelectionResult psr = ed.GetSelection(pso);
- Polyline pl = new Polyline();
- if (psr.Status == PromptStatus.OK)
- {
- SelectionSet ss = psr.Value;
- int n = ss.Count;
- ObjectIdCollection oc = new ObjectIdCollection() ;
- for (int i = 0; i -1; i--)
- {
- final.Add(pl2.GetPoint3dAt(i));
- }
-
- }
- }
- else if (pl1.StartPoint.Equals(equalpoint))
- {
- if (pl2.EndPoint.Equals(equalpoint))
- {
- for (int i = 0; i = 0; i--)
- {
- final.Add(pl2.GetPoint3dAt(i));
- }
- for (int i = 1; i = 0; i--)
- {
- final.Add(pl1.GetPoint3dAt(i));
- }
- if (equalpoint.Equals(l.StartPoint))
- final.Add(l.EndPoint);
- else final.Add(l.StartPoint);
- }
- for (int i = 0; i = 0; i--)
- {
- final.Add(pl1.GetPoint3dAt(i));
- }
- if (equalpoint.Equals(l.StartPoint))
- final.Add(l.EndPoint);
- else final.Add(l.StartPoint);
- }
- for (int i = 0; i < final.Count; i++)
- {
- pl.AddVertexAt(i, new Point2d(final[i].X, final[i].Y), 0, 0, 0);
- }
- return pl;
- }
- #endregion
- else return null;
- }
|