首页 > 解决方案 > 如何修复无法读取或编译的导出 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;  
}  

标签: jsxautocadadobe-illustratordxf

解决方案


推荐阅读