- 精华
- 活跃值
-
- 积分
- 188
- 违规
-
- 印币
-
- 鲜花值
-
- 在线时间
- 小时
累计签到:27 天 连续签到:1 天
|
如图所示,用于使用AI做工程类文件时,无需另存文件进行转曲,并转格式为PDF、DWG,而是一键转出转曲后的ai,PDF,DWG;
使用JavaScript编写,默认保存位置为桌面
- // 获取当前文档的文件名
- var currentFileName = app.activeDocument.name;
- // 将文本转换为轮廓
- var outlineText = function (doc) {
- var textFrames = doc.textFrames;
- for (var i = textFrames.length - 1; i >= 0; i--) {
- var textFrame = textFrames[i];
- textFrame.createOutline();
- }
- };
- // 将线条转换为轮廓
- /*var outlineStrokes = function (doc) {
- var paths = doc.pathItems;
- for (var i = paths.length - 1; i >= 0; i--) {
- var path = paths[i];
- if (path.stroked) {
- path.strokeWidth = 0;
- }
- }
- }; */
- // 导出为AI
- var exportToAI = function (folderPath) {
- var aiOptions = new IllustratorSaveOptions();
- var aiFile = new File(folderPath + "/" + currentFileName.replace(/\.ai$/i, "") + "-转曲" + ".ai");
- if (aiFile.exists) {
- var overwrite = confirm("已存在同名文件,是否要覆盖?");
- if (!overwrite) {
- alert("导出被取消。");
- } else {
- outlineText(app.activeDocument);
- //outlineStrokes(app.activeDocument);
- app.activeDocument.saveAs(aiFile, aiOptions);
- alert("AI文件导出成功!");
- }
- } else {
- outlineText(app.activeDocument);
- //outlineStrokes(app.activeDocument);
- app.activeDocument.saveAs(aiFile, aiOptions);
- alert("AI文件导出成功!");
- }
- };
- // 导出为PDF
- var exportToPDF = function (folderPath) {
- var pdfOptions = new PDFSaveOptions();
- pdfOptions.preset = "PDF/X-4:2008";
- var pdfFile = new File(folderPath + "/" + currentFileName.replace(/\.ai$/i, "") + ".pdf");
- if (pdfFile.exists) {
- var overwrite = confirm("已存在同名文件,是否要覆盖?");
- if (!overwrite) {
- alert("导出被取消。");
- } else {
- app.activeDocument.saveAs(pdfFile, pdfOptions);
- alert("PDF文件导出成功!");
- }
- } else {
- app.activeDocument.saveAs(pdfFile, pdfOptions);
- alert("PDF文件导出成功!");
- }
- };
- // 导出为DWG
- var exportToDWG = function (folderPath) {
- var dwgOptions = new ExportOptionsAutoCAD();
- dwgOptions.version = AutoCADCompatibility.AutoCADRelease14;
- dwgOptions.exportSelectedArtOnly = false;
- dwgOptions.convertTextToOutlines = true;
- var dwgFile = new File(folderPath + "/" + currentFileName.replace(/\.ai$/i, "") + ".dwg");
- if (dwgFile.exists) {
- var overwrite = confirm("已存在同名文件,是否要覆盖?");
- if (!overwrite) {
- alert("导出被取消。");
- } else {
- app.activeDocument.exportFile(dwgFile, ExportType.AUTOCAD, dwgOptions);
- alert("DWG文件导出成功!");
- alert("将要关闭文件");
- }
- } else {
- app.activeDocument.exportFile(dwgFile, ExportType.AUTOCAD, dwgOptions);
- alert("DWG文件导出成功!");
- alert("将要关闭文件");
- }
- };
- // 导出为AI
- var aiFolder = Folder.selectDialog("选择AI保存路径");
- if (aiFolder != null) {
- exportToAI(aiFolder);
- }
- // 导出为PDF
- var pdfFolder = aiFolder;
- if (pdfFolder != null) {
- exportToPDF(pdfFolder);
- }
- // 导出为DWG
- var dwgFolder = pdfFolder;
- if (dwgFolder != null) {
- exportToDWG(dwgFolder);
- }
- // 关闭文档
- app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
复制代码
|
评分
-
查看全部评分
|