Example #1
0
        public static void GetAngle()
        {
            PromptStatus status = new PromptStatus();
            double userInput = DrawingSpace.GetAngle("Input angle:", ref status, AngleMode.Degrees);

            Editor command = Application.DocumentManager.MdiActiveDocument.Editor;
            command.WriteMessage("Result: " + userInput);
        }
Example #2
0
        public static void GeDouble()
        {
            PromptStatus status    = new PromptStatus();
            double       userInput = DrawingSpace.GetDouble("Input double:", ref status, false);

            Editor command = Application.DocumentManager.MdiActiveDocument.Editor;

            command.WriteMessage("Result: " + userInput);
        }
 internal PromptNestedEntityThroughViewportResult(PromptNestedEntityResult pneResult)
 {
     m_status       = pneResult.Status;
     m_stringResult = pneResult.StringResult;
     m_pickPoint    = pneResult.PickedPoint;
     m_value        = pneResult.ObjectId;
     m_containers   = pneResult.GetContainers();
     m_mat          = pneResult.Transform;
     m_viewport     = Autodesk.AutoCAD.DatabaseServices.ObjectId.Null;
 }
 internal PromptNestedEntityThroughViewportResult(PromptResult pneResult)
 {
     m_status       = pneResult.Status;
     m_stringResult = pneResult.StringResult;
     m_pickPoint    = Point3d.Origin;
     m_value        = Autodesk.AutoCAD.DatabaseServices.ObjectId.Null;
     m_containers   = null;
     m_mat          = Matrix3d.Identity;
     m_viewport     = Autodesk.AutoCAD.DatabaseServices.ObjectId.Null;
 }
 internal PromptNestedEntityThroughViewportResult(PromptNestedEntityResult pneResult, ObjectId viewport)
 {
     m_status       = pneResult.Status;
     m_stringResult = pneResult.StringResult;
     m_pickPoint    = pneResult.PickedPoint;
     m_value        = pneResult.ObjectId;
     m_containers   = pneResult.GetContainers();
     m_mat          = pneResult.Transform;
     m_viewport     = viewport;
 }
Example #6
0
        /// <summary>
        /// Prompts the user to input a distance.
        /// </summary>
        /// <param name="message">Message to display in the command line.</param>
        /// <returns>The distance input by the user.</returns>
        public static double GetDistance(string message, ref PromptStatus status)
        {
            PromptDistanceOptions options = new PromptDistanceOptions(System.Environment.NewLine + message);
            Editor command = Application.DocumentManager.MdiActiveDocument.Editor;

            PromptDoubleResult result = command.GetDistance(options);

            status = result.Status;

            return(result.Value);
        }
Example #7
0
        /// <summary>
        /// Prompts the user to select a point in the drawing.
        /// </summary>
        /// <param name="message">Message to display in the command line.</param>
        public static Point3d GetPoint3d(string message, ref PromptStatus status)
        {
            PromptPointOptions options = new PromptPointOptions(message);
            PromptPointResult  result;
            Editor             command = Application.DocumentManager.MdiActiveDocument.Editor;

            options.AllowNone = true;
            result            = command.GetPoint(options);
            status            = result.Status;

            return(result.Value);
        }
Example #8
0
        getPoint(string strPrompt, Point3d pnt3d, out bool escape, out PromptStatus promptStatus, int osMode)
        {
            object mode = SnapMode.getOSnap();

            SnapMode.setOSnap(osMode);

            promptStatus = PromptStatus.Error;
            escape       = false;
            Point3d           pnt3dX = Pub.pnt3dO;
            Editor            ED     = BaseObjs._editor;
            PromptPointResult PPR    = null;

            PromptPointOptions PPO = new PromptPointOptions(strPrompt);

            PPO.AllowNone = true;
            if (pnt3d != pnt3dX)
            {
                PPO.AllowNone     = true;
                PPO.UseBasePoint  = true;
                PPO.BasePoint     = pnt3d;
                PPO.UseDashedLine = true;
            }

            try
            {
                PPR = ED.GetPoint(PPO);
                switch (PPR.Status)
                {
                case PromptStatus.Cancel:
                    escape = true;
                    break;

                case PromptStatus.Other:
                    pnt3dX = Pub.pnt3dO;
                    break;

                case PromptStatus.OK:
                    pnt3dX = PPR.Value;
                    break;
                }
                promptStatus = PPR.Status;
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " UserInput.cs: line: 138");
            }
            finally
            {
                SnapMode.setOSnap((int)mode);
            }
            return(pnt3dX);
        }
