Base quantity in BOM set to EACH by default?

Base quantity in BOM set to EACH by default?

WHolzwarth
Mentor Mentor
2,649 Views
17 Replies
Message 1 of 18

Base quantity in BOM set to EACH by default?

WHolzwarth
Mentor
Mentor

Can this be done?

I know of ways manipulating the BOM columns, or still worse, changing Document Settings of each file.

 

Smiley Wink But I'm lazy ..

Walter Holzwarth

EESignature

0 Likes
Accepted solutions (2)
2,650 Views
17 Replies
Replies (17)
Message 2 of 18

Anonymous
Not applicable

Can't you just set it up once exactly how you would like it via the BOM/document settings and then save that file as a template?

 

As long as you keep using that template you should never have to do it again.

0 Likes
Message 3 of 18

WHolzwarth
Mentor
Mentor

Thanks for quick reply, Ashley.

I've already tried that with no remedy, but I'll make another attempt. Problem appears mainly with inserting structural shapes from CC

 

Minutes later: No luck. CC shapes come in again with Base quantity in mm, here with DIN template.

Walter Holzwarth

EESignature

0 Likes
Message 4 of 18

Anonymous
Not applicable

ah, 

 

I've seen a few posts before about using iLogic to control the document settings. A rule running on part creation might be the answer.

I don't know the commands you'll be looking for to do this however. Curtis Waguespack seems to be the expert on all the past posts. 

0 Likes
Message 5 of 18

Mark.Lancaster
Consultant
Consultant

@WHolzwarth

 

Information from CC are solely based on its related family table template and has nothing to do with your templates or settings.  You can update the family template with the information if needed.  However sometimes it works and other times it doesn't.

 

Are you using the out-of-box structural shapes or from the provided read-only content center libraries.

Mark Lancaster


  &  Autodesk Services MarketPlace Provider


Autodesk Inventor Certified Professional & not an Autodesk Employee


Likes is much appreciated if the information I have shared is helpful to you and/or others


Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.

0 Likes
Message 6 of 18

WHolzwarth
Mentor
Mentor

Thanks for having a look, Mark

I've tried both:

- Tube shapes from read-only Inventor DIN library (Base quantity comes in as mm)

- Self-defined oval tubes, stored in read-write My Library of CC. Same base quantity (mm) showed up.

Walter Holzwarth

EESignature

0 Likes
Message 7 of 18

Mark.Lancaster
Consultant
Consultant

@WHolzwarth

 

For those CC components that are in your custom read/write library, you can place as custom, save it (name and location).  Open that custom CC component, change its document/BOM settings and save it.  Open content center editor (Manage tab), change your library view (upper left hand corner) to your read/write library.  Locate your family that's associated to that custom cc, right mouse click and select replace family template and pick the custom CC component you saved earlier.

Mark Lancaster


  &  Autodesk Services MarketPlace Provider


Autodesk Inventor Certified Professional & not an Autodesk Employee


Likes is much appreciated if the information I have shared is helpful to you and/or others


Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.

Message 8 of 18

WHolzwarth
Mentor
Mentor

Hmm. No luck with changing, new file was declared as invalid.

Perhaps it helps attaching my files (2017). All initial dimensions in BOM are mm.

Walter Holzwarth

EESignature

0 Likes
Message 9 of 18

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @WHolzwarth,

 

I think you'd need to set your Application Options > Files > Default CC Files setting so that the CC files are not picked up as libraries, so they are not read only, but then you could run this code from an iLogic rule in the assembly to change all of the part files to use a base qty of Each.

 

Then just reset your Application Options > Files > Default CC Files stetting back to what it was.

 

I think this would work if I understand the request correctly... but didn't really test it too much.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Dim oOccs As ComponentOccurrencesEnumerator 
oOccs = ThisDoc.Document.ComponentDefinition.Occurrences.AllLeafOccurrences

Dim oOcc As ComponentOccurrence
For Each oOcc In oOccs
	Call oOcc.Definition.Document.ComponentDefinition.BOMQuantity.SetBaseQuantity _
	(BOMQuantityTypeEnum.kEachBOMQuantity)	
Next

iLogicVb.UpdateWhenDone = True

 

EESignature

Message 10 of 18

WHolzwarth
Mentor
Mentor

Thanks for the proposal, Curtis. I think, it's another way, but perhaps changing Base Quantity by Copy and Paste in BOM seems easier to me.

 

