Hi to all. I have a question.
Each of our part drawings has quantity based on the assembly BOM. We export the BOM to excel then manually type the quantity in the drawing.
So I wonder, is there any way thru iLogic that we can get the quantity from BOM and set it as custom iproperty in the drawing?
Maybe we can turn the partslist into an assembly iproperties, then read that from the part drawing.
Solved! Go to Solution.
Solved by WCrihfield. Go to Solution.
Yes. All standard BOM quantities should be available to view within the Parts List in the drawing. There are several Quantities involved with BOM's though.
Within the Parts List dialog, click on the "Column Chooser" button (top left). With "All Properties" showing in the drop-down list under "Select available properties from:", scroll through the list of available properties, select it, then click the [Add->] button to add it to your existing Parts List columns. Then arrange them in the order you want them on the right. Then click [OK] button to finish.
Is this what you wanted, or is the Quantity you have in mind within a Custom iProperty, or do you need to pull it in from Excel?
Wesley Crihfield
(Not an Autodesk Employee)
I had placed the partslist of the drawing then removed the other column except quantity. Then I applied filter by item number. But these filters are very limited. The problem was when the sorting change and renumbering occured.
The filter by item number would stay, but the part number and quantity could be different.
Perhaps using the "Assembly View Representation" type filter would work better for you? That's what I often use. You don't necessarily need to have your Parts List tied to a specific drawing view to use this. It just goes how the DesignViewRepresentation (that you choose after setting this type of filter) is set-up. You can easily have several DVR's in your Assembly. (DVR's deal with component visibility is set to On/Off, not whether components are suppressed or not.) Then there is also an additional setting (check box) to "Limit QTY to visible components only".
Wesley Crihfield
(Not an Autodesk Employee)
@Anonymous And yes it is fairly easy to send data back and forth between model file and drawing file, especially Custom iProperties, if needed.
Wesley Crihfield
(Not an Autodesk Employee)
My understanding is that you have an assembly and you want to create drawings for each individual part?
If so below is code that I frankensteined together and modified to fit my purposes, I believe you will be able to use it as well. If you have any questions about it feel free to ask.
Sub Main() 'If the assembly is declared as a Component assignment of Item # and QTY. is unnecessary If iProperties.Value("Summary", "Subject") = "Component" Then Else 'Reference Assembly Document Dim oAssemblyDocument As AssemblyDocument oAssemblyDocument = ThisDoc.Document 'Reference each instance of a model in the assembly Dim oAssemblyComponentDefinition As AssemblyComponentDefinition oAssemblyComponentDefinition = oAssemblyDocument.ComponentDefinition 'Reference the Bill Of Materials Dim oBOM As BOM oBOM = oAssemblyComponentDefinition.BOM 'Call for Structured View oBOM.StructuredViewEnabled = True Dim oBOMView As BOMView oBOMView = oBOM.BOMViews(2) 'Structured view 'Only change the Top Level of the Model Tree models 'models within sub-assemblies are ignored. oBOM.StructuredViewFirstLevelOnly = True oBOM.StructuredViewDelimiter = "." 'Call sub-programs Call RecursiveCheckAndSetProps(oBOMView.BOMRows) Call UpdateParts() End If End Sub Sub RecursiveCheckAndSetProps(ByVal oRowsElements As BOMRowsEnumerator) 'Loop for each unique model in the assembly For Each oBOMRow As BOMRow In oRowsElements 'Reference property of models within assembly Dim oComponentDefinition As ComponentDefinition oComponentDefinition = oBOMRow.ComponentDefinitions.Item(1) 'Reference variables to BOM Item # and QTY. Dim oBOMItemNumber As String Dim oBOMItemQuantity As String oBOMItemQuantity = oBOMRow.ItemQuantity() 'this is item quantity in the BOM oBOMItemNumber = oBOMRow.ItemNumber() 'this is item number in the BOM For i = 1 To oBOMRow.ComponentDefinitions.Count Dim oComponentDefinitionPropertySet As PropertySet oComponentDefinitionPropertySet = oBOMRow.ComponentDefinitions(i).Document.PropertySets.Item(4) oComponentDefinition = oBOMRow.ComponentDefinitions.Item(i) oComponentDefinitionPropertySet = oComponentDefinition.Document.PropertySets.Item("Inventor User Defined Properties") 'Check to see if model has had BOM Item # set, if so skip editing model iProperties Try prop = oComponentDefinitionPropertySet.Item("BOM Number") Catch 'Add BOM Item # and QTY. as Custom iProperties Try oComponentDefinitionPropertySet.Add(oBOMItemNumber, "BOM Number") oComponentDefinitionPropertySet.Add(oBOMItemQuantity, "BOM QTY") Catch oComponentDefinitionPropertySet.Item("BOM Number").Value = oBOMItemNumber oComponentDefinitionPropertySet.Item("BOM QTY").Value = oBOMItemQuantity End Try End Try Logger.Info(oBOMRow.ComponentDefinitions(i).Document.DisplayName & " - " & oBOMItemNumber) Next Next End Sub Sub UpdateParts() Dim oDoc As Document = ThisApplication.ActiveDocument Dim aDoc As DocumentsEnumerator = oDoc.AllReferencedDocuments Dim iDoc As Document For Each iDoc In aDoc 'Here we set iProperties in each of the parts in assembly Dim sTS As String = iDoc.FullFileName Dim FNamePos As Long = InStrRev(sTS, "\", - 1) Dim docFName As String = Mid(sTS, FNamePos + 1, Len(sTS) -FNamePos) 'Add BOM Item # & QTY. to iProperty Fields Company and Manager respectively If iProperties.Value(docFName, "Custom", "BOM Number") = "" Then Else iProperties.Value(docFName, "Summary", "Manager") = iProperties.Value(docFName, "Custom", "BOM QTY") iProperties.Value(docFName, "Summary", "Company") = iProperties.Value(docFName, "Custom", "BOM Number") End If Next End Sub
Thank you @Anonymous for your time, it works fine and I also learning from these codes.
The disadvantage here (the way we are st-up) is that it affect the standard parts which is also used by the other team. Because we are using cloud, everytime the part is updated, it sync (takes 15 - 30 mins).
There are two other option Im thinking whic will not affect our standard part.
1.) To write the custom iproperties in the assembly itself. Then in the drawing, another iLogic to get the iproperties from the assembly.
iProperties.Value((DrawingFileName = PartName), "Custom", "Qty") = iProperties.Value(AssemblyName, "Custom", "QtyPartNumber")
2.) (just lost my idea as we always have power outage today...wil update this post)
Yes @WCrihfield filter by view representation works.
Im thinking of ilogic to create view representation of each part in the assembly. And another ilogic in drawing (template) sheet to set the partslist filter. The part filename, part number, view representation name should be the same.
I have been trying to do this for a while now and found you code works well.
I have tried to modify it to run on the parts only BOM and not had any success. I have several parts used in different assemblies and have been trying to get the BOM qty info into each part. Are you able to run code similar to this on each part in the Parts Only view?
Thanks,
Jeff
If you can post the code that you are trying I or someone else may be able to help. Right now the code modifications that I found are replacing the following:
'Call for Structured View oBOM.StructuredViewEnabled = True Dim oBOMView As BOMView oBOMView = oBOM.BOMViews(2) 'Structured view 'Only change the Top Level of the Model Tree models 'models within sub-assemblies are ignored. oBOM.StructuredViewFirstLevelOnly = True oBOM.StructuredViewDelimiter = "."
with
'Call for Parts Only View oBOM.PartsOnlyViewEnabled = True Dim oBOMView As BOMView oBOMView = oBOM.BOMViews(3) 'Parts Only view
The intent for this code was that everything in the "first level" of the assembly browser would be included, if you only need to have a standard parts list without specifying subassemblies and their components then I would recommend breaking down the subassemblies by 'Promoting' the components to the first level.
I know I'm resurrecting a 3-4 year old thread, but I absolutely love this Ilogic code, takes out my human error for counting the amount of components to have made.
Can't find what you're looking for? Ask the community or share your knowledge.