예제 #1
0
파일: ASign.cs 프로젝트: anielii/Acommands
 private PromptIntegerResult GetStartingNumber()
 {
     PromptIntegerOptions startingNumberOptions = new PromptIntegerOptions("Numer startowy : ");
     startingNumberOptions.AllowNegative = false;
     startingNumberOptions.AllowZero = false;
     startingNumberOptions.DefaultValue = 1;
     startingNumberOptions.UseDefaultValue = true;
     PromptIntegerResult startingNumberPromptResult = editor.GetInteger(startingNumberOptions);
     return startingNumberPromptResult;
 }
        public void EqualLineSegs2d()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;
            Editor   ed  = doc.Editor;

            using (Transaction trans = db.TransactionManager.StartTransaction())//开始事务处理
            {
                //1.选择空间多段线
                PromptEntityOptions plineOpt = new PromptEntityOptions("\n选择多段线");
                plineOpt.SetRejectMessage("\n并非多段线!");
                plineOpt.AddAllowedClass(typeof(Polyline), true);//仅能选择多段线
                PromptEntityResult plineRes = ed.GetEntity(plineOpt);
                if (plineRes.Status != PromptStatus.OK)
                {
                    return;
                }
                ObjectId plineId = plineRes.ObjectId;
                Polyline pline   = trans.GetObject(plineId, OpenMode.ForWrite) as Polyline;
                //2.选择起点
                PromptPointOptions startPtOpt = new PromptPointOptions("\n选择曲线上的点作为起点");
                PromptPointResult  startPtRes = ed.GetPoint(startPtOpt);
                if (startPtRes.Status != PromptStatus.OK)
                {
                    return;
                }
                Point3d startPt = pline.GetClosestPointTo(startPtRes.Value, false);//选择点到多段线的最近点
                //3.选择终点
                PromptPointOptions endPtOpt = new PromptPointOptions("\n选择曲线上的点作为终点");
                PromptPointResult  endPtRes = ed.GetPoint(endPtOpt);
                if (endPtRes.Status != PromptStatus.OK)
                {
                    return;
                }
                Point3d endPt = pline.GetClosestPointTo(endPtRes.Value, false);//选择点到多段线的最近点
                //4.输入分段数
                PromptIntegerOptions intOpt = new PromptIntegerOptions("\n输入分段数");
                intOpt.AllowNegative = false;         //不予许负值
                intOpt.AllowZero     = false;         //不允许0
                PromptIntegerResult intRes = ed.GetInteger(intOpt);
                if (intRes.Status == PromptStatus.OK) //输入成功
                {
                    int           nSegs      = intRes.Value;
                    double        distOfStPt = pline.GetDistanceToStartPt(startPt); //获取起点距曲线起点的距离
                    double        distOfEdPt = pline.GetDistanceToStartPt(endPt);   //获取终点距曲线起点的距离
                    List <double> segLengths = new List <double>();
                    for (int i = 1; i <= nSegs; i++)
                    {
                        segLengths.Add((distOfEdPt - distOfStPt) / nSegs);
                    }
                    CreateLineSegs(pline, startPt, segLengths); //绘制直线段
                }
                trans.Commit();                                 //执行事务处理
            }
        }
예제 #3
0
        private static bool GetNumberOfFloors(Editor ed, ref int numberOfFloors)
        {
            // Select text (or type number of floors)
            PromptEntityOptions entityOptions = new PromptEntityOptions("\nSelect Text (or Enter to skip): ");

            entityOptions.SetRejectMessage("Not Text or MText");
            entityOptions.AddAllowedClass(typeof(DBText), true);
            entityOptions.AddAllowedClass(typeof(MText), true);
            entityOptions.AllowNone = true;
            PromptEntityResult entityResult = ed.GetEntity(entityOptions);

            if (entityResult.Status == PromptStatus.None)
            {
                PromptIntegerOptions integerOptions = new PromptIntegerOptions("\nEnter number of floors:");
                integerOptions.DefaultValue = 1;
                PromptIntegerResult integerResult = ed.GetInteger(integerOptions);
                if (integerResult.Status != PromptStatus.OK)
                {
                    return(false);
                }
                numberOfFloors = integerResult.Value;
            }
            else if (entityResult.Status != PromptStatus.OK)
            {
                return(false);
            }
            else
            {
                using (DBObject obj = entityResult.ObjectId.Open(OpenMode.ForRead))
                {
                    DBText t1 = obj as DBText;
                    MText  t2 = obj as MText;
                    string s  = null;
                    if (t1 != null)
                    {
                        s = t1.TextString;
                    }
                    else if (t2 != null)
                    {
                        s = t2.Text;
                    }
                    else
                    {
                        throw new NotSupportedException("Entity not supported!");
                    }
                    if (!string.IsNullOrEmpty(s))
                    {
                        numberOfFloors = FloorCount.GetCount(s);
                    }
                    ed.WriteMessage($"\nNumber of floors: {numberOfFloors}");
                }
            }
            return(true);
        }
예제 #4
0
        public void Figura3()
        {
            Database db  = HostApplicationServices.WorkingDatabase;
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.GetDocument(db);
            Editor   ed  = doc.Editor;

            PromptDoubleOptions GetSpindulys = new PromptDoubleOptions("\nĮveskite apskritimų spindulį");
            double Spindulys;

            GetSpindulys.AllowNegative = false;
            GetSpindulys.AllowZero     = false;
            GetSpindulys.AllowNone     = false;
            PromptDoubleResult GetSpindulysRezultatas = ed.GetDouble(GetSpindulys);

            Spindulys = GetSpindulysRezultatas.Value;

            PromptIntegerOptions GetKiekis = new PromptIntegerOptions("\nĮveskite apskritimų skaičių");
            int Kiekis;

            GetKiekis.AllowNegative = false;
            GetKiekis.AllowZero     = false;
            GetSpindulys.AllowNone  = false;
            PromptIntegerResult GetKiekisRezultatas = ed.GetInteger(GetKiekis);

            Kiekis = GetKiekisRezultatas.Value;

            PromptPointOptions GetTaskas = new PromptPointOptions("\nPasirinkite pradžios tašką");
            Point3d            Taskas;

            GetTaskas.AllowNone = false;
            PromptPointResult GetTaskasRezultatas = ed.GetPoint(GetTaskas);

            Taskas = GetTaskasRezultatas.Value;
            Transaction tr = db.TransactionManager.StartTransaction();

            double kampas           = 360 / Kiekis;
            double dabartiniskampas = 0;

            using (tr)
            {
                BlockTable       bt  = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead, false);
                BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false);
                for (int j = 0; j < Kiekis; j++)
                {
                    dabartiniskampas += kampas;
                    Point3d beta = new Point3d(Taskas.X + Math.Sin(dabartiniskampas) * Spindulys, Taskas.Y + Math.Cos(dabartiniskampas) * Spindulys, 0);
                    Taskas = beta;
                    Circle Apskritimas = new Circle(Taskas, new Vector3d(0, 0, 1), Spindulys);
                    btr.AppendEntity(Apskritimas);
                    tr.AddNewlyCreatedDBObject(Apskritimas, true);
                }
                tr.Commit();
            }
        }
예제 #5
0
        public void CMDMBTM()
        {
            PaletteSet paletteSet = null;

            if (paletteSet != null)
            {
                Document             mdiActiveDocument    = Application.DocumentManager.MdiActiveDocument;
                PromptIntegerOptions promptIntegerOptions = new PromptIntegerOptions("\n透明度百分比:");
                PromptIntegerResult  integer = mdiActiveDocument.Editor.GetInteger(promptIntegerOptions);
                paletteSet.Opacity = integer.Value;
            }
        }
