private static void OnPointMonitor(object sender, PointMonitorEventArgs e) { if ((e.Context.History & PointHistoryBits.FromKeyboard) == PointHistoryBits.FromKeyboard) { return; } var paths = e.Context.GetPickedEntities(); if (paths == null || paths.Length == 0) { return; } var ids = paths[0].GetObjectIds(); if (ids == null || ids.Length != 1) { return; } var id = ids[0]; e.AppendToolTipText($"{id.ObjectClass.Name}\nHandle Pointer : {id.Handle.Value}"); }
static void ed_PointMonitor(object sender, PointMonitorEventArgs e) { string blockInfo = ""; //用于存储块参照的信息:名称和个数 //获取命令行对象(鼠标监视事件的发起者),用于获取文档对象 Editor ed = (Editor)sender; Document doc = ed.Document; //获取鼠标停留处的实体 FullSubentityPath[] paths = e.Context.GetPickedEntities(); try { using (Transaction trans = doc.TransactionManager.StartTransaction()) { //如果鼠标停留处有实体 if (paths.Length > 0) { //获取鼠标停留处的实体 FullSubentityPath path = paths[0]; BlockReference blockRef = trans.GetObject(path.GetObjectIds()[0], OpenMode.ForRead) as BlockReference; if (blockRef != null)//如果鼠标停留处为块参照 { //获取块参照所属的块表记录并以写的方式打开 //ObjectId blockId = blockRef.BlockTableRecord; ObjectId blockId = path.GetObjectIds()[0]; //BlockTableRecord btr = trans.GetObject(blockId, OpenMode.ForRead) as BlockTableRecord; long fid = 0, fno = 0, id = 0; PublicMethod.GetInfoByObjid(blockId, ref id, ref fid, ref fno); //获取属于同一块表记录的所有块参照 //ObjectIdCollection ids = btr.GetBlockReferenceIds(true, false); //若鼠标停留处的块参照的块表记录与上一次的不同 if (preBlockId != blockId) { preBlockId = blockId;//重新设置块表记录名 } string fnoName = default(string); if (fno != 0) { fnoName = FeatureMapping.instance.features[fno.ToString()]; } blockInfo += "FID : " + fid.ToString() + "\n设备类型 : " + fnoName; } } trans.Commit(); } } catch (Autodesk.AutoCAD.Runtime.Exception ex) { ed.WriteMessage(ex.Message); } if (blockInfo != "") { e.AppendToolTipText(blockInfo);//在鼠标停留处显示提示信息 } }
static void ed_PointMonitor(object sender, PointMonitorEventArgs e) { string blockInfo = ""; //用于存储块参照的信息:名称和个数 //获取命令行对象(鼠标监视事件的发起者),用于获取文档对象 Editor ed = (Editor)sender; Document doc = ed.Document; InputPointContext ic = e.Context; //获取鼠标停留处的实体 FullSubentityPath[] paths = e.Context.GetPickedEntities(); using (Transaction trans = doc.TransactionManager.StartTransaction()) { //如果鼠标停留处有实体 if (paths.Length > 0) { //获取鼠标停留处的实体 FullSubentityPath path = paths[0]; BlockReference blockRef = trans.GetObject(path.GetObjectIds()[0], OpenMode.ForRead) as BlockReference; if (blockRef != null)//如果鼠标停留处为块参照 { //获取块参照所属的块表记录并以写的方式打开 ObjectId blockId = blockRef.BlockTableRecord; BlockTableRecord btr = trans.GetObject(blockId, OpenMode.ForRead) as BlockTableRecord; //获取属于同一块表记录的所有块参照 ObjectIdCollection ids = btr.GetBlockReferenceIds(true, false); //若鼠标停留处的块参照的块表记录与上一次的不同 Entity ent = null; if (ids.Count >= 0) { ent = trans.GetObject(ids[0], OpenMode.ForRead) as Entity; } if (ent != null && blockName != btr.Name || ent.HighlightState(path) == HighlightStyle.None) { blockName = btr.Name; //重新设置块表记录名 blockIds.UnHighlightEntities(); //取消上一次块表记录的块参照的亮显 blockIds.Clear(); //清空块参照ObjectId列表 blockIds = ids; //设置需要亮显的块参照的ObjectId列表 blockIds.HighlightEntities(); //亮显所有同名的块参照 } blockInfo += "块名:" + btr.Name + "\n个数:" + blockIds.Count.ToString(); } } trans.Commit(); } if (blockInfo != "") { e.AppendToolTipText(blockInfo);//在鼠标停留处显示提示信息 } }
public static void ed_PointMonitor(object sender, PointMonitorEventArgs e) { try { if (mouse.acadVer.Contains("R18.0")) { var paths = e.Context.GetPickedEntities(); if (!paths.Any()) { return; } long id = 0, fid = 0, fno = 0; string blockInfo = ""; //用于存储块参照的信息:名称和个数 string strFno = ""; //获取命令行对象(鼠标监视事件的发起者),用于获取文档对象 //获取鼠标停留处的实体 using ( var trans = HostApplicationServices.WorkingDatabase.GetDocument().TransactionManager.StartTransaction()) { //如果鼠标停留处有实体 if (paths.Length > 0) { //获取鼠标停留处的实体 var path = paths[0]; if (DBEntityFinder.Instance.GetG3EIds(path.GetObjectIds()[0], ref id, ref fid, ref fno)) { if (FeatureMapping.instance.features.ContainsKey(fno.ToString())) { strFno = FeatureMapping.instance.features[fno.ToString()]; } blockInfo = string.Format("FNO:{0}\nFID:{1}\n设备类型:{2}", fno, fid, strFno); } } trans.Commit(); } if (blockInfo != "") { e.AppendToolTipText(blockInfo); //在鼠标停留处显示提示信息 } } } catch (System.Exception ex) { PublicMethod.Instance.Editor.WriteMessageWithReturn(ex); } }
private void Ed_PointMonitor(object sender, PointMonitorEventArgs e) { Editor ed = (Editor)sender; FullSubentityPath[] paths = e.Context.GetPickedEntities(); string toolTipText = string.Empty; if (paths.Length > 0) { using (var trans = Db.TransactionManager.StartTransaction()) { MText mText = trans.GetObject(paths[0].GetObjectIds()[0], OpenMode.ForRead) as MText; if (mText != null) { TypedValue[] arrTV = mText.GetXDataForApplication(appName)?.AsArray(); if (arrTV != null) { toolTipText += "员工编号:" + arrTV[1].Value + "\n职位:" + arrTV[2].Value.ToString(); } } trans.Commit(); } if (!String.IsNullOrEmpty(toolTipText)) { e.AppendToolTipText(toolTipText); string s = e.Context.ToolTipText; } } }
private static void Ed_PointMonitor(object sender, [NotNull] PointMonitorEventArgs e) { e.AppendToolTipText(DateTime.Now.ToString()); }