Пример #1
0
        public override hresult PlaceObject(PlaceFlags lInsertType)
        {
            InputJig jig = new InputJig();

            // Get the first box point from the jig
            InputResult res = jig.GetPoint("Select first point:");

            if (res.Result != InputResult.ResultCode.Normal)
            {
                return(hresult.e_Fail);
            }
            _pnt1 = res.Point;

            // Add the object to the database
            this.DbEntity.AddToCurrentDocument();

            //Exclude the object from snap points
            jig.ExcludeObject(ID);

            // Monitoring mouse moving and interactive entity redrawing
            jig.MouseMove = (s, a) => { TryModify(); _pnt2 = a.Point; this.DbEntity.Update(); };

            // Get the second box point from the jig
            res = jig.GetPoint("Select second point:");
            if (res.Result != InputResult.ResultCode.Normal)
            {
                this.DbEntity.Erase();
                return(hresult.e_Fail);
            }
            _pnt2 = res.Point;

            return(hresult.s_Ok);
        }
Пример #2
0
        public override hresult PlaceObject(PlaceFlags lInsertType)
        {
            InputJig    jig = new InputJig();
            InputResult res = jig.GetPoint("Select first point:");

            if (res.Result != InputResult.ResultCode.Normal)
            {
                return(hresult.e_Fail);
            }
            _pnt = res.Point;
            DbEntity.AddToCurrentDocument();
            //Exclude this from osnap to avoid osnap to itself
            jig.ExcludeObject(ID);
            //Monitor mouse move
            jig.MouseMove = (s, a) => {
                TryModify();
                _pnt2 = a.Point;
                _pnt3 = new Point3d(_pnt2.X, _pnt.Y, 0);
                _pnt1 = new Point3d(_pnt.X, _pnt2.Y, 0);
                DbEntity.Update();
            };

            res = jig.GetPoint("Select second point:", res.Point);
            if (res.Result != InputResult.ResultCode.Normal)
            {
                DbEntity.Erase();
                return(hresult.e_Fail);
            }
            _pnt2 = res.Point;
            _pnt1 = new Point3d(_pnt.X, _pnt2.Y, 0);
            _pnt3 = new Point3d(_pnt2.X, _pnt.Y, 0);
            return(hresult.s_Ok);
        }
Пример #3
0
        public override hresult PlaceObject(PlaceFlags lInsertType)
        {
            InputJig    jig = new InputJig();
            InputResult res = jig.GetPoint("Select first point:");

            if (res.Result != InputResult.ResultCode.Normal)
            {
                return(hresult.e_Fail);
            }
            poly = new Polyline3d();
            poly.Vertices.AddVertex(res.Point);
            poly.Vertices.AddVertex(res.Point);
            _textPoint = new Point3d(res.Point.X, res.Point.Y - 5 - Thickness, 0);
            Polyline3d.VertexDataOfPolyline polyVertecies = poly.Vertices;

            //_points.Add(res.Point);
            //_points.Add(res.Point); //Bug double?
            DbEntity.AddToCurrentDocument();
            //Exclude this from osnap to avoid osnap to itself
            jig.ExcludeObject(ID);
            //Monitor mouse move
            jig.MouseMove = (s, a) => {
                TryModify();
                //_points[_points.Count-1] = a.Point;
                //polyVertecies[polyVertecies.Count - 1].Point = a.Point;
                polyVertecies.RemoveVertexAt(uint.Parse((polyVertecies.Count - 1).ToString()));
                polyVertecies.AddVertex(a.Point);

                DbEntity.Update();
            };
            while (res.Result == InputResult.ResultCode.Normal)
            {
                res = jig.GetPoint("Select next point(" + polyVertecies.Count + "):", res.Point);
                //_points.Add(res.Point);
                poly.Vertices.AddVertex(res.Point);
            }
            DbEntity.Erase();

            polyVertecies.RemoveVertexAt(uint.Parse((polyVertecies.Count - 1).ToString()));
            polyVertecies.RemoveVertexAt(uint.Parse((polyVertecies.Count - 1).ToString()));
            DbEntity.AddToCurrentDocument();

            return(hresult.s_Ok);
        }
Пример #4
0
        public override hresult PlaceObject(PlaceFlags lInsertType)
        {
            InputJig          jig           = new InputJig();
            List <McObjectId> SelectObjects = jig.SelectObjects("Select Object");

            //InputResult res = jig.SelectObject("Select a Polyline");
            //McObjectId id = SelectObjects[0];//.ObjectId;
            //DbGeometry selection = id.GetObject();
            if (SelectObjects.Count == 0)
            {
                DbEntity.Erase();
                return(hresult.e_Fail);
            }

            McDocument document = McDocumentsManager.GetActiveDoc();
            McDocument block    = document.CreateBlock("ArrayBlock", true);

            _block_name = block.Name;

            InputResult res = jig.GetPoint("Select Base Point:");

            foreach (McObjectId obj in SelectObjects)
            {
                McDbObject item = obj.GetObject();
                item.Entity.DbEntity.Transform(Matrix3d.Displacement(res.Point.GetAsVector().MultiplyBy(-1)));
                block.AddObject(item.Clone());
            }

            _idRef = document.GetBlock(_block_name);

            res = jig.GetPoint("Select first point:");
            if (res.Result != InputResult.ResultCode.Normal)
            {
                return(hresult.e_Fail);
            }
            _pnt1 = res.Point;
            foreach (McObjectId obj in SelectObjects)
            {
                McDbObject item = obj.GetObject();
                item.Erase();
            }

            McBlockRef blockref = new McBlockRef();

            blockref.BlockName   = _block_name;
            blockref.InsertPoint = res.Point;
            blockref.DbEntity.AddToCurrentDocument();
            _blockRef.Add(blockref);
            _blockRef.Add(_blockRef[0].DbEntity.Clone());
            _blockRef.Add(_blockRef[0].DbEntity.Clone());
            DbEntity.AddToCurrentDocument();
            //Exclude this from osnap to avoid osnap to itself
            jig.ExcludeObject(ID);
            //Monitor mouse move
            jig.MouseMove = (s, a) => {
                TryModify();
                _pnt2 = a.Point;
                DbEntity.Update();
            };

            res = jig.GetPoint("Select second point:", res.Point);
            if (res.Result != InputResult.ResultCode.Normal)
            {
                DbEntity.Erase();
                blockref.DbEntity.Erase();
                return(hresult.e_Fail);
            }
            _pnt2 = res.Point;

            Editor ed = HostMgd.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            PromptIntegerOptions opts = new PromptIntegerOptions("Enter Count number: ");

            opts.AllowNegative = false;
            opts.AllowZero     = false;
            opts.DefaultValue  = 1;
            PromptIntegerResult pr = ed.GetInteger(opts);

            if (PromptStatus.OK == pr.Status)
            {
                ed.WriteMessage("You entered: " + pr.StringResult);
                _count = pr.Value;

                _blockRef.Add(blockref.DbEntity.Clone());
                _blockRef[1].InsertPoint = res.Point;
                _blockRef[1].DbEntity.AddToCurrentDocument();
            }
            else
            {
                _count = 1;

                _blockRef.Add(blockref.DbEntity.Clone());
                _blockRef[1].InsertPoint = res.Point;
                _blockRef[1].DbEntity.AddToCurrentDocument();
            }

            for (int i = 1; i < Count; i++)
            {
                _blockRef.Add(_blockRef[0].DbEntity.Clone());
            }

            return(hresult.s_Ok);
        }