BOM row static quantity programatically...?

BOM row static quantity programatically...?

oransen
Collaborator Collaborator
983 Views
14 Replies
Message 1 of 15

BOM row static quantity programatically...?

oransen
Collaborator
Collaborator

I can set the quantity in a BOM to be static by hand, and insert the quantity I want to.

 

And once it is set to static I can change the quantity programatically:

 

 

            CComBSTR bstrNewTotalQuantity = L"666,666" ;
            ThisBomRow->put_TotalQuantity(bstrNewTotalQuantity);

However I can't find out how to set the BOM quantity item to static from within my program. Both my tests and the help say that put_TotalQuantityOverridden can only be used to set things to FALSE.

 

How can I do with the API what I do by hand, i.e. set TotalQuantityOverridden to TRUE?

 

Or have I missed something?

 

 

 

 

 

0 Likes
Accepted solutions (2)
984 Views
14 Replies
Replies (14)
Message 2 of 15

bradeneuropeArthur
Mentor
Mentor
Public Sub BOMSTATIC()

Dim a As Application
Set a = ThisApplication

Dim b As AssemblyDocument
Set b = a.ActiveDocument

Dim c As BOM
Set c = b.ComponentDefinition.BOM

MsgBox c.BOMViews.Item(1).BOMRows.Item(1).TotalQuantity

c.BOMViews.Item(1).BOMRows.Item(1).TotalQuantity = 2 "OR YOUR qty...."
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 15

oransen
Collaborator
Collaborator

>> c.BOMViews.Item(1).BOMRows.Item(1).TotalQuantity = 2 "OR YOUR qty...."

 

This works if the TotalQuantity is already a static. But if it is calculated (at least as far as I can tell) it remains calculated.

 

My question was how to change from calculated to static programatically.

 

I think...

 

0 Likes
Message 4 of 15

bradeneuropeArthur
Mentor
Mentor
c.BOMViews.Item(1).BOMRows.Item(1).TotalQuantityOverridden = False

Regards,

Autodesk Software: Inventor Professional 2018 | Vault Professional 2018 | Autocad Mechanical 2018
Programming Skills: Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Dimension Component! | Partlist Export! | Derive I-properties! | Vault Prompts Via API! | Vault Handbook/Manual!
Drawing Toggle Sheets! | Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 5 of 15

oransen
Collaborator
Collaborator

@bradeneuropeArthur wrote:
c.BOMViews.Item(1).BOMRows.Item(1).TotalQuantityOverridden = False

 


But I want it to be True. The docs say you can set it to False, but not to True. And my experiments confirm that.

If the item is already True then I can change the TotalQuantity.

0 Likes
Message 6 of 15

oransen
Collaborator
Collaborator

To be more specific:

 

            hRes = ThisBomRow->put_TotalQuantityOverridden(VARIANT_TRUE);
            if (FAILED(hRes)) {
                gLogger.Printf(ekLogMsg, L"    Could not set overridden", pDefinitionsEnum->Count);
            }

If TotalQuantityOverridden is already true I don't get the message "Could not set overridden".

It TotalQuantityOverridden is false then I get the message "Could not set overridden"

And this confirms what the API help says.

 

 

 

0 Likes
Message 7 of 15

bradeneuropeArthur
Mentor
Mentor

Hi,

 

I can set it to true!

What version of Inventor are you using?

 

c.BOMViews.Item(1).BOMRows.Item(1).TotalQuantityOverridden = True

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 8 of 15

oransen
Collaborator
Collaborator

 

>> I can set it to true!

 

Inventor 2017

 

 

0 Likes
Message 9 of 15

bradeneuropeArthur
Mentor
Mentor

I don't understand the question anymore then!

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 10 of 15

oransen
Collaborator
Collaborator

When you do this...

 

c.BOMViews.Item(1).BOMRows.Item(1).TotalQuantityOverridden = True

...could you check that it was originally false and that it really goes to True?

 

Which version of Inventor are you using?

 

 

0 Likes
Message 11 of 15

bradeneuropeArthur
Mentor
Mentor
I will try that.

Inventor 2018

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 12 of 15

bradeneuropeArthur
Mentor
Mentor
Accepted solution

Sorry but you are right.

 

With this it is possible what you need I think.

 

I found out what you mean.

but you need to add the value first to initialize

 

Public Sub BOMSTATIC()

Dim a As Application
Set a = ThisApplication

Dim b As AssemblyDocument
Set b = a.ActiveDocument

Dim c As BOM
Set c = b.ComponentDefinition.BOM

Dim OriginalSet As Boolean
OriginalSet = c.BOMViews.Item(1).BOMRows.Item(1).TotalQuantityOverridden

MsgBox OriginalSet
c.BOMViews.Item(1).BOMRows.Item(1).TotalQuantity = c.BOMViews.Item(1).BOMRows.Item(1).TotalQuantity
c.BOMViews.Item(1).BOMRows.Item(1).TotalQuantityOverridden = True
Dim NewSetTrue As Boolean
NewSetTrue = c.BOMViews.Item(1).BOMRows.Item(1).TotalQuantityOverridden

MsgBox OriginalSet & " VS " & NewSetTrue

End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 13 of 15

oransen
Collaborator
Collaborator

Thanks @bradeneuropeArthur for testing all this. I'm not sure what the equivalent in C++ is though. I'll wait till the authorities reply, maybe there's a simple solution we have missed...

 

0 Likes
Message 14 of 15

bradeneuropeArthur
Mentor
Mentor

I am curious too.

I think Autodesk does the same as the last code, by setting the value first to his initial value.

Don't you think?

Regards,

Autodesk Software: Inventor Professional 2018 | Vault Professional 2018 | Autocad Mechanical 2018
Programming Skills: Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Dimension Component! | Partlist Export! | Derive I-properties! | Vault Prompts Via API! | Vault Handbook/Manual!
Drawing Toggle Sheets! | Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 15 of 15

oransen
Collaborator
Collaborator
Accepted solution

@bradeneuropeArthur  wascompletely right. Strangely enough you have to set the quantity before you set Overriden

 

            // Do this before you do put_TotalQuantityOverridden
            CComBSTR bstrNewTotalQuantity = L"77" ;
            ThisBomRow->put_TotalQuantity(bstrNewTotalQuantity);
            ThisBomRow->put_TotalQuantityOverridden(VARIANT_TRUE);

Now all I need to do is work out how to change from "Each" to...

 

Odd eh?

0 Likes