Exemplo n.º 1
0
        void AnchorDeviationsCmdForm_PointMonitor(object sender, PointMonitorEventArgs e)
        {
            //e.AppendToolTipText("Игорь - это проверка)))");
            BlockReference hBr;
            BlockReference vBr;

            using (Transaction trans = Tools.StartTransaction())
            {
                hBr = (BlockReference)arrowHorizontalId.GetObject(OpenMode.ForRead, true, true);
                vBr = (BlockReference)arrowVerticalId.GetObject(OpenMode.ForRead, true, true);
            }
            BlockReference copyHBr = this.arrowHorizontal.GetRedirectBlockReferenceCopy(hBr, e.Context.ComputedPoint);
            BlockReference copyVBr = this.arrowVertical.GetRedirectBlockReferenceCopy(vBr, e.Context.ComputedPoint);

            if (transient == null)
            {
                transient = new display.DynamicTransient();
            }
            transient.ClearTransientGraphics();

            if (copyHBr != null)
            {
                transient.AddMarker(copyHBr, arrowHorizontal.BlockName);
            }
            if (copyVBr != null)
            {
                transient.AddMarker(copyVBr, arrowVertical.BlockName);
            }

            transient.Display();
        }
Exemplo n.º 2
0
 event_PointMonitor(object sender, PointMonitorEventArgs e)
 {
     PrintEventMessage(sender, "Point Monitor");
     if (m_showDetails)
     {
     }
 }
Exemplo n.º 3
0
        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}");
        }
        private void AddNewVertex_EdOnPointMonitor(object sender, PointMonitorEventArgs pointMonitorEventArgs)
        {
            try
            {
                if (GripLeftPoint.HasValue)
                {
                    Line leftLine = new Line(GripLeftPoint.Value, pointMonitorEventArgs.Context.ComputedPoint)
                    {
                        ColorIndex = 150
                    };
                    pointMonitorEventArgs.Context.DrawContext.Geometry.Draw(leftLine);
                }

                if (GripRightPoint.HasValue)
                {
                    Line rightLine = new Line(pointMonitorEventArgs.Context.ComputedPoint, GripRightPoint.Value)
                    {
                        ColorIndex = 150
                    };
                    pointMonitorEventArgs.Context.DrawContext.Geometry.Draw(rightLine);
                }
            }
            catch
            {
                // ignored
            }
        }
Exemplo n.º 5
0
        void editor_PointMonitor(object sender, PointMonitorEventArgs e)
        {
            Document activeDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            double   viewSize
                = (double)Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("VIEWSIZE");

            Point3d viewCtr
                = (Point3d)Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("VIEWCTR");

            Point3d viewDir
                = (Point3d)Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("VIEWDIR");

            // Simple check to verify if the view parameters changed
            // since we last drew the transient graphics
            if (viewSize != _viewSize ||
                viewCtr.Equals(_viewCtr) == false ||
                viewDir.Equals(_viewDir) == false
                )
            {
                _viewSize = viewSize;

                _viewCtr = (Point3d)Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("VIEWCTR");

                _viewDir = viewDir;
                Editor edit = sender as Editor;
                edit.WriteMessage(_viewCtr.ToString());
                // Draw the transient graphics again since
                // the view parameters seem to have changed
                // DrawTransientRectMethod();
            }
            //throw new NotImplementedException();
        }
Exemplo n.º 6
0
        ed_PointMonitorTP(object sender, PointMonitorEventArgs e)
        {
            Editor ed = BaseObjs._editor;

            if (!e.Context.PointComputed)
            {
                return;
            }
            if (gp.idLine != ObjectId.Null)
            {
                gp.idLine.delete();
            }

            Point3d pnt3dBEG = gp.pnt3d1;
            Point3d pnt3dEND = gp.pnt3d2;

            pnt3dBEG = new Point3d(pnt3dBEG.X, pnt3dBEG.Y, 0);
            pnt3dEND = new Point3d(pnt3dEND.X, pnt3dEND.Y, 0);

            Point3d pnt3dPick = e.Context.ComputedPoint;

            gp.pnt3dX = gc.calcBasePnt3d(pnt3dPick, pnt3dBEG, pnt3dEND);
            if (gp.pnt3dX == Pub.pnt3dO)
            {
                return;
            }

            gp.idLine = Draw.addLine(gp.pnt3dX, pnt3dPick);
        }