Example #9
0
        public override PromptStatus JigDraw()
        {
            PromptStatus res = PromptStatus.Cancel;

            if ((res = base.JigDraw()) != PromptStatus.OK)
            {
                return(PromptStatus.Cancel);
            }
            if (!_lowerComplite)
            {
                _lowerComplite = true;
            }

            if ((res = base.JigDraw()) != PromptStatus.OK)
            {
                return(PromptStatus.Cancel);
            }
            if (!_lowerJigComplite)
            {
                _lowerJigComplite = true;
                var ids = Tools.AppendEntity(Entities);
                Entities.Clear();

                var brId = ids.FirstOrDefault();
                if (brId != ObjectId.Null)
                {
                    Tools.StartTransaction(() =>
                    {
                        brId.GetObjectForRead <BlockReference>();
                        var xrecord = CustomObjects.Helpers.XRecordTools.GetSetExtensionDictionaryEntry(brId, "ARROW_JigPosition").GetObjectForRead <Xrecord>();
                        xrecord.UpgradeOpen();

                        //Point3d p = _jigPoint.TransformBy(Arrow.GetToLocalTransform(_lowerPointUcs, _ucs));
                        Point3d p = _jigPoint.TransformBy(_ucs);

                        ResultBuffer rb = new ResultBuffer(
                            new TypedValue((int)DxfCode.Real, p.X),
                            new TypedValue((int)DxfCode.Real, p.Y),
                            new TypedValue((int)DxfCode.Real, p.Z)
                            );
                        xrecord.Append(rb);
                    });
                }
            }

            /*if ((res = base.JigDraw()) != PromptStatus.OK)
             *  return PromptStatus.Cancel;
             * if (!_upperComplite)
             *  _upperComplite = true;*/

            return(res);
        }
Example #10
0
        public static SelectionSet Implied()
        {
            Init();

            var result = acEd.SelectImplied();

            if (result.Status == PromptStatus.OK)
            {
                Console.WriteLine("Š—Š°ŃˆŠ»Šø Š² ŠøŠ¼ŠæŠ»Š°Š¹ŠµŠ“");
            }
            status = result.Status;
            return(result.Value);
        }
Example #11
0
        public PromptStatus StartJig()
        {
            PromptStatus res = PromptStatus.Other;

            while ((res = Tools.GetAcadEditor().Drag(this).Status) != PromptStatus.Cancel)
            {
                if (res == PromptStatus.OK)
                {
                    return(res);
                }
            }
            return(res);
        }