Both methods look like avoidable work, if a default setting for EACH would be existing. I'd never use mm or inch as BASE_QTY.

Walter Holzwarth

EESignature

0 Likes
Message 11 of 18

paulobelesa
Contributor
Contributor

I wonder how i can make it show MM not pol in my assemblies ,

Im from Brazil and here we use metric system. 

Any advice?

 

0 Likes
Message 12 of 18

johnsonshiue
Community Manager
Community Manager

Hi! It should be fairly straight forward like Curtis has shown in his reply. Or, you can make change in the part and assembly templates (Tools -> Doc Settings -> BOM). If you cannot figure it out, please share an example here so forum experts can take a look.

Many thanks!

 



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 13 of 18

Kersh
Contributor
Contributor

Hi Curtis,

You're code works fine for me with some assemblies, but then fails for others. I've tried suppressing fasteners and anything odd out of the assemblies to see if it helps, but I still get this error:

 

'System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)
at ThisRule.Main() in external rule: Qty to Each:line 6
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

Any ideas how to fix this, I'd dearly like att parts within the assembly to have 'Each' for their Base QTY.

(All parts within the assembly were checked out).

Message 14 of 18

Curtis_Waguespack
Consultant
Consultant

@Kersh, I can't replicate the error, or determine from the error message what might be the issue, but here is an update to this that will catch the error and write out the occurrence name to the logger. This should help determine which occurrence(s) are the problem, and then from there maybe we can update the code to handle those file(s).

Hope that helps,

Curtis

 

Dim oOccs As ComponentOccurrencesEnumerator
oOccs = ThisDoc.Document.ComponentDefinition.Occurrences.AllLeafOccurrences

Dim oOcc As ComponentOccurrence
For Each oOcc In oOccs
	Try 
		Call oOcc.Definition.Document.ComponentDefinition.BOMQuantity.SetBaseQuantity _
		(BOMQuantityTypeEnum.kEachBOMQuantity)
	Catch ex As Exception
		Logger.Info("---------------")
		Logger.Info("Could not set BOM QTY to Each in " & oOcc.Name)
		Logger.Info(ex.Message)
		Logger.Info("---------------")
	End Try
Next

iLogicVb.UpdateWhenDone = True

'Turn on iLogic Logger browser window
ThisApplication.UserInterfaceManager.DockableWindows.Item("ilogic.logwindow").Visible = True

 

EESignature

Message 15 of 18

Kersh
Contributor
Contributor

@Curtis_Waguespack , Brilliant, thanks Curtis.

With that code added the file now doesn't crash out with that previous error.

It appears from the log to be failing on the content centre fixings in the model.

I had tried to suppress them in a model state, but that didn't work.

Is it possible to adjust the code to only change Base Qty for things you have checked out?

 

Many Thanks

Kersh

 

Part of error log below: (there were literally hundreds of fixings within the assy)

 

INFO| 2: >>---------------------------
INFO|---------------
INFO|Could not set BOM QTY to Each in FWGR-0075:1
INFO|Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
INFO|---------------
INFO|---------------
INFO|Could not set BOM QTY to Each in BOGR-7522:1
INFO|Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
INFO|---------------
INFO|---------------
INFO|Could not set BOM QTY to Each in FWGR-0075:2
INFO|Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
INFO|---------------
INFO|---------------
INFO|Could not set BOM QTY to Each in LWGR-0075:1
INFO|Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
INFO|---------------
INFO|---------------
INFO|Could not set BOM QTY to Each in NTGR-0075:1
INFO|Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
INFO|---------------
INFO|---------------
INFO|Could not set BOM QTY to Each in FWGR-0075:3
INFO|Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
INFO|---------------
INFO|---------------
INFO|Could not set BOM QTY to Each in BOGR-7522:2
INFO|Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
INFO|---------------
INFO|---------------
INFO|Could not set BOM QTY to Each in FWGR-0075:4
INFO|Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
INFO|---------------
INFO|---------------
INFO|Could not set BOM QTY to Each in LWGR-0075:2
INFO|Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
INFO|---------------
INFO|---------------
INFO|Could not set BOM QTY to Each in NTGR-0075:2
INFO|Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
INFO|---------------
INFO|---------------
INFO|Could not set BOM QTY to Each in FWGR-0075:5
INFO|Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
INFO|---------------
INFO|---------------
INFO|Could not set BOM QTY to Each in FWGR-0075:6
INFO|Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
INFO|---------------
INFO|---------------
INFO|Could not set BOM QTY to Each in FWGR-0075:7
INFO|Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
INFO|---------------
INFO|---------------
INFO|Could not set BOM QTY to Each in FWGR-0075:8
INFO|Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
INFO|---------------
INFO|---------------
INFO|Could not set BOM QTY to Each in FWGR-0075:9
INFO|Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
INFO|---------------
INFO|---------------
INFO|Could not set BOM QTY to Each in FWGR-0075:10
INFO|Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
INFO|---------------

