我一直在使用设计自动化 API 在一些绘图文件上运行一些简单的脚本,但我的输出文件总是损坏,我不知道为什么。
我正在运行以下脚本以将一些数据添加到 MTEXT 中的图形中
; Some setup of variables
;
; Get the co-ords of the bottom right corner
(setq x-coord (car (getvar 'extmax)))
(setq y-coord (cadr (getvar 'extmin)))
; Move the coords away from the drawing a bit
(setq y-coord (- y-coord 5))
; Create multi-line text at bottom right in a 200 x 100 box
-mtext (list x-coord y-coord) h 2 (list (+ x-coord 200) (- y-coord 100)) - - MED data - -
Project: Project X
End User: TestCorp
Tag No: P1234567
Version: 1
Created: 29/09/16
Modified: 29/09/16
(command "_save" "result.dwg")
; end
当我在本地版本的 AutoCAD 中运行该脚本时,它运行良好,但是当我在设计自动化 API 上运行它时,结果文件是一个无法打开的小混乱!
我正在使用以下详细信息进行活动
{
"HostApplication":"",
"RequiredEngineVersion":"20.1",
"Parameters":{
"InputParameters": [
{
"Name":"HostDwg",
"LocalFileName":"$(HostDwg)"
}
],
"OutputParameters":[
{
"Name":"Result",
"LocalFileName":"result.dwg"
}
]
},
"Instruction":{
"CommandLineParameters":null,
"Script":"; Some setup of variables\n;\n; Get the co-ords of the bottom right corner\n(setq x-coord (car (getvar 'extmax)))\n(setq y-coord (cadr (getvar 'extmin)))\n; Move the coords away from the drawing a bit\n(setq y-coord (- y-coord 5))\n; Create multi-line text at bottom right in a 200 x 100 box\n-mtext (list x-coord y-coord) h 2 (list (+ x-coord 200) (- y-coord 100)) - - MED data - - \nProject: Project X\nEnd User: TestCorp\nTag No: P1234567\nVersion: 1\nCreated: 29\/09\/16\nModified: 29\/09\/16\n\n(command \"_save\" \"result.dwg\")\n; end"
},
"Version":1,
"Id":"TagMtextDataAndSave"
}
当我在设计自动化 API 上运行此活动时,我收到以下响应
ActivityId => 'TagMtextDataAndSave'
Arguments => object(stdClass) {
InputArguments => [
(int) 0 => object(stdClass) {
Resource => 'https://drive.google.com/uc?export=download&id=XXXXXXXXXXXXXXXXXXXXX'
Name => 'HostDwg'
Headers => []
ResourceKind => null
StorageProvider => 'Generic'
HttpVerb => null
}
]
OutputArguments => [
(int) 0 => object(stdClass) {
Resource => 'https://developer.api.autodesk.com/oss/v2/buckets/my-persistent-bucket/objects/result.dwg'
Name => 'Result'
Headers => [
(int) 0 => object(stdClass) {
Name => 'Authorization'
Value => 'Bearer XXXXXXXXXXXXXXXXX'
}
]
ResourceKind => null
StorageProvider => 'Generic'
HttpVerb => 'PUT'
}
]
}
Status => 'Succeeded'
StatusDetails => object(stdClass) {
Report => ''
}
AvailabilityZone => null
TimeQueued => '2016-10-13T11:49:40.151Z'
TimeInputTransferStarted => '2016-10-13T11:49:40.085Z'
TimeScriptStarted => '2016-10-13T11:49:42.085Z'
TimeScriptEnded => '2016-10-13T11:49:43.35Z'
TimeOutputTransferEnded => '2016-10-13T11:49:43.741Z'
BytesTranferredIn => (int) 59840
BytesTranferredOut => (int) 22702
Timestamp => '2016-10-13T11:49:43.741Z'
Id => '694fa87557db46a985a63f6e40c1e681'
这就是事情变得混乱的地方。正如您在上面看到的报告有Status => 'Succeeded'
,但是如果我们查看输入/输出字节,我们会看到
BytesTranferredIn => (int) 59840
BytesTranferredOut => (int) 22702
当我尝试下载并打开文件时,AutoCAD 说它已损坏,这并不奇怪,因为似乎缺少很多东西。我已经从 API 下载了报告,但我再次看不到任何失败的原因!
[10/13/2016 11:49:40] Starting work item 694fa87557db46a985a63f6e40c1e681
[10/13/2016 11:49:40] Start download phase.
[10/13/2016 11:49:40] Start downloading file https://drive.google.com/uc?export=download&id=XXXXXXXXXXXXXXXXXXXX
[10/13/2016 11:49:41] Redirected, download from https://doc-0s-10-docs.googleusercontent.com/docs/securesc/ha0roXXXXXXXXXXXXXXXXXXXXmbp1/XXXXXXXXXXXXXXXXXXXX/1476352800000/02518323576368124429/*/0B7GM1RWKWZHGdnhMSmRrSDhodDQ?e=download instead.
[10/13/2016 11:49:42] Time spent on downloading from redirected url is 0.1718424 seconds.
[10/13/2016 11:49:42] End downloading file https://drive.google.com/uc?export=download&id=XXXXXXXXXXXXXXXXXXXX. 59840 bytes have been written to C:\Aces\Jobs\694fa87557db46a985a63f6e40c1e681\test.dwg.
[10/13/2016 11:49:42] End download phase.
[10/13/2016 11:49:42] Start preparing script and command line parameters.
[10/13/2016 11:49:42] Start script content.
[10/13/2016 11:49:42] ; Some setup of variables
;
; Get the co-ords of the bottom right corner
(setq x-coord (car (getvar 'extmax)))
(setq y-coord (cadr (getvar 'extmin)))
; Move the coords away from the drawing a bit
(setq y-coord (- y-coord 5))
; Create multi-line text at bottom right in a 200 x 100 box
-mtext (list x-coord y-coord) h 2 (list (+ x-coord 200) (- y-coord 100)) - - MED data - -
Project: Project X
End User: TestCorp
Tag No: P1234567
Version: 1
Created: 29/09/16
Modified: 29/09/16
(command "_save" "result.dwg")
; end
[10/13/2016 11:49:42] End script content.
[10/13/2016 11:49:42] Command line: /i "C:\Aces\Jobs\694fa87557db46a985a63f6e40c1e681\test.dwg" /s "C:\Aces\Jobs\694fa87557db46a985a63f6e40c1e681\script.scr"
[10/13/2016 11:49:42] End preparing script and command line parameters.
[10/13/2016 11:49:42] Start script phase.
[10/13/2016 11:49:42] ### Command line arguments: /isolate job_694fa87557db46a985a63f6e40c1e681 "C:\Aces\Jobs\694fa87557db46a985a63f6e40c1e681\userdata" /exe "C:\Aces\AcesRoot\20.1\coreEngine\Exe\accoreconsole.exe" /i "C:\Aces\Jobs\694fa87557db46a985a63f6e40c1e681\test.dwg" /s "C:\Aces\Jobs\694fa87557db46a985a63f6e40c1e681\script.scr".
[10/13/2016 11:49:42] HostApp = C:\Aces\AcesRoot\20.1\coreEngine\Exe\sandboxer.exe.
[10/13/2016 11:49:42] Start AutoCAD Core application output.
[10/13/2016 11:49:42] Redirect stdout (file: C:\Users\ACESWO~1\AppData\Local\Temp\accc40643).
[10/13/2016 11:49:42] Isolating to userId=job_694fa87557db46a985a63f6e40c1e681, userDataFolder=C:\Aces\Jobs\694fa87557db46a985a63f6e40c1e681\userdata.
[10/13/2016 11:49:42] Launching sandbox process: [C:\Aces\AcesRoot\20.1\coreEngine\Exe\accoreconsole.exe /i C:\Aces\Jobs\694fa87557db46a985a63f6e40c1e681\test.dwg /s C:\Aces\Jobs\694fa87557db46a985a63f6e40c1e681\script.scr /isolate job_694fa87557db46a985a63f6e40c1e681 C:\Aces\Jobs\694fa87557db46a985a63f6e40c1e681\userdata]
[10/13/2016 11:49:42] Setting TMP to [C:\Aces\Jobs\694fa87557db46a985a63f6e40c1e681\userdata\temp]
[10/13/2016 11:49:42] Redirect stdout (file: C:\Aces\Jobs\694fa87557db46a985a63f6e40c1e681\userdata\temp\accc24922).
[10/13/2016 11:49:42] AutoCAD Core Engine Console - Copyright 2015 Autodesk, Inc. All rights reserved. (M.49.Z.1)
[10/13/2016 11:49:42] Running at low integrity.
[10/13/2016 11:49:42] Substituting [simplex.shx] for [G415L_A3.SHX].
[10/13/2016 11:49:42] Regenerating model.
[10/13/2016 11:49:42] Command:
[10/13/2016 11:49:42] Command:
[10/13/2016 11:49:42] Command:
[10/13/2016 11:49:42] Command: (setq x-coord (car (getvar 'extmax)))
[10/13/2016 11:49:42] 50.2149
[10/13/2016 11:49:42] Command: (setq y-coord (cadr (getvar 'extmin)))
[10/13/2016 11:49:42] 7.46976
[10/13/2016 11:49:42] Command: (setq y-coord (- y-coord 5))
[10/13/2016 11:49:42] 2.46976
[10/13/2016 11:49:43] Command: -mtext
[10/13/2016 11:49:43] Current text style: "Standard" Text height: 0.2000 Annotative: No
[10/13/2016 11:49:43] Specify first corner: (list x-coord y-coord) (50.2149 2.46976)
[10/13/2016 11:49:43] Specify opposite corner or [Height/Justify/Line spacing/Rotation/Style/Width/Columns]: h
[10/13/2016 11:49:43] Specify height <0.2000>: 2
[10/13/2016 11:49:43] Specify opposite corner or [Height/Justify/Line spacing/Rotation/Style/Width/Columns]: (list (+ x-coord 200) (- y-coord 100)) (250.215 -97.5302)
[10/13/2016 11:49:43] MText: - - MED data - -
[10/13/2016 11:49:43] MText: Project: Project X
[10/13/2016 11:49:43] MText: End User: TestCorp
[10/13/2016 11:49:43] MText: Tag No: P1234567
[10/13/2016 11:49:43] MText: Version: 1
[10/13/2016 11:49:43] MText: Created: 29/09/16
[10/13/2016 11:49:43] MText: Modified: 29/09/16
[10/13/2016 11:49:43] MText:
[10/13/2016 11:49:43] Command: (command "_save" "result.dwg")
[10/13/2016 11:49:43] _save Save drawing as <C:\Aces\Jobs\694fa87557db46a985a63f6e40c1e681\test.dwg>: result.dwg
[10/13/2016 11:49:43] Command: nil
[10/13/2016 11:49:43] Command: _quit
[10/13/2016 11:49:43] End AutoCAD Core Console output
[10/13/2016 11:49:43] End script phase.
[10/13/2016 11:49:43] Start upload phase.
[10/13/2016 11:49:43] Uploading C:\Aces\Jobs\694fa87557db46a985a63f6e40c1e681\result.dwg to https://developer.api.autodesk.com/oss/v2/buckets/my-persistent-bucket/objects/result.dwg.
[10/13/2016 11:49:43] End upload phase.
[10/13/2016 11:49:43] Job finished with result Succeeded
当一切似乎都指向成功时,我不知道是什么导致了这些问题。任何帮助都会很棒。
如果您需要更多信息,请告诉我。
======= Update =======
感谢大家的建议,我已经离开办公室几天了,所以没有机会测试你的想法。
我想在周末我可能正在运行 autoCad 2017,但我今天早上检查了一下,现在是 2016 年。我尝试使用 21.0 引擎作为测试再次运行脚本,但结果几乎相同!
我已允许共享访问我从中获取文件的 g-drive 目录,并且我还上传了 results.dwg 文件和最后一份报告供大家查看。
你可以在这里找到它们
我确定我缺少一些愚蠢的东西