Example #12
0
        /*ŠŸŠµŃ€ŠµŃ…Š¾Š“ Š½Š° ŠæŠ¾Š»ŠøŠ»ŠøŠ½Šøю Š½Š° ŠæŠµŃ€ŃŠæŠµŠŗтŠøŠ²Ńƒ
         * [RibbonCommandButton("Š”трŠµŠ»ŠŗŠø Š¾Ń‚ŠŗŠ»Š¾Š½ŠµŠ½Šøя", "Š”трŠµŠ»ŠŗŠø")]
         * [Autodesk.AutoCAD.Runtime.CommandMethod("iCmd_DrawValueArrows", Autodesk.AutoCAD.Runtime.CommandFlags.UsePickSet)]
         * public static void DrawValueArrows()
         * {
         *  Matrix3d ucs = CoordinateSystem.CoordinateTools.GetCurrentUcs();
         *  double tolerance = _dataProvider.Read("tolerance", 0.005d);
         *  bool isToleranceOnly = _dataProvider.Read("isToleranceOnly", false);
         *
         *  Polyline pline;
         *  if (!ObjectCollector.TrySelectAllowedClassObject(out pline))
         *      return;
         *
         *
         *  PromptPointOptions ppo = new PromptPointOptions("\nŠ£ŠŗŠ°Š¶ŠøтŠµ фŠ°ŠŗтŠøчŠµŃŠŗŠ¾Šµ ŠæŠ¾Š»Š¾Š¶ŠµŠ½ŠøŠµ:");
         *  ppo.AllowArbitraryInput = false;
         *  ppo.Keywords.Add("Tolerance", "Š”ŠžŠŸŃƒŃŠŗ", "Š”ŠžŠŸŃƒŃŠŗ", true, true);
         *  ppo.Keywords.Add("IsToleranceOnlyTrue", "Š¢ŠžŠ›ŃŒŠŗŠ¾Š’Š”Š¾ŠæусŠŗŠµ", "Š¢ŠžŠ›ŃŒŠŗŠ¾ Š’ Š”Š¾ŠæусŠŗŠµ", true, true);
         *  ppo.Keywords.Add("IsToleranceOnlyFalse", "Š¤ŠŠšŠ¢ŠøчŠµŃŠŗŠø", "Š¤ŠŠšŠ¢ŠøчŠµŃŠŗŠøŠµ Š“Š°Š½Š½Ń‹Šµ", true, true);
         *  ppo.Keywords.Add("Exit", "Š’Š«Š„Š¾Š“", "Š’Š«Š„Š¾Š“", true, true);
         *
         *  PromptPointResult ppr;
         *  while ((ppr = Tools.GetAcadEditor().GetPoint(ppo)).Status == PromptStatus.OK || ppr.Status == PromptStatus.Keyword)
         *  {
         *      var insertPoint = pline.GetOrthoNormalPoint(ppr.Value, new Plane());
         *      if (insertPoint == null || !insertPoint.HasValue)
         *          continue;
         *      try
         *      {
         *          Vector3d axisVector = pline.GetFirstDerivative(insertPoint.Value);
         *          ValueArrow mainBlock = new ValueArrow(axisVector, ucs);
         *          mainBlock._isToleranceOnly = isToleranceOnly;
         *          mainBlock._toleranceBottom = tolerance;
         *          mainBlock._insertPointUcs = insertPoint.Value;
         *
         *          PromptStatus res = PromptStatus.Cancel;
         *          if ((res = mainBlock.JigDraw()) != PromptStatus.OK)
         *              return;
         *
         *          _dataProvider.Write("tolerance", mainBlock._toleranceBottom);
         *          _dataProvider.Write("isToleranceOnly", mainBlock._isToleranceOnly);
         *      }
         *      catch (Exception ex)
         *      {
         *          Tools.GetAcadEditor().WriteMessage($"\n\aŠžŃˆŠøŠ±ŠŗŠ° \n{ex.Message}");
         *          return;
         *      }
         *  }
         *
         * }
         */
        #endregion

        /// <summary>
        /// ŠžŃŠ½Š¾Š²Š½Š¾Š¹ Š¼ŠµŃ‚Š¾Š“ Š²Ń‹Š²Š¾Š“Š° Š“Š°Š½Š½Ń‹Ń…. Š ŠøсуŠµŃ‚ стрŠµŠ»ŠŗŠø ŠæŠ¾ ŠæŠ¾Š»ŃƒŃ‡ŠµŠ½Š½Ń‹Š¼ с эŠŗрŠ°Š½Š° тŠ¾Ń‡ŠŗŠ°Š¼
        /// </summary>
        /// <param name="axisVector">Š’ŠµŠŗтŠ¾Ń€ Š½Š°ŠæрŠ°Š²Š»ŠµŠ½Šøя Š¾ŃŠø/Š³Ń€Š°Š½Šø (ŠæŠµŃ€ŠæŠµŠ½Š“ŠøŠŗуŠ»ŃŃ€Š½Š¾ стрŠµŠ»ŠŗŠ°Š¼)</param>
        /// <param name="ucs">Š¢ŠµŠŗущŠ°Ń ŠŸŠ”Šš</param>
        /// <param name="onlyOnce">Š˜Š”Š¢Š˜ŠŠ ŠµŃŠ»Šø Š½ŃƒŠ¶Š½Š¾ Š²Ń‹ŠæŠ¾Š»Š½Šøть тŠ¾Š»ŃŒŠŗŠ¾ рŠ°Š·, ŠøŠ½Š°Ń‡Šµ цŠøŠŗŠ»</param>
        /// <returns></returns>
        public static PromptStatus DrawWallArrows(Vector3d axisVector, Matrix3d ucs, bool onlyOnce = false, bool mirrorText = false)
        {
            double toleranceBottom = /*0.005;*/ _dataProvider.Read("tolerance", 0.005d);
            bool   isToleranceOnly = /*false;*/ _dataProvider.Read("isToleranceOnly", false);
            object mirrorTextValue = null;

            if (mirrorText)
            {
                mirrorTextValue = SetMirrorTextValue(1);
            }
            try
            {
                Point3d?insertPoint = Point3d.Origin;
                while ((insertPoint = GetInsertPoint(axisVector, ucs, ref toleranceBottom, ref isToleranceOnly)).HasValue)
                {
                    PromptStatus res = PromptStatus.Cancel;

                    ValueArrow mainBlock = new ValueArrow(axisVector, ucs);

                    mainBlock._isToleranceOnly = isToleranceOnly;
                    mainBlock._toleranceBottom = toleranceBottom;

                    mainBlock._insertPointUcs = insertPoint.Value;
                    if ((res = mainBlock.JigDraw()) != PromptStatus.OK)
                    {
                        return(res);
                    }
                    if (onlyOnce)
                    {
                        break;
                    }

                    _dataProvider.Write("tolerance", mainBlock._toleranceBottom);
                    _dataProvider.Write("isToleranceOnly", mainBlock._isToleranceOnly);
                }

                return(PromptStatus.OK);
            }
            catch (Exception ex)
            {
                Tools.GetAcadEditor().WriteMessage(ex.Message);
                return(PromptStatus.Error);
            }
            finally
            {
                if (mirrorText)
                {
                    SetMirrorTextValue(mirrorTextValue);
                }
            }
        }
