Example #1
0
        //移动夹点
        public override void MoveGripPointsAt(Entity entity, GripDataCollection grips, Vector3d offset, MoveGripPointsFlags bitFlags)
        {
            LArrow la = new LArrow(entity);

            foreach (GripData gd in grips)
            {
                if (gd is LArrowGripData)
                {
                    LArrowGripData lagd = (LArrowGripData)gd;
                    lagd.Move(la, offset);
                }
            }
            //排除自定义的夹点移动,让剩下的夹点按默认规则移动
            for (int i = grips.Count - 1; i >= 0; i--)
            {
                if (grips[i] is LArrowGripData)
                {
                    grips.Remove(grips[i]);
                }
            }
            if (grips.Count > 0)
            {
                base.MoveGripPointsAt(entity, grips, offset, bitFlags);
            }
        }
Example #2
0
        //显示重载
        public override bool WorldDraw(Drawable drawable, WorldDraw wd)
        {
            LArrow la = new LArrow(drawable);

            la.WorldDraw(wd);
            return(base.WorldDraw(drawable, wd));
        }
Example #3
0
        //获取夹点,简单实体应重载该函数以获取更灵活的控制
        public override void GetGripPoints(Entity entity, GripDataCollection grips, double curViewUnitSize, int gripSize, Vector3d curViewDir, GetGripPointsFlags bitFlags)
        {
            LArrow la = new LArrow(entity);

            base.GetGripPoints(entity, grips, curViewUnitSize, gripSize, curViewDir, bitFlags);
            grips.Remove(grips[2]);
            grips.Add(new LArrowGripData(la.Position));
        }
Example #4
0
 public void Move(LArrow la, Vector3d vec)
 {
     la.Position += vec;
     la.SaveExtendedData();
 }
Example #5
0
 void IExtensionApplication.Terminate()
 {
     LArrow.OverruleEnd();
     Overrule.Overruling = false;
 }
Example #6
0
        public static void DoIt()
        {
            Document            doc       = Application.DocumentManager.MdiActiveDocument;
            Editor              ed        = doc.Editor;
            PromptDoubleOptions optDouble = new PromptDoubleOptions("\n请输入箭头长度:");

            optDouble.AllowNone       = true;
            optDouble.AllowZero       = false;
            optDouble.DefaultValue    = CurrArrowLength;
            optDouble.UseDefaultValue = true;
            PromptDoubleResult resDouble = ed.GetDouble(optDouble);

            if (resDouble.Status == PromptStatus.OK)
            {
                //改变箭头长度设定值
                CurrArrowLength = resDouble.Value;
                PromptPointResult resStartPoint = ed.GetPoint("\n请输入起点:");
                if (resStartPoint.Status == PromptStatus.OK)
                {
                    PromptPointOptions optEndPoint = new PromptPointOptions("\n请输入终点:");
                    optEndPoint.BasePoint    = resStartPoint.Value;
                    optEndPoint.UseBasePoint = true;
                    PromptPointResult resEndPoint = ed.GetPoint(optEndPoint);
                    if (resEndPoint.Status == PromptStatus.OK)
                    {
                        Point3d  startpnt = resStartPoint.Value;
                        Point3d  endpnt   = resEndPoint.Value;
                        Database db       = doc.Database;
                        using (Transaction tr = db.TransactionManager.StartTransaction())
                        {
                            BlockTableRecord btr =
                                (BlockTableRecord)tr.GetObject(
                                    db.CurrentSpaceId,
                                    OpenMode.ForWrite,
                                    false);
                            Line line = new Line(startpnt, endpnt);
                            btr.AppendEntity(line);
                            tr.AddNewlyCreatedDBObject(line, true);
                            RegAppTable rat =
                                (RegAppTable)tr.GetObject(
                                    db.RegAppTableId,
                                    OpenMode.ForRead,
                                    false);
                            if (!rat.Has(RegAppName))
                            {
                                rat.UpgradeOpen();
                                RegAppTableRecord regapp = new RegAppTableRecord();
                                regapp.Name = RegAppName;
                                rat.Add(regapp);
                                tr.AddNewlyCreatedDBObject(regapp, true);
                            }
                            Point3d midpnt = (startpnt + endpnt.GetAsVector()) / 2;
                            LArrow  la     = new LArrow(line);
                            //附着当前设定的箭头长度
                            la.ArrowLength = CurrArrowLength;
                            la.Scale       = 0.5;
                            la.SaveExtendedData();
                            tr.Commit();
                        }
                    }
                }
            }
        }
Example #7
0
 void IExtensionApplication.Initialize()
 {
     LArrow.OverruleStart();
     Overrule.Overruling = true;
 }