GLB export - Inventor server

GLB export - Inventor server

mateusz_baczewski
Advocate Advocate
71 Views
1 Reply
Message 1 of 2

GLB export - Inventor server

mateusz_baczewski
Advocate
Advocate

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 you found it helpful, a "Like" would be much appreciated!
If this post solved your problem, please mark it as "Solution.".

0 Likes
72 Views
1 Reply
Reply (1)
Message 2 of 2

mateusz_baczewski
Advocate
Advocate

Hi,

I think I managed to solve this issue, and the problem simply lies with Inventor.Server. So in the future, if you want to generate .glb files using Vault add-ins or Job Processor tasks, I recommend using Inventor.Application instead.

At first, I thought the problem was caused by deep editing of models, which led to broken references. However, even after disabling in-place editing, generating a GLB model from an IAM sometimes resulted in missing meshes for some occurrences in the assembly.

If you found it helpful, a "Like" would be much appreciated!
If this post solved your problem, please mark it as "Solution.".

0 Likes