예제 #6
0
파일: API.cs 프로젝트: iLeif96/AutoCadGcode
        public static void SetOrder(Properties properties = null)
        {
            int order = -1;

            if (properties != null)
            {
                order = properties.Order;
            }

            PromptSelectionResult acSSPrompt = Global.Doc.Editor.GetSelection();
            List <Entity>         list       = ListFromSelecion(acSSPrompt);

            if (list.Count == 0)
            {
                return;
            }

            if (order < 0)
            {
                PromptIntegerOptions pOpts = new PromptIntegerOptions(
                    "Пожалуйста, введите порядковый номер линии в чертеже: ");
                pOpts.LowerLimit   = -1;
                pOpts.DefaultValue = API.prevOrder + 1;
                PromptIntegerResult promptInteger = Global.Doc.Editor.GetInteger(pOpts);
                order = promptInteger.Value;
                if (order < 0)
                {
                    Global.Editor.WriteMessage("Порядковый номер не может быть меньше нуля для печатной линии\n");
                    return;
                }
            }
            API.prevOrder = order;
            foreach (Entity entity in list)
            {
                UserEntity uEntity = XDataManage.getXData(entity);

                if (uEntity == null)
                {
                    uEntity = UserEntity.Create(entity, new Properties());
                }

                if (uEntity == null)
                {
                    continue;
                }

                uEntity.Properties.Printable = true;
                uEntity.Properties.Order     = order;

                uEntity = XDataManage.setXData(uEntity);
                OrderChangeEvent?.Invoke(uEntity);
            }
        }
예제 #7
0
        public static void draw2D()
        {
            Document akDoc = Application.DocumentManager.MdiActiveDocument;
            Database akDb  = akDoc.Database;
            var      ed    = akDoc.Editor;

            //Get user Input
            PromptIntegerOptions widthOne   = new PromptIntegerOptions("\nEnter the Width:");
            PromptIntegerResult  pResWidth  = ed.GetInteger(widthOne);
            PromptIntegerOptions heightOne  = new PromptIntegerOptions("\nEnter the Height: ");
            PromptIntegerResult  pResHeight = ed.GetInteger(heightOne);

            double heightBox = pResHeight.Value;
            double widthBox  = pResWidth.Value;


            using (Transaction tr = akDb.TransactionManager.StartTransaction())
            {
                BlockTable akBlkTbl;
                akBlkTbl = tr.GetObject(akDb.BlockTableId, OpenMode.ForRead) as BlockTable;
                BlockTableRecord akBlkTblRec;
                akBlkTblRec = tr.GetObject(akBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;

                // DRAW THE BOX
                //Left Vertical [0,0 -> 0,heightBox]
                using (Line leftVert = new Line(new Point3d(0, 0, 0), new Point3d(0, heightBox, 0)))
                {
                    akBlkTblRec.AppendEntity(leftVert);
                    tr.AddNewlyCreatedDBObject(leftVert, true);
                }
                //Right Vertical [widthBox,0 -> widthBox, heightBox]
                using (Line rightVert = new Line(new Point3d(widthBox, 0, 0), new Point3d(widthBox, heightBox, 0)))
                {
                    akBlkTblRec.AppendEntity(rightVert);
                    tr.AddNewlyCreatedDBObject(rightVert, true);
                }
                //Bottom Horizontal [0,0 -> widthBox,0]
                using (Line bottomHoriz = new Line(new Point3d(0, 0, 0), new Point3d(widthBox, 0, 0)))
                {
                    akBlkTblRec.AppendEntity(bottomHoriz);
                    tr.AddNewlyCreatedDBObject(bottomHoriz, true);
                }
                //Top Horizontal [0, heightBox -> widthBox, heightBox]
                using (Line topHoriz = new Line(new Point3d(0, heightBox, 0), new Point3d(widthBox, heightBox, 0)))
                {
                    akBlkTblRec.AppendEntity(topHoriz);
                    tr.AddNewlyCreatedDBObject(topHoriz, true);
                }
                //Commit the  new Objects to the Database
                tr.Commit();
            }
        }
예제 #8
0
 /// <summary>
 /// Запрос целого числа
 /// </summary>      
 /// <param name="defaultNumber">Номер по умолчанию</param>
 /// <param name="msg">Строка запроса</param>
 /// <exception cref="Exception">Отменено пользователем.</exception>
 /// <returns>Результат успешного запроса.</returns>
 public static int GetNumber(this Editor ed, int defaultNumber, string msg)
 {
     var opt = new PromptIntegerOptions(msg);
     opt.DefaultValue = defaultNumber;
     var res = ed.GetInteger(opt);
     if (res.Status == PromptStatus.OK)
     {
         return res.Value;
     }
     else
     {
         throw new Exception("Отменено пользователем.");
     }
 }
예제 #9
0
        /// <summary> ed.GetDouble(new PromptDoubleOptions(message) { AllowNone = true })
        /// 提示用户输入整数
        /// </summary>
        /// <param name="msg">用户输入命令后的提示信息</param>
        /// <returns>返回Point3d</returns>
        /// <summary>
        public static int getInteger(string msg)
        {
            PromptIntegerOptions options = new PromptIntegerOptions(msg)
            {
                AllowNone = false
            };
            PromptIntegerResult pt = GoatDB.ed.GetInteger(options);

            if (pt.Status == PromptStatus.OK)
            {
                return(pt.Value);
            }
            return(0);
        }
예제 #10
0
        private int getValueWith(string message, Editor ed)
        {
            PromptIntegerOptions ptIntegerOpt = new PromptIntegerOptions(message);
            PromptIntegerResult  ptIntegerRes = ed.GetInteger(ptIntegerOpt);

            if (ptIntegerRes.Status != PromptStatus.OK)
            {
                return(-1);
            }

            int radius = ptIntegerRes.Value;

            return(radius);
        }
예제 #11
0
파일: API.cs 프로젝트: iLeif96/AutoCadGcode
        public static void SetDisablePumping(Properties properties = null)
        {
            bool disablePumping = false;

            PromptSelectionResult acSSPrompt = Global.Doc.Editor.GetSelection();
            List <Entity>         list       = ListFromSelecion(acSSPrompt);

            if (list.Count > 1)
            {
                return;
            }

            if (properties == null)
            {
                PromptIntegerOptions pOpts = new PromptIntegerOptions(
                    "Введите 1, чтобы отключить подач бетона после этой точки. 0, чтобы восстановить подачу: ");
                pOpts.LowerLimit = 0;
                pOpts.UpperLimit = 1;
                PromptIntegerResult promptInteger = Global.Doc.Editor.GetInteger(pOpts);
                disablePumping = promptInteger.Value == 1 ? true : false;
            }
            else
            {
                disablePumping = properties.DisablePumping;
            }

            foreach (Entity entity in list)
            {
                UserEntity uEntity = XDataManage.getXData(entity);

                if (uEntity == null)
                {
                    uEntity = UserEntity.Create(entity, new Properties());
                }

                if (uEntity == null)
                {
                    continue;
                }

                uEntity.Properties.Printable      = false;
                uEntity.Properties.Command        = true;
                uEntity.Properties.CommandType    = CommandType.DisablePumping;
                uEntity.Properties.DisablePumping = disablePumping;

                uEntity = XDataManage.setXData(uEntity);
                DisablePumpingEvent?.Invoke(uEntity);
            }
        }
예제 #12
0
파일: API.cs 프로젝트: iLeif96/AutoCadGcode
        public static void SetStopAndPump(Properties properties = null)
        {
            int stopAndPump = -1;

            if (properties != null)
            {
                stopAndPump = properties.StopAndPump;
            }

            PromptSelectionResult acSSPrompt = Global.Doc.Editor.GetSelection();
            List <Entity>         list       = ListFromSelecion(acSSPrompt);

            if (list.Count > 1)
            {
                return;
            }

            if (stopAndPump == -1)
            {
                PromptIntegerOptions pOpts = new PromptIntegerOptions(
                    "Пожалуйста, введите время прокачки в милисекундах: ");
                pOpts.LowerLimit = 0;
                PromptIntegerResult promptInteger = Global.Doc.Editor.GetInteger(pOpts);
                stopAndPump = promptInteger.Value;
            }

            foreach (Entity entity in list)
            {
                UserEntity uEntity = XDataManage.getXData(entity);

                if (uEntity == null)
                {
                    uEntity = UserEntity.Create(entity, new Properties());
                }

                if (uEntity == null)
                {
                    continue;
                }

                uEntity.Properties.Printable   = false;
                uEntity.Properties.Command     = true;
                uEntity.Properties.CommandType = CommandType.StopAndPump;
                uEntity.Properties.StopAndPump = stopAndPump;

                uEntity = XDataManage.setXData(uEntity);
                StopAndPumpEvent?.Invoke(uEntity);
            }
        }
예제 #13
0
        private int GetInt(string str, int defaultValue)
        {
            PromptIntegerOptions promptIntegerOptions = new PromptIntegerOptions(str);

            ((PromptNumericalOptions)promptIntegerOptions).set_AllowNone(true);
            ((PromptNumericalOptions)promptIntegerOptions).set_UseDefaultValue(true);
            promptIntegerOptions.set_DefaultValue(defaultValue);
            PromptIntegerResult integer = this.ed.GetInteger(promptIntegerOptions);

            if (((PromptResult)integer).get_Status() == 5100)
            {
                return(integer.get_Value());
            }
            return(promptIntegerOptions.get_DefaultValue());
        }
예제 #14
0
        /// <summary>
        /// Запрос целого числа
        /// </summary>
        /// <param name="ed">ed</param>
        /// <param name="defaultNumber">Номер по умолчанию</param>
        /// <param name="msg">Строка запроса</param>
        /// <exception cref="Exception">Отменено пользователем.</exception>
        /// <returns>Результат успешного запроса.</returns>
        public static int GetNumber([NotNull] this Editor ed, int defaultNumber, string msg)
        {
            var opt = new PromptIntegerOptions(msg)
            {
                DefaultValue = defaultNumber
            };
            var res = ed.GetInteger(opt);

            if (res.Status == PromptStatus.OK)
            {
                return(res.Value);
            }

            throw new OperationCanceledException();
        }
예제 #15
0
        /// <summary>
        /// Prompts the user to input a double.
        /// </summary>
        /// <param name="message">Message to display in the command line.</param>
        /// <param name="allowNone">If false, the user is forced to enter a number or cancel.</param>
        /// <returns>The integer the user wrote. Any other operation will return the default value.</returns>
        public static int GetInteger(string message, ref PromptStatus status, bool allowNone,
                                     int defaultValue)
        {
            PromptIntegerOptions options = new PromptIntegerOptions(System.Environment.NewLine + message);

            options.AllowNone    = allowNone;
            options.DefaultValue = defaultValue;
            Editor command = Application.DocumentManager.MdiActiveDocument.Editor;

            PromptIntegerResult result = command.GetInteger(options);

            status = result.Status;

            return(result.Value);
        }
예제 #16
0
        public void DrawParabola()
        {
            if (!CheckLicense.Check())
            {
                return;
            }

            Autodesk.AutoCAD.ApplicationServices.Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Autodesk.AutoCAD.DatabaseServices.Database    db  = doc.Database;

            PromptPointResult p0Res;

            while (true)
            {
                PromptPointOptions p0Opts = new PromptPointOptions("\nVertex Point: [Seçenekler]", "Settings");
                p0Res = doc.Editor.GetPoint(p0Opts);
                if (p0Res.Status == PromptStatus.Keyword && p0Res.StringResult == "Settings")
                {
                    PromptIntegerOptions opts = new PromptIntegerOptions("Eğri segment sayısı: ");
                    opts.AllowNone       = true;
                    opts.AllowZero       = false;
                    opts.AllowNegative   = false;
                    opts.LowerLimit      = 1;
                    opts.UpperLimit      = 100;
                    opts.DefaultValue    = CurveSegments;
                    opts.UseDefaultValue = true;
                    PromptIntegerResult res = doc.Editor.GetInteger(opts);
                    if (res.Status == PromptStatus.Cancel)
                    {
                        return;
                    }
                    else if (res.Status == PromptStatus.OK)
                    {
                        CurveSegments = res.Value;
                    }
                }
                else if (p0Res.Status != PromptStatus.OK)
                {
                    return;
                }
                else
                {
                    break;
                }
            }

            ParabolaJig.Jig(p0Res.Value, CurveSegments);
        }
예제 #17
0
        public void integerTest()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            PromptIntegerOptions opt0 = new PromptIntegerOptions("Enter your age");

            opt0.AllowNegative = false;
            opt0.AllowNone     = false;
            opt0.AllowZero     = false;
            opt0.DefaultValue  = 1;
            PromptIntegerResult IntRes = ed.GetInteger(opt0);

            if (IntRes.Status == PromptStatus.OK)
            {
                ed.WriteMessage(string.Format("\nYou entered {0}", IntRes.Value));
            }
        }
        /// <summary>
        /// Метод служит для первоначального опроса пользователя
        /// </summary>
        public void GetInitialData()
        {
            PromptIntegerResult piRes = null;  // Номер первого Layout
            bool exitLoop             = false; // Условие продолжения команды

            do
            {
                // Получаем начальный номер для Layout
                PromptIntegerOptions pio = new PromptIntegerOptions("\n" + CP.FirstLayoutNumber);
                pio.Keywords.Add(CO.Configuration);
                if (!this.useTemplate)
                {
                    pio.Keywords.Add(CO.UseTemplate);
                    pio.Keywords.Add(CO.TemplateSelect);
                }
                pio.AllowNegative = false;
                pio.AllowNone     = false;
                pio.DefaultValue  = this.Index;
                piRes             = ed.GetInteger(pio);
                // TODO Обрабатывать выход по escape
                switch (piRes.Status)
                {
                // Введён номер - продолжаем
                case PromptStatus.OK:
                    this.Index = piRes.Value;
                    exitLoop   = true;
                    break;

                // Отрабатываем ключевые слова
                case PromptStatus.Keyword:
                    if (piRes.StringResult.Equals(CO.Configuration, StringComparison.InvariantCulture))
                    {
                        Configuration.AppConfig.Instance.ShowDialog();
                    }
                    else
                    {
                        TemplateProcessing(piRes.StringResult);
                    }
                    break;

                default:
                    this.InitialDataStatus = PromptResultStatus.Cancelled;
                    return;
                }
            } while (!exitLoop);
            this.InitialDataStatus = PromptResultStatus.OK;
        }
