Search code examples
autodesk-forge

System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)


BOM export Automation throws below exception.


Exception :

System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32\[\] aWrapperTypes, MessageData& msgData)

at Inventor.BOMViews.get_Item(Object Index)

at UpdateParams.SampleAutomation.ProcessAssembly(AssemblyDocument doc)

at UpdateParams.SampleAutomation.Run(Document doc)

CODE :

  var rows = new List<object[]>();

            AssemblyComponentDefinition assemblyComponentDef = doc.ComponentDefinition;
            BOM bom = assemblyComponentDef.BOM;
            BOMViews bomViews = bom.BOMViews;

            // enable structured view in case of iAssembly
            if (assemblyComponentDef.IsiAssemblyFactory && bom.StructuredViewEnabled == false)
                bom.StructuredViewEnabled = true;

 <Place where exception throws> BOMView structureView = bomViews["Structured"];

            GetBomRowProperties(structureView.BOMRows, rows);

            extractedBOM.Data = rows.ToArray();

            return extractedBOM;

Can some body help me how to fix this issue.?


Solution

  • Once we done with param updates, then the assembly document should be closed. Then open the same assembly doc to get the BOM details. Until we close and open the assembly document the BOM retrieve will throw the above error.