我正在尝试使用Design Automation API对存储在存储桶中的DWG文件执行CAD脚本。它只是写着“ Hello World !!!”。在文件上。
为了创建脚本,我跟随了本教程:
https://help.autodesk.com/view/OARX/2019/ENU/?guid=GUID-BA686431-C8BF-49F2-946E-9CEB2F7AE4FA
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
namespace MyFirstProject
{
public class Class1
{
[CommandMethod("AdskGreeting")]
public void AdskGreeting()
{
// Get the current document and database, and start a transaction
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
// Starts a new transaction with the Transaction Manager
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
// Open the Block table record for read
BlockTable acBlkTbl;
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
OpenMode.ForRead) as BlockTable;
// Open the Block table record Model space for write
BlockTableRecord acBlkTblRec;
acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
OpenMode.ForWrite) as BlockTableRecord;
/* Creates a new MText object and assigns it a location,
text value and text style */
using (MText objText = new MText())
{
// Specify the insertion point of the MText object
objText.Location = new Autodesk.AutoCAD.Geometry.Point3d(2, 2, 0);
// Set the text string for the MText object
objText.Contents = "Hello World!!!";
// Set the text style for the MText object
objText.TextStyleId = acCurDb.Textstyle;
// Appends the new MText object to model space
acBlkTblRec.AppendEntity(objText);
// Appends to new MText object to the active transaction
acTrans.AddNewlyCreatedDBObject(objText, true);
}
// Saves the changes to the database and closes the transaction
acTrans.Commit();
}
}
}
}
我完成了设计自动化工作流程。我能够使用Forge Node.js SDK发布AppPackage,发布活动和发布WorkItem。
但是,WorkItem的状态返回为FailedExecution
。
由于其中包含机密信息,因此我不会显示完整的错误日志,但以下是一些重点内容:
[01/17/2019 21:30:44] End download phase.
[01/17/2019 21:30:44] Start preparing script and command line parameters.
[01/17/2019 21:30:44] Start script content.
[01/17/2019 21:30:44] _ADSKGREETING
[01/17/2019 21:30:44] End script content.
//Blah
[01/17/2019 21:30:44] End preparing script and command line parameters.
[01/17/2019 21:30:44] Start script phase.
//Blah
[01/17/2019 21:30:44] Start AutoCAD Core Engine standard output dump.
//Blah blah blah
[01/17/2019 21:30:44] AutoCAD Core Engine Console - Copyright 2015 Autodesk, Inc. All rights reserved. (M.49.Z.1)
[01/17/2019 21:30:44] Running at low integrity.
[01/17/2019 21:30:45] Loading AEC Base...
[01/17/2019 21:30:45] Loading AEC Base Extended...
[01/17/2019 21:30:45] Loading AEC Project Base...
[01/17/2019 21:30:45] Loading AEC Architectural Base...
[01/17/2019 21:30:46] Loading AEC Schedule...
[01/17/2019 21:30:46] Substituting [simplex.shx] for [fed-s.shx].
[01/17/2019 21:30:46] Substituting [simplex.shx] for [fed-s.shx].
[01/17/2019 21:30:46] Substituting [simplex.shx] for [fed-s.shx].
[01/17/2019 21:30:46] Substituting [simplex.shx] for [fed-l.shx].
[01/17/2019 21:30:46] Substituting [simplex.shx] for [fed-s.shx].
[01/17/2019 21:30:46] Substituting [simplex.shx] for [fed-s.shx].
[01/17/2019 21:30:46] Substituting [simplex.shx] for [fed-l.shx].
[01/17/2019 21:30:46] Substituting [simplex.shx] for [fed-s.shx].
[01/17/2019 21:30:46] Substituting [simplex.shx] for [fed-l.shx].
[01/17/2019 21:30:46] Substituting [simplex.shx] for [fed-l.shx].
[01/17/2019 21:30:46] Substituting [simplex.shx] for [fed-s.shx].
[01/17/2019 21:30:46] Regenerating model.
[01/17/2019 21:30:47] Command:
[01/17/2019 21:30:47] Command:
[01/17/2019 21:30:47] Command:
[01/17/2019 21:30:47] Command: _ADSKGREETING_quit
[01/17/2019 21:30:47] Unknown command "ADSKGREETING_QUIT". Press F1 for help.
[01/17/2019 21:31:47] Error: AutoCAD Core Console is shut down due to timeout.
[01/17/2019 21:31:47] End script phase.
[01/17/2019 21:31:47] Error: An unexpected error happened during phase CoreEngineExecution of job.
[01/17/2019 21:31:47] Job finished with result FailedExecution
我认为脚本很好,因为我可以通过以下操作在计算机上使用AutoCAD成功运行它:
NETLOAD
->选择MyFirstProject.dll文件-> ADSKGREETING
我的脚本中缺少什么吗?我是否必须包括退出脚本的命令?如果是这样,怎么办?
答案 0 :(得分:0)
是,不是。如果在终止阶段没有任务要执行,只需将处理程序留空。但是,您仍然需要在脚本开始时指定必要的汇编属性。有关详细信息,请参见here。
[assembly: CommandClass(typeof(MyFirstProject.Class1))]
[assembly: ExtensionApplication(null)]
namespace ...
答案 1 :(得分:0)
我认为您的问题很简单,例如缺少空格或在ADSKGREETING命令的末尾输入。请将您的活动定义中的ADSKGREETING更改为ADSKGREETING \
。答案 2 :(得分:0)
创建活动时,您的命令行应包含/ al参数,该参数将在启动accoreconsole时加载您的软件包。
类似这样的东西:
^0$|^[1-9]{1}\.[0-9]{1}$|[1-9]{1}\.[0-9]{2}$^10\.0$