Example #13
0
        FindAtPoint(Point3d worldPoint, bool selectAll = true)
        {
            List <ObjectId> ids = new List <ObjectId>();

            Document doc = Application.DocumentManager.MdiActiveDocument;

            Matrix3d wcs2ucs =
                doc.Editor.CurrentUserCoordinateSystem.Inverse();

            Point3d ucsPoint = worldPoint.TransformBy(wcs2ucs);

            string arg = selectAll ? ":E" : string.Empty;

            IntPtr ptrPoint = Marshal.UnsafeAddrOfPinnedArrayElement(
                worldPoint.ToArray(), 0);


            PromptStatus prGetResult = ArxImports.acedSSGet(
                arg, ptrPoint, IntPtr.Zero, IntPtr.Zero, out ArxImports.Ads_name sset);

            ArxImports.acedSSLength(ref sset, out int len);

            if (len <= 0)
            {
                return(ids);
            }

            for (int i = 0; i < len; ++i)
            {
                if (ArxImports.acedSSName(
                        ref sset, i, out ArxImports.Ads_name name) != PromptStatus.OK)
                {
                    continue;
                }


                if (ArxImports.acdbGetObjectId(
                        out ObjectId id, ref name) != ErrorStatus.OK)
                {
                    continue;
                }

                ids.Add(id);
            }

            ArxImports.acedSSFree(ref sset);

            return(ids);
        }
