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();
        }
        public void numberInDwg(int inputUserTextHeight, int startNumber)
        {
            int            vertStartNum = startNumber;
            List <Point3d> Vert         = new List <Point3d>();

            Vert = this.listVertecs(plineGetFromUser);

            Vector3d forTextVector = new Vector3d(100, 0, 0);
            double   hTx           = inputUserTextHeight; // получаем от пользователя
            DbText   forDraw       = new DbText();

            for (int i = 0; i < Vert.Count; i++)
            {
                TextGeom textNumberPoint = new TextGeom(Convert.ToString(i + startNumber), Vert[i], forTextVector, "");
                textNumberPoint.Height = hTx;
                forDraw = textNumberPoint;
                forDraw.DbEntity.AddToCurrentDocument();
                vertStartNum = vertStartNum + 1;
            }
        }
        public void geometryPlaceToPlVertex()
        {
            // учитываем  систему координат
            McDocument doc        = McDocument.WorkingDocument;
            Matrix3d   matCurrent = doc.UCS;
            Matrix3d   matUsc     = matCurrent.Inverse();

            List <Point3d> Vertices = new List <Point3d>();

            // собираем все вершины в list
            Vertices = this.PlineGetFromUser.listVertecs(this.PlineGetFromUser.plineGetFromUser);

            // какой тип объекта расставляем (блок либо обычную геометрию).у текстов отдельная обработка.
            if (ObjPlace is McBlockRef)
            {
                McBlockRef objPlMcBlockRef = new McBlockRef();
                objPlMcBlockRef = ObjPlace as McBlockRef;

                foreach (Point3d onePt in Vertices)
                {
                    McBlockRef refBlock = new McBlockRef();
                    String     selBlock = objPlMcBlockRef.BlockName;
                    refBlock.DbEntity.MatchProperties(objPlMcBlockRef.DbEntity, MatchPropEnum.All);//копирование свойств
                    refBlock.BlockName = selBlock;
                    refBlock.DbEntity.AddToCurrentDocument();

                    Point3d  centrObj = refBlock.InsertPoint;
                    Vector3d vec      = centrObj.GetVectorTo(onePt);
                    Matrix3d mat      = Matrix3d.Displacement(vec);
                    refBlock.DbEntity.Transform(mat);
                }
            }

            else if (ObjPlace is DbText)
            {
                DbText objPlDbText = new DbText();
                objPlDbText = ObjPlace as DbText;

                foreach (Point3d onePt in Vertices)
                {
                    McDbObject cloneGeom = objPlDbText.DbEntity.Clone() as McDbObject;
                    cloneGeom.Entity.DbEntity.MatchProperties(objPlDbText.DbEntity, MatchPropEnum.All);//копирование свойств
                    Point3d  centrObj = objPlDbText.Text.Origin;
                    Vector3d vec      = centrObj.GetVectorTo(onePt);
                    Matrix3d mat      = Matrix3d.Displacement(vec);
                    cloneGeom.Entity.DbEntity.Transform(mat);
                    cloneGeom.Entity.DbEntity.AddToCurrentDocument();
                }
            }

            else
            {
                DbGeometry objPlDbGeometry = new DbGeometry();
                objPlDbGeometry = ObjPlace as DbGeometry;

                foreach (Point3d onePt in Vertices)
                {
                    McDbObject cloneGeom = objPlDbGeometry.DbEntity.Clone() as McDbObject;
                    cloneGeom.Entity.DbEntity.MatchProperties(objPlDbGeometry.DbEntity, MatchPropEnum.All);//копирование свойств
                    Point3d  centrObj = cloneGeom.Entity.DbEntity.BoundingBox.Center;
                    Vector3d vec      = centrObj.GetVectorTo(onePt);
                    Matrix3d mat      = Matrix3d.Displacement(vec);
                    cloneGeom.Entity.DbEntity.Transform(mat);
                    cloneGeom.Entity.DbEntity.AddToCurrentDocument();
                }
            }
        }
Exemplo n.º 4
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");
        }