One way of doing this is by using the AllReferencedDocuments. There is only reference per file so this approach will take care of the unique item issue. This differs from the original alternative approach I took where I looked at the ComponentOccurrences.
' Get the active assembly. Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument ' Get the PropertySets object. Dim oPropSets As PropertySets Dim oPropSet As PropertySet ' Iterate thru each referenced document Dim oDoc As Document For Each oDoc In oAsmDoc.AllReferencedDocuments oPropSets = oDoc.PropertySets oPropSet = oPropSets.Item("Inventor User Defined Properties") Try ' Push the required iProperties down to the documents oSONumiProp = oPropSet.Item("SO_Number") oSONumiProp.Value = Sales_Order_Number oCompanyiProp = oPropSet.Item("Company") oCompanyiProp.Value = Customer_Name oProjectiProp = oPropSet.Item("Project Description") oProjectiProp.Value = Project_Description Catch ' Do not raise or display an error. End Try Next
Hopefully you see some benefit in the above solution. Leave me a comment and let me know.
Randy
"The mind is everything. What you think you become." - Buddha
Randy
"The mind is everything. What you think you become." - Buddha
I'd like to use this to read the part level Thickness parameter and with that write to the stock number iProperty. How would I do that?
ReplyDeleteHi Stephen,
ReplyDeleteThis can be done. You'd need to go thru the ComponentDefinition of the oDoc to get to the parameters.
By the way, we moved all our blogging to our official company site:
http://blogs.rand.com/manufacturing/
Regards,
Randy