Our requirement is to open an assembly in the Level of Detail representation in which the assembly was last saved.
When we open an assembly through "File->Open" , Inventor opens the assembly correctly in last saved Level of Detail representation.
But when assembly is opened through API Documents->Open(), the file always opens in Master Level of Detail representation.
I understand that Documents->OpenWithOptions() can be used to open document in desired LOD, but in this case we do not know the last saved LOD for the assembly, and hence the name can not be supplied to Documents->OpenWithOptions().
Is there a way through APIs to open assembly in last saved LOD?
[ We are using Inventor 2010 SP3]
Get the last active representation using FileManager.GetLastActiveLevelOfDetailRepresentati
Thank you for the reply. I am able to open assembly in last saved LOD through regular Inventor APIs.
Sometimes we also need to open assemblies in last saved LOD, using apprentice server component.
But ApprenticeServer.OpenWithOptions() throws exception "the parameter is incorrect"
the sample code is as shown below
BSTR GetLastLOD(BSTR bstrFilePath) // returns last LOD
FileManagerPtr spFileManager = 0;
spFileManager = spApp->FileManager;
bstrLastLOD = spFileManager->MethodGetLastActiveLevelOfDetailRep
HRESULT hr = S_OK;
ApprenticeServerDocumentPtr spDocument = 0;
NameValueMapPtr docOpenOptions = spApprenticeServer->TransientObjects->MethodCreate
if(docOpenOptions != 0)
BSTR bstrFilePath = :ysAllocString(L"E:\\INV_WORK_DIR\\files\\Assembly1.iam");
BSTR bstrLastLOD = GetLastLOD(bstrFilePath);
//This line MethodOpenWithOptions() throws exception "the parameter is incorrect"
spDocument = spApprenticeServer->MethodOpenWithOptions(bstrFile
Is there anything wrong here or MethodOpenWithOptions() method not supported through apprentice?
You're right. Apprentice does seem to have a problem with the OpenWithOptions method. I'll have this issue filed in our database. Thanks for reporting.
Luckily, there's an alternate way to open a document with a specific LOD. The following VB code should demonstrate...
Dim strFullFileName As String strFullFileName = "C:\temp\Assembly1.iam" ' Set a reference to the FileManager object. Dim oFileManager As FileManager Set oFileManager = oApprentice.FileManager ' Get the name of the last active Level of Detail (LOD) Representation. Dim strLastActiveLOD As String strLastActiveLOD = oFileManager.GetLastActiveLevelOfDetailRepresentat
ion(strFullFileName) ' Use the full file name and LOD name to get the full document name. Dim strFullDocumentName As String strFullDocumentName = oFileManager.GetFullDocumentName(strFullFileName, strLastActiveLOD) ' Create a new NameValueMap object Dim oDocOpenOptions As NameValueMap Set oDocOpenOptions = oApprentice.TransientObjects.CreateNameValueMap ' Open the document. Dim oDoc As ApprenticeServerDocument Set oDoc = oApprentice.OpenWithOptions(strFullDocumentName, oDocOpenOptions)
The alternate solution is working to open assembly in specified LOD using apprentice.
I am facing another issue w.r.to replacing suppressed components of an assembly when assembly is opened in apprentice.
When an assembly that is in non-master LOD(meaning few components are suppressed) is opened in apprentice server,
the RreplaceReference() is not working.
Let us say an assembly has single part that is suppressed, and say the LOD is "LevelOfDetail1". Now open the assembly using apprentice in "LevelOfDetail" then try to perform replace reference.
The sample code is as below
ApprenticeServerDocumentPtr spDocument = function_to_get_assemblydoc(path) //as per the suggested method,
FilePtr spFile = spDocument->File;
FileDescriptorsEnumeratorPtr spFileDescEnum = spFile->ReferencedFileDescriptors;
nCountOfRefFiles = spFileDescEnum->Count;
spFileDescriptor = spFileDescEnum->GetItem(i);
if(spFileDescriptor != NULL)
for(long i = 1; i <= nCountOfRefFiles; i++)
//Say original location is E:\\INV_WORK_DIR\\files\\Part1.ipt, and this needs to be replaced.
//The below line is throwing exception
hr = spFileDescriptor->MethodReplaceReference(L"E:\\INV_WORK_DIR\\edit\\Part1.ipt");
//Save assembly because components are replaced
FileSaveAsPtr spFileSaveAs = spApprenticeServer->FileSaveAs;
If the same code executed using regular Inventor APIs, i.e, if we open assembly using Documents->OpenWithOptions() in "LevelofDetail1" the above code works and the suppressed components are also replaced.
If assembly is opened in Apprentice in master LOD, only then all the components are getting replaced.
Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.