Ejemplo n.º 1
0
        public string GetCanonNameByWidthAndHeight()
        {
            StandartCopier standartCopier = new StandartCopier();
            PlotConfig     pConfig        = PlotConfigManager.SetCurrentConfig(standartCopier.Pc3Location);

            //паттерн для размера листов
            string pat = @"\d{1,}?\.\d{2}";

            string canonName = "";

            foreach (var line in pConfig.CanonicalMediaNames)
            {
                Regex pattern = new Regex(pat, RegexOptions.Compiled |
                                          RegexOptions.Singleline);
                if (pattern.IsMatch(line))
                {
                    var    items = DivideStringToWidthAndHeight(pattern, line);
                    double curWidth;
                    double curHeight;

                    if (IsFormatHorizontal())
                    {
                        curWidth  = Math.Round(Width / ScaleX);
                        curHeight = Math.Round(Height / ScaleX);
                    }
                    else
                    {
                        curWidth  = Math.Round(Height / ScaleX);
                        curHeight = Math.Round(Width / ScaleX);
                    }

                    if (items.Item1 == curWidth & items.Item2 == curHeight)
                    {
                        canonName = line;
                        break;
                    }
                }
            }
            return(canonName);
        }
Ejemplo n.º 2
0
        public void Initialize()
        {
            string executablePath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            ProxyDomain pd       = new ProxyDomain();
            Assembly    assembly = pd.GetAssembly(System.IO.Path.Combine(executablePath, "MaterialDesignThemes.Wpf.dll"));

            Assembly assembly1 = pd.GetAssembly(Path.Combine(executablePath, "MaterialDesignColors.dll"));

            if (assembly != null | assembly1 != null)
            {
                Active.Editor.WriteMessage("style dlls not load");
            }


            StandartCopier standartCopier = new StandartCopier();

            if (!File.Exists(standartCopier.Pc3Location) & !File.Exists(standartCopier.PmpLocation))
            {
                bool isCopied = standartCopier.CopyParamsFiles();
                if (isCopied)
                {
                    Active.Editor.WriteMessage("Файлы {0}, {1} скопированы", standartCopier.Pc3Location,
                                               standartCopier.PmpLocation);
                }
                else
                {
                    Active.Editor.WriteMessage(
                        "Не удалось скопировать файлы настройки, скопируйте с сервера \\\\uz-fs\\install\\CAD\\Blocks файлы {0}  в {1} и {2} ",
                        standartCopier.Pc3Dest, standartCopier.Pc3Location, standartCopier.PmpLocation);
                }
            }
            else
            {
                Active.Editor.WriteMessage("Файлы настройки присутствуют, для перевода в pdf наберите CreateTranspdf");
            }

            Active.Editor.WriteMessage("Файлы настройки присутствуют, для перевода в pdf наберите CreateTranspdf");
        }
Ejemplo n.º 3
0
        public void SetLayoutPlotSetting()
        {
            Document       acDoc          = Application.DocumentManager.MdiActiveDocument;
            Database       acCurDb        = acDoc.Database;
            StandartCopier standartCopier = new StandartCopier();

            PlotConfigManager.SetCurrentConfig(standartCopier.Pc3Location);

            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                Layout acLayout;

                LayoutModels = LayoutModels.OrderBy(x => x.Layout.TabOrder).ToList();

                foreach (var layout in LayoutModels)
                {
                    acLayout = acTrans.GetObject(layout.LayoutPlotId,
                                                 OpenMode.ForRead) as Layout;

                    if (acLayout == null)
                    {
                        continue;
                    }

                    LayoutManager lm = LayoutManager.Current;
                    lm.CurrentLayout = acLayout.LayoutName;

                    var plotArea = acLayout.Extents;
                    // 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.SetCurrentStyleSheet(acPlSet, "monochrome.ctb");
                    bool isHor = layout.PrintModel.IsFormatHorizontal();

                    acPlSetVdr.SetPlotType(acPlSet, PlotType.Extents);
                    acPlSetVdr.SetPlotRotation(acPlSet, isHor ? PlotRotation.Degrees000 : PlotRotation.Degrees090);
                    acPlSetVdr.SetPlotWindowArea(acPlSet, Get2dExtentsFrom3d(plotArea));
                    acPlSetVdr.SetStdScaleType(acPlSet, StdScaleType.ScaleToFit);

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

                    acPlSetVdr.SetPlotConfigurationName(acPlSet, "DWG_To_PDF_Uzle.pc3",
                                                        layout.CanonicalName);
                    acPlSetVdr.SetZoomToPaperOnUpdate(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);

                    Active.Editor.Regen();
                }

                // Save the new objects to the database
                acTrans.Commit();
            }
        }