Example #14
0
        selectCogoPointByNode(string prompt, int osMode)
        {
            ObjectId     id        = ObjectId.Null;
            PromptStatus ps        = PromptStatus.Cancel;
            Point3d      pnt3dBase = UserInput.getPoint(prompt, out ps, osMode);

            BaseObjs._db.forEachMS <CogoPoint>(cg =>
            {
                if (cg.Location == pnt3dBase)
                {
                    id = cg.ObjectId;
                }
            });
            return(id);
        }
Example #15
0
        /// <summary>
        /// Prompts the user to input a string.
        /// </summary>
        /// <param name="message">Message to display in the command line.</param>
        /// <returns>The string the user wrote or the default value if nothing was written.</returns>
        /// <remarks>If the user doesn't select anything, status will still return OK, not None.</remarks>
        public static string GetString(string message, ref PromptStatus status, bool allowSpaces,
                                       string defaultValue)
        {
            PromptStringOptions options = new PromptStringOptions(System.Environment.NewLine + message);

            options.AllowSpaces  = allowSpaces;
            options.DefaultValue = defaultValue;
            Editor command = Application.DocumentManager.MdiActiveDocument.Editor;

            PromptResult result = command.GetString(options);

            status = result.Status;

            return(result.StringResult);
        }
Example #16
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);
        }
Example #17
0
        /// <summary>
        /// Prompts the user to select a keyword from a list.
        /// </summary>
        /// <param name="message">Message to display in the command line.</param>
        /// <param name="keywords">List of keywords from which the user will choose.</param>
        /// <returns>The keyword selected by the user.</returns>
        /// <remarks>The keywords must be single words. If a keyword includes spaces,
        /// only the first word will be returned.</remarks>
        public static string GetKeyword(string message, ref PromptStatus status, string[] keywords)
        {
            PromptKeywordOptions options = new PromptKeywordOptions(message);
            PromptResult         result;
            Editor command = Application.DocumentManager.MdiActiveDocument.Editor;

            foreach (string keyword in keywords)
            {
                options.Keywords.Add(keyword);
            }

            result = command.GetKeywords(options);
            status = result.Status;

            return(result.StringResult);
        }
Example #18
0
        public PromptStatus JigDraw(bool isDestPointSelected)
        {
            PromptStatus promptStatus = PromptStatus.OK;

            if (!isDestPointSelected)
            {
                _jigSelected = false;
                promptStatus = base.JigDraw();
            }
            if (promptStatus == PromptStatus.OK)
            {
                _jigSelected = true;
                base.JigDraw();
            }
            return(promptStatus);
        }
Example #19
0
        selectCogoPointByNode(string prompt, ref Point3d pnt3dBase, out bool escape, out PromptStatus ps, int osMode)
        {
            ObjectId id = ObjectId.Null;

            pnt3dBase = UserInput.getPoint(prompt, pnt3dBase, out escape, out ps, osMode);
            Point3d pnt3dTar = pnt3dBase;

            BaseObjs._db.forEachMS <CogoPoint>(cg =>
            {
                if (cg.Location == pnt3dTar)
                {
                    id = cg.ObjectId;
                }
            });
            return(id);
        }
Example #20
0
File: cmdS.cs Project: 15831944/EM
        S(Point3d pnt3d, string desc)
        {
            ObjectId idPnt3d = ObjectId.Null;
            Object   osMode  = SnapMode.getOSnap();

            SnapMode.setOSnap(0);
            PromptStatus ps = PromptStatus.Cancel;

            try
            {
                if (pnt3d == Pub.pnt3dO)
                {
                    pnt3d = UserInput.getPoint("New Point: ", out ps, osMode: 641);
                    if (pnt3d == Pub.pnt3dO)
                    {
                        return(ObjectId.Null);
                    }
                    else
                    {
                        if (pnt3d.Z == 0.0)
                        {
                            double elev;
                            bool   escape = UserInput.getUserInput("Enter Elevation: ", out elev, 0.0);
                            if (escape)
                            {
                                return(ObjectId.Null);
                            }
                            pnt3d = new Point3d(pnt3d.X, pnt3d.Y, elev);
                        }
                    }
                }

                uint pntNum;

                ObjectId idCgPnt = pnt3d.setPoint(out pntNum, desc);
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " cmdS.cs: line: 48");
            }
            finally
            {
                SnapMode.setOSnap((int)osMode);
            }

            return(idPnt3d);
        }
