![]() |
多条相交直线全部打断问题!!!~~~急
多条相交直线全部打断问题!!!~~~急
www.dimcax.com 多条相交直线全部打断问题!!!~~~急 如题,将多条相交直线选中,然后全部打断,高手指点下 有什么好办法???最好是c#的 ,万分感谢!!! 你是要怎么处理:在焦点中把线断开? 如果你是做测绘的,可以用autodesk map 怎么个打断法?要说清楚! //仅适用于同一平面上的直线 [commandmethod("mtest")] public void m_test() { editor m_ed = autodesk.autocad.applicationservices.application.documentmanager.mdiactivedocument.editor; database m_db = hostapplicationservices.workingdatabase; m_ed.writemessage("\n请选择相交的直线:"); promptselectionoptions m_pso = new promptselectionoptions(); m_pso.allowduplicates = false; selectionfilter m_sf = new selectionfilter(new typedvalue[] { new typedvalue(0, "line") }); promptselectionresult m_psr = m_ed.getselection(m_pso,m_sf); if (m_psr.status != promptstatus.ok) return; list<objectid> m_objids=new list<objectid>(); for (int i = 0; i < m_psr.value.count; i++) m_objids.add((objectid)(m_psr.value.getobjectids())[i]); using (transaction m_tr = m_db.transactionmanager.starttransaction()) { blocktablerecord m_btr = (blocktablerecord)m_tr.getobject(m_db.currentspaceid, openmode.forwrite, false); dbobjectcollection m_newlines = new dbobjectcollection(); start: objectid m_objid = m_objids[0]; line m_line1 = (line)m_tr.getobject(m_objid, openmode.forwrite); list<oint3d> m_pts =new list<oint3d>(); for (int i = 1; i < m_objids.count; i++) { line m_line2 = (line)m_tr.getobject(m_objids, openmode.forwrite); point3dcollection m_interpts = new point3dcollection(); m_line1.intersectwith(m_line2, intersect.onbothoperands, m_interpts, 0, 0); if (m_interpts.count > 0) foreach (point3d pt in m_interpts) if (!m_line1.startpoint.equals(pt) && !m_line1.endpoint.equals(pt) && !m_pts.contains(pt)) m_pts.add(pt); } if (m_pts.count > 0) { if (m_pts.count > 1) { //按各点到直线起点的距离从小到大排序 m_pts.sort(delegate(point3d a, point3d b) { return a.distanceto(m_line1.startpoint).compareto(b.distanceto(m_line1.startpoint));}); } point3dcollection m_splitepts = new point3dcollection(); foreach (point3d pt in m_pts) m_splitepts.add(pt); m_newlines = m_line1.getsplitcurves(m_splitepts); foreach (entity m_newline in m_newlines) { m_objids.add(m_btr.appendentity(m_newline)); m_tr.addnewlycreateddbobject(m_newline, true); } m_line1.erase(); } m_objids.remove(m_objid); if (m_objids.count > 1) goto start; m_tr.commit(); } } 复制代码 [ |
| 所有的时间均为北京时间。 现在的时间是 08:10 AM. |