AutoCAD的AccoreConsole - 第二篇(执行脚本)

来源:互联网 发布:八仙尘爆事件 知乎 编辑:程序博客网 时间:2024/06/07 03:47
从上篇可以看到AccoreConsole 启动了一种AutoCAD命令行环境,以最轻量化的方式操作图纸,效率和易用性得到很大的提高,尤其适合于批处理的场景。通常情况下,我们不会那样一行行的输入,而是用脚本批处理。在这之前,看看AccoreConsole几个可选参数:


可选参数功能/i输入需要操作的图纸所在路径/s操作脚本所在路径/l指定某语言版本的AccoreConsole/isolate防止影响AutoCAD本身的系统变量


AccoreConsole使用 *.scr 作为脚本文件。来看一个例子:先把上篇得到的图纸拷贝到一个目录,例如

C:\temp\testAccoreConsole\

1. 在该目录下创建一个名为testPDF.scr文件,其中填入如下内容。脚本首先通过LISP命令获取到当前图纸的名字,然后构造出导出PDF的文件名。最后运行Plot命令,导出PDF。


(setq CurrDwgName (getvar "dwgname"))(setq Fname (substr CurrDwgName 1 (- (strlen CurrDwgName) 4)))(setq name (strcat (getvar "DWGPREFIX") Fname "_EN.pdf"));Command:FILEDIA;Enter new value for FILEDIA <1>:0;Command:-PLOT;Detailed plot configuration? [Yes/No] <No>: Yes;Enter a layout name or [?] <Model>:Model;Enter an output device name or [?] <None>:DWG To PDF.pc3;Enter paper size or [?] <ANSI A (11.00 x 8.50 Inches)>:ANSI A (11.00 x 8.50 Inches);Enter paper units [Inches/Millimeters] <Inches>:Inches;Enter drawing orientation [Portrait/Landscape] <Portrait>: Landscape;Plot upside down? [Yes/No] <No>:No;Enter plot area [Display/Extents/Limits/View/Window] <Display>: Extents;Enter plot scale (Plotted Inches=Drawing Units) or [Fit] <Fit>:Fit;Enter plot offset (x,y) or [Center] <0.00,0.00>:;Plot with plot styles? [Yes/No] <Yes>:Yes;Enter plot style table name or [?] (enter . for none) <>:.;Plot with lineweights? [Yes/No] <Yes>:Yes;Enter shade plot setting [As displayed/legacy Wireframe/legacy Hidden/Visualstyles/Rendered] <As displayed>:;Enter file name <C:\Work\solids-Model.pdf>:!name;Save changes to page setup? Or set shade plot quality? [Yes/No/Quality] <N>:No;Proceed with plot [Yes/No] <Y>:Yes;Command:FILEDIA;;;Enter new value for FILEDIA <1>:1(princ "DONE")


2. 接着,创建一个名为RunAccore.bat的批处理文件,其中内容是


cd "C:\Program Files\Autodesk\AutoCAD 2016"c:clsaccoreconsole.exe /i "C:\temp\testAccoreConsole\Drawing1.dwg" /s "C:\temp\testAccoreConsole\testPDF.scr" /l en-USPAUSE

它切换到AutoCAD 2016安装路径,这样能找到accoreconsole.exe. 接着执行accoreconsole.exe,操作指定位置的图纸,使用指定位置的脚本,最后的参数是使用英文本的accoreconsole.exe。

3. 运行RunAccore.bat,  accoreconsole启动,执行脚本。最后看到生成的PDF文件Drawing1_EN.pdf.



所以,我们能很方便执行设置需要的脚本,操作特定的图纸。下一篇我们看看如何加载和执行插件命令。




0 0
原创粉丝点击