예제 #19
0
        public void ChangeZBConfig(ObjectId tableID)
        {
            DataCellCollection Row = new DataCellCollection();
            DataCell           TH  = new DataCell();
            DataCell           HM  = new DataCell();

            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                try
                {
                    DataTable           dt         = (DataTable)trans.GetObject(tableID, OpenMode.ForWrite);
                    PromptDoubleOptions doubleopts = new PromptDoubleOptions("\n输入字高:");
                    doubleopts.AllowNone       = true;
                    doubleopts.AllowNegative   = false;
                    doubleopts.AllowZero       = false;
                    doubleopts.UseDefaultValue = true;
                    doubleopts.DefaultValue    = (double)dt.GetCellAt(0, 0).Value;
                    PromptDoubleResult doubleresult = ed.GetDouble(doubleopts);
                    if (doubleresult.Status == PromptStatus.OK || doubleresult.Status == PromptStatus.None)
                    {
                        TH.SetDouble(doubleresult.Value);

                        PromptIntegerOptions intopts = new PromptIntegerOptions("\n输入高程数量级(高程在10以内为0,100以内为1,以此类推):");
                        intopts.AllowNone       = true;
                        intopts.AllowNegative   = false;
                        intopts.UseDefaultValue = true;
                        intopts.DefaultValue    = (int)dt.GetCellAt(0, 1).Value;
                        PromptIntegerResult intresult = ed.GetInteger(intopts);
                        if (intresult.Status == PromptStatus.OK || intresult.Status == PromptStatus.None)
                        {
                            HM.SetInteger(intresult.Value);

                            Row.Add(TH);
                            Row.Add(HM);
                            dt.SetRowAt(0, Row, true);
                        }
                    }
                }
                catch (Autodesk.AutoCAD.Runtime.Exception EX)
                {
                    ed.WriteMessage("出错了!" + EX.ToString());
                }
                trans.Commit();
            }
        }
