使用 APS 从 ACC 检索 Revit 模型时出现“Autodesk.Revit.Exceptions.CentralModelMissingException”

问题描述 投票:0回答:1

我正在开发 APS(Autodesk 平台服务)插件来访问存储在 ACC 上的 Revit 文件。我已成功获取项目 GUID 和模型 GUID,但在尝试打开模型时遇到“CentralModelMissingException”。

C# 代码片段:

var cloudModelPath = ModelPathUtils.ConvertCloudGUIDsToCloudPath(inputParams.Region, inputParams.ProjectGuid, inputParams.ModelGuid);
Document doc = rvtApp.OpenDocumentFile(cloudModelPath, new OpenOptions()); 

错误信息:

Autodesk.Revit.Exceptions.CentralModelMissingException:中央 模型丢失。 在 Autodesk.Revit.DB.ModelPathUtils.ConvertCloudGUIDsToCloudPath(字符串 区域、Guid 项目Guid、Guid 模型Guid)

详情:

我使用以下 API 端点来获取项目和模型 GUID:

https://developer.api.autodesk.com/data/v1/projects/b.ab6853f0-5a67-4906-bcf8-c78daecc38be/items/urn:adsk.wipprod:dm.lineage:2_RgTcCLSvWwx7ct1TETkA/versions

并得到以下回复:

{
    "jsonapi": {
        "version": "1.0"
    },
    "links": {
        "self": {
            "href": "https://developer.api.autodesk.com/data/v1/projects/b.ab6853f0-5a67-4906-bcf8-c78daecc38be/items/urn:adsk.wipprod:dm.lineage:2_RgTcCLSvWwx7ct1TETkA/versions"
        }
    },
    "data": [
        {
            "type": "versions",
            "id": "urn:adsk.wipprod:fs.file:vf.2_RgTcCLSvWwx7ct1TETkA?version=2",
            "attributes": {
                "name": "001_ US method_MODEL FOR TESTING.rvt",
                "displayName": "001_ US method_MODEL FOR TESTING.rvt",
                "createTime": "2024-04-30T07:52:41.0000000Z",
                "createUserId": "JP3VNYE6UKU8",
                "createUserName": "SWAPP SU",
                "lastModifiedTime": "2024-04-30T07:55:03.0000000Z",
                "lastModifiedUserId": "JP3VNYE6UKU8",
                "lastModifiedUserName": "SWAPP SU",
                "versionNumber": 2,
                "mimeType": "application/vnd.autodesk.r360",
                "storageSize": 41287680,
                "fileType": "rvt",
                "extension": {
                    "type": "versions:autodesk.bim360:C4RModel",
                    "version": "1.3.1",
                    "schema": {
                        "href": "https://developer.api.autodesk.com/schema/v1/versions/versions:autodesk.bim360:C4RModel-1.3.1"
                    },
                    "data": {
                        "modelVersion": 17,
                        "isCompositeDesign": false,
                        "mimeType": "application/vnd.autodesk.r360",
                        "revitProjectVersion": 2023,
                        "projectGuid": "3fa3b423-3b58-48b8-bccf-c2e32babf431",
                        "publishType": "WithLinks",
                        "originalItemUrn": "urn:adsk.wipprod:dm.lineage:2_RgTcCLSvWwx7ct1TETkA",
                        "modelType": "multiuser",
                        "latestEpisodeGuid": "1d1873fc-cd7b-4079-92ab-1c28152c02a0",
                        "modelGuid": "5a015771-c579-42b2-a87c-77cd68ff0b29",
                        "processState": "PROCESSING_COMPLETE",
                        "extractionState": "SUCCESS",
                        "splittingState": "NOT_SPLIT",
                        "reviewState": "NOT_IN_REVIEW",
                        "revisionDisplayLabel": "2",
                        "sourceFileName": "001_ US method_MODEL FOR TESTING.rvt",
                        "conformingStatus": "NONE"
                    }
                }
            },
            "links": {...},
            "relationships": {...}
        },
        {
            "type": "versions",
            "id": "urn:adsk.wipprod:fs.file:vf.2_RgTcCLSvWwx7ct1TETkA?version=1",
            "attributes": {
                "name": "001_ US method_MODEL FOR TESTING.rvt",
                "displayName": "001_ US method_MODEL FOR TESTING.rvt",
                "createTime": "2024-04-30T07:52:00.0000000Z",
                "createUserId": "JP3VNYE6UKU8",
                "createUserName": "SWAPP SU",
                "lastModifiedTime": "2024-04-30T07:52:05.0000000Z",
                "lastModifiedUserId": "JP3VNYE6UKU8",
                "lastModifiedUserName": "SWAPP SU",
                "versionNumber": 1,
                "mimeType": "application/vnd.autodesk.r360",
                "extension": {
                    "type": "versions:autodesk.bim360:C4RModel",
                    "version": "1.1.0",
                    "schema": {
                        "href": "https://developer.api.autodesk.com/schema/v1/versions/versions:autodesk.bim360:C4RModel-1.1.0"
                    },
                    "data": {
                        "modelVersion": 17,
                        "projectGuid": "3fa3b423-3b58-48b8-bccf-c2e32babf431",
                        "modelType": "multiuser",
                        "latestEpisodeGuid": "1d1873fc-cd7b-4079-92ab-1c28152c02a0",
                        "mimeType": "application/vnd.autodesk.r360",
                        "modelGuid": "5a015771-c579-42b2-a87c-77cd68ff0b29",
                        "processState": "PROCESSING_COMPLETE",
                        "extractionState": "SKIPPED",
                        "splittingState": "NOT_SPLIT",
                        "revisionDisplayLabel": "1",
                        "sourceFileName": "001_ US method_MODEL FOR TESTING.rvt",
                        "conformingStatus": "NONE"
                    }
                }
            },
            "links": {...},
            "relationships": {...}
        }
    ]
}

