Reputation: 71
I am following this guide to build an automation and the appbundle it takes is a local file. I'd like to eliminate the step of user inputting the file so that file is automatically gets picked up from BIM360 or a SharePoint document library. Is there a way to directly stream this zip file?
I have tried getting its storage link after uploading it to BIM360 but this didn't work. However, this works fine for DWG file that is also an user input as identified in task 5.
Any help or ideas would be really appreciated.
Upvotes: 0
Views: 89
Reputation: 4451
The AppBundle file needs to be uploaded to DA. That is the only way DA can download it to the worker when your workitem runs.
BIM 360 APIs provide you a means to download the file through a downloadable presigned URL. The DA APIs provide you means to upload the app bundle through upload presigned URL. Streaming the file directly from source to destination will depend on the technology / language you choose. Here is a rough python pseudo sample below. The key is to choose stream=True
.
sourceResponse = requests.get(sourceUrl, headers=headers, stream=True)
requests.put(targetUrl, headers=headers, data = sourceResponse.content)
Upvotes: 0
Reputation: 705
Yes, you need to pass the storage ID of the file to the Design Automation workitem
along with the necessary authorization headers. Your activity should reference the drawing from the zip folder if you want that drawing to be the primary host.dwg
to start the accoreconsole
instance.
Let's see how to do that.
https://developer.api.autodesk.com/data/v1/projects/{{ _.projectId }}/folders/{{ _.folderId }}/contents
The response will include the storage information of the zip file DimTest.zip:
{
"storage": {
"data": {
"type": "objects",
"id": "urn:adsk.objects:os.object:wip.dm.prod/8db7cdce-5755-49bf-942c-8d61081c0664.zip"
},
"meta": {
"link": {
"href": "https://developer.api.autodesk.com/oss/v2/buckets/wip.dm.prod/objects/8db7cdce-5755-49bf-942c-8d61081c0664.zip?scopes=b360project.adeb4f3b-1ee0-4fca-bb80-30934ae15668,O2tenant.14823638"
}
}
}
}
TCircle.dwg
file to be present in the extracted DimTest.zip
on the DA server.{
"commandLine": [
"$(engine.path)\\accoreconsole.exe /i \"$(args[inputFile].path)\\TCircle.dwg\" /s $(settings[script].path)"
],
"parameters": {
"inputFile": {
"verb": "get",
"required": true,
"zip": true,
"localName": "bim360files"
}
},
"id": "{{ _.activityId }}",
"engine": "Autodesk.AutoCAD+24_3",
"settings": {
"script": "(vl-directory-files \"bim360files\" nil 1)\n"
},
"description": "Get a bim360 zip file on to DA"
}
There is a Script file that tells DA to list all the drawing files in bim360files. This is the folder extracted from DimTest.zip on the DA server.
After creating the activity and its alias, let's create a suitable workitem
to drive the activity.
{
"activityId": "adnworks.getbim360files+prod",
"arguments": {
"inputFile": {
"url": "urn:adsk.objects:os.object:wip.dm.prod/8db7cdce-5755-49bf-942c-8d61081c0664.zip",
"headers": {
"Authorization": "Bearer {{ _.oAuthToken }}",
"Content-type": "application/octet-stream"
}
}
}
}
The result.txt
will have -
[08/08/2024 09:09:26] Starting work item 66c7bda157ab40d39d5d2b992f7e7374
[08/08/2024 09:09:26] Start download phase.
[08/08/2024 09:09:26] Start downloading input: verb - 'Get', url - 'urn:adsk.objects:os.object:wip.dm.prod/8db7cdce-5755-49bf-942c-8d61081c0664.zip'
[08/08/2024 09:09:27] End downloading file. Source=urn:adsk.objects:os.object:wip.dm.prod/8db7cdce-5755-49bf-942c-8d61081c0664.zip,LocalFile=C:\DARoot\Jobs\66c7bda157ab40d39d5d2b992f7e7374\zip_2431.zip,BytesDownloaded=55423,Duration=310ms
[08/08/2024 09:09:27] C:\DARoot\Jobs\66c7bda157ab40d39d5d2b992f7e7374\zip_2431.zip has been unpacked to folder C:\DARoot\Jobs\66c7bda157ab40d39d5d2b992f7e7374\bim360files.
[08/08/2024 09:09:27] End download phase successfully.
[08/08/2024 09:09:27] Start preparing script and command line parameters.
[08/08/2024 09:09:27] Command line: [ /i "C:\DARoot\Jobs\66c7bda157ab40d39d5d2b992f7e7374\bim360files\TCircle.dwg" /s C:\DARoot\Jobs\66c7bda157ab40d39d5d2b992f7e7374\setting_script.scr]
[08/08/2024 09:09:27] End preparing script and command line parameters.
[08/08/2024 09:09:27] Start script phase.
[08/08/2024 09:09:27] Start AutoCAD Core Engine standard output dump.
[08/08/2024 09:09:27] Redirect stdout (file: C:\DARoot\Jobs\66c7bda157ab40d39d5d2b992f7e7374\tmp\accc41802).
[08/08/2024 09:09:27] AcCoreConsole: StdOutConsoleMode: processed-output: disabled,auto
[08/08/2024 09:09:27] AutoCAD Core Engine Console - Copyright 2023 Autodesk, Inc. All rights reserved. (U.61.Z.187)
[08/08/2024 09:09:27] Execution Path:
[08/08/2024 09:09:27] C:\DARoot\AcesRoot\24.3\coreEngine\Exe\accoreconsole.exe
[08/08/2024 09:09:27] Current Directory: C:\DARoot\Jobs\66c7bda157ab40d39d5d2b992f7e7374
[08/08/2024 09:09:27] Isolating to regkey=HKEY_CURRENT_USER\SOFTWARE\AppDataLow\Software\Autodesk\CoreUser\WorkItem_66c7bda157ab40d39d5d2b992f7e7374, userDataFolder=C:\DARoot\Jobs\66c7bda157ab40d39d5d2b992f7e7374\userdata.
[08/08/2024 09:09:28] Version Number: U.61.Z.187 (UNICODE)
[08/08/2024 09:09:28] LogFilePath has been set to the working folder.
[08/08/2024 09:09:29] Regenerating model.
[08/08/2024 09:09:29] AutoCAD menu utilities loaded.
[08/08/2024 09:09:29] Command:
[08/08/2024 09:09:29] Command:
[08/08/2024 09:09:29] Command:
[08/08/2024 09:09:29] Command: (vl-directory-files "bim360files" nil 1)
[08/08/2024 09:09:29] ("DimTest.dwg" "TCircle.dwg")
[08/08/2024 09:09:30] End AutoCAD Core Engine standard output dump.
[08/08/2024 09:09:30] End script phase.
[08/08/2024 09:09:30] Start upload phase.
[08/08/2024 09:09:30] End upload phase successfully.
[08/08/2024 09:09:30] Job finished with result Succeeded
[08/08/2024 09:09:30] Job Status:
Upvotes: 0