大RVT文件上传超时及ModelViewMetadataProperties提取报错的解决方案咨询
Hey there, let's tackle both your upload timeout and URN size issues step by step—200MB RVT files are totally manageable with the right approach in Forge SDK v1.9.0.
1. Fixing Upload Timeouts: Use Chunked Uploads
Directly using UploadObjectAsync() for large files is prone to timeouts because it sends the entire file in one request. Instead, Forge recommends chunked uploads—splitting the file into smaller pieces and uploading them individually. This also adds resumability if a chunk fails mid-upload.
Step-by-Step Chunked Upload Code (v1.9.0)
First, adjust the API client timeout to give each chunk enough time to upload, then follow this flow:
using Autodesk.Forge; using Autodesk.Forge.Model; using System.IO; // Initialize Objects API with extended timeout var objectsApi = new ObjectsApi(); objectsApi.Configuration.AccessToken = "your-access-token-here"; objectsApi.Configuration.Timeout = 300000; // 5 minutes (adjust as needed) string bucketKey = "your-bucket-key"; string fileName = "your-file.rvt"; FileInfo fileInfo = new FileInfo(fileName); long fileSize = fileInfo.Length; // 1. Initialize chunked upload to get an upload key string uploadKey = await objectsApi.CreateChunkedUploadAsync(bucketKey, fileName, fileSize); // 2. Split file into chunks (5MB is a safe default; Forge allows 5MB-100MB) int chunkSize = 5 * 1024 * 1024; byte[] fileBytes = File.ReadAllBytes(fileName); int totalChunks = (int)Math.Ceiling((double)fileSize / chunkSize); // 3. Upload each chunk for (int i = 0; i < totalChunks; i++) { int startByte = i * chunkSize; int chunkLength = Math.Min(chunkSize, (int)(fileSize - startByte)); byte[] chunk = new byte[chunkLength]; Array.Copy(fileBytes, startByte, chunk, 0, chunkLength); // Define the byte range for this chunk string rangeHeader = $"bytes {startByte}-{startByte + chunkLength - 1}/{fileSize}"; await objectsApi.UploadChunkAsync( bucketKey, fileName, uploadKey, rangeHeader, new MemoryStream(chunk) ); } // 4. Finalize the chunked upload await objectsApi.FinishChunkedUploadAsync(bucketKey, fileName, uploadKey);
2. Fixing "URN is too big to extract" Error
This error almost always stems from using the wrong URN when requesting metadata. Here's what to check:
Use the Derivative Service URN, Not the Raw Object URN
After uploading your RVT file, you need to translate it to SVF format using the Derivatives API. The URN returned by the translation job is what you should use for extracting ModelViewMetadataProperties—not the base64-encoded object ID from the storage service.
Correct Workflow for Metadata Extraction
var derivativesApi = new DerivativesApi(); derivativesApi.Configuration.AccessToken = "your-access-token-here"; // 1. Prepare translation request to convert RVT to SVF var translateJob = new JobPayload { Input = new JobPayloadInput { Urn = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes($"urn:adsk.objects:os.object:{bucketKey}/{fileName}")) }, Output = new JobPayloadOutput { Formats = new List<JobPayloadFormat> { new JobPayloadFormat { Type = "svf", Views = new List<string> { "2d", "3d" } // Include both if you need 2D sheets } } } }; // 2. Start the translation job Job response = await derivativesApi.TranslateAsync(translateJob); string derivativeUrn = response.Urn; // 3. Wait for translation to complete (poll periodically) JobStatus status; do { status = await derivativesApi.GetManifestAsync(derivativeUrn); await Task.Delay(5000); // Wait 5 seconds between checks } while (status.Status == "pending" || status.Status == "inprogress"); // 4. Extract metadata once translation succeeds if (status.Status == "success") { // Get model view metadata using the derivative URN ModelviewMetadata metadata = await derivativesApi.GetModelviewMetadataAsync(derivativeUrn); // Access ModelViewMetadataProperties from the metadata object here }
Additional Checks
- Validate URN Format: Ensure your object URN is correctly base64-encoded (URL-safe, no extra line breaks).
- Optimize RVT File: If the issue persists, clean up your RVT file (use Revit's
Purgecommand to remove unused elements) to reduce its size—this can shorten the object ID and resulting URN. - Avoid Old SDK Limitations: While you're using v1.9.0, if possible, consider upgrading to the latest SDK version for improved handling of large files and bug fixes.
内容的提问来源于stack exchange,提问作者Seda AYKUTLU

