我正在尝试使用 C# 中的“GetModelviewProperties”API 获取大型模型属性。 (模型翻译为svf2格式)
我遇到了这个问题并收到了错误。
错误消息是
Autodesk.Forge.Client.ApiException: 'Error calling GetModelviewProperties:
{"diagnostic":"Property Database is too large under this URN"}'
你有解决这个问题的想法吗?
当然!这是一个简洁的回应:
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
class Program
{
static async Task Main()
{
try
{
string accessToken = "YOUR_ACCESS_TOKEN";
string modelId = "YOUR_MODEL_ID";
string apiEndpoint = "YOUR_ENDPOINT";
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + accessToken);
string apiURL = $"{apiEndpoint}/modelview/{modelId}/properties";
HttpResponseMessage response = await client.GetAsync(apiURL);
if (response.IsSuccessStatusCode)
{
string responseBody = await response.Content.ReadAsStringAsync();
JArray propertiesArray = JObject.Parse(responseBody)["data"]["collection"].Value<JArray>();
foreach (JToken property in propertiesArray)
{
Console.WriteLine(property.ToString());
}
}
else
{
Console.WriteLine($"Error: {response.StatusCode} - {response.ReasonPhrase}");
}
}
}
catch (Exception ex)
{
Console.WriteLine($"Exception: {ex.Message}");
}
}
}
此版本保留了与以前的代码相同的功能,但形式更紧凑。在使用代码之前,请将占位符替换为您的实际凭据和端点。