05-11-2015
09:43 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
05-11-2015
09:43 AM
Hei BrandonBG,
Thanks for the tip but when I use that first code I get an error:
Error in rule: Rule1, in document: 7951 P02 Rømningstrapp.iam
The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
I ran the rule while standing in the main assembly. Right?
Dim oAssemblyDocument As AssemblyDocument
oAssemblyDocument= ThisDoc.Document
Dim oAssemblyComponentDefinition As AssemblyComponentDefinition
oAssemblyComponentDefinition = oAssemblyDocument.ComponentDefinition
Dim oBOM As BOM
oBOM = oAssemblyComponentDefinition.BOM
oBOM.PartsOnlyViewEnabled = True
Dim oBOMView As BOMView
oBOMView = oBOM.BOMViews.Item("Parts Only") 'or structured
For Each oBOMRow As BOMRow In oBOMView.BOMRows
Dim oComponentDefinition As ComponentDefinition
oComponentDefinition = oBOMRow.ComponentDefinitions.Item(1)
Dim oBOMItemNumber As String
oBOMItemNumber = oBOMRow.ItemNumber() 'this is item number in the BOM
MessageBox.Show(oBOMItemNumber, "BOM Number") 'just to show what's going on
Dim oComponentDefinitionPropertySet As PropertySet
oComponentDefinitionPropertySet = oComponentDefinition.Document.PropertySets.Item("Inventor User Defined Properties")
'custom property tab
oComponentDefinitionPropertySet.Add(oBOMItemNumber, "BOM Number")
'creates the custom property and inputs the value
Next