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

问题描述

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

enter image description here

In the viewer vs in Inventor

如何纠正此问题,以使所有模型的查看器方向与输入的Inventor模型相匹配? 以下代码是SVF的导出位置。关于此功能的博客文章会有所帮助。

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,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

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...