Esempio n. 1
0
        /// <inheritdoc/>
        public void CreateAnalog(SmartEntity sourceEntity, bool copyLayer)
        {
#if !DEBUG
            Statistic.SendCommandStarting(
                SecantNodalLeader.GetDescriptor().Name, ModPlusConnector.Instance.AvailProductExternalVersion);
#endif
            try
            {
                Overrule.Overruling = false;

                /* Регистрация ЕСКД приложения должна запускаться при запуске
                 * функции, т.к. регистрация происходит в текущем документе
                 * При инициализации плагина регистрации нет!
                 */
                ExtendedDataUtils.AddRegAppTableRecord(SecantNodalLeader.GetDescriptor());
                var lastNodeNumber = FindLastNodeNumber();
                var nodalLeader    = new SecantNodalLeader(lastNodeNumber);
                var blockReference = MainFunction.CreateBlock(nodalLeader);
                nodalLeader.SetPropertiesFromSmartEntity(sourceEntity, copyLayer);

                InsertSecantNodalLeaderWithJig(nodalLeader, blockReference);
            }
            catch (Exception exception)
            {
                ExceptionBox.Show(exception);
            }
            finally
            {
                Overrule.Overruling = true;
            }
        }
Esempio n. 2
0
        private static void CreateSecantNodalLeader()
        {
#if !DEBUG
            Statistic.SendCommandStarting(
                SecantNodalLeader.GetDescriptor().Name, ModPlusConnector.Instance.AvailProductExternalVersion);
#endif
            try
            {
                Overrule.Overruling = false;

                /* Регистрация ЕСКД приложения должна запускаться при запуске
                 * функции, т.к. регистрация происходит в текущем документе
                 * При инициализации плагина регистрации нет!
                 */
                ExtendedDataUtils.AddRegAppTableRecord(SecantNodalLeader.GetDescriptor());
                var style          = StyleManager.GetCurrentStyle(typeof(SecantNodalLeader));
                var lastNodeNumber = FindLastNodeNumber();
                var nodalLeader    = new SecantNodalLeader(lastNodeNumber);

                var blockReference = MainFunction.CreateBlock(nodalLeader);
                nodalLeader.ApplyStyle(style, true);

                InsertSecantNodalLeaderWithJig(nodalLeader, blockReference);
            }
            catch (Exception exception)
            {
                ExceptionBox.Show(exception);
            }
            finally
            {
                Overrule.Overruling = true;
            }
        }
Esempio n. 3
0
        private static void InsertSecantNodalLeaderWithJig(SecantNodalLeader secantNodalLeader, BlockReference blockReference)
        {
            // <msg1>Укажите точку вставки:</msg1>
            var insertionPointPrompt = Language.GetItem("msg1");

            // <msg18>Укажите точку выноски:</msg18>
            var leaderPointPrompt = Language.GetItem("msg18");

            var entityJig = new DefaultEntityJig(secantNodalLeader, blockReference, new Point3d(0, 0, 0))
            {
                PromptForInsertionPoint = insertionPointPrompt
            };

            secantNodalLeader.JigState = SecantNodalLeaderJigState.InsertionPoint;
            do
            {
                var status = AcadUtils.Editor.Drag(entityJig).Status;
                if (status == PromptStatus.OK)
                {
                    if (secantNodalLeader.JigState == SecantNodalLeaderJigState.InsertionPoint)
                    {
                        secantNodalLeader.JigState   = SecantNodalLeaderJigState.LeaderPoint;
                        entityJig.PromptForNextPoint = leaderPointPrompt;
                        entityJig.PreviousPoint      = secantNodalLeader.InsertionPoint;
                    }
                    else
                    {
                        break;
                    }

                    entityJig.JigState = JigState.PromptNextPoint;
                }
                else
                {
                    // mark to remove
                    using (AcadUtils.Document.LockDocument())
                    {
                        using (var tr = AcadUtils.Document.TransactionManager.StartTransaction())
                        {
                            var obj = (BlockReference)tr.GetObject(blockReference.Id, OpenMode.ForWrite, true, true);
                            obj.Erase(true);
                            tr.Commit();
                        }
                    }

                    break;
                }
            }while (true);

            if (!secantNodalLeader.BlockId.IsErased)
            {
                using (var tr = AcadUtils.Database.TransactionManager.StartTransaction())
                {
                    var ent = tr.GetObject(secantNodalLeader.BlockId, OpenMode.ForWrite, true, true);
                    ent.XData = secantNodalLeader.GetDataForXData();
                    tr.Commit();
                }
            }
        }
Esempio n. 4
0
        /// <inheritdoc/>
        public void Initialize(IWithDoubleClickEditor smartEntity)
        {
            if (!(smartEntity is SecantNodalLeader secantNodalLeader))
            {
                throw new ArgumentException("Wrong type of entity");
            }

            _secantNodalLeader = secantNodalLeader;

            TbNodeNumber.Text  = _secantNodalLeader.NodeNumber;
            TbNodeAddress.Text = _secantNodalLeader.NodeAddress;
            TbSheetNumber.Text = _secantNodalLeader.SheetNumber;
        }