- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I have a code snippet exporting Excel. I have described the standard iProperties. I would like to export the "Custom" property "Welding" which is in part files and has a yes or no value.
.......
bRows = oBOMView.BOMRows For Each bRow In bRows Dim rDoc As Document rDoc = bRow.ComponentDefinitions.Item(1).Document Dim docPropertySet As PropertySet docPropertySet = rDoc.PropertySets.Item("Design Tracking Properties") xlWorksheet.Range("A" & row).Value = bRow.ItemNumber xlWorksheet.Range("C" & row).Value = docPropertySet.Item("Part Number").Value xlWorksheet.Range("D" & row).Value = docPropertySet.Item("Description").Value xlWorksheet.Range("E" & row).Value = bRow.ItemQuantity xlWorksheet.Range("F" & row).Value = docPropertySet.Item("Vendor").Value xlWorksheet.Range("P" & row).Value = docPropertySet.Item("Cost").Value
E
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
See code below ![]()
bRows = oBOMView.BOMRows For Each bRow In bRows Dim rDoc As Document rDoc = bRow.ComponentDefinitions.Item(1).Document Dim docPropertySet As PropertySet docPropertySet = rDoc.PropertySets.Item("Design Tracking Properties") xlWorksheet.Range("A" & Row).Value = bRow.ItemNumber xlWorksheet.Range("C" & Row).Value = docPropertySet.Item("Part Number").Value xlWorksheet.Range("D" & Row).Value = docPropertySet.Item("Description").Value xlWorksheet.Range("E" & Row).Value = bRow.ItemQuantity xlWorksheet.Range("F" & Row).Value = docPropertySet.Item("Vendor").Value xlWorksheet.Range("P" & Row).Value = docPropertySet.Item("Cost").Value '----------------------------Here is what you need------------------------------------------- Dim customPropSet As PropertySet customPropSet = rDoc.PropertySets.Item("Inventor User Defined Properties") 'xlWorksheet.Range("Q" & Row).Value = customPropSet.Item("Welding").Value 'If you want True/False xlWorksheet.Range("Q" & Row).Value = customPropSet.Item("Welding").Expression 'If you want Yes/No '----------------------------------------------------------------------- Next
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks, still a question ...
The script stops if the .ipt part does not have the "Welding" parameter. How to make nothing in the excle tab in the "Q" column? That the parts that do not have this parameter have an empty field in the "Q" column.
E
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, adding to the excellent contribution of @JhoelForshav , can you add the instruction try - catch - end try?
You could add it if you don't have an "on error resume next" line before
bRows = oBOMView.BOMRows For Each bRow In bRows Dim rDoc As Document,docPropertySet As PropertySet,customPropSet As PropertySet rDoc = bRow.ComponentDefinitions.Item(1).Document docPropertySet = rDoc.PropertySets.Item("Design Tracking Properties") xlWorksheet.Range("A" & Row).Value = bRow.ItemNumber xlWorksheet.Range("C" & Row).Value = docPropertySet.Item("Part Number").Value xlWorksheet.Range("D" & Row).Value = docPropertySet.Item("Description").Value xlWorksheet.Range("E" & Row).Value = bRow.ItemQuantity xlWorksheet.Range("F" & Row).Value = docPropertySet.Item("Vendor").Value xlWorksheet.Range("P" & Row).Value = docPropertySet.Item("Cost").Value Try customPropSet = rDoc.PropertySets.Item("Inventor User Defined Properties") 'xlWorksheet.Range("Q" & Row).Value = customPropSet.Item("Welding").Value 'If you want True/False xlWorksheet.Range("Q" & Row).Value = customPropSet.Item("Welding").Expression 'If you want Yes/No Catch End Try Next
I hope this helps with your problem. Regards
Please accept as solution and give likes if applicable.
I am attaching my Upwork profile for specific queries.
Sergio Daniel Suarez
Mechanical Designer
| Upwork Profile | LinkedIn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report