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

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

                InsertNodalLeaderWithJig(nodalLeader, blockReference);
            }
            catch (Exception exception)
            {
                ExceptionBox.Show(exception);
            }
            finally
            {
                Overrule.Overruling = true;
            }
        }
Пример #2
0
        private static void CreateNodalLeader()
        {
#if !DEBUG
            Statistic.SendCommandStarting(NodalLeader.GetDescriptor().Name, ModPlusConnector.Instance.AvailProductExternalVersion);
#endif
            try
            {
                Overrule.Overruling = false;

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

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

                InsertNodalLeaderWithJig(nodalLeader, blockReference);
            }
            catch (Exception exception)
            {
                ExceptionBox.Show(exception);
            }
            finally
            {
                Overrule.Overruling = true;
            }
        }
        /// <inheritdoc/>
        public void Initialize(IWithDoubleClickEditor smartEntity)
        {
            if (!(smartEntity is NodalLeader nodalLeader))
            {
                throw new ArgumentException("Wrong type of entity");
            }

            _nodalLeader = nodalLeader;

            TbNodeNumber.Text  = _nodalLeader.NodeNumber;
            TbNodeAddress.Text = _nodalLeader.NodeAddress;
            TbSheetNumber.Text = _nodalLeader.SheetNumber;
        }
Пример #4
0
        private static void InsertNodalLeaderWithJig(NodalLeader nodalLeader, BlockReference blockReference)
        {
            // <msg1>Укажите точку вставки:</msg1>
            var insertionPointPrompt = Language.GetItem("msg1");

            // <msg17>Укажите точку рамки:</msg17>
            var framePointPrompt = Language.GetItem("msg17");

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

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

            nodalLeader.JigState = NodalLeaderJigState.InsertionPoint;
            do
            {
                var status = AcadUtils.Editor.Drag(entityJig).Status;
                if (status == PromptStatus.OK)
                {
                    if (nodalLeader.JigState == NodalLeaderJigState.InsertionPoint)
                    {
                        nodalLeader.JigState         = NodalLeaderJigState.FramePoint;
                        entityJig.PromptForNextPoint = framePointPrompt;
                        entityJig.PreviousPoint      = nodalLeader.InsertionPoint;
                    }
                    else if (nodalLeader.JigState == NodalLeaderJigState.FramePoint)
                    {
                        nodalLeader.JigState         = NodalLeaderJigState.LeaderPoint;
                        entityJig.PromptForNextPoint = leaderPointPrompt;
                        nodalLeader.FramePoint       = nodalLeader.EndPoint;

                        // Тут не нужна привязка к предыдущей точке
                        entityJig.PreviousPoint = nodalLeader.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 (!nodalLeader.BlockId.IsErased)
            {
                using (var tr = AcadUtils.Database.TransactionManager.StartTransaction())
                {
                    var ent = tr.GetObject(nodalLeader.BlockId, OpenMode.ForWrite, true, true);
                    ent.XData = nodalLeader.GetDataForXData();
                    tr.Commit();
                }
            }
        }