【问题标题】:How to open .rvt file from zip?如何从 zip 打开 .rvt 文件?
【发布时间】:2021-05-02 22:45:26
【问题描述】:

我正在尝试从 Design Automation for Revit 的 zip 文件夹中打开 Revit 文件,但出现错误:

>  Autodesk.Revit.Exceptions.FileNotFoundException: The filePath:T:\Aces\Jobs\1532f21bb19d4605b941472d4961ed96\input.rvt to be opened doesn't exist.

我已尝试为“localname”和“pathInZip”使用不同的参数,但仍然出现此错误

我正在使用 OpenOptions 打开我的模型:

var path = ModelPathUtils.ConvertUserVisiblePathToModelPath("input.rvt");
        var openOptions = new OpenOptions();
        openOptions.DetachFromCentralOption = DetachFromCentralOption.DetachAndPreserveWorksets;
        Document doc = rvtApp.OpenDocumentFile(path, openOptions);

我的活动:

   {
    "commandLine": [
        "$(engine.path)\\\\revitcoreconsole.exe /al \"$(appbundles[AppBundle].path)\""
    ],
    "parameters": {
        "inputFile": {
            "zip":true,
            "verb": "get",
            "description": "Input Revit model",
            "required": true,
            "localName":"input.rvt"     
        }       
}

我的工作项目:

{
    "activityId": "activityId",
    "arguments": {
        "inputFile": {
        "pathInZip":"test.rvt",
            "url": "https://developer.api.autodesk.com/oss/v2/buckets/my_bucket/objects/test.zip",
            "Headers": {
                "Authorization": "Bearer {{Bearer}}"
            }

    }
}

【问题讨论】:

    标签: autodesk-forge autodesk-designautomation


    【解决方案1】:

    使用下面的定义,Design Automation 会将 zip 解压缩到名为“input.rvt”的文件夹中,然后根据需要在该文件夹中查找名为“test.rvt”的文件。

    "parameters": {
            "inputFile": {
                "zip":true,
                "verb": "get",
                "description": "Input Revit model",
                "required": true,
                "localName":"input.rvt"     
            }
    
        "arguments": {
            "inputFile": {
            "pathInZip":"test.rvt",
                "url": "https://developer.api.autodesk.com/oss/v2/buckets/my_bucket/objects/test.zip",
                "Headers": {
                    "Authorization": "Bearer {{Bearer}}"
                }
        }
    
    

    zippathInzip的用法可以参考forge doc-->arguments-->*--> XrefTreeArgument--> pathInZip或者DWG Sheet Combination failing on AutoDesk Forge看看你想怎么用。

    【讨论】:

    • 我在我的活动 "localname":"input" 和 workItem "pathInZip":"input.rvt" 中进行了更改,我正在发送带有 test.rvt 的 test.zip 文件。 DA4R 应该将其解压缩到文件夹:“input”。之后,它应该获取我的文件“test.rvt”并使用它。太好了。谢谢。但是,如果我在 zip 文件夹中的文件不是“input.rvt”,我该怎么办?我在 AppBundle 中使用了“input.rvt”作为本地参数。我需要更改它。我试图在没有 /i 命令的情况下通过控制台参数传递文件名。这没有帮助
    • 我的问题是这样的stackoverflow.com/questions/55708612/…我如何为zip文件夹中的文件设置本地名称?
    • 如果我理解正确,您在 zip 中有“test.rvt”作为输入,但您的 appbundles 想要打开一个名为“input.rvt”的文件?如果是这样,不幸的是,Design Automation 只会将 zip 解压缩到由“localname”定义的文件夹中,除非输入不是 zip,否则“test.rvt”上不会发生重命名,但您将其“localname”定义为“input.rvt”。 rvt”。由于输入 zip 是您自己提供的,您能否确保在发布 WI 之前将“test.rvt”或其他名称重命名为“input.rvt”?
    • 我尝试通过活动中定义的附加 json 文件中的参数传递模型名称。然后在 appbundle 中读取此模型名称,并将其用作模型路径。效果很好。
    • 好的,很高兴它有效。由于输入和应用程序包都是由客户提供的,因此客户可以灵活地使用它们。 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-26
    • 1970-01-01
    • 2014-01-03
    • 2016-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多