0 Likes
Message 16 of 18

Kersh
Contributor
Contributor

Also, If it could skip 'Virtual Parts' that'd be brilliant too. We're going away from actual fasteners in models as they're a bit resource hungry 😁

0 Likes
Message 17 of 18

Curtis_Waguespack
Consultant
Consultant
Accepted solution

@Kersh , we can't know the check out status ( as far as I know) but here are a few ways that might work to only change the status for things that can be changed.

You could skip all content center parts:

Dim oOccs As ComponentOccurrencesEnumerator
oOccs = ThisDoc.Document.ComponentDefinition.Occurrences.AllLeafOccurrences

Dim oOcc As ComponentOccurrence
For Each oOcc In oOccs
	Dim oDoc As Document = oOcc.Definition.Document
	If oDoc.ComponentDefinition.IsContentMember = True Then Continue For
		
	Call oDoc.ComponentDefinition.BOMQuantity.SetBaseQuantity(BOMQuantityTypeEnum.kEachBOMQuantity)

Next

iLogicVb.UpdateWhenDone = True



Or you could use this to check the read only status of the part, and skip all read only parts

 

Dim oOccs As ComponentOccurrencesEnumerator
oOccs = ThisDoc.Document.ComponentDefinition.Occurrences.AllLeafOccurrences

Dim oOcc As ComponentOccurrence
For Each oOcc In oOccs
	Dim oDoc As Document = oOcc.Definition.Document

	Dim oFile As System.IO.FileInfo = New System.IO.FileInfo(oDoc.FullFileName)
	If oFile.IsReadOnly = True Then Continue For

	Call oDoc.ComponentDefinition.BOMQuantity.SetBaseQuantity(BOMQuantityTypeEnum.kEachBOMQuantity)

Next

iLogicVb.UpdateWhenDone = True


Or maybe this to see if it can be modified

Dim oOccs As ComponentOccurrencesEnumerator
oOccs = ThisDoc.Document.ComponentDefinition.Occurrences.AllLeafOccurrences

Dim oOcc As ComponentOccurrence
For Each oOcc In oOccs
	Dim oDoc As Document = oOcc.Definition.Document

	If oDoc.IsModifiable = False Then Continue For
	Call oDoc.ComponentDefinition.BOMQuantity.SetBaseQuantity(BOMQuantityTypeEnum.kEachBOMQuantity)

Next

iLogicVb.UpdateWhenDone = True


Or go full "belt and suspenders" mode and check all of those things and use the try/catch too

Dim oOccs As ComponentOccurrencesEnumerator
oOccs = ThisDoc.Document.ComponentDefinition.Occurrences.AllLeafOccurrences

Dim oOcc As ComponentOccurrence
For Each oOcc In oOccs
	Dim oDoc As Document = oOcc.Definition.Document
	Dim oFile As System.IO.FileInfo = New System.IO.FileInfo(oDoc.FullFileName)

	If oFile.IsReadOnly = True Then Continue For
	If oDoc.ComponentDefinition.IsContentMember = True Then Continue For
	If oDoc.IsModifiable = False Then Continue For

	Try
		Call oDoc.ComponentDefinition.BOMQuantity.SetBaseQuantity(BOMQuantityTypeEnum.kEachBOMQuantity)
	Catch ex As Exception
		'Logger.Info("Could not set BOM QTY to Each in " & oOcc.Name)
	End Try

Next

iLogicVb.UpdateWhenDone = True

 

EESignature

Message 18 of 18

Kersh
Contributor
Contributor

Thanks @Curtis_Waguespack .

That's superb and now works 100% and quickly.

I've gone with the third option just in case I miss something.

Thanks so much for the help and quick responce. 😎

No longer any errors in the Log 🏆