BOM.GetPartNumberMergeSettings2

BOM.GetPartNumberMergeSettings2

ThomasRambach
Advisor Advisor
382 Views
4 Replies
Message 1 of 5

BOM.GetPartNumberMergeSettings2

ThomasRambach
Advisor
Advisor

Whenever I use the following:

Inventor.AssemblyDocument ASMdoc = (Inventor.AssemblyDocument)mDoc;
AssemblyComponentDefinition oAsmCompDef = ASMdoc.ComponentDefinition;

oAsmCompDef.BOM.GetPartNumberMergeSettings2(out bool boolMergeEnabled, out string[] strMergeExcludeList, out bool boolMergeInstanceRows);

 

It always results in an error with GetPartNumberMergeSettings2 like: 

System.NullReferenceException: 'Object reference not set to an instance of an object.'

 

 

I'm not sure why this is. It's a normal Inventor assembly file each time. What am I doing wrong?

0 Likes
Accepted solutions (1)
383 Views
4 Replies
Replies (4)
Message 2 of 5

Curtis_Waguespack
Consultant
Consultant

Hi @ThomasRambach ,

 

Maybe you're not setting the string array?

 

This runs without error

 

Dim ASMdoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oAsmCompDef As ComponentDefinition = ASMdoc.ComponentDefinition

Dim strings = New String() {"1111", "2222" }

oAsmCompDef.BOM.GetPartNumberMergeSettings2(True, strings, False)

 

 

{
    AssemblyDocument ASMdoc = Inventor.ActiveDocument;
    ComponentDefinition oAsmCompDef = ASMdoc.ComponentDefinition;

    var strings = new string[] { "1111", "2222" };

    oAsmCompDef.BOM.GetPartNumberMergeSettings2(true, strings, false);
}

 

 

 

EESignature

0 Likes
Message 3 of 5

ThomasRambach
Advisor
Advisor

@Curtis_Waguespack  Wouldn't that only be needed if I'm "Setting" and not "Getting"? It's always looking for the the "Out" on Get.

Message 4 of 5

Curtis_Waguespack
Consultant
Consultant

@ThomasRambach 

 

Ahhh, I think you're right. I only took a quick look at this earlier. I'll try to have another look later.

 

https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-D7361CFC-43FF-4108-8CA0-0110D05DDD23

 

EESignature

0 Likes
Message 5 of 5

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@ThomasRambach,

The C# code sample for GetPartNumberMergeSettings2 API method is as below:

AssemblyDocument oDoc =(AssemblyDocument) m_inventorApp.ActiveDocument;

AssemblyComponentDefinition oDef = oDoc.ComponentDefinition;
BOM oBom = oDef.BOM;

bool bMerged = false;
string[] sExcludeList = new string[] { };
bool bMergeInsRows = false;

oBom.GetPartNumberMergeSettings2(out bMerged, out sExcludeList,out bMergeInsRows);


Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network