Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

BOM renumbering? and Part List Sort by Item (iLogic)

13 REPLIES 13
Reply
Message 1 of 14
DeerSpotter
2524 Views, 13 Replies

BOM renumbering? and Part List Sort by Item (iLogic)

i = MessageBox.Show("Do you wish to Renumber & Sort BOM?", "My iLogic Dialog", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) 
If i = vbyes Then
	Trace.WriteLine ("INV - Transfer; User Selection; Do you wish to Renumber & Sort BOM? - YES")
	'Renumbers & Sort BOM
oPartsList1.Renumber   
oPartsList1.SaveItemOverridesToBOM
oPartsList1.Sort("ITEM") 

Trace.WriteLine ("INV-ExternalRule - Renumber & Sort BOM#")	
Else if i = vbno 
	Trace.WriteLine ("INV -  Transfer; User Selection; Do you wish to change Renumber & Sort BOM? - NO")
End if	

 what am i doing wrong?

 

what i want to do, is renumber the BOM by (001) then go to part list and sort by item.

Image and video hosting by TinyPic
..........................................................................................................................
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
..........................................................................................................................


See My LinkedIn Profile
13 REPLIES 13
Message 2 of 14
rhasell
in reply to: DeerSpotter

Have not debugged your code, below is my sort, maybe you can extract something usefull from it?

 

On Error Resume Next
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oPartsList As PartsList
oPartsList = oDrawDoc.ActiveSheet.PartsLists.Item(1)
If Not oPartsList Is Nothing Then
Call oPartsList.Sort("ITEM")
End If

Reg
2024.2
Please Accept as a solution / Kudos
Message 3 of 14
rhasell
in reply to: rhasell

Hey

 

I tried the renumber, but I could not get it to work?

 

Reg
2024.2
Please Accept as a solution / Kudos
Message 4 of 14
mikejones
in reply to: rhasell

I've had a look at this aswell as I think it is quite useful. I've attached the code I've been using for you to try, it seems to work for me.

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oPartsList As PartsList
oPartsList = oDrawDoc.ActiveSheet.PartsLists.Item(1)

i = MessageBox.Show("Do you wish to Renumber & Sort BOM?", "My iLogic Dialog", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) 
If i = vbYes Then
	Trace.WriteLine ("INV - Transfer; User Selection; Do you wish to Renumber & Sort BOM? - YES")
	'Renumbers & Sort BOM
oPartsList.Renumber   
oPartsList.SaveItemOverridesToBOM
oPartsList.Sort("ITEM") 

Trace.WriteLine ("INV-ExternalRule - Renumber & Sort BOM#")	
Else If i = vbNo 
	Trace.WriteLine ("INV -  Transfer; User Selection; Do you wish to change Renumber & Sort BOM? - NO")
End If	

On Error Resume Next
If Not oPartsList Is Nothing Then
Call oPartsList.Sort("ITEM")
End If

 

Mike


Autodesk Certified Professional
Message 5 of 14
mikejones
in reply to: mikejones

I hope I've understoos what you were trying to do with this. My work flow with it is to order my parts list on the drawing as required and then let the code renumber the bom accordingly.

 

Mike

Autodesk Certified Professional
Message 6 of 14
DeerSpotter
in reply to: mikejones

The way we usually do it here;

 

1. go to BOM, renumber from there with the start # @ (001).

2. Go to Parts List and sort by #.

 

I will try your code, and see what happens.

 

I succeeded in getting the part list to overide the BOM, but is there any BOM functions that we can use instead of partslist?

 

Image and video hosting by TinyPic
..........................................................................................................................
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
..........................................................................................................................


See My LinkedIn Profile
Message 7 of 14
DeerSpotter
in reply to: DeerSpotter

Great!

 

working so far..

 

i really really want to renumber the parts by 001,002,003.etc.. not 1,2,3.etc.... any ideas?

Image and video hosting by TinyPic
..........................................................................................................................
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
..........................................................................................................................


See My LinkedIn Profile
Message 8 of 14
DeerSpotter
in reply to: DeerSpotter

In pursuit of all my inventor problems I need to know what are all the funstions i can call in ilogic to get the BOM to do things for me.

 

If you provide something as simple as opening the BOM through ilogic, i can figure out all the rest.

 

any ideas?

 

Thanks! 

Image and video hosting by TinyPic
..........................................................................................................................
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
..........................................................................................................................


See My LinkedIn Profile
Message 9 of 14
Anonymous
in reply to: DeerSpotter

m.teleguz1

 

Have you looked at the programming help file?

 

iLogic BOM Help.jpg

iLogic BOM Help 2.jpg

 

T.S.

Message 10 of 14

Hi m.teleguz1,

 

If I understand correctly, you can just write to the ITEM cells as an override, and then save the item overrides to the assembly BOM.

 

Here is a quick example that first sorts the BOM by the PART NUMBER column, then steps through the ITEM column and sets the override value starting with 001, and then finally writes the overrides to the BOM.

 

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

 

' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
    
' Set a reference to the first parts list on the active sheet.
' This assumes that a parts list is on the active sheet.
Dim oPartsList As PartsList
oPartsList = oDrawDoc.ActiveSheet.PartsLists.Item(1)

'sort by named column in ascending order
oPartsList.Sort("PART NUMBER", 1)

Dim i As Integer
i = 1
   
' Iterate through the contents of the parts list.
Dim oRow As PartsListRow
For each oRow in oPartsList.PartsListRows
    'look at only the ITEM column
    oCell  = oPartsList.PartsListRows.Item(i).Item("ITEM")
    'write to the target cell
    'formats correctly up to 099 rows
    oCell.Value = If(i < 10, "00" + CStr(i), "0" + CStr(i))
    i = i+1
Next

'save new item numbers to assembly BOM
oPartsList.SaveItemOverridesToBOM

 

Message 11 of 14

This code basically runs that rule individually for each cell...really takes a long time when you have 81 rows.

 

Thank you for the code, that is way more than enough for me to go by and reverse learn what you did there. Hopefully with some patience and time i can figure something else out.

 

 

Image and video hosting by TinyPic
..........................................................................................................................
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
..........................................................................................................................


See My LinkedIn Profile
Message 12 of 14
Anonymous
in reply to: DeerSpotter

Hi,

 

I get some errors when I tried to run these Ilogic

' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
    
' Set a reference to the first parts list on the active sheet.
' This assumes that a parts list is on the active sheet.
Dim oPartsList As PartsList
oPartsList = oDrawDoc.ActiveSheet.PartsLists.Item(1)

'sort by named column in ascending order
oPartsList.Sort("PART NUMBER", 1)

Dim i As Integer
i = 1
   
' Iterate through the contents of the parts list.
Dim oRow As PartsListRow
For each oRow in oPartsList.PartsListRows
    'look at only the ITEM column
    oCell  = oPartsList.PartsListRows.Item(i).Item("ITEM")
    'write to the target cell
    'formats correctly up to 099 rows
    oCell.Value = If(i < 10, "00" + CStr(i), "0" + CStr(i))
    i = i+1
Next

'save new item numbers to assembly BOM
oPartsList.SaveItemOverridesToBOM


The errors are:

error message

Error in rule: Testirule3, in document: LED-seinä ehdotus.idw

 

Määrittämätön virhe. (Exception from HRESULT: 0x80004005 (E_FAIL))

More info

System.Runtime.InteropServices.COMException (0x80004005): Määrittämätön virhe. (Exception from HRESULT: 0x80004005 (E_FAIL))

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

   at Inventor.PartsList.Sort(String PrimaryColumnTitle, Boolean PrimaryColumnAscending, String SecondaryColumnTitle, Boolean SecondaryColumnAscending, String TertiaryColumnTitle, Boolean TertiaryColumnAscending)

   at LmiRuleScript.Main()

   at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)

   at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

 

Could sombody help me? I am so noob 😞

Message 13 of 14
rhasell
in reply to: Anonymous

Hi

 

I am also a noob, so I did not debug your error message. What I did do was compare your code to mine. The only difference is the renumber section.

 

I don't have the  Counter, and item number rename. If I may ask what are you trying to achive, that is not already there, I might have missed it.

 

Therefore give the following a try:

 

' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
    
' Set a reference to the first parts list on the active sheet.
' This assumes that a parts list is on the active sheet.
Dim oPartsList As PartsList
oPartsList = oDrawDoc.ActiveSheet.PartsLists.Item(1)

'sort by named column in ascending order
oPartsList.Sort("PART NUMBER", 1)

 

'save new item numbers to assembly BOM
oPartsList.SaveItemOverridesToBOM

 

Reg
2024.2
Please Accept as a solution / Kudos
Message 14 of 14
rhasell
in reply to: rhasell

Apologies, I missed a step.

 

See new code

 

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oPartsList As PartsList
oPartsList = oDrawDoc.ActiveSheet.PartsLists.Item(1)
oPartsList.Sort("PART NUMBER",1)
oPartsList.Renumber
oPartsList.SaveItemOverridesToBOM

 

Reg
2024.2
Please Accept as a solution / Kudos

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report