You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

关于在AutoCAD捆绑应用中引用Forge Design Automation JSON信息的问询

How to Reference JSON Input in a Bundled AutoCAD App for Design Automation

Great question! Let's break this down into two key parts: accessing the JSON data from your AutoCAD plugin, and checking for any overlooked filename references in your curl request.


1. Reading the JSON Input in Your AutoCAD Application

When you define an Activity in Design Automation, any input parameters you specify (including your JSON) are downloaded to the task's working directory using the LocalName you set in the Activity definition. This is the filename you'll use to access the JSON from your plugin.

Step-by-Step:

  • First, confirm your Activity includes an Input for the JSON. For example, your Activity might have a section like this:

    "Inputs": [
      {
        "Name": "TaskParameters",
        "LocalName": "task-settings.json",
        "Description": "Configuration JSON for the AutoCAD task",
        "Optional": false,
        "StorageProvider": "Generic"
      }
    ]
    

    Here, LocalName: "task-settings.json" is the filename that will exist in the task's working directory when your plugin runs.

  • In your AutoCAD .NET/ARX plugin, read this file directly from the working directory (Design Automation sets the current working directory to the task's root, so relative paths work):

    using System.IO;
    using Newtonsoft.Json; // Or your preferred JSON serializer
    
    // Read the JSON file
    string jsonFilePath = "task-settings.json";
    string jsonContent = File.ReadAllText(jsonFilePath);
    
    // Deserialize into your custom class
    TaskSettings settings = JsonConvert.DeserializeObject<TaskSettings>(jsonContent);
    
    // Use the settings in your plugin logic
    Console.WriteLine($"Processing with scale: {settings.ScaleFactor}");
    
  • Pro Tip: Avoid hardcoding absolute paths—Design Automation's environment is ephemeral, and the working directory is guaranteed to be the correct location for all input files.


2. Checking for Overlooked Filename References in Your Curl Request

Your curl request needs to map the JSON input to the Activity's defined Input parameter. The most common oversight here is mismatching the parameter name in your curl Arguments with the Name field in your Activity's Input definition.

Example Curl Request (with JSON Input):

curl -X POST "https://developer.api.autodesk.com/da/us-east/v3/WorkItems" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -d '{
    "ActivityId": "YourCompany.YourActivity+Alias",
    "Arguments": {
      "TaskParameters": { // This MUST match the "Name" in your Activity's Input
        "Url": "https://your-oss-bucket.s3.amazonaws.com/your-settings.json",
        "Headers": {
          "Authorization": "Bearer YOUR_SIGNED_OSS_URL_TOKEN"
        }
      },
      "InputDwg": {
        "Url": "https://your-oss-bucket.s3.amazonaws.com/input-file.dwg",
        "Headers": {
          "Authorization": "Bearer YOUR_SIGNED_OSS_URL_TOKEN"
        }
      },
      "OutputDwg": {
        "Url": "https://your-oss-bucket.s3.amazonaws.com/output-file.dwg",
        "Headers": {
          "Authorization": "Bearer YOUR_SIGNED_OSS_URL_TOKEN"
        },
        "Verb": "put"
      }
    }
  }'

Key Things to Verify:

  • The Arguments key (TaskParameters in the example) exactly matches the Name of the JSON Input in your Activity.
  • The Url in the curl argument points to your JSON file hosted in Autodesk OSS (or another supported storage provider), with a valid signed token for access.
  • You haven't mixed up LocalName (used in your plugin) with the Input's Name (used in the curl request)—these are two distinct values.

Common Mistakes to Double-Check

  • Forgetting to include the JSON Input in your Activity definition entirely.
  • Using the wrong filename in your plugin (not matching the LocalName from the Activity).
  • Failing to sign the JSON file's URL in your curl request, leading to access denied errors.

内容的提问来源于stack exchange,提问作者Charles Dodson

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 21:03:12