예제 #20
0
        private void GetNumFloor()
        {
            PromptIntegerOptions options = new PromptIntegerOptions("")
            {
                Message       = "\nВведите количество этажей или ",
                AllowZero     = false,
                AllowNegative = false,
                AllowNone     = true,
                DefaultValue  = _guessnum
            };

            PromptIntegerResult result = _document.Editor.GetInteger(options);

            if (result.Value != _guessnum)
            {
                _guessnum = result.Value;
            }
        }
예제 #21
0
        public void LayerOps()
        {
            string layerName = "";

            PromptStringOptions propStrOps = new PromptStringOptions("请输入图层名称:\n");

            do
            {
                var propStrRes = Ed.GetString(propStrOps);

                if (propStrRes.Status == PromptStatus.OK)
                {
                    layerName = propStrRes.StringResult;
                }
            } while (layerName == "");

            try
            {
                SymbolUtilityServices.ValidateSymbolName(layerName, false);

                ObjectId lyId = AddLayer(Db, layerName);

                if (lyId != null)
                {
                    PromptIntegerOptions propIntOps = new PromptIntegerOptions("请输入层的颜色索引:\n");

                    propIntOps.AllowNegative = false;
                    propIntOps.AllowNone     = false;
                    propIntOps.AllowZero     = true;

                    var propIntRes = Ed.GetInteger(propIntOps);

                    if (propIntRes.Status == PromptStatus.OK)
                    {
                        SetLayerColor(Db, layerName, (short)propIntRes.Value);
                    }
                    SetCurrentLayer(Db, layerName);
                }
            }
            catch (Autodesk.AutoCAD.Runtime.Exception e)
            {
                Ed.WriteMessage(e.Message + "\n");
            }
        }
예제 #22
0
        public static int Integer(string message, string[] keywords = null)
        {
            Init();
            var pio = new PromptIntegerOptions(message);

            if (keywords != null)
            {
                for (int i = 0; i < keywords.GetLength(0); i++)
                {
                    pio.Keywords.Add(keywords[i], keywords[++i]);
                }
                pio.AppendKeywordsToMessage = true;
            }
            var pir = acEd.GetInteger(pio);

            status       = pir.Status;
            StringResult = pir.StringResult;
            return(pir.Value);
        }
예제 #23
0
        public void DisplayPolyArea()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;


            PromptIntegerResult  prIntRes;
            PromptIntegerOptions prIntOpts = new PromptIntegerOptions("");

            prIntOpts.Message = "Enter number of Points";
            prIntRes          = doc.Editor.GetInteger(prIntOpts);

            PromptPointResult  prPtRes;
            PromptPointOptions prPtOpts = new PromptPointOptions("");

            prPtOpts.Message = "\nEnter number of points";

            Point2dCollection colPt = new Point2dCollection();

            for (int i = 0; i < prIntRes.Value; i++)
            {
                prPtOpts.Message = $"\nEnter Point. [{i + 1}]: ";
                prPtRes          = doc.Editor.GetPoint(prPtOpts);

                colPt.Add(new Point2d(prPtRes.Value.X, prPtRes.Value.Y));

                if (prPtRes.Status == PromptStatus.Cancel)
                {
                    return;
                }
            }

            using (Polyline acPoly = new Polyline())
            {
                for (int i = 0; i < colPt.Count; i++)
                {
                    acPoly.AddVertexAt(i, colPt[i], 0, 0, 0);
                }

                acPoly.Closed = true;

                Application.ShowAlertDialog($"Area: {acPoly.Area.ToString()}");
            }
        }