Example #21
0
        public void InsertTabalimBlock()
        {
            Editor ed           = Application.DocumentManager.MdiActiveDocument.Editor;
            String blkDirectory = Assembly.GetAssembly(typeof(Tabalim.Addin.Runtime.Commands)).Location;

            blkDirectory = Path.GetDirectoryName(blkDirectory);
            blkDirectory = Path.Combine(blkDirectory, BLOCK_DIR);
            View.WinBlockInsert win = new View.WinBlockInsert();
            win.ShowDialog();
            AutoCADUtils.VoidTransaction((Document doc, Transaction tr) =>
            {
                if (win.DialogResult.Value)
                {
                    String blockName = win.SelectedBlock.Index.ToString(),
                    file             = Path.Combine(blkDirectory, String.Format("{0}.dwg", blockName));
                    tr.LoadBlock(doc.Database, file, blockName);
                }
                ;
            });
            PromptStatus      status = PromptStatus.OK;
            PromptPointResult res;

            while (status == PromptStatus.OK)
            {
                AutoCADUtils.VoidTransaction((Document doc, Transaction tr) =>
                {
                    String blockName              = win.SelectedBlock.Index.ToString();
                    BlockTable blkTab             = (BlockTable)doc.Database.BlockTableId.GetObject(OpenMode.ForRead);
                    BlockTableRecord currentSpace = (BlockTableRecord)doc.Database.CurrentSpaceId.GetObject(OpenMode.ForWrite);
                    res = ed.GetPoint(new PromptPointOptions("Selecciona el punto de inserciĆ³n del bloque.")
                    {
                        AllowNone = true
                    });
                    status = res.Status;
                    if (status == PromptStatus.OK)
                    {
                        BlockReference blkRef = new BlockReference(res.Value, blkTab[blockName]);
                        blkRef.Rotation       = 0;
                        blkRef.ScaleFactors   = new Scale3d(16);
                        currentSpace.AppendEntity(blkRef);
                        tr.AddNewlyCreatedDBObject(blkRef, true);
                    }
                    ed.Regen();
                });
            }
        }
Example #22
0
        public PromptStatus Execute(Editor ed)
        {
            if (Application.DocumentManager.IsApplicationContext)
            {
                throw new Exception(ErrorStatus.InvalidContext);
            }
            if (!Settings.Variables.NEXTFIBERWORLD)
            {
                Application.ShowAlertDialog("Set NEXTFIBERWORLD = 0 & restart AutoCAD!");
            }
            PromptStatus ps = PromptStatus.None;

            ed.InitCommandVersion(InitCommandVersion);
            IAcedCmdArg name = Argument(FormattedName);

            ps = name.Execute(ed);
            if (!IsActive() || _arguments.Count <= 0)
            {
                return(ps);
            }
            int index = 0;

            while (index < _arguments.Count && ps == PromptStatus.OK && IsActive())
            {
                IAcedCmdArg arg = _arguments[index];
                if (arg == null)
                {
                    int argIndex = index + 1;
                    throw new ArgumentNullException(argIndex.ToString(CultureInfo.InvariantCulture) +
                                                    " argument for command is null");
                }

                ps = arg.Execute(ed);
                index++;
            }
            if (!SendPauseForPrompts)
            {
                return(ps);
            }
            while (IsActive() && ps == PromptStatus.OK)
            {
                ps = Pause().Execute(ed);
            }
            return(ps);
        }
