Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
EDited
Solved! Go to Solution.
EDited
Solved! Go to Solution.
Hi @haphanthanhtam.work . Please try this code, is it what you need?
Step 1 - choose your components, step 2 - run the code.
Sub main
Dim oDoc As Document = ThisApplication.ActiveDocument
If TypeOf oDoc Is AssemblyDocument Then
Dim oADoc As AssemblyDocument = oDoc
Dim oSS As SelectSet = oADoc.SelectSet
If oSS.Count = 0 Then Exit Sub
Dim sParam As String = InputBox("Prompt", "Mi-Logic", "Purt number")
If String.IsNullOrEmpty(sParam) Then Exit Sub
Dim oOcc As ComponentOccurrence
Dim oOccsList As New List(Of ComponentOccurrence)
Dim i As Integer
For i = 1 To oSS.Count
If oSS.Item(i).Type = ObjectTypeEnum.kComponentOccurrenceObject Then
oOccsList.Add(oSS.Item(i))
End If
Next i
Dim oOccDoc As Document
For i = 0 To oOccsList.Count -1
oOcc = oOccsList.Item(i)
If Not oOcc.Suppressed Then
oOccDoc = oOcc.Definition.Document
If Not oOccDoc.IsModifiable Then Continue For
oOccDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value = sParam
End If
Next i
oADoc.Update()
End If
End Sub
Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor
LinkedIn | My free Inventor Addin | My Repositories
Did you find this reply helpful ? If so please use the Accept as Solution/Like.
Thank you @Andrii_Humeniuk
It''s perfect
You can add Description more
And finally, it will automatically hide the selected sections.
I added the "Description" property entry, but I don't understand what you mean by "automatically hide the selected sections". Do you want your components to be invisible or hidden after the rule is executed? In the code, line 26 is responsible for visibility, and line 27 for its suppression.
Sub main
Dim oDoc As Document = ThisApplication.ActiveDocument
If TypeOf oDoc Is AssemblyDocument Then
Dim oADoc As AssemblyDocument = oDoc
Dim oSS As SelectSet = oADoc.SelectSet
If oSS.Count = 0 Then Exit Sub
Dim sPurtNumb As String = InputBox("Prompt", "Mi-Logic", "Purt number")
If String.IsNullOrEmpty(sPurtNumb) Then Exit Sub
Dim sDesc As String = InputBox("Prompt", "Mi-Logic", "Description")
If String.IsNullOrEmpty(sDesc) Then Exit Sub
Dim oOcc As ComponentOccurrence
Dim oOccsList As New List(Of ComponentOccurrence)
Dim i As Integer
For i = 1 To oSS.Count
If oSS.Item(i).Type = ObjectTypeEnum.kComponentOccurrenceObject Then
oOccsList.Add(oSS.Item(i))
End If
Next i
For i = 0 To oOccsList.Count -1
oOcc = oOccsList.Item(i)
If Not oOcc.Suppressed Then
Dim oOccDoc As Document = oOcc.Definition.Document
If Not oOccDoc.IsModifiable Then Continue For
oOccDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value = sPurtNumb
oOccDoc.PropertySets.Item("Design Tracking Properties").Item("Description").Value = sDesc
oOcc.Visible = False
' oOcc.Suppress(True)
End If
Next i
oADoc.Update()
End If
End Sub
Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor
LinkedIn | My free Inventor Addin | My Repositories
Did you find this reply helpful ? If so please use the Accept as Solution/Like.
I want it to be invisible
So that I can continue to assign values to other Parts
it works great!!!
Thank you so much !!!! @Andrii_Humeniuk