API响应提供的项目GUID为3fa3b423-3b58-48b8-bccf-c2e32babf431,这似乎与我最初使用的项目ID不同。

问题:

项目 ID 与项目 GUID:这两个标识符之间有什么区别?我应该将哪一个与 ModelPathUtils.ConvertCloudGUIDsToCloudPath 结合使用?

“CentralModelMissingException”故障排除:

  • 中心模型缺失的常见原因有哪些?
  • 如何在 ACC 上验证 Revit 模型的状态和工作共享配置?
  • 访问前验证:有没有办法使用 API 调用“ping”ACC 模型,以确保在尝试在 Revit 中打开它之前可以访问它?

提前致谢!


更新: 我尝试从 Revit 本身运行以下代码

string Region = "US";
System.Guid ModelGuid = new System.Guid("5a015771-c579-42b2-a87c-77cd68ff0b29");
System.Guid ProjectGuid = new System.Guid("3fa3b423-3b58-48b8-bccf-c2e32babf431");
ModelPath cloudModelPath = ModelPathUtils.ConvertCloudGUIDsToCloudPath(Region, ProjectGuid, ModelGuid);
TransactionUtils.ForceCloseTransaction();
OpenOptions options = new OpenOptions();
options.DetachFromCentralOption = DetachFromCentralOption.DetachAndDiscardWorksets;
var doc1 = uiApplication.OpenAndActivateDocument(cloudModelPath, options, true);

又出现另一个错误:

警告 DynamicCodeUtils:InvalidOperationException - 本文档是 不是工作共享文档。

但是该文档是工作共享的,我已经从 Revit Web 视图中检查了它。

autodesk-forge revit-api autodesk-designautomation autodesk-data-management autodesk-construction-cloud
1个回答
0
投票

回答您的问题:

- 项目 ID 与项目 GUID:这两个标识符之间有什么区别,我应该将哪一个与 ModelPathUtils.ConvertCloudGUIDsToCloudPath 结合使用?

解答:要打开Revit云模型,您需要项目和模型的GUID,如您在attributes.extension.data中找到的,项目ID只是ACC项目,与Revit云模型无关。

- 中心模型丢失的常见原因有哪些?

答:您能否确保为 ModelPathUtils.ConvertCloudGUIDsToCloudPath() 方法提供的 Region 是正确的?您是否想在欧盟地区开设 RCM?您需要使用正确的区域来获取 RCM。

- 如何在 ACC 上验证 Revit 模型的状态和工作共享配置?

答案:要验证 RCM 是否已发布到最新版本,您可以尝试使用 https://aps.autodesk.com/en/docs/data/v2/reference/http/GetPublishModelJob/ .

- 预访问验证:有没有办法使用 API 调用“ping”ACC 模型,以确保在尝试在 Revit 中打开它之前可以访问它?

答案:据我所知,没有这样的“ping”方法,也许您可以使用我上面提到的 GetPublishModelJob 来检查?但我建议尝试通过 ModelPathUtils.ConvertCloudGUIDsToCloudPath() 获取模型路径,如果找不到模型,你会得到异常。

© www.soinside.com 2019 - 2024. All rights reserved.