Exemplo n.º 7
0
        private void Ed_PointMonitor(object sender, PointMonitorEventArgs e)
        {
            try
            {
                var     fsPaths   = e.Context.GetPickedEntities();
                var     pickedPt  = e.Context.ComputedPoint;
                Point2d pixels    = e.Context.DrawContext.Viewport.GetNumPixelsInUnitSquare(e.Context.RawPoint);
                int     glyphSize = CustomObjectSnapMode.GlyphSize;
                glyphHeight = glyphSize / pixels.Y * 1.0;

                radius = glyphHeight / 2.0;
                center = e.Context.RawPoint + new Vector3d(3 * radius, 3 * radius, 0);

                // nothing under the mouse cursor.
                if (fsPaths == null || fsPaths.Length == 0)
                {
                    if (currentId != ObjectId.Null)
                    {
                        EraseTransientGraphics();
                        currentId = ObjectId.Null;
                    }
                    return;
                }
                var oIds = fsPaths[0].GetObjectIds();
                var id   = oIds[oIds.GetUpperBound(0)];

                // hovering over the same object.
                if (currentId == id)
                {
                    UpdateTransientGraphics();
                }
                else
                {
                    using (Transaction trans = db.TransactionManager.StartTransaction())
                    {
                        Polyline pline = trans.GetObject(id, OpenMode.ForRead) as Polyline;
                        EraseTransientGraphics();

                        if (pline == null)
                        {
                            strCurrentShape = "X";
                            AddTransientGraphics("X");
                        }
                        else
                        {
                            strCurrentShape = "V";
                            AddTransientGraphics("V");
                        }
                        currentId = id;
                    }
                }
            }
            catch (Autodesk.AutoCAD.Runtime.Exception ex)
            {
                ed.WriteMessage(ex.Message);
            }
            finally
            {
            }
        }
 private void ed_PointMonitor(object sender, PointMonitorEventArgs e)
 {
     if (!e.Context.PointComputed)
     {
         return;
     }
     this.SetNewSize();
 }
Exemplo n.º 9
0
            //EVENT HANDLER
            private void Editor_PointMonitor(object sender, PointMonitorEventArgs e)
            {
                Point3d Currpoint = e.Context.ComputedPoint;

                if (drawline)
                {
                    reDraw_PreviewLine(Currpoint);
                }
            }
Exemplo n.º 10
0
        void ed_PointMonitor(object sender, PointMonitorEventArgs e)
        {
            Point3d ptLast = e.Context.LastPoint;

            if (ptLast != Point3d.Origin && m_pts.Contains(e.Context.LastPoint) == false)
            {
                m_pts.Add(ptLast);
            }
        }
 private void ed_PointMonitor(object sender, PointMonitorEventArgs e)
 {
     if (!e.Context.PointComputed)
     {
         return;
     }
     this.CheckForUpdates();
     this.CheckForUpdates();
 }
Exemplo n.º 12
0
        void ed_PointMonitor(object sender, PointMonitorEventArgs e)
        {
            if (!e.Context.PointComputed)
            {
                return;
            }

            MonitoredPoint = e.Context.ComputedPoint;
        }
        private static void Arc2Line_EdOnPointMonitor(object sender, PointMonitorEventArgs pointMonitorEventArgs)
        {
            var ed  = (Editor)sender;
            var doc = ed.Document;

            try
            {
                var paths = pointMonitorEventArgs.Context.GetPickedEntities();

                using (var tr = doc.TransactionManager.StartTransaction())
                {
                    using (doc.LockDocument())
                    {
                        foreach (var path in paths)
                        {
                            var ids = path.GetObjectIds();

                            if (ids.Length > 0)
                            {
                                var id  = ids[ids.GetUpperBound(0)];
                                var obj = tr.GetObject(id, OpenMode.ForRead);
                                if (obj is Polyline polyline)
                                {
                                    var p     = polyline.GetClosestPointTo(pointMonitorEventArgs.Context.ComputedPoint, false);
                                    var param = polyline.GetParameterAtPoint(p);
                                    var vx    = Convert.ToInt32(Math.Truncate(param));
                                    if (polyline.GetSegmentType(vx) == SegmentType.Arc)
                                    {
                                        var nextVx = vx + 1;
                                        if (vx == polyline.NumberOfVertices - 1)
                                        {
                                            if (polyline.Closed)
                                            {
                                                nextVx = 0;
                                            }
                                        }

                                        var line = new Line(
                                            polyline.GetPoint3dAt(vx),
                                            polyline.GetPoint3dAt(nextVx))
                                        {
                                            ColorIndex = PlinesEditFunction.HelpGeometryColor
                                        };
                                        pointMonitorEventArgs.Context.DrawContext.Geometry.Draw(line);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
                // ignored
            }
        }
Exemplo n.º 14
0
        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);//在鼠标停留处显示提示信息
            }
        }
Exemplo n.º 15
0
 private void callback_PointMonitor(object sender, PointMonitorEventArgs e)
 {
     try
     {
         WriteLine(String.Format("PointMonitor - {0}", e.Context.ComputedPoint));
     }
     catch (System.Exception ex)
     {
         Helper.Message(ex);
     }
 }
Exemplo n.º 16
0
        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);//在鼠标停留处显示提示信息
            }
        }
