Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Drawing- parts quantity. iLogic

17 REPLIES 17
SOLVED
Reply
Message 1 of 18
Anonymous
2707 Views, 17 Replies

Drawing- parts quantity. iLogic

Hi,

I would like to know, is it possible to make a rule, which will multiplicate part quantity on drawing by some defined number, "n"? I have different number of ass'ys for different orders and I will manually set parts quantities for one ass'y  and then save it as a copy and then run rule for quantity multiplication. Any advices?
Greetings

17 REPLIES 17
Message 2 of 18
MechMachineMan
in reply to: Anonymous

_ORDER ASSEMBLY.iam

    - General Assembly

        - SubAsm1

            - Part 1

        - Part 2

        - etc.

 

In the BOM of _ORDER ASSEMBLY, override the quantity of the 1 general assembly.

 

Enjoy having the functionality of a working structured/parts only list instead of just a dumb overridden static parts list.


--------------------------------------
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
Message 3 of 18
rhasell
in reply to: Anonymous

Hi

You need to create a multiplier in the same manner you would when calculating the total mass.

 

Create another qty column in the Parts List, and then use it as a multiplier, that way you can specify the qty required for each assembly, and it will multiply the quantity required by the number you specified.

 

Create Two new properties in the parts list

1 - Total

Rename this one to QTY if you wish

2 - Multiplier, (mine is called something else, but it gets blocked when I write it on the forums.)

 

Then follow my storyboard to get it running.

If you are happy with this solution, I can supply the iLogic code to speed it up.

 

Hope this makes sense to you.

 

 

Starting viewStarting viewEdit the parts listEdit the parts listRename the new propertyRename the new propertySet the multiplierSet the multiplierEnter the number of Sub Assemblies requiredEnter the number of Sub Assemblies requiredSet the column width to 1 in order to hide it.Set the column width to 1 in order to hide it.The finished Parts ListThe finished Parts List

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

Hi

 

I have edited and tested my ilogic code.

All you need to do is change the column heading to suit your column label. (Highlighted in red)

' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oPartList As PartsList
'''---------------------
'The next line is if you have more than one parts list on your drawing.
oPRTL = InputBox("Choose the Parts List", "Parts List Filter", "1")
'''---------------------
'define custom property collection
oCustomPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties")
Try
'set property value
oProp = oCustomPropertySet.Item("ASSQTY")
Catch
' Assume error means not found so create it
oCustomPropertySet.Add("", "ASSQTY")
End Try
'''-----------------------

' Set a reference to the first parts list on the active sheet.
'expand the parts list
oPartList = oDrawDoc.ActiveSheet.PartsLists.Item(oPRTL)
oPartList.Style = oDrawDoc.StylesManager.PartsListStyles.Item("Parts List")
oASSQTY = InputBox("Enter Quantity of Assemblies Required", "iLogic",iProperties.Value("Custom", "ASSQTY") )
iProperties.Value("Custom", "ASSQTY") = oASSQTY
' Iterate through the contents of the parts list.
Dim i As Long
For i = 1 To oPartList.PartsListRows.Count
oCell = oPartList.PartsListRows.Item(i).Item("ASS")
'write to the target cell
oCell.Value = iProperties.Value("Custom", "ASSQTY")
Next 
MessageBox.Show("All Done", "BOM QTY")
Reg
2024.2
Please Accept as a solution / Kudos
Message 5 of 18
Anonymous
in reply to: rhasell

Thanks a lot, I found it helpful. Until now, I used to make ass'y with number of subass'ys needed for production order and make parts/only BOM, but it was a bit uncomfortable. One more question, is it possible, to change automatically QTY on single part drawing title block, (lowest in structure), considering the result I got with your method?

Message 6 of 18
rhasell
in reply to: Anonymous

Not 100% sure I understand your question, but if you are asking if it will work with a parts list of a single part (.IPT) then yes it will still work.

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

Well, I have one .idw with multiple sheets. And I stick to the sequence : main assembly drawing (with BOM)-> subassembly drawings (with BOM)-> single part drawings (which goes to the workshop with Qty in title block). And I wonder if its possible, to change quantity on  details drawings with the numbers received in main assembly BOM.
By the way, thank you very much for your help.

Message 8 of 18
rhasell
in reply to: Anonymous

Hi

 

I don't know.  I have not used Mutisheet drawings for about 7 years now, so none of my work takes that into consideration. I have found that everything is easier with single sheet drawings. (I use mutisheet for padding with sheet numbers, but nothing else (eg: sheet 2 of 3))

 

I ran a quick test to see if everything works on multiple sheets, and each parts list is handled independently, but I will have to revisit the code, to update all sheets at the same time. (Honestly, my skills do not extend to that level, and I would have to search the forums for something similar, and modify it to suit my needs)

 

I will try and find/write something, but I make no promises, perhaps someone has already done the work for multisheet files and can step in here?

 

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

Well, it's not up to me- I had to adapt to this style and was just wondering if it's possible to make things a bit easier and faster. However, thanks for Your help.

Message 10 of 18
AMISTRYZ5Q34
in reply to: rhasell

Hello

I have a similar question. 

Is there a way to get the prompt box that is linked with the quantity on drawing as soon as we open .idw?

For example: at this point in order to change the part quantities on the drawing I manually input the number in the title block.

Any help would be appreciated.

Thank you

 

title block.PNG

Message 11 of 18
rhasell
in reply to: AMISTRYZ5Q34

Hi

 

As long as the "ASSQTY" iProperty exists, then you can update the value and run the code.

So a prompted entry in the title block will update the value, and then update the parts list.

I tested using an iLogic trigger, but it was painful, as the code ran every time a property change was made.

 

So in a nutshell, I don't have a smooth working solution for you just yet, the quickest option I have for the moment is placing the rule on the ribbon.

Perhaps some of the gurus can help with the auto run of the rule without it getting too irritating.

 

I have taken some of the prompts out of the above listed rule, to allow it run without user input.

Hope this helps a little.

 

' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oPartList As PartsList
'''---------------------
'The next line is if you have more than one parts list on your drawing.
'''oPRTL = InputBox("Choose the Parts List", "Parts List Filter", "1")
'''---------------------
'define custom property collection
oCustomPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties")
Try
'set property value
oProp = oCustomPropertySet.Item("ASSQTY")
Catch
' Assume error means not found so create it
oCustomPropertySet.Add("", "ASSQTY")
End Try
'''-----------------------

' Set a reference to the first parts list on the active sheet.
'expand the parts list
'oPartList = oDrawDoc.ActiveSheet.PartsLists.Item(oPRTL)
oPartList = oDrawDoc.ActiveSheet.PartsLists.Item(1)
oPartList.Style = oDrawDoc.StylesManager.PartsListStyles.Item("Parts List")
'''oASSQTY = InputBox("Enter Quantity of Assemblies Required", "iLogic",iProperties.Value("Custom", "ASSQTY") )
'''iProperties.Value("Custom", "ASSQTY") = oASSQTY
' Iterate through the contents of the parts list.
Dim i As Long
For i = 1 To oPartList.PartsListRows.Count
oCell = oPartList.PartsListRows.Item(i).Item("ASS")
'write to the target cell
oCell.Value = iProperties.Value("Custom", "ASSQTY")
Next 
'MessageBox.Show("All Done", "BOM QTY")

 

Reg
2024.2
Please Accept as a solution / Kudos
Message 12 of 18
R_Cygan
in reply to: Anonymous

Hi There,

 

I do not get that, but have similar issue. I was testing previous Rules- did not work

 

I have an Assembly with parts and subassemblies, I'd like to have Rule that will multiply all parts in Part List by a "N" number. That can work only in Drawing file

E.G. Lets say need to make "N" = 5 Units, (My BOM Shows quantity of each part for 1 Unit)

 was hoping to add a column that will multiply each quantity value by the "N" =5

 

Thank You for our help

Message 13 of 18
R_Cygan
in reply to: R_Cygan

.

Message 14 of 18
R_Cygan
in reply to: rhasell

Hi There,

 

I do not get that, but have similar issue. I was testing previous Rules- did not work

 

I have an Assembly with parts and subassemblies, I'd like to have Rule that will multiply all parts in Part List by a "N" number. That can work only in Drawing file

E.G. Lets say need to make "N" = 5 Units, (My BOM Shows quantity of each part for 1 Unit)

 was hoping to add a column that will multiply each quantity value by the "N" =5

 

Thank You for our help

Tags (1)
Message 15 of 18
rhasell
in reply to: R_Cygan

Hi

This particular method only work in  the drawing environment.

 

You have to make a new column, I renamed the column I created  from "TOTAL" to "QTY" I then removed the visibility of the original QTY column and replaced it with the new qty column.

The "TOTAL/QTY" column is updated with the multiplier

So in your case you just need to show both columns in the BOM.

The default "QTY" column as well as the "TOTAL" column.

 

Been a while since I worked on this one, but I will gladly assist you in getting yours working.

 

Something like this?

bom qty.png

 

Reg
2024.2
Please Accept as a solution / Kudos
Message 16 of 18
GosponZ
in reply to: R_Cygan

'Make custom iProperties TTL and TotalUnits
'Run rule in assembly or make form. Library and CC parts are exluded.

Sub
Main On Error Resume Next Dim openDoc As Document openDoc = ThisDoc.Document Dim docFile As Document Dim oCustomPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties") If iProperties.Value("Custom", "TotalUnits") = 0 Then iProperties.Value("Custom", "TotalUnits") = 1 End If Dim Total_Units = iProperties.Value("Custom", "TotalUnits") '**** FOR TESTING PURPOSES - place a ' in front of the next line to skip it ' MessageBox.Show("TotalUnits = " & Total_Units, "iLogic") If openDoc.DocumentType = 12291 Then For Each docFile In openDoc.AllReferencedDocuments Dim propertyName As String = "TTL" Dim propertyValue As Integer = 1 customPropertySet = docFile.PropertySets.Item("Inventor User Defined Properties") ' Try ' prop = customPropertySet.Item("TTL") ' Catch ' ' Assume error means not found ' customPropertySet.Add(1, "TTL") ' End Try Dim FNamePos As Long Dim docFName As String FNamePos = InStrRev(docFile.FullFileName, "\", -1) docFName = Mid(docFile.FullFileName, FNamePos + 1, Len(docFile.FullFileName) -FNamePos) If docFile.IsModifiable = True Then Dim assemblyDoc As AssemblyDocument Dim assemblyDef As AssemblyComponentDefinition Dim partQty As ComponentOccurrencesEnumerator assemblyDoc = openDoc assemblyDef = assemblyDoc.ComponentDefinition partQty = assemblyDef.Occurrences.AllReferencedOccurrences(docFile) If IsNumeric(partQty.Count) = True Then iProperties.Value(docFName, "Custom", "TTL") = partQty.Count * Total_Units '**** FOR TESTING PURPOSES - place a ' in front of the next 3 lines to skip it ' MessageBox.Show(docFName _ ' & vbLf & " Part Qty = " & partQty.Count _ ' & vbLf & " TTL = " & iProperties.Value(docFName, "Custom", "TTL"), "iLogic") End If End If Next Else MessageBox.Show("You must have a valid Assembly document open before using this code!", "File Type Mismatch!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) End If End Sub
Message 17 of 18
R_Cygan
in reply to: rhasell

Thank You very much. I like that the rule will work in drawings,
Where I can get the code?/ rule

Thank You for your help

Message 18 of 18
rhasell
in reply to: R_Cygan

Check reply #4 higher up in the thread

 

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  

Technology Administrators


Autodesk Design & Make Report