예제 #24
0
파일: Test1.cs 프로젝트: caobinh92/Autocad
        public static int GetIntPrompt(Document acDoc, string Message, int Min, int Max)
        {
            Database             acCurDb = acDoc.Database;
            Editor               acDocEd = acDoc.Editor;
            PromptIntegerOptions pIntOpt = new PromptIntegerOptions("\n" + Message);

            pIntOpt.LowerLimit = Min;
            pIntOpt.UpperLimit = Max;
            PromptIntegerResult pIntRes = acDocEd.GetInteger(pIntOpt);

            if (pIntRes.Status == PromptStatus.OK)
            {
                return(pIntRes.Value);
            }
            else
            {
                return(0);
            }
        }
        // 提示用户输入整数
        public static bool GetInputInteger(string prompt, ref int val)
        {
            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            PromptIntegerOptions pio = new PromptIntegerOptions(prompt);

            pio.LowerLimit = 1;
            pio.UpperLimit = 1000000;
            PromptIntegerResult pir = ed.GetInteger(pio);

            if (pir.Status == PromptStatus.OK)
            {
                val = pir.Value;
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #26
0
        public void ThirdObject()
        {
            var db     = HostApplicationServices.WorkingDatabase;
            var doc    = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.GetDocument(db);
            var editor = doc.Editor;

            var startPointInput = new PromptPointOptions("\nSelect starting point:");

            startPointInput.AllowNone = false;
            Point3d startPoint = editor.GetPoint(startPointInput).Value;

            var triangleCountInput = new PromptIntegerOptions("\nNumber of branches:");

            triangleCountInput.AllowNone = false;
            int triangleCount = editor.GetInteger(triangleCountInput).Value;

            var transaction = db.TransactionManager.StartTransaction();

            using (transaction)
            {
                var treeBase = DrawBase(startPoint);

                var triangles = DrawTriangles(new Point3d(startPoint.X, startPoint.Y + 2, startPoint.Z), triangleCount);

                var record = (BlockTableRecord)transaction.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);

                foreach (var line in treeBase)
                {
                    record.AppendEntity(line);
                    transaction.AddNewlyCreatedDBObject(line, true);
                }

                foreach (var line in triangles)
                {
                    record.AppendEntity(line);
                    transaction.AddNewlyCreatedDBObject(line, true);
                }


                transaction.Commit();
            }
        }
예제 #27
0
        private static void SelectNamedLayers(this Editor ed, SortedList <string, ObjectId> ld, ObjectIdCollection lids)
        {
            int i = 1;

            foreach (KeyValuePair <string, ObjectId> kv in ld)
            {
                ed.WriteMessage("\n{0} - {1}", i++, kv.Key);
            }
            // We will ask the user to select from the list
            var pio = new PromptIntegerOptions("\nEnter number of layer to add: ");

            pio.LowerLimit = 1;
            pio.UpperLimit = ld.Count;
            pio.AllowNone  = true;
            // And will do so in a loop, waiting for Escape or Enter to terminate
            PromptIntegerResult pir;

            do
            {
                // Select one from the list
                pir = ed.GetInteger(pio);
                if (pir.Status == PromptStatus.OK)
                {
                    // Get the layer's name
                    string ln = ld.Keys[pir.Value - 1];
                    // And then its ID
                    ObjectId lid;
                    ld.TryGetValue(ln, out lid);
                    // Add the layer'd ID to the list, if it's not already on it
                    if (lids.Contains(lid))
                    {
                        ed.WriteMessage("\nLayer \"{0}\" has already been selected.", ln);
                    }
                    else
                    {
                        lids.Add(lid);
                        ed.WriteMessage("\nAdded \"{0}\" to selected layers.", ln);
                    }
                }
            } while (pir.Status == PromptStatus.OK);
        }
예제 #28
0
        public static bool Integer(string msg, out int value, int minValue)
        {
            PromptIntegerOptions opt = new PromptIntegerOptions(msg);

            opt.AllowNegative = false;
            opt.AllowZero     = false;
            opt.LowerLimit    = minValue;
            opt.AllowNone     = false;
            PromptIntegerResult result = Ed.GetInteger(opt);

            if (result.Status == PromptStatus.OK)
            {
                value = result.Value;
                return(true);
            }
            else
            {
                value = 0;
                return(false);
            }
        }
예제 #29
0
        /// <summary> 隔多少个顶点进行分段 </summary>
        private static int GetSegVertices(DocumentModifier docMdf)
        {
            var op = new PromptIntegerOptions("\n每隔多少个顶点进行分段")
            {
                LowerLimit = 1,
                UpperLimit = (int)1e6,
                //
                AllowNegative       = false,
                AllowNone           = false,
                AllowZero           = false,
                AllowArbitraryInput = false
            };

            //
            var res = docMdf.acEditor.GetInteger(op);

            if (res.Status == PromptStatus.OK)
            {
                return(res.Value);
            }
            return(0);
        }
예제 #30
0
        /// <summary> 在命令行中获取一个整数值 </summary>
        private static int GetInterger(DocumentModifier docMdf)
        {
            var op = new PromptIntegerOptions(message: "\n每隔多少个顶点进行分段")
            {
                LowerLimit = 1,
                UpperLimit = (int)1e6,
                //
                AllowNegative       = false,
                AllowNone           = true, // true 表示允许用户直接按下回车或者右键,以退出 GetPoint() 方法,此时返回的 PromptPointResult.Status 为 None。
                AllowZero           = false,
                AllowArbitraryInput = false
            };

            //
            var res = docMdf.acEditor.GetInteger(op);

            if (res.Status == PromptStatus.OK)
            {
                return(res.Value);
            }
            return(0);
        }
예제 #31
0
        public static void draw3D()
        {
            Document akDoc = Application.DocumentManager.MdiActiveDocument;
            Database akDb  = akDoc.Database;
            var      ed    = akDoc.Editor;


            //Get user Input
            PromptIntegerOptions widthOne  = new PromptIntegerOptions("\nEnter the Width: ");
            PromptIntegerResult  boxWidth  = ed.GetInteger(widthOne);
            PromptIntegerOptions heightOne = new PromptIntegerOptions("\nEnter the Height: ");
            PromptIntegerResult  boxHeight = ed.GetInteger(heightOne);

            double VH = boxHeight.Value;
            double VW = boxWidth.Value;

            ed.WriteMessage("\nBefore Transaction ... ");
            using (Transaction tr = akDb.TransactionManager.StartTransaction())
            {
                BlockTable akBlkTbl;
                akBlkTbl = tr.GetObject(akDb.BlockTableId, OpenMode.ForRead) as BlockTable;
                BlockTableRecord akBlkTblRec;
                akBlkTblRec = tr.GetObject(akBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;

                ed.WriteMessage($"\n{boxWidth}, {boxHeight} ... ");
                using (Line vert = new Line(new Point3d(0, 0, 0), new Point3d(0, VH, 0)))
                {
                    akBlkTblRec.AppendEntity(vert);
                    tr.AddNewlyCreatedDBObject(vert, true);
                }
                using (Line horiz = new Line(new Point3d(VW, 0, 0), new Point3d(VW, VH, 0)))
                {
                    akBlkTblRec.AppendEntity(horiz);
                    tr.AddNewlyCreatedDBObject(horiz, true);
                }
                tr.Commit();
            }
        }
예제 #32
0
        public override hresult OnEdit(Point3d pnt, EditFlags lFlag)
        {
            Editor ed = HostMgd.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

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

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

            if (PromptStatus.OK == pr.Status)
            {
                ed.WriteMessage("You entered: " + pr.StringResult);
                Count = pr.Value;
                DbEntity.Erase();
                DbEntity.AddToCurrentDocument();
            }
            else
            {
                ed.WriteMessage("Cancel");
            }

            return(hresult.s_Ok);
        }
예제 #33
0
        public void dataChange()
        {
            Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;

            try
            {
                PlantProject mainPrj = PlantApplication.CurrentProject;
                Project prj = mainPrj.ProjectParts["PnId"];
                DataLinksManager dlm = prj.DataLinksManager;

                PromptIntegerOptions pOpts = new PromptIntegerOptions("Enter a PnPID number");
                PromptIntegerResult prIntRes = ed.GetInteger(pOpts);

                int iRowId = prIntRes.Value;

                if (prIntRes.Status == PromptStatus.OK)
                {
                    // Declare a List (System.Collections.Generic) of the properties
                    // from the selected entity
                    List<KeyValuePair<string, string>> list_Properties;
                    list_Properties = dlm.GetAllProperties(iRowId, true);

                    // 3.20 Create a new KeyValuePair (System.Collections.Generic)
                    // name it something like oldVal. Make it equal a new KeyValuePair
                    // use string for the Key and Value. (use null for the string key
                    // and string value. 
                    KeyValuePair<string, string> oldVal =
                        new KeyValuePair<string, string>(null, null);

                    // 3.21 Create another KeyValuePair (System.Collections.Generic)
                    // name it something like newVal. Make it equal a new KeyValuePair
                    // use string for the Key and Value. (use null for the string key
                    // and string value. 
                    KeyValuePair<string, string> newVal =
                        new KeyValuePair<string, string>(null, null);


                    // Iterate through the entries in the list.
                    for (int i = 0; i < list_Properties.Count; i++)
                    {

                        //areMake the the string for the key from 
                        // step 3.15 equal to the Key property of the list in
                        // this iteration of the loop "[i]". (The list form step 3.14
                        //string strKey = list_Properties[i].Key;

                        // 3.22 Use and if statement and see if the Key property
                        // of the list in this iteration of the loop "[i]" is 
                        // equal to "Manufacturer"
                        // Note: put the closing curly brace after step 3.25
                        if (list_Properties[i].Key == "Manufacturer")
                        {

                            // 3.23 Make the KeyValuePair created in step 3.20 equal to
                            // a new KeyValuePair. Use string for the Key and Value. For the 
                            // Key, use Key property of the List in this iteration of the loop
                            // [i]. For the Value use the Value property of the List in this 
                            // iteration of the loop. 
                            oldVal = new KeyValuePair<string, string>(list_Properties[i].Key,
                                       list_Properties[i].Value);

                            // 3.24 Declare a string variable and make it equal to something
                            // like "Some new Manufacturer"
                            string txtNewVal = "Some new Manufacturer";

                            // 3.25 Make the KeyValuePair created in step 3.21 equal to
                            // a new KeyValuePair. Use string for the Key and Value. For the 
                            // Key, use Key property of the List in this iteration of the loop
                            // [i]. For the Value use the Value property use the string
                            // from step 3.24
                            newVal = new KeyValuePair<string, string>(list_Properties[i].Key,
                                txtNewVal);

                            // 3.25 exit the for loop by adding break.
                            break;

                        }
                    }


                    // 3.26 Remove the old KeyValuePair from the List by calling the 
                    // Remove method from the list created above. (list_Properties) Pass
                    // in the old KeyValuePair from step 3.20
                    list_Properties.Remove(oldVal);

                    // 3.27 Add the new KeyValuePair to the List by calling the 
                    // Add method from the list created above. (list_Properties) Pass
                    // in the KeyValuePair from step 3.21
                    list_Properties.Add(newVal);

                    // 3.28 Declare a new System.Collections.Specialized.StringCollection
                    // name it something like strNames. Instantiate it by making it 
                    // equal to a new System.Collections.Specialized.StringCollection()
                    System.Collections.Specialized.StringCollection strNames =
                        new System.Collections.Specialized.StringCollection();

                    // 3.29 Declare a new System.Collections.Specialized.StringCollection
                    // name it something like strValues. Instantiate it by making it 
                    // equal to a new System.Collections.Specialized.StringCollection()
                    System.Collections.Specialized.StringCollection strValues =
                        new System.Collections.Specialized.StringCollection();

                    // 3.30 Iterate through the List declared above (list_Properties)
                    // Note: Put the closing curly brace below step 3.34
                    for (int i = 0; i < list_Properties.Count; i++)
                    {
                        // 3.31 Declare a string named something like "name" make
                        // it equal to the Key Property of this Iteration of the list 
                        // in the loop. "[i]"
                        String name = list_Properties[i].Key;

                        // 3.32 Declare a string named something like "value" make
                        // it equal to the Value property of this Iteration of the list 
                        // in the loop. "[i]"
                        String value = list_Properties[i].Value;

                        // 3.33 Use the Add method of the StringCollection created in 
                        // step 3.28. Pass in the string from step 3.31
                        strNames.Add(name);


                        // 3.34 Use the Add method of the StringCollection created in 
                        // step 3.29. Pass in the string from step 3.32
                        strValues.Add(value);
                    }

                    // 3.35 Use the SetProperties method of the DataLinksManager created
                    // above (dlm) to update the properties. Pass in the Row Id that was
                    // provided by the user above. (iRowId) For the first StringCollection
                    // pass in the one from step 3.28. For the second StringCollection
                    // pass in the one from step 3.29. 
                    dlm.SetProperties(iRowId, strNames, strValues);


                    // Build debug and test this code. In the DataManager
                    // You should see a new value for the Manufacturer.
                }
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage(ex.ToString());
            }
        }
예제 #34
0
        public void Figura3()
        {
            Database db = HostApplicationServices.WorkingDatabase;
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.GetDocument(db);
            Editor ed = doc.Editor;

            PromptDoubleOptions GetSpindulys = new PromptDoubleOptions("\nĮveskite apskritimų spindulį");
            double Spindulys;
            GetSpindulys.AllowNegative = false;
            GetSpindulys.AllowZero = false;
            GetSpindulys.AllowNone = false;
            PromptDoubleResult GetSpindulysRezultatas = ed.GetDouble(GetSpindulys);
            Spindulys = GetSpindulysRezultatas.Value;

            PromptIntegerOptions GetKiekis = new PromptIntegerOptions("\nĮveskite apskritimų skaičių");
            int Kiekis;
            GetKiekis.AllowNegative = false;
            GetKiekis.AllowZero = false;
            GetSpindulys.AllowNone = false;
            PromptIntegerResult GetKiekisRezultatas = ed.GetInteger(GetKiekis);
            Kiekis = GetKiekisRezultatas.Value;

            PromptPointOptions GetTaskas = new PromptPointOptions("\nPasirinkite pradžios tašką");
            Point3d Taskas;
            GetTaskas.AllowNone = false;
            PromptPointResult GetTaskasRezultatas = ed.GetPoint(GetTaskas);
            Taskas = GetTaskasRezultatas.Value;
            Transaction tr = db.TransactionManager.StartTransaction();

            double kampas = 360 / Kiekis;
            double dabartiniskampas = 0;
            using (tr)
            {
                BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead, false);
                BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false);
                for (int j = 0; j < Kiekis; j++)
                {
                    dabartiniskampas += kampas;
                    Point3d beta = new Point3d(Taskas.X + Math.Sin(dabartiniskampas) * Spindulys, Taskas.Y + Math.Cos(dabartiniskampas) * Spindulys, 0);
                    Taskas = beta;
                    Circle Apskritimas = new Circle(Taskas , new Vector3d(0, 0, 1), Spindulys);
                    btr.AppendEntity(Apskritimas);
                    tr.AddNewlyCreatedDBObject(Apskritimas, true);
                }
                tr.Commit();
            }
        }
