在 Forge Viewer 中的 Design Automation 上生成的 Forge 可视化方向与 Inventor 中的方向不匹配

Orientation of Forge viewable generated on Design Automation in Forge Viewer not matching orientation in Inventor

我正在使用设计自动化 API 从模型中导出 SVF。对于某些模型,查看器中的可视项方向与 Inventor 中的方向不匹配。

如何更正此问题,以便所有模型的查看器方向与输入的 Inventor 模型相匹配? 下面的代码是导出SVF的地方。有关此功能的博客 post 会有所帮助。

private string SaveForgeViewable(Inventor.Document doc) {
    string viewableOutputDir = null;
    using(new HeartBeat()) {
        //LogTrace($"** Saving SVF");
        try {
            TranslatorAddIn oAddin = null;

            foreach(ApplicationAddIn item in inventorApplication.ApplicationAddIns) {

                if (item.ClassIdString == "{C200B99B-B7DD-4114-A5E9-6557AB5ED8EC}") {
                    //Trace.TraceInformation("SVF Translator addin is available");
                    oAddin = (TranslatorAddIn) item;
                    break;
                }
                else {}
            }

            if (oAddin != null) {
                //Trace.TraceInformation("SVF Translator addin is available");
                TranslationContext oContext = inventorApplication.TransientObjects.CreateTranslationContext();
                // Setting context type
                oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism;

                NameValueMap oOptions = inventorApplication.TransientObjects.CreateNameValueMap();
                // Create data medium;
                DataMedium oData = inventorApplication.TransientObjects.CreateDataMedium();

                Trace.TraceInformation("SVF save");
                var workingDir = Path.GetDirectoryName(doc.FullFileName);
                var sessionDir = Path.Combine(workingDir, "SvfOutput");

                // Make sure we delete any old contents that may be in the output directory first,
                // this is for local debugging. In DA4I the working directory is always clean
                if (Directory.Exists(sessionDir)) {
                    Directory.Delete(sessionDir, true);
                }

                oData.FileName = Path.Combine(sessionDir, "result.collaboration");
                var outputDir = Path.Combine(sessionDir, "output");
                var bubbleFileOriginal = Path.Combine(outputDir, "bubble.json");
                var bubbleFileNew = Path.Combine(sessionDir, "bubble.json");

                // Setup SVF options
                if (oAddin.get_HasSaveCopyAsOptions(doc, oContext, oOptions)) {
                    oOptions.set_Value("GeometryType", 1);
                    oOptions.set_Value("EnableExpressTranslation", true);
                    oOptions.set_Value("SVFFileOutputDir", sessionDir);
                    oOptions.set_Value("ExportFileProperties", false);
                    oOptions.set_Value("ObfuscateLabels", true);
                }

                oAddin.SaveCopyAs(doc, oContext, oOptions, oData);
                LogTrace($ "** Saved SVF as {oData.FileName}");
                File.Move(bubbleFileOriginal, bubbleFileNew);
                viewableOutputDir = sessionDir;
            }
        }
        catch(Exception e) {
            LogError($ "********Export to format SVF failed: {e.Message}");
            return null;
        }
    }
    return viewableOutputDir;
}

我们也遇到过这个问题,这是我们的 SVF 输出设置,它尊重您的设计基础:

oOptions.set_Value("EnableExpressTranslation", false);
oOptions.set_Value("ExportFileProperties", true);
oOptions.set_Value("ObfuscateLabels", false);

有关完整代码,您可以查看我们新的示例应用存储库 https://github.com/Developer-Autodesk/forge-configurator-inventor/blob/master/AppBundles/CreateSVFPlugin/CreateSvfAutomation.cs#L96