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: 

Exporting Multi-level Product Structure to Optimization Software

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
400 Views, 7 Replies

Exporting Multi-level Product Structure to Optimization Software

Hello All,

 

I am trying to export structured Bill of materials to an optimization software that stores multi-level product structures for future production. The database that the multi-level product structures are stored in needs to be in the specific order shown below...

 

PARENT CHILD Quantity
10000-10 10000-100 1
10000-10 10000-101 1
10000-20 10000-200 1
10000-20 10000-201 1
10000 10000-10 1
10000 10000-20 1

 

We draw in top down design, starting with the parent level (10000), performing a "make components" sending specific parts to different sub-assemblies (10000-100 and 10000-101 sent to a 10000-10 folder, 10000-200 and 10000-201 sent to a 10000-20 folder), then we would like to perform the BOM export from the parent level.

 

I understand that when you activate "All Levels" in the structured properties, you can expand the assemblies to see the children, but I would like to see the parent number on the same line as the child. Unfortunately it is not as simple as adding a custom property to the parts and subs because parts can be shared between sub-assemblies. 

 

I appreciate your comments in advance.

 

7 REPLIES 7
Message 2 of 8
JamieVJohnson2
in reply to: Anonymous

The BOM crawls assembly components and constructs its tree.  You can write your own BOM crawler to do the same, and capture the data as you please along the way.

for each componentdefinition in Assembly.Definition.Components

jvj
Message 3 of 8
Anonymous
in reply to: JamieVJohnson2

Thank you for your response. You wouldn't happen to know of a previous post to create a custom crawler would you? I have searched the forums for a solution but cannot find it.

Message 4 of 8
pball
in reply to: Anonymous

If i'm understanding you correctly you want to be able to generate a list from the bill of material for all of the parts in an assembly. I posted some code in the linked thread for exporting part number, description, and quantity to an excel document. Make sure you read all the posts and use the later version of the code. Let me know if this is what you are looking for and if you have any questions on it. Please note this isn't guaranteed to be a fully working script, it might require changes to suit your needs.

 

https://forums.autodesk.com/t5/inventor-customization/vba-counting-quantity-of-parts-in-assemblies/t...

 

Message 5 of 8
Anonymous
in reply to: pball

The export function in Bill of Materials currently exports part number, description, and quantity per assembly like I need. I am looking for a custom field that will populate based on the assembly it is located in.

 

For example:

Current structured BOMs

-10 sub-assembly

 Capture1.PNG

-20 sub assembly (uses the same parts as -10, but may have other parts added to the assembly to make it different)

Capture2.PNG

 

The field should read the assembly part number, and display that part number for each .ipt as demonstrated using filled in text:

-10 sub assembly (Parent Number filled in manually)

Capture3.PNG

-20 sub assembly (Parent Number filled in manually)

Capture4.PNG

 

It's a stretch, but I figured I would ask the experts. 🙂 

 

Thanks again for your responses.

Message 6 of 8
pball
in reply to: Anonymous

So you are looking to save the parent part number inside each item? If that is the case that is possible but if you have one part used in two different assemblies that could make the process harder.

 

The code I referenced in my previous post could be modified to do this. If we're on the same page I could try putting something together.

Message 7 of 8
Anonymous
in reply to: pball

That is correct. As long as it exports in that fashion then it will work for me. The parent part number doesn't necessarily need to be stored under the part properties for future reference, only during the export to excel does it need to query the assembly number.

Message 8 of 8
JamieVJohnson2
in reply to: Anonymous

    Public Sub SetChildComponentCustomProperty(ByVal propertyName As String, ByVal ParentPropertySet As String, ByVal ParentPropetyName As String, ByVal ForceOverwrite As Boolean, ByVal parentDoc As Inventor.Document, Optional ByRef comparer As IComparer = Nothing)
        For Each occ As ComponentOccurrence In parentDoc.ComponentDefinition.Occurrences
            If occ.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject OrElse occ.DefinitionDocumentType = DocumentTypeEnum.kPartDocumentObject Then
                Dim childDoc As Inventor.Document = occ.Definition.Document
                Dim childPartNo As String = childDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value
                If IsEngineeredPart(childPartNo) = True Then 'dont process children of assemblies that are not engineered files (no library, or components)
                    If childDoc IsNot parentDoc Then
                        If comparer IsNot Nothing Then
                            If comparer.Compare(childDoc, parentDoc) = 1 Then
                                WriteCustomProperty(propertyName, parentDoc.PropertySets.Item(ParentPropertySet).Item(ParentPropetyName).Value, childDoc, ForceOverwrite)
                            End If
                        Else
                            WriteCustomProperty(propertyName, parentDoc.PropertySets.Item(ParentPropertySet).Item(ParentPropetyName).Value, childDoc, ForceOverwrite)
                        End If
                        If occ.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
                            SetChildComponentCustomProperty(propertyName, ParentPropertySet, ParentPropetyName, ForceOverwrite, childDoc, comparer)
                        End If
                    End If
                End If
            End If
        Next
    End Sub

This routine is the completion of my walking down your similar road.  We call it "Next Assembly" in our industry.  I needed 3 sub routines to make this work.

1.  IsEngineeredPart - simply weeds out part numbers that do not conform to our document standard.  This prevents the program from diving into vendor assemblies we don't care to see a list of part1, part2 from the vendor.

2.  Comparer - I created a custom comparer to determine if a part is to be written with the property or not.  In your scenario, you may not need a comparer.  We checked for needing to bump the next assembly value to a different assembly (because it was drawn first), or discard writing because it was not an Engineered Part, and different minor logic decisions.  The comparer only needs to answer 0 or 1 for the program to write or not write.  I used a comparer because it can be called on to sort the list, or just answer a single question.

3. WriteCustomProperty - this is how we choose to capture the value within each file's custom iProperty.  You would want a different approach, such as creating your own class (more later).

 

Otherwise here is the basics of this self recurring crawler:

Assembly (top at top of tree), has children assemblies and parts (as component occurrences).  I loop through all the occurrences.

Then I ask if each occurrence is a part or assembly. 

If part, then I do my thing (capture the parent assembly number) then quit. 

If assembly, I do my thing, and then run the same routine on that lower level assembly.

 

You can create a simple class to capture the information you want and hold it in memory until you write it to excel.

Public Class BOMExcelItem 'I made that up

Public Property Document as Inventor.Document 'keep track of the actual data to be written to a single row

Public Property PartNumber as string 'quick reference to the above document's part number

Public Property ParentPartNumber as string 'reference to the parent document's part number

Public Property ParentDocument as Inventor.Document 'keep track of the parent document

Public Property ItemNo as string 'this is the BOM item number (1.1.1.1.1) you can later sort your excel file by this to reorganize the tree.

 

'So instead of WriteCustomProperty, you could create a new instance of this 'helper class' and put the known objects into it.

Public Sub New(Child, Parent, ItemNo)

Document = Child

ParentDocument = Parent

'get part numbers and such

End Class

 

Then add them to a list of your own

dim BOMList as list(of BOMExcelItem)

 

'crawl data

'found data - dim bei as new bomexcelitem(child,parent,item)

bomlist.add(bei)

 

That is likely the overall path you will want to take.  I'm trying not to write out all the details, because it is your baby to raise up.  Happy parenting.

 

 

jvj

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report