Официальный форум российского программного комплекса T-FLEX PLM


Поиск  Пользователи  Правила 
Закрыть
Логин:
Пароль:
Забыли свой пароль?
Регистрация
Войти
 
Страницы: 1
Пакетное сохранение GRB в PDF формат
 
Код

// System.Windows.Forms                        - Добавить в ссылки

using System;
using System.IO;
using System.Collections.Generic;
using System.Windows.Forms;
using TFlex.Model;

namespace NewMacroNamespace
{
                public class NewMacroClass
                {
                               public static void NewMacro()
                               {
                                               List<Document> lst = new List<Document>();
                                               System.Windows.Forms.FolderBrowserDialog folderDialog = new System.Windows.Forms.FolderBrowserDialog();
                                               string pathFolder = "";
                                               if (folderDialog.ShowDialog() == DialogResult.OK)
                                               {
                                                               pathFolder = folderDialog.SelectedPath;
                                               }

                                               DirectoryInfo dirInfo = new DirectoryInfo(pathFolder);
                                               FileInfo[] files = dirInfo.GetFiles();
                                               foreach (FileInfo file in files)
                                               {
                                                               Document document = TFlex.Application.OpenDocument(file.FullName);
                                                               ExportToPDF ex = new ExportToPDF(document);
                                                               string path = document.FileName.ToString();
                                                               int slash = 0;
                                                               int pnt = 0;
                                                               for (int i = 0; i < path.ToCharArray().Length; i++)
                                                               {
                                                                              if (path[i] == '\\')
                                                                                              slash = i;
                                                               }
                                                               slash++;
                                                               string res = path.Substring(slash);
                                                               for (int i = 0; i < res.ToCharArray().Length; i++)
                                                               {
                                                                              if (res[i] == '.')
                                                                                              pnt = i;
                                                               }
                                                               res = res.Substring(0, pnt);
                                                               ex.Export(pathFolder + "\\" + res + ".pdf");
                                               }
                               }
                }
}

Изменено: SaprOnOff86 - 10.11.2017 10:41:12
 
А не затруднит ли прокомментировать строчки кода?
Сам далеко не программист (даже не понимаю на каком языке написан макрос).
 
Код
using System;
using System.IO;
using System.Collections.Generic;
using System.Windows.Forms;
using TFlex.Model;

namespace NewMacroNamespace
{
                public class NewMacroClass
                {
                               public static void NewMacro()
                               {
                                               List<Document> lst = new List<Document>();
                                               System.Windows.Forms.FolderBrowserDialog folderDialog = new System.Windows.Forms.FolderBrowserDialog();
                                               string pathFolder = "";
                                               if (folderDialog.ShowDialog() == DialogResult.OK)
                                               {
                                                               pathFolder = folderDialog.SelectedPath;
                                               }

                                               DirectoryInfo dirInfo = new DirectoryInfo(pathFolder);
                                               FileInfo[] files = dirInfo.GetFiles();
                                               foreach (FileInfo file in files)
                                               {
                                                               Document document = TFlex.Application.OpenDocument(file.FullName);
                                                
                                                               ExportToPDF ex = new ExportToPDF(document);                                                
                                                               string path = document.FileName.ToString();
                                                               int slash = 0;
                                                               int pnt = 0;
                                                               for (int i = 0; i < path.ToCharArray().Length; i++)
                                                               {
                                                                              if (path[i] == '\\')
                                                                                              slash = i;
                                                               }
                                                               slash++;
                                                               string res = path.Substring(slash);
                                                               for (int i = 0; i < res.ToCharArray().Length; i++)
                                                               {
                                                                              if (res[i] == '.')
                                                                                              pnt = i;
                                                               }
                                                               res = res.Substring(0, pnt);
                                                               ex.Export(pathFolder + "\\" + res + ".pdf");
                                                //закрываем документ
                                                document.Close();
                                                document = null;

                                               }
                               }
                }
}



Научил закрывать документ .grb после экспорта. А вот как запретить макросу не открывать .pdf документ при создании.
За это вроде отвечает свойство OpenExportFile, но как его применять ума не приложу, т.к. не программист.
Может кто разбирающийся в C# подскажет?
 
avm,

Код
ex.OpenExportFile = false;
T-FLEX CAD 15.1.68.0
 
Цитата
vite написал:
avm ,
Код
 ex.OpenExportFile = false;
 

ExportToPDF ex = new ExportToPDF(document);
ex.OpenExportFile = false;
string path = document.FileName.ToString();

Так?
 
avm, именно так.
T-FLEX CAD 15.1.68.0
 
vite, спасибо!
 
Добрый день а можете файл макроса скинут , буду очень благодарен!!!!
 
Цитата
Sergey Kasay написал:
Добрый день а можете файл макроса скинут , буду очень благодарен!!!!
Страницы: 1