04-06-2016
12:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
04-06-2016
12:06 AM
Hi, here you go:
For more than one seleced parts:
' Select parts, use Esc key when you have selected all wished parts Dim Comps As ObjectCollection
Dim Comp As ComponentOccurrence
While True
Comp = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter,"Select End 1:")
' If nothing gets selected then we're done
If IsNothing(comp) Then Exit While
comps.Add(comp)
End While
' If none parts are selected, end the rule If Comps.Count = 0 Then Exit Sub
' Go throught all selected parts
For Each Comp In Comps MessageBox.Show(Comp.Name, "End1") Dim oDoc as document = Comp.Definition.Document oProSet = oDoc.PropertySets.Item("Inventor User Defined Properties") oProSet.Item("Connected To").Value = Comp.Name Next
For single part:
' Select part
Dim Comp As ComponentOccurrence
Comp = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter,"Select End 1:")
' If no part is selected, end the rule
If Comp Is Nothing Then Exit Sub
MessageBox.Show(Comp.Name, "End1")
Dim oDoc as document = Comp.Definition.Document
oProSet = oDoc.PropertySets.Item("Inventor User Defined Properties")
oProSet.Item("Connected To").Value = Comp.Name
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
- - - - - - - - - - - - - - -
Regards,
Mike
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods