Ilogic rule to change the BOM Item Renumbering

Ilogic rule to change the BOM Item Renumbering

mdavis22569
Mentor Mentor
2,315 Views
11 Replies
Message 1 of 12

Ilogic rule to change the BOM Item Renumbering

mdavis22569
Mentor
Mentor

 

Does anyone know of a Rule to change the Item renumbers in a structured BOM ..

 

On where you are prompted for the Start Value and Increment ... or it's reset to be the 10, and 10 values?

renumber.PNG

 

Thank you


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------
Mike Davis

EESignature

0 Likes
2,316 Views
11 Replies
Replies (11)
Message 2 of 12

mrattray
Advisor
Advisor
I'm not sure what your asking for, Michael. I assume you're aware of the Renumber method.
Mike (not Matt) Rattray

0 Likes
Message 3 of 12

mdavis22569
Mentor
Mentor
Yeah ... What happens is we do our numbering in our BOM's in 10's ...so 10, 20 , 30 ... However I'd like to get an ilogic where I go to the model run the Ilogic run and basically it would change them all to this renumbering Version .. 1) click on Asssemble 2) click on Bill of Material 3) click on Structured if it's not picked 4) click on Item renumber 5) Input Start value 10, Increment 10

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------
Mike Davis

EESignature

0 Likes
Message 4 of 12

mdavis22569
Mentor
Mentor
Maybe I don't know of the renumbering you're talking about ...but looking ..

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------
Mike Davis

EESignature

0 Likes
Message 5 of 12

mrattray
Advisor
Advisor

The Renumber method supports optinal arguments for starting number and increments. Here's a snippet I use for automatically sorting and renumbering my BOMs.

 

Sub bomSort()

Dim oAsmDoc As AssemblyDocument
Dim oAsmCompDef As AssemblyComponentDefinition
Dim oBOMView As BOMView

oAsmDoc = ThisDoc.Document
oAsmCompDef = oAsmDoc.ComponentDefinition

Try
	oBOMView = oAsmCompDef.BOM.BOMViews.Item("Parts Only")
Catch
	oAsmCompDef.BOM.PartsOnlyViewEnabled = True
	oBOMView = oAsmCompDef.BOM.BOMViews.Item("Parts Only")
End Try
Try
	oBOMView.Sort("WORK CENTER CODE", True, "VISUAL PART NUMBER", True, "Description", True)
	oBOMView.Renumber()
Catch
	MsgBox("Any error was encountered while sorting your BOM. The most likely cause is missing custom properties(WORK CENTER CODE " _
	   & "& VISUAL PART NUMBER). Please, add these properties and try again.", vbOKOnly, "Error")
	Exit Sub
End Try

Try
	oBOMView = oAsmCompDef.BOM.BOMViews.Item("Structured")
Catch
	oAsmCompDef.BOM.StructuredViewEnabled = True
	oBOMView = oAsmCompDef.BOM.BOMViews.Item("Structured")
End Try
Try
	oBOMView.Sort("WORK CENTER CODE", True, "VISUAL PART NUMBER", True, "Description", True)
	oBOMView.Renumber()
Catch
	MsgBox("Any error was encountered while sorting your BOM. The most likely cause is missing custom properties(WORK CENTER CODE " _
	   & "& VISUAL PART NUMBER). Please, add these properties and try again.", vbOKOnly, "Error")
	Exit Sub
End Try

End Sub

 

Mike (not Matt) Rattray

0 Likes
Message 6 of 12

mdavis22569
Mentor
Mentor

Getting an error when I try it

 

 

snippet.PNG


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------
Mike Davis

EESignature

0 Likes
Message 7 of 12

BrandonBG
Collaborator
Collaborator

Michael--

 

See an earlier thread on a similar issue with BOM numbers:

http://forums.autodesk.com/t5/inventor-customization/make-a-custom-iproperty-equal-to-the-item-in-th...

 

After poking around with the BOM in iLogic, I determined that the BOM numbering can't be changed with iLogic. You'll have to use VB outside Inventor to access it with the API.

 

 

BOM.jpg

 

 

BrandonBG

Inventor 2015

0 Likes
Message 8 of 12

MechMachineMan
Advisor
Advisor

Simply change the Sub bomsort to Sub Main(). Sub bomsort would be useful for it you are calling it within Sub Main().

 

Chcek here for some more learning on the topic if you plan to delve any deeper into API that you currently are.

 

http://au.autodesk.com/au-online/classes-on-demand/class-catalog/2013/product-design-suite/ma1936


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 9 of 12

mrattray
Advisor
Advisor
MechMachineMan is correct. I use this snippet as a component of more complex rules, but you can simply change bomSort() to Main() or delete that line and the End Sub line.
Mike (not Matt) Rattray

0 Likes
Message 10 of 12

mrattray
Advisor
Advisor
Brandon, the issue you had in that thread was with ThisBOM, which I'm not using. I'm accessing the BOMView directly.
Mike (not Matt) Rattray

0 Likes
Message 11 of 12

mrattray
Advisor
Advisor
Sorry for the multiple posts, but I keep forgetting to mention things.
You'll want to do some tweaking to that code anyways, as it's not written to do exactly what you want. Really, you don't need any of the sorting code unless you want it and you need to add the optional arguments to the renumber method to get your increments.
Mike (not Matt) Rattray

0 Likes
Message 12 of 12

mdavis22569
Mentor
Mentor

It's ok keep posting

 

 ...I'll work on it more tonight.   I'm not that great at ilogic at all ..

 

don't be surprised if I ask for some more help.

 

 

Mike


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------
Mike Davis

EESignature

0 Likes