GLB export - Inventor server
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I’m having an issue with generating a correct .glb file for assemblies. The problem is that sometimes, in the exported .glb file, the mesh of a part/assembly is missing.
I’m developing an add-in for Vault that works in such a way that for released items, it generates a GLB model, ensuring that the names of assemblies and parts contain the ERP ID. For welded assemblies, it creates a simplification, sets a new model state with the simplified part, and also names it with the ERP ID.
All of this is done using a recursive function that goes down through the assembly and performs the required operations. The issue is that if I refresh the document after all the editing and then generate the GLB model, there are cases where some parts in the GLB are invisible — they don’t have a mesh.
Has anyone ever encountered this kind of issue? I’m working in Inventor 2026.
This is what my recursive method looks like.
public void TraverseAssembly(ComponentOccurrences occurrences)
{
List<ComponentOccurrences> nextLevel = new List<ComponentOccurrences>();
foreach (ComponentOccurrence oOcc in occurrences)
{
string oOccName = oOcc.Name;
oOcc.Visible = true;
if (oOcc.Suppressed) { continue; }
oOcc.IsAssociativeToDesignViewRepresentation = false;
Document oOccDoc = (Document)oOcc.ReferencedDocumentDescriptor.ReferencedDocument;
string oOccDocName = oOccDoc.DisplayName.Split('.').FirstOrDefault();
string oOccDocSubType = oOccDoc.SubType;
string modelName = System.IO.Path.GetFileNameWithoutExtension(oOcc.ReferencedFileDescriptor.FullFileName);
string simplifyPath = System.IO.Path.Combine(_simplyfyFolder, modelName + ".ipt");
string asmName = System.IO.Path.GetFileName(oOcc.ReferencedFileDescriptor.FullFileName);
object erpId = VaultMethods.GetErpIdByPartName(asmName, _connection);
if (erpId == null) continue;
if (!nameCountDict.ContainsKey(erpId.ToString()))
nameCountDict[erpId.ToString()] = 0;
nameCountDict[erpId.ToString()]++;
int partCount = nameCountDict[erpId.ToString()];
string material = GetComponentMaterial(oOccDoc);
if (!string.IsNullOrEmpty(oOcc.Name) &&
!oOcc.Name.Contains("Weldbead"))
{
if (oOccDocSubType == DocumentSubTypeIds.Assembly)
{
var oOccAseCompDef = oOcc.Definition as AssemblyComponentDefinition;
oOcc.Name = $"{erpId}:{partCount}";
if (oOcc.BOMStructure != Inventor.BOMStructureEnum.kPurchasedBOMStructure)
{
if (oOccAseCompDef.IsModelStateMember)
{
var factoryDocument = (AssemblyDocument)oOccAseCompDef.FactoryDocument;
factoryDocument.ComponentDefinition.ModelStates.MemberEditScope = MemberEditScopeEnum.kEditAllMembers;
nextLevel.Add(factoryDocument.ComponentDefinition.Occurrences);
}
else
{
nextLevel.Add(oOcc.Definition.Occurrences);
}
}
else if (oOcc.BOMStructure == Inventor.BOMStructureEnum.kPurchasedBOMStructure)
{
AssemblyDocument asmDoc = null;
AssemblyComponentDefinition oOccAsmCompDef = null;
if (oOccAseCompDef.IsModelStateMember)
{
asmDoc = (AssemblyDocument)oOccAseCompDef.FactoryDocument;
}
else
{
asmDoc = (AssemblyDocument)oOcc.ReferencedDocumentDescriptor.ReferencedDocument;
}
oOccAsmCompDef = asmDoc.ComponentDefinition;
string folder = System.IO.Path.GetDirectoryName(asmDoc.FullFileName);
if (!System.IO.File.Exists(simplifyPath))
{
simplifyPath = CreateSimplifyModel(asmDoc, folder);
ModelState newState = oOccAsmCompDef.ModelStates.AddSubstitute(simplifyPath, $"{erpId}", false);
}
oOcc.Name = $"{erpId}:{partCount}";
oOcc.ActiveModelState = $"{erpId}";
}
}
else if (oOccDocSubType == DocumentSubTypeIds.Weldment)
{
var oOccAseCompDef = oOcc.Definition as AssemblyComponentDefinition;
AssemblyDocument asmDoc = null;
AssemblyComponentDefinition oOccAsmCompDef = null;
if (oOccAseCompDef.IsModelStateMember)
{
asmDoc = (AssemblyDocument)oOccAseCompDef.FactoryDocument;
}
else
{
asmDoc = (AssemblyDocument)oOcc.ReferencedDocumentDescriptor.ReferencedDocument;
}
oOccAsmCompDef = asmDoc.ComponentDefinition;
string folder = System.IO.Path.GetDirectoryName(asmDoc.FullFileName);
if (!System.IO.File.Exists(simplifyPath))
{
simplifyPath = CreateSimplifyModel(asmDoc, folder);
ModelState newState = oOccAsmCompDef.ModelStates.AddSubstitute(simplifyPath, $"{erpId}", false);
}
oOcc.Name = $"{erpId}:{partCount}";
oOcc.ActiveModelState = $"{erpId}";
}
else
{
oOcc.Name = $"{erpId}:{partCount}";
}
}
}
foreach (var occs in nextLevel)
{
TraverseAssembly(occs);
}
}
If this post solved your problem, please mark it as "Solution.".