Import .rvt into Assembly with API

Import .rvt into Assembly with API

autodeskuser58
Explorer Explorer
94 Views
0 Replies
Message 1 of 1

Import .rvt into Assembly with API

autodeskuser58
Explorer
Explorer

Hi, I have a task to upload a cheat file to the build. I found a simple example for iLogic in the help and it works when running in Inventor. But when I do the same thing, it's only with an external request that I get an error, maybe I'm not connecting any addins or something like that. Could you please suggest solutions to the problem

name_RVT = System.IO.Path.GetFileNameWithoutExtension(filePathRVT);

if (invApp == null)
{
Console.WriteLine("Error: Application");
return;
}

AssemblyDocument assemDoc = (AssemblyDocument)invApp.Documents.Add(Inventor.DocumentTypeEnum.kAssemblyDocumentObject, "", true);

Thread.Sleep(60 * 1000);
ImportedRVTComponentDefinition importedRvtDef = (ImportedRVTComponentDefinition)assemDoc.ComponentDefinition.ImportedComponents.CreateDefinition(filePathRVT);
importedRvtDef.Imported3DView = "{3D}";
importedRvtDef.ImportedAssemblyOrganizationType = ImportedAssemblyOrganizationTypeEnum.kImportedAsAssembly;

ImportedComponentDefinition baseDef = (ImportedComponentDefinition)importedRvtDef;


ImportedRVTComponent rvtComp = (ImportedRVTComponent)assemDoc.ComponentDefinition.ImportedComponents.Add(baseDef);

var savePath = System.IO.Path.Combine(defaultPath, name_RVT + ".iam");
assemDoc.Update();

assemDoc.SaveAs(savePath, false);

 

The error is in this line: ImportedRVTComponentDefinition importedRvtDef = (ImportedRVTComponentDefinition)assemDoc.ComponentDefinition.ImportedComponents.CreateDefinition(filePathRVT); Error: "Unidentified error (0x80004005 (E_FAIL))"

0 Likes
95 Views
0 Replies
Replies (0)