Exemplo n.º 17
0
 private void EditorOnPointMonitor(object sender, PointMonitorEventArgs args)
 {
     lock (_lock) {
         InputPointContext = args.Context;
         Cursor            = args.Context.RawPoint;
         if (args.Context.PointComputed)
         {
             ComputedCursor = args.Context.ComputedPoint;
         }
         else
         {
             ComputedCursor = null;
         }
     }
 }
Exemplo n.º 18
0
        //point Monitor callback
        static void ed_PointMonitor(object sender, PointMonitorEventArgs e)
        {
            FullSubentityPath[] entPaths = e.Context.GetPickedEntities();

            if (entPaths.Length > 0)
            {
                //entity present below cursor, so show Transient points
                FullSubentityPath entPath = entPaths[0];
                AddOrModifyTGPoints(entPath.GetObjectIds()[0]);
            }
            else
            {
                //No entity present below cursor, so erase Transient points
                eraseTGPoints();
            }
        }
Exemplo n.º 19
0
 void Editor_PointMonitor(object sender, PointMonitorEventArgs e)
 {
     if (drawPreviewCircle)
     {
         previewCircle.Center = circleCenter;
         if (circleCenter.DistanceTo(e.Context.ComputedPoint) != 0)
         {
             previewCircle.Visible = true;
             previewCircle.Radius  = circleCenter.DistanceTo(e.Context.ComputedPoint);
         }
         else
         {
             previewCircle.Visible = false;
         }
     }
 }
Exemplo n.º 20
0
 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);
     }
 }
Exemplo n.º 21
0
        public void GetMousePoint(object sender, PointMonitorEventArgs e)
        {
            Document mdiActiveDocument = Application.DocumentManager.MdiActiveDocument;

            try
            {
                if (this.point3dCollection_0.Count >= 1)
                {
                    this.AddPline1(this.point3dCollection_0, 250.0, "注释");
                }
                this.point3dCollection_0.Add(e.Context.RawPoint);
            }
            catch (Exception ex)
            {
                Interaction.MsgBox(ex.Message, MsgBoxStyle.OkOnly, null);
            }
        }
Exemplo n.º 22
0
 public void GetMousePoint(object sender, PointMonitorEventArgs e)
 {
     try
     {
         this.point3d_5 = e.Context.RawPoint;
         Point3d point3d;
         if (this.point3d_5 != point3d)
         {
             Random random = new Random();
             this.double_4 = 1.0 + random.NextDouble();
             ObjectId objectId = this.polyline_0.ObjectId;
             Point3d  minPoint = this.polyline_0.GeometricExtents.MinPoint;
             Point3d  targetPt;
             targetPt..ctor(this.point3d_5.X, this.point3d_3.Y, 0.0);
             CAD.EntMove(objectId, minPoint, targetPt);
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 23
0
        void FindUsingPointMonitor(object sender, PointMonitorEventArgs e)
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

            // Not working when running editor selection
            //foreach (var subId in e.Context.GetPickedEntities())
            //{
            //    foreach (var id in subId.GetObjectIds())
            //    {
            //        ed.WriteMessage("\n - " +
            //            " Entity: " + id.ObjectClass.Name +
            //            " Id: " + id.ToString());
            //    }
            //}

            var ids = FindAtPoint(e.Context.RawPoint);

            foreach (var id in ids)
            {
                ed.WriteMessage("\n + " +
                                " Entity: " + id.ObjectClass.Name +
                                " Id: " + id.ToString());
            }
        }
Exemplo n.º 24
0
        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;
                }
            }
        }
