Simulate Pressing the "Start 2D Sketch" button.

Simulate Pressing the "Start 2D Sketch" button.

chaines59GWR
Contributor Contributor
201 Views
2 Replies
Message 1 of 3

Simulate Pressing the "Start 2D Sketch" button.

chaines59GWR
Contributor
Contributor

Hello all!

 

Does anyone know how to "Simulate" having pressed the "Start 2D Sketch" button in the toolbar? I am creating a program that will create new parts and then I want the user to be able to choose what axis they start their sketch on.

 

I could program that myself, but I figure using Inventors built in methods may be nicer. Below is what I have so far, I can get into the part to edit it but I'm not sure how to trigger the sketch creator.

 

Function CreateFiles(ProjectFolder As String, ProjectName As String)

	Dim Origin As Matrix = ThisApplication.TransientGeometry.CreateMatrix()	
	
	Dim oPart As PartDocument = ThisApplication.Documents.Add(kPartDocumentObject,,False)
	oPart.SaveAs(ProjectFolder & "\" & ProjectName & ".ipt", False)
	oPart.Close
	
	Dim oAsm As AssemblyDocument = ThisApplication.Documents.Add(kAssemblyDocumentObject)
	oAsm.SaveAs(ProjectFolder & "\" & ProjectName & ".iam", False)

	Dim oOcc As ComponentOccurrence = oAsm.ComponentDefinition.Occurrences.Add(ProjectFolder & "\" & ProjectName & ".ipt", Origin) : oOcc.Grounded = True

	With ThisApplication.ActiveView.Camera
		.ViewOrientationType = ViewOrientationTypeEnum.kIsoTopRightViewOrientation
		.Fit
		.ApplyWithoutTransition
	End With
	
	Dim oOccDef As PartComponentDefinition = oOcc.Definition
	oOcc.Edit
	
End Function

 

Thanks!

0 Likes
Accepted solutions (1)
202 Views
2 Replies
Replies (2)
Message 2 of 3

hollypapp65
Advocate
Advocate
Accepted solution

It is a internal command: PartNewSketchCmd

You can run it:

 

	Dim oControlDef As Inventor.ControlDefinition
	oControlDef = ThisApplication.CommandManager.ControlDefinitions.Item("PartNewSketchCmd")
	oControlDef.Execute2(True)

 

 

You can use "EventWatcher" from SDK to get the command name.

0 Likes
Message 3 of 3

chaines59GWR
Contributor
Contributor

Beauty! Thanks!

0 Likes