예제 #35
0
        public void getDataUsingManager()
        {
            Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;

            try
            {
                PlantProject mainPrj = PlantApplication.CurrentProject;
                Project prj = mainPrj.ProjectParts["PnId"];
                DataLinksManager dlm = prj.DataLinksManager;

                PromptIntegerOptions pOpts = new PromptIntegerOptions("Enter a PnPID number");
                PromptIntegerResult prIntRes = ed.GetInteger(pOpts);

                if (prIntRes.Status == PromptStatus.OK)
                {

                    // 3.13 Declare a List (System.Collections.Generic) Use KeyValuePair
                    // with string for the two elements in the List. (Key, Value)
                    List<KeyValuePair<string, string>> list_Properties;


                    // 3.14 Instantiate the List from step 3.13. Use the 
                    // GetAllProperties method of the DataLinksManager 
                    // from above (dlm). For the RowId argument using the 
                    // Value property of the PromptIntegerResult from above.
                    // (prIntRes) Use true for the current version property.
                    list_Properties = dlm.GetAllProperties(prIntRes.Value, true);

                    // 3.15 Declare a couple of strings. These will be used to get
                    // the Key and the Value from the entries in the list. Name them
                    // something like strKey and strValue.
                    string strKey, strValue = null;

                    // 3.16 Iterate through the entries in the list. 
                    // Use a for statement. Something like the example below. (Change
                    // list_Properties to the name of the List from step 3.14.
                    // for (int i = 0; i < list_Properties.Count; i++)
                    // Note: put the closing curly brace below step 3.19
                    for (int i = 0; i < list_Properties.Count; i++)
                    {
                        // 3.17 Make the string for the key from 
                        // step 3.15 equal to the Key property of the list in
                        // this iteration of the loop "[i]". (The list form step 3.14)
                        strKey = list_Properties[i].Key;

                        // 3.18 Make the string for the value from step 3.15
                        // equal to the Value property of the list in
                        // this iteration of the loop "[i]" of the list form step 3.14
                        strValue = list_Properties[i].Value;

                        // 3.19 Use the WriteMessage function of the editor (ed) and print
                        // the values of the string with the key and the string with the
                        // the value (from steps 3.17 and 3.18) Use "\n" for a return. 
                        // (add it to the end + "\n")
                        // Build, debug and test this code. (Command "GetDataByMGR")
                        // Note: Continue to step 3.20 below
                        ed.WriteMessage("Key = " + strKey + " Value = " + strValue + "\n");
                    }
                }
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage(ex.ToString());
            }
        }