Example #23
0
        moveDimPL(MText mText = null)
        {
            Object osMode = Base_Tools45.SnapMode.getOSnap();

            Base_Tools45.SnapMode.setOSnap(0);

            ObjectId idMtxt = ObjectId.Null;

            TypedValue[] tvsTX = null;

            Editor ed = BaseObjs._editor;
            PromptSelectionResult psr = ed.SelectImplied();

            if (psr.Value == null)
            {
                bool escape = true;
                idMtxt = Select.selectMTextForMoving("TEXT", out escape);
                if (escape)
                {
                    return;
                }
                tvsTX = idMtxt.getXData(apps.lnkDimPL).AsArray();
            }
            else
            {
                ObjectId[] ids = psr.Value.GetObjectIds();
                if (ids[0] is MText)
                {
                    tvsTX = ids[0].getXData(apps.lnkDimPL).AsArray();
                    if (tvsTX == null)
                    {
                        return;
                    }
                    idMtxt = ids[0];
                }
            }
            PromptStatus ps     = PromptStatus.Cancel;
            Point3d      pnt3dX = UserInput.getPoint("Pick desired location for text: ", out ps, osMode: 0);

            modTXlnkDimPl(idMtxt, tvsTX, pnt3dX);
            int osM;

            int.TryParse(osMode.ToString(), out osM);
            Base_Tools45.SnapMode.setOSnap(osM);
        }
Example #24
0
        /// <summary>
        /// Prompts the user to input an angle.
        /// </summary>
        /// <param name="message">Message to display in the command line.</param>
        /// <returns>The angle input by the user.</returns>
        public static double GetAngle(string message, ref PromptStatus status, AngleMode mode)
        {
            PromptAngleOptions options = new PromptAngleOptions(System.Environment.NewLine + message);
            Editor             command = Application.DocumentManager.MdiActiveDocument.Editor;

            PromptDoubleResult result = command.GetAngle(options);

            status = result.Status;

            double angle = result.Value;

            if (mode == AngleMode.Degrees)
            {
                angle = angle * 180 / Math.PI;
            }

            return(angle);
        }
Example #25
0
        public static void DrawOneArrow()
        {
            Curve curve = PromptCurve();

            if (curve == null)
            {
                return;
            }
            Polyline pline = null;

            Tools.StartTransaction(() =>
            {
                pline = curve.ConvertToPolyline();
            });
            PromptStatus res = PromptStatus.OK;

            while (res == PromptStatus.OK)
            {
                var pos = PromptPosition();
                //var vec = PromptVector();
                if (!pos.HasValue)
                {
                    return;
                }

                Point3d?normalPoint = pline.GetOrthoNormalPoint(pos.Value, null, false);
                if (normalPoint == null)
                {
                    return;
                }
                Vector3d vec = pline.GetFirstDerivative(normalPoint.Value);

                Arrow arrow = new Arrow(pos.Value, vec, Matrix3d.Identity);

                Tools.StartTransaction(() =>
                {
                    if ((res = arrow.DrawJig()) == PromptStatus.OK)
                    {
                        arrow.SaveToDatabase();
                    }
                });
            }
        }
Example #26
0
        public static void GetString()
        {
            PromptStatus status    = new PromptStatus();
            string       userInput = DrawingSpace.GetString("Input string:", ref status, true);

            if (status == PromptStatus.OK)
            {
                Editor command = Application.DocumentManager.MdiActiveDocument.Editor;

                if (userInput != "")
                {
                    command.WriteMessage("You wrote: " + userInput);
                }
                else
                {
                    command.WriteMessage("No input");
                }
            }
        }
Example #27
0
        public static void GetEntity()
        {
            Transaction transaction = HostApplicationServices.WorkingDatabase.TransactionManager
                                      .StartTransaction();
            PromptStatus status = new PromptStatus();
            Entity       entity = DrawingSpace.GetEntity("Select object:", ref status, transaction,
                                                         OpenMode.ForWrite);

            // The status lets us know if the user actually selected something or cancelled.
            if (status == PromptStatus.OK)
            {
                entity.Color = Color.FromColorIndex(ColorMethod.ByAci, 2);
                transaction.Commit();
            }
            else
            {
                transaction.Dispose();
            }
        }
