Hi @jeanchile,
This sort of post could be assisted with in the iLogic forums perhaps, but I saw your post and thought this is something I may be able to do. I have found a few bits and pieces from different codes over the years and just chopped it up a bit and created a rule for you to perform what you're after, with option to turn sketch dimensions off or on.
For it to work you have to have at least one sketch selected, and with the selection of sketches, run the rule and you get an input box to select whether you want to turn Dim visibility off or on.
This code may not be the most clean or efficient way to do this, but I don't really have much experience with it and have just taught myself by looking at and adapting others codes/rules. Hope this is helpful.
Sub Main()
'Make a ref to active doc
Dim oDoc As Inventor.Document
oDoc = ThisApplication.ActiveDocument
'selected components collection
Dim oSelected As ObjectCollection
oSelected = ThisApplication.TransientObjects.CreateObjectCollection
Dim oCount As Integer
oCount = oDoc.SelectSet.Count
'Check that at least 1 is selected
If oCount = 0 Then
MessageBox.Show("Please select a sketch.", "iLogic")
Exit Sub 'bail out
End If
'add to Object Collection
Dim i As Long
For i = 1 To oCount
If oDoc.SelectSet.Item(i).Type = _
ObjectTypeEnum.kComponentOccurrenceObject Then
oSelected.Add (oDoc.SelectSet.Item(i))
End If
Next
' Decide if you want to turn on or off the dimensions of your selected sketches:
wfBoolean = InputRadioBox("Toggle Sketch Dimension Visibility", "On", "Off", False, "Sketch Dimension Visibility")
For Each o2DSketch As Sketch In oDoc.ComponentDefinition.Sketches
o2DSketch.DimensionsVisible = wfBoolean
Next
'get names item name from collection
For Each oItem In oSelected
oMsg = oMsg & vbLf & oItem.Name
Next
MessageBox.Show(oCount & " Sketch Dimensions Updated" & vbLf & oMsg, "iLogic")
End Sub
If you have any questions feel free to ask, I'll be happy to assist where I can 🙂
Cheers,
Kerem