Exemplo n.º 25
0
        void PointMonitorMulti(object sender, PointMonitorEventArgs e)
        {
            //Filters only block references (INSERT)
            //that are on layer "0"

            ResultBuffer resbuf = new ResultBuffer(
                new TypedValue(-4, "<and"),
                new TypedValue(0, "INSERT"),
                new TypedValue(8, "0"),
                new TypedValue(-4, "and>"));

            ObjectId[] ids = FindAtPointNested(
                _ed.Document,
                e.Context.RawPoint,
                true,
                resbuf.UnmanagedObject);

            //Dump result to commandline

            foreach (ObjectId id in ids)
            {
                _ed.WriteMessage("\n - Entity: {0} [Id:{1}]", id.ObjectClass.Name, id.ToString());
            }
        }
Exemplo n.º 26
0
        ed_PointMonitorRTR(object sender, PointMonitorEventArgs e)
        {
            Editor ed = BaseObjs._editor;

            if (!e.Context.PointComputed)
            {
                return;
            }
            if (gp.idLine != ObjectId.Null)
            {
                gp.idLine.delete();
            }

            Point3dCollection pnts3d = gp.poly3dRF.getCoordinates3d();

            Point3d pnt3dBEG = pnts3d[gp.vertex + 0];
            Point3d pnt3dEND = pnts3d[gp.vertex + 1];

            pnt3dBEG = new Point3d(pnt3dBEG.X, pnt3dBEG.Y, 0);
            pnt3dEND = new Point3d(pnt3dEND.X, pnt3dEND.Y, 0);

            Point3d pnt3dPick = e.Context.ComputedPoint;

            gp.pnt3dX = gc.calcBasePnt2d(pnt3dPick, pnt3dBEG, pnt3dEND);
            if (gp.pnt3dX == Pub.pnt3dO)
            {
                gp.inBounds = false;
                return;
            }
            else
            {
                gp.inBounds = true;
            }

            gp.idLine = Draw.addLine(gp.pnt3dX, pnt3dPick);
        }
Exemplo n.º 27
0
 private void callback_PointMonitor(object sender, PointMonitorEventArgs e)
 {
     try
     {
         WriteLine(String.Format("PointMonitor - {0}", e.Context.ComputedPoint));
     }
     catch (System.Exception ex)
     {
         Helper.Message(ex);
     }
 }
Exemplo n.º 28
0
 void Editor_PointMonitor(object sender, PointMonitorEventArgs e)
 {
     CurrPoint = e.Context.ComputedPoint;
 }
        private void OnMouseMove(object sender, PointMonitorEventArgs e)
        {
            Point3d a = e.Context.RawPoint;

            DrawPoint(a);
        }
Exemplo n.º 30
0
 //EVENT HANDLER
 private void Editor_PointMonitor(object sender, PointMonitorEventArgs e)
 {
     Point3d Currpoint = e.Context.ComputedPoint;
     if (drawline)
     {
         reDraw_PreviewLine(Currpoint);
     }
 }
Exemplo n.º 31
0
        void ed_PointMonitor(object sender, PointMonitorEventArgs e)
        {
            if (!e.Context.PointComputed)
                return;

            MonitoredPoint = e.Context.ComputedPoint;
        }
Exemplo n.º 32
0
 private void ed_PointMonitor(object sender, PointMonitorEventArgs e)
 {
     _position = e.Context.ComputedPoint;
 }
Exemplo n.º 33
0
 private static void Ed_PointMonitor(object sender, [NotNull] PointMonitorEventArgs e)
 {
     e.AppendToolTipText(DateTime.Now.ToString());
 }
Exemplo n.º 34
0
 void Editor_PointMonitor(object sender, PointMonitorEventArgs e)
 {
     if (drawPreviewCircle)
     {
         previewCircle.Center = circleCenter;
         if (circleCenter.DistanceTo(e.Context.ComputedPoint) != 0)
         {
             previewCircle.Visible = true;
             previewCircle.Radius = circleCenter.DistanceTo(e.Context.ComputedPoint);
         }
         else
         {
             previewCircle.Visible = false;
         }
     }
 }
Exemplo n.º 35
0
 private void Ed_PointMonitor(object sender, PointMonitorEventArgs e)
 {
 }