Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get the active sketch

2 REPLIES 2
Reply
Message 1 of 3
CadUser46
724 Views, 2 Replies

Get the active sketch

Is there some simple way to get the sketch number of the active sketch in either part or assembly?

 

I understand the document.sketchactive boolean but this doesnt allow me to find which sketch in the collection is the active one.


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------------------------------------------------------------------------------------------------------------------------
Inventor 2010 Certified Professional
Currently using 2023 Pro
2 REPLIES 2
Message 2 of 3

Hi CadUser46,

 

I use something like this in iLogic to 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

 There might be a better way, but this is what I had handy.

 

It occurred me after I posted the above that we could so something like this to find the active sketch number as you requested:

 

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

 

 

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Message 3 of 3

As sketch number in the sketches collection could be changed it is safer to use Sketch.Name property to reference the particular Sketch.  


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report