Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to rename a parameter "d2" from a number of selected parts in an Assembly to "LENGTH" and then set to export with a custom property format so I can use it in a BoM export later.
I've gleaned as much as i can from other posts and i'm 99% there. I'm just not sure how to dig in to the selected occurrence parameters properly. Below is my current code. I'm using the same selection structure for another rule and it's working fine. It's just the parameters section i'm not getting right.
Can anyone correct me please?
'Description of the Rule and if you want to continue
Result = MessageBox.Show("Do you want to continue?" _
& vbNewLine &"" _
& vbNewLine & "This rule allows you to browse the tree and select multiple items,then press the Esc Key and have an action carried out" _
& vbNewLine & "", "Browse And Select" _
, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2)
If Result = vbNo Then
MessageBox.Show ("Rule Canceled Exiting", "Title")
ElseIf Result = vbYes Then
Dim oDoc As AssemblyDocument
oDoc = ThisDoc.Document
oCompDef = oDoc.ComponentDefinition
Dim oSet As HighlightSet
oSet = oDoc.CreateHighlightSet
'MessageBox.Show ("Rule will Run", "Title")
'[Pick Assembly Occurrences
Dim comps As ObjectCollection
Dim comp As Object
comps = ThisApplication.TransientObjects.CreateObjectCollection
While True
comp = ThisApplication.CommandManager.Pick(
SelectionFilterEnum.kAssemblyLeafOccurrenceFilter,
"Select a component")
' If nothing gets selected then we're done
If IsNothing(comp) Then Exit While
comps.Add(comp)
oSet.AddItem(comp)
End While
'Description of the Rule and if you want to continue
Result = MessageBox.Show("Do you want to process all Selected?", "Process selected files", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2)
If Result = vbNo Then
MessageBox.Show ("Rule Cancelled", "iLogic")
'If there are selected Components we can Do something
ElseIf Result = vbYes Then
For Each comp In comps
'Pick only parts
If comp.DefinitionDocumentType = kPartDocumentObject Then
'Get document of each occurrence
Dim oOccDoc As Document
oOccDoc = comp.Definition.Document
oOccDoc.Parameter("d2").Name = "LENGTH"
oOccDoc.Parameter("LENGTH").ExposedAsProperty = True
oOccDoc.Parameter("LENGTH").CustomPropertyFormat.ShowUnitsString = False
oOccDoc.Parameter("LENGTH").CustomPropertyFormat.Precision = "0"
']
End If
Next
MessageBox.Show("Files Processed", "iLogic")
'Clear Highlighting
oSet.Clear()
End If
']
End If
Solved! Go to Solution.