Example #28
0
        public static void GetEntity()
        {
            Transaction transaction = HostApplicationServices.WorkingDatabase.TransactionManager
                .StartTransaction();
            PromptStatus status = new PromptStatus();
            Entity entity = DrawingSpace.GetEntity("Select object:", ref status, transaction,
                OpenMode.ForWrite);

            // The status lets us know if the user actually selected something or cancelled.
            if (status == PromptStatus.OK)
            {
                entity.Color = Color.FromColorIndex(ColorMethod.ByAci, 2);
                transaction.Commit();
            }
            else
            {
                transaction.Dispose();
            }
        }
Example #29
0
        public static string Text(string message, string[] keywords = null)
        {
            Init();
            var pso = new PromptStringOptions(message);

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

            status       = res.Status;
            StringResult = res.StringResult;
            return(StringResult);
        }
Example #30
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);
        }
Example #31
0
        /// <summary>
        /// Prompts the user to select a single entity from the drawing.
        /// </summary>
        /// <param name="message">Message to display in the command line.</param>
        public static Entity GetEntity(string message, ref PromptStatus status, Transaction transaction,
                                       OpenMode mode, bool openErased, bool forceOpenOnLockedLayer)
        {
            PromptEntityOptions options = new PromptEntityOptions(System.Environment.NewLine + message);
            PromptEntityResult  result;
            Entity entity  = null;
            Editor command = Application.DocumentManager.MdiActiveDocument.Editor;

            options.AllowNone = true;
            result            = command.GetEntity(options);
            status            = result.Status;

            if (status == PromptStatus.OK)
            {
                entity = (Entity)transaction.GetObject(result.ObjectId, mode, openErased,
                                                       forceOpenOnLockedLayer);
            }

            return(entity);
        }
Example #32
0
        public static double Double(string message, string[] keywords = null)
        {
            Init();
            var pdo = new PromptDoubleOptions(message);

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

            var pdr = acEd.GetDouble(pdo);

            status       = pdr.Status;
            StringResult = pdr.StringResult;
            return(pdr.Value);
        }
Example #33
0
        public static void GetKeyword()
        {
            PromptStatus status = new PromptStatus();
            string[] keywords = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" };
            string userInput = DrawingSpace.GetKeyword("Select a day:", ref status, keywords);

            Editor command = Application.DocumentManager.MdiActiveDocument.Editor;

            if (status == PromptStatus.OK)
            {
                if (userInput != "")
                {
                    command.WriteMessage("You selected: " + userInput);
                }
            }
            else
            {
                command.WriteMessage("No selection");
            }
        }
Example #34
0
        public static void GetSelection()
        {
            Transaction transaction = HostApplicationServices.WorkingDatabase.TransactionManager
                .StartTransaction();
            PromptStatus status = new PromptStatus();
            DBObjectCollection selection = DrawingSpace.GetSelection("Select objects:", ref status,
                transaction, OpenMode.ForWrite);

            // Another way of dealing with the canceling of the operation or empty selection.
            if (status != PromptStatus.OK)
            {
                transaction.Dispose();
                return;
            }

            foreach (Entity entity in selection)
            {
                entity.Color = Color.FromColorIndex(ColorMethod.ByAci, 4);
            }

            transaction.Commit();
        }
Example #35
0
        public static void GetString()
        {
            PromptStatus status = new PromptStatus();
            string userInput = DrawingSpace.GetString("Input string:", ref status, true);

            if (status == PromptStatus.OK)
            {
                Editor command = Application.DocumentManager.MdiActiveDocument.Editor;

                if (userInput != "")
                {
                    command.WriteMessage("You wrote: " + userInput);
                }
                else
                {
                    command.WriteMessage("No input");
                }
            }
        }