【问题标题】:JSON Files as parameter input using Forge Design Automation使用 Forge Design Automation 作为参数输入的 JSON 文件
【发布时间】:2020-09-28 20:49:40
【问题描述】:

查看 Autodesk Forge 站点上的文档,我注意到我可以向设计自动化活动提供 JSON 信息。我的问题是:如何在捆绑的 AutoCAD 应用程序中引用 JSON 信息。在显示的 -curl 示例中是否有文件名引用,我没有看到或理解?我没有得到什么?

【问题讨论】:

    标签: autodesk-designautomation


    【解决方案1】:

    找到我的答案:以下是文档中的示例:

    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": "YOUR_NICKNAME.CountItActivity+test",
              "arguments": {
                "rvtFile": {
                  "url": "https://s3.amazonaws.com/revitio-dev/test-data/CountIt.rvt"
                },
                "countItParams": {
                  "url": "data:application/json,{'walls': false, 'floors': true, 'doors': true, 'windows': true}"
                },
                "result": {
                  "verb": "put",
                  "url": "SIGNED_URL_TO_RESULT"
                }
              }
          }'
    

    countItParams 是创建的 .json 文件的名称,与输入文件位于同一文件夹中。 https://github.com/Autodesk-Forge/design.automation-csharp-revit.local.debug.tool

    您可以稍后通过引用当前目录访问捆绑应用程序中的文件。

    很抱歉回答我自己的问题。我觉得我在作弊。哈哈

    【讨论】:

    • "countItParams": { "url": "data:application/json,{'walls': false, 'floors': true, 'doors': true, 'windows': true}" } 仅在参数数量较少时建议使用,如果 JSON 参数较多,则需要将 JSON 文件放入存储箱中,并像任何其他输入对象一样提供其 url,避免HTTP 413 Payload Too Large
    • 第一件事,第一。我如何在 C# 中将其构造为新的参数参数?
    • 更正:这不在活动中,而是在工作项中。 { "inputJson", new XrefTreeArgument() {Verb= Verb.Put, LocalName = "parameters.json", Url = "data:application/json,{'ProtoCycle':" + protocycle} } 其中 protocycle 是我的参数方法。这看起来正确吗?
    • exhale 所以,Activity 中必须有一个匹配的字典参数:这看起来对吗? { “inputJson”,新参数() { LocalName = “parameters.json”,必需 = true} }。有我应该使用的动词吗? WorkItem 如下所示:{ "inputJson", new XrefTreeArgument() { LocalName = "parameters.json", Url = "data:application/json,{'ProtoCycle':" + protocycle} }。再一次,我删除了动词。
    • 嗨,首先,你需要在你的C#中创建一个兼容的类结构引用github.com/KeanW/Jigsawify/blob/…,其次,你需要将它作为serializedJson传递,引用github.com/KeanW/Jigsawify/blob/…,动词应该get,或留空,默认为get
    【解决方案2】:

    您像任何其他输入一样引用 JSON:通过其文件名。服务器将像下载 DWG/RVT 等一样下载您的 json。该文件将位于工作进程的工作目录中。

    【讨论】:

    • 嗯,我猜到了,但我不知道实际的文件名是什么。
    猜你喜欢
    • 2019-08-07
    • 2020-08-05
    • 1970-01-01
    • 2020-09-12
    • 2020-04-02
    • 2020-04-10
    • 2020-11-19
    • 2021-09-17
    • 2018-07-06
    相关资源
    最近更新 更多