0

I'm trying to modify DWG file with the API of AutoDesk.

I created a simple command with Visual Basic, this command works well in AutoCAD. The command name is 'Rota'.

Then I created a XML file:

<?xml version="1.0" encoding="utf-8"?>
<ApplicationPackage
  SchemaVersion="1.0"
  Version="1.0"
  AutodeskProduct="AutoCAD"
  AppVersion="0.1.0"
  Name="PluginPrueba"
  Description="Paquete de Prueba"
  Author="Yomisma" >

  <Components>
    <RuntimeRequirements 
      OS="Win64" 
      Platform="AutoCAD" 
      SeriesMin="R23.0" 
      SeriesMax="R23.0"/>
  <ComponentEntry
    AppName="Comandos"
    ModuleName="./Contents/PluginPrueba.dll"
    AppType=".Net"
    AppDescription="Rotate 45 degrees"
    LoadOnCommandInvocation="True"
    LoadOnAutoCADStartup="True">
    <Commands GroupName="ComandosVB">
      <Command Global="Rota" Local="Rota" />
      </Commands>
    </ComponentEntry>
  </Components>
</ApplicationPackage>

I put XML into the folder PluginPrueba.bundle, and I created the folder Contests (in this folder I put de DLL file). Then I maked the ZIP file.

Then into my code, I follows the following steps:

1.- oAuth.

2.- Create a Bucket. I put into the Bucket de DWG file to modify.

3.- Publish Bundle

4.- CreateBundleAlias

5.- UploadToForge the ZIP file.

6.- Create Activity

{
    "id": "ActivityPrueba",
    "commandLine": "$(engine.path)\\accoreconsole.exe /i $(args[inputFile].path) /al $(appbundles[{{ AppBundleName  }}].path) /s $(settings[script].path)",
    "parameters": {
        "inputFile": {
            "zip": false,
            "ondemand": false,
            "verb": "get",
            "description": "Rota DWG",
            "localName": "$(inputFile)"
        },
        "outputFile": {
            "zip": false,
            "ondemand": false,
            "verb": "put",
            "description": "output file",
            "localName": "outputFile.dwg",
            "required": "true"
        }
    },
    "engine": "Autodesk.AutoCAD+23",
    "appbundles": [
        "{{ client_id  }}.{{ AppBundleName  }}+prod"
    ],
    "settings": {
        "script": "Rota\n"
    },
    "description": "AutoCAD Prueba Comando."
}

7.- Create Activity Alias

8.- Create WorkItem

When I executed, this is the report:

[07/17/2019 08:10:23] Starting work item { id }
[07/17/2019 08:10:23] Start download phase.
[07/17/2019 08:10:23] Start preparing AppPackage appBundlePrueba.
[07/17/2019 08:10:23] Start downloading file https://developer.api.autodesk.com/oss/v2/buckets/newtoken/objects/square.dwg.
[07/17/2019 08:10:23] Download bits and install app to local cache.
[07/17/2019 08:10:23] Error: Failed to prepare app package(s).
[07/17/2019 08:10:23] End downloading file https://developer.api.autodesk.com/oss/v2/buckets/newtoken/objects/square.dwg. 32049 bytes have been written to T:\Aces\Jobs\b64f9613734b497db06459cdcd6e6fb1\square.dwg.
[07/17/2019 08:10:23] End download phase.
[07/17/2019 08:10:23] Error: An unexpected error happened during phase Downloading of job.
[07/17/2019 08:10:23] Job finished with result FailedEnvironmentSetup
[07/17/2019 08:10:23] Job Status:
{
  "status": "failedDownload",
  ..........................
}

What it´s wrong?

Beth
  • 1
  • 1

2 Answers2

0

As the error message suggests our service was unable to download the input file from the bucket... most likely due to lack of authentication info in header.

Keep in mind that our buckets are OAuth2 protected so you will need to provide access token (see here for details) in your workitem or generate a signed URL to download/upload objects temporarily w/o authentication (see details here)

"headers": {
              "Authorization": "", //header goes here
              "Content-type": "application/octet-stream"
            },

Alternatively you can store your input/output files to any remote storage of your choice - AWS/GCD/Azure etc.

Bryan Huang
  • 5,247
  • 2
  • 15
  • 20
0

Thanks Bryan!!

I solved the error change in Activity:

"settings": {
    "script": "Rota\n"

to:

"settings": {
    "script": "(command \"Rota\")\n"

Now I have another error:

[07/18/2019 09:24:00] Error: Non-optional output [outputFile.dwg] is missing .

[07/18/2019 09:24:00] Error: An unexpected error happened during phase Publishing of job.

In Activity I have the follow code:

    "outputFile": {
        "zip": false,
        "ondemand": false,
        "verb": "put",
        "description": "output file",
        "localName": "outputFile.dwg",
        "required": "true"
    }

And in WorkItem:

    "outputFile": {
        "url": "https://developer.api.autodesk.com/oss/v2/buckets/{{ TokenKey}}/objects/square.dwg",
        "headers": {
            "Authorization": "Bearer {{ oAuthToken  }}",
            "Content-type": "application/octet-stream"
        },
        "verb": "put"
    },

What may be change?

Thanks!!

Beth
  • 1
  • 1