예제 #1
0
        private static void CreateLayoutCollectionFromBlockNames(Transaction trans, LayoutModelCollection layoutModelCollection, string[] blockNames)
        {
            DynamicBlockFinder dynamicBlocks = new DynamicBlockFinder(layoutModelCollection)
            {
                BlockNameToSearch = blockNames
            };

            dynamicBlocks.GetLayoutsWithDynBlocks(trans);

            layoutModelCollection.DeleteEmptyLayout();

            var blocksList = layoutModelCollection.LayoutModels.Select(x => x.BlocksObjectId).ToArray();

            if (blocksList.Length == 0)
            {
                return;
            }

            layoutModelCollection.SetPrintModels(trans);
            layoutModelCollection.SetLayoutPlotSetting();
        }
예제 #2
0
        public static void ChangePlotSetting()
        {
            // Get the current document and database, and start a transaction
            Document acDoc   = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                // Reference the Layout Manager
                LayoutManager acLayoutMgr;
                acLayoutMgr = LayoutManager.Current;

                // Get the current layout and output its name in the Command Line window
                Layout acLayout;

                LayoutModelCollection layoutModelCollection = new LayoutModelCollection();
                layoutModelCollection.ListLayouts("Model");
                var layouts = layoutModelCollection.LayoutModels.OrderBy(x => x.Layout.TabOrder).ToList();

                foreach (var layout in layouts)
                {
                    acLayout = acTrans.GetObject(layout.LayoutPlotId,
                                                 OpenMode.ForRead) as Layout;
                    if (acLayout != null)
                    {
                        // Output the name of the current layout and its device
                        acDoc.Editor.WriteMessage("\nCurrent layout: " +
                                                  acLayout.LayoutName);

                        acDoc.Editor.WriteMessage("\nCurrent device name: " +
                                                  acLayout.PlotConfigurationName);

                        // Get the PlotInfo from the layout
                        PlotInfo acPlInfo = new PlotInfo();
                        acPlInfo.Layout = acLayout.ObjectId;

                        // Get a copy of the PlotSettings from the layout
                        PlotSettings acPlSet = new PlotSettings(acLayout.ModelType);
                        acPlSet.CopyFrom(acLayout);

                        // Update the PlotConfigurationName property of the PlotSettings object
                        PlotSettingsValidator acPlSetVdr = PlotSettingsValidator.Current;
                        acPlSetVdr.SetPlotConfigurationName(acPlSet, "DWG_To_PDF_Uzle.pc3",
                                                            "UserDefinedMetric (891.00 x 420.00мм)");

                        acPlSetVdr.SetStdScaleType(acPlSet, StdScaleType.ScaleToFit);
                        // Center the plot
                        //acPlSetVdr.SetPlotCentered(acPlSet, true);

                        // Update the layout
                        acLayout.UpgradeOpen();
                        acLayout.CopyFrom(acPlSet);

                        // Output the name of the new device assigned to the layout
                        acDoc.Editor.WriteMessage("\nNew device name: " +
                                                  acLayout.PlotConfigurationName);
                    }
                }

                // Save the new objects to the database
                acTrans.Commit();
            }
        }
예제 #3
0
 public PrintPackageCreator(LayoutModelCollection layoutModels, string[] mainPageName)
 {
     LayoutModels = layoutModels;
     MainPageName = mainPageName;
     CreatePrintPackages();
 }
 public DynamicBlockFinder(LayoutModelCollection layoutModelCollection)
 {
     LayoutModelCollection = layoutModelCollection;
 }
예제 #5
0
        public void CreateTransmitallFromLayout()
        {
            string fileName = (string)Application.GetSystemVariable("DWGNAME");
            string path     = (string)Application.GetSystemVariable("DWGPREFIX");
            string allPath  = Path.Combine(path, fileName);

            Active.Database.SaveAs(allPath, true, DwgVersion.Current, Active.Database.SecurityParameters);

            List <Sheet>          sheets = new List <Sheet>();
            LayoutModelCollection layoutModelCollection = new LayoutModelCollection();

            layoutModelCollection.ListLayouts("Model");
            string[] blockNames = { "ФорматM25", "Формат" };
            using (Transaction trans = Active.Database.TransactionManager.StartTransaction())
            {
                DynamicBlockFinder dynamicBlocks = new DynamicBlockFinder(layoutModelCollection)
                {
                    BlockNameToSearch = blockNames
                };

                dynamicBlocks.GetLayoutsWithDynBlocks(trans);

                layoutModelCollection.DeleteEmptyLayout();

                var blocksList = layoutModelCollection.LayoutModels.Select(x => x.BlocksObjectId).ToArray();
                if (blocksList.Length == 0)
                {
                    return;
                }

                layoutModelCollection.SetPrintModels(trans);
                layoutModelCollection.SetLayoutPlotSetting();
                trans.Commit();
            }

            using (Transaction trans = Active.Database.TransactionManager.StartTransaction())
            {
                string[] viewNames      = { "Форма 3 ГОСТ Р 21.1101-2009 M25", "Форма 3 ГОСТ Р 21.1101-2009" };
                var      packageCreator = new PrintPackageCreator(layoutModelCollection, viewNames);

                LayoutTreeView window = new LayoutTreeView(packageCreator.PrintPackageModels);
                Application.ShowModalWindow(window);

                if (!window.isClicked)
                {
                    return;
                }

                var printPackages = window._printPackages;
                packageCreator.PrintPackageModels = printPackages;

                packageCreator.PublishAllPackages();

                var blockIds = printPackages.SelectMany(x => x.Layouts.Select(y => y.BlocksObjectId)).ToArray();

                Utils utils = new Utils();
                GetSheetsFromBlocks(Active.Editor, sheets, trans, new ObjectIdCollection(blockIds));

                utils.CreateJsonFile(sheets);
            }
        }