Пример #1
0
        /// <summary>
        /// Функция инициализации (выполняется при загрузке плагина)
        /// </summary>
        public void Initialize()
        {
            _settings.SectionMaxSize = _initialSectionMaxSize;

            var document = Autodesk.AutoCAD.ApplicationServices
                           .Application.DocumentManager.MdiActiveDocument;

            acadApp.Idle += StartPluginHandler;

            AcadTools.SetDefaultPdMode(document);

            BuildRibbonItem buildRibbonItem = new BuildRibbonItem();

            if (Autodesk.Windows.ComponentManager.Ribbon == null)
            {
                acadApp.SystemVariableChanged += new SystemVariableChangedEventHandler(Application_SystemVariableChanged);
            }
            else
            {
                acadApp.SystemVariableChanged += new SystemVariableChangedEventHandler(Application_SystemVariableChanged);
            }

            void Application_SystemVariableChanged(object sender, SystemVariableChangedEventArgs e)
            {
                if (e.Name.ToLower() == "wscurrent")
                {
                    AcadTools.CreateLayersForPluginTool(document);
                    new BuildRibbonItem().CreateRibbonTab();
                }
            }
        }
Пример #2
0
        private void StartPluginHandler(object sender, EventArgs e)
        {
            var document = Autodesk.AutoCAD.ApplicationServices
                           .Application.DocumentManager.MdiActiveDocument;

            acadApp.Idle -= StartPluginHandler;

            AcadTools.CreateLayersForPluginTool(document);
            new BuildRibbonItem().CreateRibbonTab();
        }
Пример #3
0
        private static void SetTextParams(
            BlockTableRecord block,
            string paramsTextPrefix,
            Func <string> GetParamsText)
        {
            ApplyFunction(
                GetAnyMText(AcadTools.GetBlockEntities(block), paramsTextPrefix),
                e =>
            {
                var text      = (MText)e;
                text.Contents = GetParamsText();
            });

            RefreshBlockGraphics(block);
        }
        public void BuildHeight()
        {
            Func <string> GetAnyIniqueBlockName = () => DateTime.Now.Ticks.ToString();

            var document = Autodesk.AutoCAD.ApplicationServices
                           .Application.DocumentManager.MdiActiveDocument;

            AcadTools.CreateLayersForPluginTool(document);
            AcadTools.ChangeCurrentLayers();

            while (AcadTools.CreateHeightPointBlock(document))
            {
            }
            ;

            AcadTools.ChangeCurrentLayers();
        }
        void acadApp_SystemVariableChanged(object sender, SystemVariableChangedEventArgs e)
        {
            try
            {
                if (e.Name.Equals("WSCURRENT"))
                {
                    var document = Autodesk.AutoCAD.ApplicationServices
                                   .Application.DocumentManager.MdiActiveDocument;

                    AcadTools.CreateLayersForPluginTool(document);
                    new BuildRibbonItem().CreateRibbonTab();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                throw;
            }
        }
        private void BuildRoadPoint(Func <Document, int, bool> CreatePointBlockDialog)
        {
            var document = Autodesk.AutoCAD.ApplicationServices
                           .Application.DocumentManager.MdiActiveDocument;

            int pointNumber = 0;

            if (!AcadTools.GetPointNumberDialog(out pointNumber))
            {
                return;
            }

            AcadTools.CreateLayersForPluginTool(document);
            AcadTools.ChangeCurrentLayers();

            while (CreatePointBlockDialog(document, pointNumber))
            {
                pointNumber++;
            }
            ;

            AcadTools.ChangeCurrentLayers();
        }