You're working with sketches in some iLogic code and want to be able to find the active sketch name, or active sketch number.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhK9HYKmHzH4UeTJYny6_s9mlvFiCllzQcHWTzoz2QOY752pZ_qHZGD1xvpPATzO9DDyWmi7_25gnCNrqok7BGk7GbVPLjl6v-SM5SQFIvIi4EkNoImyN_LGY6Hmq_OZLC4QC8eCTe76cye/s1600/Autodesk+Inventor+iLogic+Sketch+Number+Sketch+Name2.png)
Solution:
Here are a couple of quick rules that will do this. And also as a bonus there is a quick rule to delete all sketches in the part.
Rule1: Find the active sketch name
Dim oSketch As PlanarSketch
If Typeof ThisApplication.ActiveEditObject Is Sketch Then
oSketch = ThisApplication.ActiveEditObject
MessageBox.Show(oSketch.Name & " is the active
Sketch", "iLogic")
Else
MessageBox.Show("Active Edit Object is
not a Sketch", "iLogic")
End If
Rule2: Find the active sketch number
Dim oSketches As PlanarSketches
oSketches = ThisApplication.ActiveDocument.ComponentDefinition.Sketches
i=1
For Each oSketch in oSketches
oSketch
= oSketches.Item(i)
If oSketch Is ThisApplication.ActiveEditObject Then
MessageBox.Show("The active sketch is
number: " & i, "iLogic")
Else
End If
i=i+1
Next
Rule3: Delete all sketches.
Dim oSketches As PlanarSketches
oSketches = ThisApplication.ActiveDocument.ComponentDefinition.Sketches
If Typeof ThisApplication.ActiveEditObject Is Sketch Then
ThisApplication.ActiveEditObject.ExitEdit
Else
End If
For Each oSketch in oSketches
oSketch
= oSketches.Item(oSketch.Name)
oSketch.Delete
Next