通过鼠标光标悬停高亮显示闭合多段线
当我将光标悬停在组成闭合多段线的多段线上时,我试图生成临时图案填充和文本。文本将显示区域等。现在,显示沿周长的简单白色多段线
参见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();
public static void StartMonitor()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
ed.PointMonitor += new PointMonitorEventHandler(ed_PointMonitor);
}
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, collectints);
m_markers.Dispose();
}
m_markers.Clear();
}
}
}
**** Hidden Message ***** 一种方法是获取所有模型空间封闭折线的选择集,检查当前光标位置是否在其中一条内,然后突出显示折线并显示阴影/文本。我可能还会获取折线的几何范围,这样它就不会在dwg的其他地方不断检查点在里面。我在C3D走廊中突出显示区域时也做了类似的事情。 经过反复试验,我使用SendStringToExecute将CLIPROMPTLINES设置为0。程序完成后,我对其进行了编码以恢复到默认值。不是一个非常干净的解决方案,但似乎有效。
感谢Jeff_M的建议-我接下来会考虑这样做 您可以在代码中设置sysvar,而不必求助于sendstringtoexecute。一个更好的sysvar可能是NOMUTT。
应用。SetSystemVariable("NOMUTT ",1);//完成后重置为0
页:
[1]