How can I create an activity for data conversion in Design Automation API?

二次信任 提交于 2019-12-24 19:42:53

问题


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:


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"
      }
    ]
  }
}


来源:https://stackoverflow.com/questions/51496188/how-can-i-create-an-activity-for-data-conversion-in-design-automation-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!