jsx - 如何修复无法读取或编译的导出 DXF
问题描述
我是一名考古学家,试图对我们在挖掘过程中所做的图纸进行地理参考 3D 可视化。数百幅绘图已使用 Illustrator CS6 完成,然后由 AutoCad Map 2018 和 Covadis 16.0b 读取。图纸在 .ai 中,我使用 .jsx 脚本自动将它们导出为 .dxf(节省工作时间,有数百个文件,如果可行的话,将来可能有数千个文件)。我的同事使用 AutoCad 完成最后的工作,当我手动导出文件时(2004/2005/2006 AutoCad 格式),可以完美读取文件。但是,当我自动导出它们时,他无法做到这一点,但我可以用 Illustrator 阅读它们。
我不是开发人员,我的工作场所也没有开发人员。我只知道如何稍微修改代码,或者了解代码中的哪个部分与哪个操作相关。
我认为问题在于导出的版本(第 107 行):它是 AutoCad 2018,我的同事已经遇到了问题,这就是为什么他们总是在 2004/2005/2006 AutoCad 版本中要求 dxf。我试图(几乎随机)找到这样一个版本的正确语法,但我做不到。并且出于安全问题,我们无法在我们的计算机上更新或安装任何东西。有谁知道语法?
我的另一个不太乐观的猜测是整个脚本功能失调:我用它导出的 dxf 似乎已编译,无论我手动导出的那些不是。
我的代码部分来自这个线程:如何在目录中的所有文件上运行 Illustrator javascript?(用于选择整个目录)
还有这个帖子:https ://forums.adobe.com/thread/2345496 (虽然我修改了一下,因为我只需要dxf格式,但是由于这是一个未解决的帖子,我怕误会真正的问题)。
额外的问题:图纸是按1-20的比例完成的,他需要1-1的比例。我认为规模的线是 110,有人知道如何以这种规模出口吗?
这是代码:
//Beginning of the selecter script
// Select several files at once
var dir = Folder.selectDialog("Where?");
var files = dir.getFiles("*.eps");
for(var f = 0; f < files.length; f++){
var doc = app.open(files[f]);
//Your processing
doc.close(SaveOptions.SAVECHANGES);
}
var destFolder, sourceFolder, files, fileType, sourceDoc, targetFile, dxfExportOpts;
// Beginning of the exporter script
// Select the source folder.
sourceFolder = Folder.selectDialog( 'Select the folder with Illustrator files you want to convert to DXF', '~' );
// If a valid folder is selected
if ( sourceFolder != null )
{
files = new Array();
//fileType = prompt( 'Select type of Illustrator files to you want to process. Eg: *.ai', '*.ai' );
fileType = "*.ai"
// Get all files matching the pattern
files = sourceFolder.getFiles( fileType );
if ( files.length > 0 )
{
// Get the destination to save the files
// destFolder = Folder.selectDialog( 'Select the folder where you want to save the converted dxf files.', '~' );
destFolderdxf = new Folder (files[0].parent+"/dxf");
if (!destFolderdxf.exists) {
destFolderdxf.create();
}
if(confirm( files.length + ' found.\nFiles will be saved in respective extension folders.\nPlease wait even if you get a spinning wheel.\n\nProceed with saving files?'))
{
for ( i = 0; i < files.length; i++ )
{
sourceDoc = app.open(files[i]); // returns the document object
// export DXF
targetFile = getNewName(destFolderdxf, '.dxf');
dxfExportOpts = getDXFOptions();
sourceDoc.exportFile( targetFile, ExportType.AUTOCAD, dxfExportOpts );
sourceDoc.close(SaveOptions.DONOTSAVECHANGES);
}
//alert( 'Done. ' + i + ' Files are saved as DXF.');
}
else
{
alert( 'No matching files found' );
}
}
else
{
// Do nothing!
}
}
/*********************************************************
getNewName: Function to get the new file name. The primary
name is the same as the source file.
**********************************************************/
function getNewName(destFolder, ext)
{
var ext, docName, newName, saveInFile, docName;
docName = sourceDoc.name;
//ext = '.dxf'; // new extension for dxf file
newName = "";
for ( var i = 0 ; docName[i] != "." ; i++ )
{
newName += docName[i];
}
newName += ext; // full dxf name of the file
// Create a file object to save the dxf
saveInFile = new File( destFolder + '/' + newName );
return saveInFile;
}
/*********************************************************
getDXFOptions: Function to set the DXF saving options of the
files using the dxfSaveOptions object.
**********************************************************/
function getDXFOptions()
{
var exportAutoCADOptions = new ExportOptionsAutoCAD();
exportAutoCADOptions.exportFileFormat = AutoCADExportFileFormat.DXF; // AutoCADExportFileFormat.DWG DXF
exportAutoCADOptions.exportOption = AutoCADExportOption.MaximumEditability; //PreserveAppearance MaximumEditability
exportAutoCADOptions.version = AutoCADCompatibility.AutoCADRelease18;
exportAutoCADOptions.exportSelectedArtOnly = false;
exportAutoCADOptions.convertTextToOutlines = false;
exportAutoCADOptions.unit = AutoCADUnit.Millimeters;
}
解决方案
推荐阅读
- google-apis-explorer - API 资源管理器正在加载而没有响应
- openam - 在树上进行身份验证时记住我在 ForgeRock 登录上的用户名复选框
- powershell - 如何遍历包含具有键、值的多个数组的哈希表并将其附加到另一个字符串?
- reactjs - 在 Gatsby 中禁用进入成功页面
- python - 为什么我的 numpy 数组的元素被地板分割?
- json - 考虑一个线程组中的2个请求,如何根据线程数执行一次请求和剩余请求
- python - (venv) (base) 在 python 项目中都处于活动状态,我如何只进入 venv?
- python - Python - 在for循环中更改变量会产生不同的结果
- ios - 颤振:“失去与设备的连接。” 第二次使用 image_picker 从 iOS 上的图库中选择照片
- swift - 快速在 UIImage 上添加文本 - 以编程方式