예제 #36
0
 private void btnPickNumber_Click(object sender, EventArgs e)
 {
     Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
     using (EditorUserInteraction UI = ed.StartUserInteraction(this))
     {
         TypedValue[] tvs = new TypedValue[] {
             new TypedValue((int)DxfCode.Operator, "<OR"),
             new TypedValue((int)DxfCode.Start, "TEXT"),
             new TypedValue((int)DxfCode.Start, "MTEXT"),
             new TypedValue((int)DxfCode.Start, "DIMENSION"),
             new TypedValue((int)DxfCode.Operator, "OR>")
         };
         PromptSelectionResult res = ed.GetSelection(new SelectionFilter(tvs));
         if (res.Status == PromptStatus.OK && res.Value.Count > 0)
         {
             PromptIntegerOptions nopts = new PromptIntegerOptions("\nCarpan <1>: ");
             nopts.AllowNegative = false;
             nopts.AllowZero = false;
             nopts.DefaultValue = 1;
             PromptIntegerResult nres = ed.GetInteger(nopts);
             if (nres.Status == PromptStatus.OK)
             {
                 string multiplierString = (nres.Value == 1 ? "" : nres.Value.ToString() + "*");
                 Database db = HostApplicationServices.WorkingDatabase;
                 using (Transaction tr = db.TransactionManager.StartTransaction())
                 {
                     try
                     {
                         boundDimensions.Clear();
                         int total = 0;
                         foreach (SelectedObject sobj in res.Value)
                         {
                             string text = "";
                             DBObject obj = tr.GetObject(sobj.ObjectId, OpenMode.ForRead);
                             if (obj is DBText)
                             {
                                 DBText dobj = obj as DBText;
                                 text = dobj.TextString;
                             }
                             else if (obj is MText)
                             {
                                 MText dobj = obj as MText;
                                 text = dobj.Text;
                             }
                             else if (obj is Dimension)
                             {
                                 boundDimensions.Add(sobj.ObjectId);
                             }
                             if (!string.IsNullOrEmpty(text))
                             {
                                 text = text.TrimStart('(').TrimEnd(')');
                                 int num = 0;
                                 if (int.TryParse(text, out num))
                                 {
                                     total += num;
                                 }
                             }
                         }
                         string countText = "";
                         if (total != 0)
                         {
                             countText = multiplierString + total.ToString();
                         }
                         if (boundDimensions.Count > 0)
                         {
                             countText = (total == 0 ? "" : countText + "+") + multiplierString + "<>";
                         }
                         txtPosCount.Text = countText;
                     }
                     catch (System.Exception ex)
                     {
                         MessageBox.Show("Error: " + ex.Message, "RebarPos", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     }
                 }
             }
         }
     }
 }
예제 #37
0
파일: Class1.cs 프로젝트: guchanghai/Cut
 public void GetData()
 {
     //��ȡEditor����
     Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
     //��ȡ��������
     PromptIntegerOptions intOp = new PromptIntegerOptions("���������εı�����");
     PromptIntegerResult intRes;
     intRes = ed.GetInteger(intOp);
     //�ж��û�����
     if (intRes.Status == PromptStatus.OK)
     {
         int nSides = intRes.Value;
         ed.WriteMessage("����εı���Ϊ��" + nSides);
     } if (intRes.Status == PromptStatus.Cancel)
     {
         ed.WriteMessage("�û�����ȡ��ESC��/n" );
     }
 }
        public static void CreateCloset()
        {
            _panels.Clear();

            Document activeDoc = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument;

            Database db = activeDoc.Database;

            Editor ed = activeDoc.Editor;

            PromptDoubleOptions pdo = new PromptDoubleOptions("Total closet width in feet : ");
            PromptDoubleResult pdr = ed.GetDouble(pdo);
            if (pdr.Status != PromptStatus.OK)
                return;
            W = pdr.Value * 12.0;

            pdo = new PromptDoubleOptions("Total closet depth in feet : ");
            pdr = ed.GetDouble(pdo);
            if (pdr.Status != PromptStatus.OK)
                return;
            D = pdr.Value * 12.0;

            pdo = new PromptDoubleOptions("Total closet height in feet : ");
            pdr = ed.GetDouble(pdo);
            if (pdr.Status != PromptStatus.OK)
                return;
            H = pdr.Value * 12.0;

            pdo = new PromptDoubleOptions("Ply thickness in inches : ");
            pdr = ed.GetDouble(pdo);
            if (pdr.Status != PromptStatus.OK)
                return;
            t = pdr.Value;

            pdo = new PromptDoubleOptions("Door height as percentage of total closet height : ");
            pdr = ed.GetDouble(pdo);
            if (pdr.Status != PromptStatus.OK)
                return;
            doorH = H * pdr.Value * 0.01;

            PromptIntegerOptions pio = new PromptIntegerOptions("Number of drawer rows : ");
            PromptIntegerResult pir = ed.GetInteger(pio);
            if (pir.Status != PromptStatus.OK)
                return;
            N = pir.Value;

            pio = new PromptIntegerOptions("Split drawers ? (1 / 0) : ");
            pir = ed.GetInteger(pio);
            if (pir.Status != PromptStatus.OK)
                return;
            splitDrawers = (pir.Value != 0);

            ed.WriteMessage(String.Format("\nTotal closet width  : {0}", W));
            ed.WriteMessage(String.Format("\nTotal closet depth  : {0}", D));
            ed.WriteMessage(String.Format("\nTotal closet height : {0}", H));
            ed.WriteMessage(String.Format("\nPly thickness       : {0}", t));
            ed.WriteMessage(String.Format("\nDoor height : {0}", doorH));
            ed.WriteMessage(String.Format("\nNumber of drawer rows :  {0}", N));
            ed.WriteMessage(String.Format("\nSplit drawers ?  : {0}", splitDrawers ? "yes" : "no"));
           
            CreateHandleBlock();

            // Left
            PlyYZ(new Point2d[] { new Point2d(0.0, 0.0), 
                                            new Point2d(D-t, 0.0),
                                            new Point2d(D-t, H-2*t),
                                            new Point2d(0.0, H-2*t)
                                            }, new Point3d(0.0, t, t), WoodGrainAlignment.Vertical);
            _panels.Add(new PanelDetails("Left panel", String.Format("{0} x {1}", (D-t), H-2*t), 1));

            // Right
            PlyYZ(new Point2d[] { new Point2d(0.0, 0.0), 
                                            new Point2d(D-t, 0.0),
                                            new Point2d(D-t, H-2*t),
                                            new Point2d(0.0, H-2*t)
                                            }, new Point3d(W - t, t, t), WoodGrainAlignment.Vertical);
            _panels.Add(new PanelDetails("Right panel", String.Format("{0} x {1}", (D - t), H - 2 * t), 1));

            // Top
            PlyXY(new Point2d[] { new Point2d(0.0, 0.0), 
                                            new Point2d(W, 0.0),
                                            new Point2d(W, D-t),
                                            new Point2d(0.0, D-t)
                                            }, new Point3d(0.0, t, H - t), WoodGrainAlignment.Horizontal);
            _panels.Add(new PanelDetails("Top panel", String.Format("{0} x {1}", W, (D - t)), 1));

            // Bottom
            PlyXY(new Point2d[] { new Point2d(0.0, 0.0), 
                                            new Point2d(W, 0.0),
                                            new Point2d(W, D-t),
                                            new Point2d(0.0, D-t)
                                            }, new Point3d(0.0, t, 0.0), WoodGrainAlignment.Horizontal);
            _panels.Add(new PanelDetails("Bottom panel", String.Format("{0} x {1}", W, (D - t)), 1));

            // Back
            PlyXZ(new Point2d[] { new Point2d(0.0, 0.0), 
                                            new Point2d(-W+2*t, 0.0),
                                            new Point2d(-W+2*t, H-2*t),
                                            new Point2d(0.0, H-2*t)
                                            }, new Point3d(t, D - t, t), WoodGrainAlignment.Vertical);
            _panels.Add(new PanelDetails("Back panel", String.Format("{0} x {1}", W+2*t, H-2*t), 1));

            // Front twin doors
            // Left
            ObjectId leftDoorId = PlyXZ(new Point2d[] { new Point2d(0.0, 0.0), 
                                            new Point2d(-W * 0.5, 0.0),
                                            new Point2d(-W * 0.5, doorH),
                                            new Point2d(0.0, doorH)
                                            }, new Point3d(0.0, 0.0, H - doorH), WoodGrainAlignment.Vertical);
            _panels.Add(new PanelDetails("Front twin doors", String.Format("{0} x {1}", W * 0.5, doorH), 2));

            // Swing the door open
            // comment it to shut the drawer
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                Entity ent = tr.GetObject(leftDoorId, OpenMode.ForWrite) as Entity;
                ent.TransformBy(Matrix3d.Rotation(-135 * Math.PI / 180.0, Vector3d.ZAxis, new Point3d(0.0, 0.0, H - doorH)));
                tr.Commit();
            }

            // Right
            ObjectId rightDoorId = PlyXZ(new Point2d[] { new Point2d(0.0, 0.0), 
                                            new Point2d(-W * 0.5, 0.0),
                                            new Point2d(-W * 0.5, doorH),
                                            new Point2d(0.0, doorH)
                                            }, new Point3d(W * 0.5, 0.0, H - doorH), WoodGrainAlignment.Vertical);

            // Swing the door open
            // comment it to shut the drawer
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                Entity ent = tr.GetObject(rightDoorId, OpenMode.ForWrite) as Entity;
                ent.TransformBy(Matrix3d.Rotation(135 * Math.PI / 180.0, Vector3d.ZAxis, new Point3d(W, 0.0, H - doorH)));
                tr.Commit();
            }

            // Inner shelf divider
            PlyXY(new Point2d[] { new Point2d(0.0, 0.0), 
                                            new Point2d(W-2*t, 0.0),
                                            new Point2d(W-2*t, D-2*t),
                                            new Point2d(0.0, D-2*t)
                                            }, new Point3d(t, t, H - doorH), WoodGrainAlignment.Horizontal);
            _panels.Add(new PanelDetails("Inner shelf divider", String.Format("{0} x {1}", W - 2 * t, D - 2 * t), 1));
            CreateDrawerBlock(splitDrawers);

            InsertDrawers();
        }
