How can I create an activity for data conversion i

2019-08-23 03:52发布

I'm prototyping a web service to convert data using Design Automation API in Autodesk Forge.

My approach is to invoke an activity that executes a script to import a target data file (such as STEP, IGES format). As an example, I created an activity to convert a STEP file to DWG as follows:

{
    "HostApplication": "",
    "RequiredEngineVersion": "22.0",
    "Parameters": {
        "InputParameters": [{
            "Name": "Source",
            "LocalFileName": "input.stp"
        }, {
            "Name": "HostDwg",
            "LocalFileName": "$(HostDwg)"
        }],
        "OutputParameters": [{
            "Name": "Result",
            "LocalFileName": "output.dwg"
        }]
    },
    "Instruction": {
        "CommandLineParameters": null,
        "Script": "import\ninput.stp\nsaveas\n\noutput.dwg\n"
    },
    "Version": 1,
    "Id": "Step2Dwg"
}

The workitem to invoke this activity was executed without errors, but the output file (output.dwg) had nothing imported from the input file (input.stp). Perhaps this is because some fields (e.g., AllowedChildProcess) were missing in the definition of the activity "Step2Dwg", but I do not know how to fix it.

My questions are:

  1. How to fix the definition of the activity "Step2Dwg" to convert data successfully?
  2. Is there any other approach to create an activity to convert data successfully?

1条回答
祖国的老花朵
2楼-- · 2019-08-23 04:23

You can use the Activity “Translate-STEP2DWG". It takes a .stp file as input and generate result.dwg as output. This is a public activity that anybody can send workitems against to it.

The activity is defined like this:

{
      "Id": "Translate-STEP2DWG",
      "AppPackages": [],
      "HostApplication": "AcTranslators.exe",
      "RequiredEngineVersion": "22.0",
      "Parameters": {
        "InputParameters": [
          {
            "Name": "HostDwg",
            "LocalFileName": "source.stp"
          }
        ],
        "OutputParameters": [
          {
            "Name": "Result",
            "LocalFileName": "result.dwg"
          }
        ]
      },
      "Instruction": {
        "CommandLineParameters": "-i source.stp -o result.dwg",
        "Script": ""
      },
      "AllowedChildProcesses": [
      ],
      "IsPublic": true,
      "Version": 1,
      "Description": ""
    }

Here is a sample workitem request body:

{
  "ActivityId": "Translate-STEP2DWG",
  "Arguments": {
    "InputArguments": [
      {
        "Resource": "https://s3.amazonaws.com/AutoCAD-Core-Engine-Services/TestDwg/3DStep.stp",
        "Name": "HostDwg"
      }
    ],
    "OutputArguments": [
      {
        "Name": "Result",
        "HttpVerb": "POST"
      }
    ]
  }
}
查看更多
登录 后发表回答