Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

ilogic export to excel custom properties

idealogicERZYZ
Advocate

ilogic export to excel custom properties

idealogicERZYZ
Advocate
Advocate

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

0 Likes
Reply
Accepted solutions (2)
1,218 Views
4 Replies
Replies (4)

JhoelForshav
Mentor
Mentor
Accepted solution

hi @idealogicERZYZ 

See code below :slightly_smiling_face:

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

idealogicERZYZ
Advocate
Advocate

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

0 Likes

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

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

idealogicERZYZ
Advocate
Advocate

Thank you

 

E

0 Likes