예제 #39
0
 public void SupUtil()
 {
     Document acDoc = Application.DocumentManager.MdiActiveDocument;
     Database acCurDb = acDoc.Database;
     Editor ed = acDoc.Editor;
     List<Incapere> incapere;
     PromptIntegerOptions scaraOpt = new PromptIntegerOptions("Scara planului 1: ");
     PromptIntegerResult scaraResult = ed.GetInteger(scaraOpt);
     SelecteazaIncapere(out incapere, ed, acCurDb);
     TableHelper tb = new TableHelper(acDoc);
     tb.DrawSupUtilTabel(incapere, "Releveu parter");
 }
    public void ImportFromKinect()
    {
      Document doc =
        Autodesk.AutoCAD.ApplicationServices.
          Application.DocumentManager.MdiActiveDocument;
      Editor ed = doc.Editor;

      // Get some user input for the number of snapshots...

      PromptIntegerOptions pio =
        new PromptIntegerOptions("\nNumber of captures");
      pio.AllowZero = false;
      pio.DefaultValue = _numShots;
      pio.UseDefaultValue = true;
      pio.UpperLimit = 20;
      pio.LowerLimit = 1;

      PromptIntegerResult pir = ed.GetInteger(pio);

      if (pir.Status != PromptStatus.OK)
        return;

      _numShots = pir.Value;

      // ... and the delay between them

      PromptDoubleOptions pdo =
        new PromptDoubleOptions("\nNumber of seconds delay");
      pdo.AllowZero = false;
      pdo.AllowNegative = false;
      pdo.AllowArbitraryInput = false;
      pdo.DefaultValue = _delay;
      pdo.UseDefaultValue = true;

      PromptDoubleResult pdr = ed.GetDouble(pdo);

      if (pdr.Status != PromptStatus.OK)
        return;

      _delay = pdr.Value;

      Transaction tr =
        doc.TransactionManager.StartTransaction();

      KinectDelayJig kj = new KinectDelayJig(_numShots, _delay);

      if (!kj.StartSensor())
      {
        ed.WriteMessage(
          "\nUnable to start Kinect sensor - " +
          "are you sure it's plugged in?"
        );
        return;
      }
      
      PromptResult pr = ed.Drag(kj);
      if (pr.Status == PromptStatus.OK)
      {
        kj.StartTimer();
        pr = ed.Drag(kj);
      }
      kj.StopSensor();

      if (pr.Status != PromptStatus.OK && !kj.Finished)
      {
        tr.Dispose();
        return;
      }

      tr.Commit();

      // Manually dispose to avoid scoping issues with
      // other variables

      tr.Dispose();

      kj.WriteAndImportPointCloud(doc, kj.Vectors);
    }
예제 #41
0
 private int GetLenPrompt(string msg, int defaultVal)
 {
     int res = defaultVal;
      var prOpt = new PromptIntegerOptions(msg);
      prOpt.AllowZero = false;
      prOpt.AllowNegative = false;
      prOpt.DefaultValue = defaultVal;
      prOpt.UseDefaultValue = true;
      var resPrompt = Application.DocumentManager.MdiActiveDocument.Editor.GetInteger(prOpt);
      if (resPrompt.Status == PromptStatus.OK)
     res = resPrompt.Value;
      return res;
 }
예제 #42
0
 // Запрос номера этажа
 private void getNumberFloor()
 {
     var opt = new PromptIntegerOptions($"\nВведи номер этажа {_planTypeName} плана");
     opt.DefaultValue = _numberFloor;
     //opt.Keywords.Add(_planTypeName);
     string keySection = "Секция" + _section;
     opt.Keywords.Add(keySection);
     opt.Keywords.Add("Чердак");
     opt.Keywords.Add("Парапет");
     opt.Keywords.Add("сБорка");
     var res = _ed.GetInteger(opt);
     if (res.Status == PromptStatus.OK)
     {
         _numberFloor = res.Value;
         _nameFloor = null;
     }
     else if (res.Status == PromptStatus.Keyword)
     {
         if (res.StringResult == keySection)
         {
             _section = getSection();
             getNumberFloor();
         }
         else if (res.StringResult == "Чердак")
         {
             _nameFloor = Settings.Default.PaintIndexUpperStorey;
         }
         else if (res.StringResult == "Парапет")
         {
             _nameFloor = Settings.Default.PaintIndexParapet;
         }
         else if (res.StringResult == _planTypeName)
         {
             setTypeBlock(_planType == BlockPlanTypeEnum.Mounting ? BlockPlanTypeEnum.Architect : BlockPlanTypeEnum.Mounting);
             getNumberFloor();
         }
         else if (res.StringResult == "сБорка")
         {
             // Собрать все блоки в одну точку.
             Utils.UtilsPlanBlocksTogether.Together();
             throw new Exception(AcadLib.General.CanceledByUser);
         }
         else
         {
             throw new Exception("Отменено пользователем.");
         }
     }
     else
     {
         throw new Exception("Отменено пользователем.");
     }
 }
예제 #43
0
 public void integerTest()
 {
     Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
     PromptIntegerOptions opt0 = new PromptIntegerOptions("Enter your age");
     opt0.AllowNegative = false;
     opt0.AllowNone = false;
     opt0.AllowZero = false;
     opt0.DefaultValue = 1;
     PromptIntegerResult IntRes = ed.GetInteger(opt0);
     if(IntRes.Status == PromptStatus.OK)
     {
         ed.WriteMessage(string.Format("\nYou entered {0}",IntRes.Value));
     }
 }
 /// <summary>
 /// Метод служит для первоначального опроса пользователя
 /// </summary>
 public void GetInitialData()
 {
     PromptIntegerResult piRes = null; // Номер первого Layout
     bool exitLoop = false; // Условие продолжения команды
     do
     {
         // Получаем начальный номер для Layout
         PromptIntegerOptions pio = new PromptIntegerOptions("\n"+CP.FirstLayoutNumber);
         pio.Keywords.Add(CO.Configuration);
         if (!this.useTemplate)
         {
             pio.Keywords.Add(CO.UseTemplate);
             pio.Keywords.Add(CO.TemplateSelect);
         }
         pio.AllowNegative = false;
         pio.AllowNone = false;
         pio.DefaultValue = this.Index;
         piRes = ed.GetInteger(pio);
         // TODO Обрабатывать выход по escape
         switch (piRes.Status)
         {
                 // Введён номер - продолжаем
             case PromptStatus.OK:
                 this.Index = piRes.Value;
                 exitLoop = true;
                 break;
                 // Отрабатываем ключевые слова
             case PromptStatus.Keyword:
                 if (piRes.StringResult.Equals(CO.Configuration, StringComparison.InvariantCulture))
                     Configuration.AppConfig.Instance.ShowDialog();
                 else
                     TemplateProcessing(piRes.StringResult);
                 break;
             default:
                 this.InitialDataStatus = PromptResultStatus.Cancelled;
                 return;
         }
     } while (!exitLoop);
     this.InitialDataStatus = PromptResultStatus.OK;
 }
예제 #45
0
        private short? TryGetBarNumber(string message)
        {
            PromptIntegerOptions options = new PromptIntegerOptions(message);
            options.AllowNone = false;
            options.AllowNegative = false;
            options.UpperLimit = 32767;
            options.DefaultValue = BWCadOperationManager.LastUsedBarNumber;
            options.UseDefaultValue = true;

            PromptIntegerResult result = editor.GetInteger(options);
            if (result.Status == PromptStatus.OK)
            {
                BWCadOperationManager.LastUsedBarNumber = (short)result.Value;
                return (short)result.Value;
            }
            else
            {
                return null;
            }
        }