public void DrawFace()
        {
            DbCircle body = new DbCircle();

            body.Center = new Point3d(200, 200, 0);
            body.Radius = 105;
            body.DbEntity.AddToCurrentDocument();
            DbCircle eye1 = new DbCircle();

            eye1.Center = new Point3d(150, 255, 0);
            eye1.Radius = 8;
            eye1.DbEntity.AddToCurrentDocument();

            DbCircle pupil1 = new DbCircle();

            pupil1.Center = new Point3d(148, 254, 0);
            pupil1.Radius = 2;
            pupil1.DbEntity.AddToCurrentDocument();

            DbCircle eye2 = new DbCircle();

            eye2.Center = new Point3d(250, 260, 0);
            eye2.Radius = 8;
            eye2.DbEntity.AddToCurrentDocument();
            DbCircle pupil2 = new DbCircle();

            pupil2.Center = new Point3d(252, 258, 0);
            pupil2.Radius = 2;
            pupil2.DbEntity.AddToCurrentDocument();

            DbLine hand1 = new DbLine();

            hand1.StartPoint = new Point3d(102, 239, 0);
            hand1.EndPoint   = new Point3d(72, 183, 0);
            hand1.DbEntity.AddToCurrentDocument();

            DbLine hand2 = new DbLine();

            hand2.StartPoint = new Point3d(298, 236, 0);
            hand2.EndPoint   = new Point3d(325, 192, 0);
            hand2.DbEntity.AddToCurrentDocument();

            DbPolyline     nose       = new DbPolyline();
            List <Point3d> nosePoints = new List <Point3d>()
            {
                new Point3d(171, 222, 0), new Point3d(198, 177, 0), new Point3d(231, 222, 0)
            };

            nose.Polyline = new Polyline3d(nosePoints);
            nose.Polyline.SetClosed(false);
            nose.DbEntity.Transform(McDocumentsManager.GetActiveDoc().UCS); //change coordinates from UCS to WCS for BD
            nose.DbEntity.AddToCurrentDocument();

            DbText spech = new DbText();

            spech.Text = new TextGeom("Hello Habr!", new Point3d(310, 55, 0), Vector3d.XAxis, "Standard", 25);
            spech.DbEntity.AddToCurrentDocument();
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public void DrawFace()
        {
            //We draw half of face

            // Draw eye
            DbCircle eye = new DbCircle();

            eye.Radius = 100;
            eye.Center = new Point3d(200, 500, 0);
            eye.DbEntity.AddToCurrentDocument();

            //Draw nose
            DbLine nose = new DbLine();

            nose.StartPoint = new Point3d(350, 400, 0);
            nose.EndPoint   = new Point3d(350, 200, 0);
            nose.DbEntity.AddToCurrentDocument();

            //Draw mouth
            DbPolyline     mouth       = new DbPolyline();
            List <Point3d> mouthPoints = new List <Point3d>()
            {
                new Point3d(100, 150, 0), new Point3d(200, 100, 0), new Point3d(350, 100, 0)
            };

            mouth.Polyline = new Polyline3d(mouthPoints);
            mouth.Polyline.SetClosed(false);
            mouth.DbEntity.Transform(McDocumentsManager.GetActiveDoc().UCS); //change coordinates from UCS to WCS for BD
            mouth.DbEntity.AddToCurrentDocument();

            //draw mirror half the face (2nd half)

            DbCircle eye2 = new DbCircle();

            eye2.Radius = 100;
            eye2.Center = new Point3d(500, 500, 0);
            eye2.DbEntity.AddToCurrentDocument();

            DbPolyline mouth2 = new DbPolyline();

            mouth2.Polyline = mouth.Polyline.Mirror(new Plane3d(new Point3d(350, 100, 0), new Vector3d(200, 0, 0))) as Polyline3d;
            mouth2.DbEntity.AddToCurrentDocument();

            //Get notification in command line
            McContext.ShowNotification("You need to enter data into the console");


            //Get uaser input
            InputJig editorInput = new InputJig();
            string   name        = editorInput.GetText("Input your name and press Enter");

            //Drawing face's text
            DbText spech = new DbText();

            spech.Text = new TextGeom("Oh Master! Why I'm so ugly? Please remove me!", new Point3d(510, 15, 0), Vector3d.XAxis, "Standard", 15);
            spech.DbEntity.AddToCurrentDocument();


            //Get windows message box
            MessageBox.Show("Congratulation " + name + " you did it! But look, it want, to say something to you...");

            //Get popup help
            McContext.PopupNotification("Delete command has activated");

            //Activate another command (Delete)
            McContext.ExecuteCommand("Delete");
        }