我正在开发一个 Inventor appbundle,它加载创建 SVF 插件,更新模型中的几个参数并创建一个 SVF2 文件,稍后我将查看该文件。所以问题是当我尝试保存 SVF 文件时出现无效参数异常。有人可以帮我弄这个吗? 提前致谢。附上代码片段。
try
{
ApplicationAddIn svfAddin = m_server
.ApplicationAddIns
.Cast<ApplicationAddIn>()
.FirstOrDefault(item => item.ClassIdString == "{C200B99B-B7DD-4114-A5E9-6557AB5ED8EC}");
var oAddin = (TranslatorAddIn)svfAddin;
if (oAddin != null)
{
Trace.TraceInformation("SVF Translator addin is available");
TranslationContext oContext = m_server.TransientObjects.CreateTranslationContext();
// Setting context type
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism;
NameValueMap oOptions = m_server.TransientObjects.CreateNameValueMap();
// Create data medium;
DataMedium oData = m_server.TransientObjects.CreateDataMedium();
Trace.TraceInformation("SVF save");
var sessionDir = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "SvfOutput");
oData.FileName = System.IO.Path.Combine(sessionDir, "result.collaboration");
var outputDir = System.IO.Path.Combine(sessionDir, "output");
var bubbleFileOriginal = System.IO.Path.Combine(outputDir, "bubble.json");
var bubbleFileNew = System.IO.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", true);
oOptions.set_Value("ObfuscateLabels", false);
}
LogTrace($"SVF files are output to: {oOptions.get_Value("SVFFileOutputDir")}");
oAddin.SaveCopyAs(Doc, oContext, oOptions, oData);
Trace.TraceInformation("SVF can be exported.");
LogTrace($"** Saved SVF as {oData.FileName}");
System.IO.File.Move(bubbleFileOriginal, bubbleFileNew);
string zipPath = outputZipFile;
ZipFolder(sessionDir, zipPath);
if(System.IO.File.Exists(zipPath))
{
LogTrace("Zip created");
}
}
}
catch (Exception e)
{
LogTrace($"********Export to format SVF failed: {e.Message}");
}
异常恰恰是——参数不正确。 (HRESULT 的异常:0x80070057(E_INVALIDARG))我正在尝试获取 SVF2 文件。
Logtrace of workitem:
[05/16/2023 08:37:07] Starting work item <...>
[05/16/2023 08:37:07] Start download phase.
[05/16/2023 08:37:07] Start downloading input: verb - 'GET', url - 'https://developer.api.autodesk.com/oss/v2/buckets/<...>'
[05/16/2023 08:37:07] Embedded resource [ {'browserConnectionId':'dG86hPu4eKngXcsy4Ycy0w','useCache':false,'keepWorkitem':false,'params':{},'screenshot':{'width':1236,'height':847}}] is saved as a file in 'Unicode' at: 'T:\Aces\Jobs\8081eec5293e4ac2bd925247943e3299\params.json'.
[05/16/2023 08:37:13] End downloading file. Source=https://developer.api.autodesk.com/oss/v2/buckets/<...>,LocalFile=T:\Aces\Jobs\8081eec5293e4ac2bd925247943e3299\zip_31.zip,BytesDownloaded=225378628,Duration=5740ms
[05/16/2023 08:37:15] T:\Aces\Jobs\8081eec5293e4ac2bd925247943e3299\zip_31.zip has been unpacked to folder T:\Aces\Jobs\8081eec5293e4ac2bd925247943e3299\<...>.
[05/16/2023 08:37:15] End download phase successfully.
[05/16/2023 08:37:15] Start preparing script and command line parameters.
[05/16/2023 08:37:15] Command line: [ /al "T:\Aces\Applications\895b47da1b160a025fb2b06b74016def.pQHzjERS2mVkQNCKBmWwvCvJecOdhgdB.UpdateIPTParam[6].package"]
[05/16/2023 08:37:15] End preparing script and command line parameters.
[05/16/2023 08:37:15] Start script phase.
[05/16/2023 08:37:15] Start Inventor Core Engine standard output dump.
[05/16/2023 08:37:16] InventorCoreConsole.exe Information: 0 : InventorCoreConsole.exe: 25.0.18300.0, 15-e376d5d
[05/16/2023 08:37:16] InventorCoreConsole.exe Information: 0 : Starting Inventor Server.
[05/16/2023 08:37:16] InventorCoreConsole.exe Information: 0 : Trying to get Inventor Server version in use.
[05/16/2023 08:37:16] InventorCoreConsole.exe Information: 0 : Inventor Server version is 26, 20, 28702, 0001.
[05/16/2023 08:37:16] InventorCoreConsole.exe Information: 0 : Inventor Server version is older than 2023
[05/16/2023 08:37:16] InventorCoreConsole.exe Information: 0 : Started Inventor Server 2022.2 (Build 262287010, 287A) (26, 20, 28702, 0001)
[05/16/2023 08:37:16] InventorCoreConsole.exe Information: 0 : Loading plug-in: iLogic Plugin
[05/16/2023 08:37:16] InventorCoreConsole.exe Information: 0 : Activating plug-in: iLogic Plugin
[05/16/2023 08:37:16] iLogic Plugin: initializing...
[05/16/2023 08:37:16] InventorCoreConsole.exe Information: 0 : Loading plug-in: iLogic Plugin
[05/16/2023 08:37:16] InventorCoreConsole.exe Information: 0 : Setting up iLogicLogLevelTo: Warn
[05/16/2023 08:37:16] InventorCoreConsole.exe Information: 0 : Getting Inventor plug-in.
[05/16/2023 08:37:16] InventorCoreConsole.exe Information: 0 : Plug-in: UpdateIPTParam
[05/16/2023 08:37:16] InventorCoreConsole.exe Information: 0 : Activating plug-in: UpdateIPTParam
[05/16/2023 08:37:16] InventorCoreConsole.exe Information: 0 : : UpdateIPTParam (1.0.0.8): initializing...
[05/16/2023 08:37:16] InventorCoreConsole.exe Information: 0 : Executing 'Run' method on Automation object.
[05/16/2023 08:37:16] InventorCoreConsole.exe Information: 0 : ** Saving SVF
[05/16/2023 08:37:16] InventorCoreConsole.exe Information: 0 : SVF Translator addin is available
[05/16/2023 08:37:16] InventorCoreConsole.exe Information: 0 : SVF save
[05/16/2023 08:37:16] InventorCoreConsole.exe Information: 0 : SVF files are output to: T:\Aces\Jobs\8081eec5293e4ac2bd925247943e3299\SvfOutput
[05/16/2023 08:37:16] InventorCoreConsole.exe Information: 0 : ********Export to format SVF failed: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
[05/16/2023 08:37:16] InventorCoreConsole.exe Information: 0 : Performing iLogic diagnostics...
[05/16/2023 08:37:16] InventorCoreConsole.exe Information: 0 : End of iLogic diagnostics...
[05/16/2023 08:37:16] InventorCoreConsole.exe Information: 0 : Deactivating plug-in: UpdateIPTParam
[05/16/2023 08:37:16] InventorCoreConsole.exe Information: 0 : : UpdateIPTParam: deactivating...
[05/16/2023 08:37:16] CoreConsole Dispose start
[05/16/2023 08:37:16] CoreConsole ReleaseAll start
[05/16/2023 08:37:16] CoreConsole ReleaseAll end
[05/16/2023 08:37:16] CoreConsole Dispose end
[05/16/2023 08:37:16] CoreConsole exiting (0)
[05/16/2023 08:37:17] End Inventor Core Engine standard output dump.
[05/16/2023 08:37:17] End script phase.
[05/16/2023 08:37:17] Start upload phase.
[05/16/2023 08:37:17] Error: Non-optional output [output.zip] is missing.
[05/16/2023 08:37:17] Error: An unexpected error happened during phase Publishing of job.
[05/16/2023 08:37:17] Job finished with result FailedMissingOutput
我从我们的示例中看到的唯一区别https://github.com/Autodesk-Forge/forge-configurator-inventor/blob/master/AppBundles/CreateSVFPlugin/CreateSvfAutomation.cs#L90
是我们没有启用快速翻译,但您启用了。你能在那里设置假吗? oOptions.set_Value("EnableExpressTranslation", true);
如果它没有帮助,我们需要您的输入数据集,因为它可能在那里。