Forge Viewer无法加载DWG文件(报404错误)技术求助
Hey there, let's work through why your DWGs aren't loading in Forge Viewer while DWFs work perfectly, and you're hitting that 404 error when requesting the manifest. Here's a breakdown of the most likely causes and fixes:
1. You Didn't Trigger the Derivative Conversion for DWGs
First, let's clarify a critical difference between your Forge app and Autodesk Viewer:
Autodesk Viewer automatically handles converting uploaded files into a format the viewer can render (like SVF). But in your own Forge integration, uploading the file to the OSS bucket is only the first step—you have to explicitly call the Model Derivative API to start the conversion job.
If you skipped this step for DWGs (but did it for DWFs), that's exactly why the manifest returns 404: no converted derivative files exist yet.
To fix this:
- Make sure your code calls the
POST /modelderivative/v2/designdata/jobAPI right after uploading the DWG. - Use a valid conversion payload that specifies the output format and views required for DWGs. For example:
(Note: Older Viewer versions like 4.0 might not support SVF2, so stick with SVF for now.){ "input": { "urn": "your-dwg-urn-here" }, "output": { "formats": [ { "type": "svf", "views": ["2d", "3d"] } ] } }
2. The Conversion Job Failed (Check for Errors)
If you did trigger the conversion but still get a 404, the job probably failed. Common reasons for DWG conversion failures include:
- Missing external references (Xrefs): DWGs often rely on linked files (like other DWGs, fonts, or images). If you only uploaded the main DWG without these dependencies, the conversion will fail. Autodesk Viewer might handle this more gracefully, but Forge requires all linked files to be uploaded (preferably in a ZIP bundle with a root file specified).
- Incorrect conversion parameters: Forgetting to specify
views(e.g., ["2d", "3d"]) in the payload can cause the job to fail for DWGs, since they have both 2D and 3D content. - Corrupted upload: Even if Autodesk Viewer can open the file, a partial or corrupted upload to your Forge bucket could break conversion. Try re-uploading the DWG and triggering the conversion again.
To diagnose failure:
- Poll the manifest endpoint (
GET /modelderivative/v2/designdata/{urn}/manifest) until it returns a status. If it fails, look forstatusandprogressfields in the response to get error details. - Use the
GET /modelderivative/v2/designdata/{urn}/manifest/{derivativeUrn}/logendpoint to fetch the conversion log for more specific error messages.
3. Viewer Version Compatibility
You mentioned using Viewer versions 2.17 and 4.0—these are quite old. While the 404 manifest error is almost certainly a conversion issue, if you get past that and still can't view the DWG, it might be because older Viewer versions don't support newer DWG formats (e.g., AutoCAD 2020+ files). Autodesk Viewer runs on the latest code, so it can handle newer files that your legacy Viewer versions can't.
If that's the case, consider upgrading to a newer Viewer version to get better DWG support.
内容的提问来源于stack exchange,提问作者Khoa Ho

