当我将光标悬停在组成闭合多段线的多段线上时,我试图生成临时图案填充和文本。文本将显示区域等。
现在,显示沿周长的简单白色多段线
参见GIF:
我正在成功使用编辑器。TraceBoundary()但是,每当可以/无法找到闭合边界时,它都会在命令编辑器框中生成消息
是否有任何方法关闭此功能?否则,是否有其他方法实现此功能?
- using Autodesk.AutoCAD.ApplicationServices;
- using Autodesk.AutoCAD.DatabaseServices;
- using Autodesk.AutoCAD.EditorInput;
- using Autodesk.AutoCAD.Geometry;
- using Autodesk.AutoCAD.Runtime;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using aGi = Autodesk.AutoCAD.GraphicsInterface;
- namespace Test
- {
- public class PointMonitorTooltips
- {
- private static DBObjectCollection m_markers = new DBObjectCollection();
- private static IntegerCollection collectints = new IntegerCollection();
- [CommandMethod("starto")]
- public static void StartMonitor()
- {
- Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
- ed.PointMonitor += new PointMonitorEventHandler(ed_PointMonitor);
- }
- [CommandMethod("stopo")]
- public static void stopmonitor()
- {
- Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
- ed.PointMonitor -= ed_PointMonitor;
- ClearMarkers();
- }
- static void ed_PointMonitor(object sender, PointMonitorEventArgs e)
- {
- showRegionHatch(e.Context.RawPoint);
- }
- static void showRegionHatch(Point3d pt)
- {
- ClearMarkers();
- Document doc = Application.DocumentManager.MdiActiveDocument;
- Database db = doc.Database;
- Editor edt = doc.Editor;
- var objs = edt.TraceBoundary(pt, false);
- if (objs == null || objs.Count == 0)
- return;
- // If we have some geometry, create a Region from it
- try
- {
- var regstest = Region.CreateFromCurves(objs);
- }
- catch (Autodesk.AutoCAD.Runtime.Exception Ex)
- {
- Application.ShowAlertDialog("Error");
- }
- var regs = Region.CreateFromCurves(objs);
- if (regs == null || regs.Count == 0)
- return;
- foreach (Region reg in regs)
- {
- DBObjectCollection dbocRegionPolylines = Extensions.PolylineFromRegion(reg);
- foreach (Entity ent in dbocRegionPolylines)
- {
- m_markers.Add(ent);
- aGi.TransientManager.CurrentTransientManager.AddTransient(ent, aGi.TransientDrawingMode.DirectShortTerm, 128, collectints);
- }
- }
- }
- static void ClearMarkers()
- {
- for (int i = 0; i < m_markers.Count; i++)
- {
- aGi.TransientManager.CurrentTransientManager.EraseTransient(m_markers[i], collectints);
- m_markers[i].Dispose();
- }
- m_markers.Clear();
- }
- }
- }
本帖以下内容被隐藏保护;需要你回复后,才能看到! 游客,如果您要查看本帖隐藏内容请 回复 |