Send a CTRL+TAB keystroke to iProperties dialog with iLogic

Send a CTRL+TAB keystroke to iProperties dialog with iLogic

Anonymous
Not applicable
3,851 Views
22 Replies
Message 1 of 23

Send a CTRL+TAB keystroke to iProperties dialog with iLogic

Anonymous
Not applicable

Ok I have an iLogic rule that opens the iProperties dialog for the file type that is active.  That much I got.  Now I need to send a CTRL + TAB keystroke after it is opened so that the 'Summary' tab is active when the iProperties dialog is shown.  

here is the code I got:

 

SyntaxEditor Code Snippet

Imports System.Windows.Forms

Sub Main()
    
    Dim oCommandMgr As CommandManager 
        oCommandMgr = ThisApplication.CommandManager 
    Dim oControlDef As ControlDefinition 
     oControlDef = oCommandMgr.ControlDefinitions.Item("DrawingiPropertiesCmd")
    Call oControlDef.Execute '2(False)
    SendKeys.SendWait("^{TAB}")  '← I'm guessing that the '^' carot is supposed to be the 'CTRL key'  but all this does is just a normal 'TAB' which sets the 'Help' active 
    ThisApplication.UserInterfaceManager.DoEvents()
End Sub

Please do not reply with HOW to get the dialog to open I know how to do that I just want the Summary TAB to be the active tab when it does.  

 

 

Accepted solutions (2)
3,852 Views
22 Replies
Replies (22)
Message 21 of 23

Curtis_Waguespack
Consultant
Consultant

 Hi @Mike_Y2 

 

Nice..... here's a version that deals with other open files in step, by adding a line to close the active edit document to the Try/Catch at the end.

 

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

imports System.Windows.Forms



'https://forums.autodesk.com/t5/inventor-customization/send-a-ctrl-tab-keystroke-to-iproperties-dialo...
Sub Main()


'Loop until user presses ESC
Do
	'Select the part
	Dim oOcc As ComponentOccurrence
	oOcc = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select a component (Press ESC to exit select)")

	'Exit if the user presses ESC
	If oOcc Is Nothing
		GoTo ExitSelectLoop
	End If

	'Edit the selected part
	oOcc.Edit

	Dim oDoc As Document
	oDoc = oOcc.Definition.Document

	'Check file type
	If oDoc.DocumentType = kPartDocumentObject Then
		oCmd = "PartiPropertiesCmd"
	Else If oDoc.DocumentType = kAssemblyDocumentObject Then
	oCmd = "AssemblyiPropertiesCmd"
	Else If oDoc.DocumentType = kDrawingDocumentObject Then
	oCmd = "DrawingiPropertiesCmd"
	End If

	Dim oCommandMgr As CommandManager
	oCommandMgr = ThisApplication.CommandManager
	Dim oControlDef As ControlDefinition
	oControlDef = oCommandMgr.ControlDefinitions.Item(oCmd)

	Call oControlDef.Execute2(False)

	'Opens Iproperties and sends "right arrow" key 4 times and "TAB" key 2 times)
	SendKeys.SendWait("{Right 4}{TAB 2}{A}{DOWN}{TAB 2}")
	ThisApplication.UserInterfaceManager.DoEvents()

	'Exit editting the selected part
	Try
		oOcc.ExitEdit(ExitTypeEnum.kExitToPrevious)
	Catch
		ThisApplication.ActiveEditDocument.close
	End Try

Loop
ExitSelectLoop :
End Sub

 

EESignature

0 Likes
Message 22 of 23

Mike_Y2
Advocate
Advocate

@Curtis_Waguespack  I used this but it appears to save the part document (that is being closed) without prompting the user to confirm if they want to save the document or not. I have therefore tweaked it to just open the assembly again...

 

Imports System.Windows.Forms



'https://forums.autodesk.com/t5/inventor-customization/send-a-ctrl-tab-keystroke-to-iproperties-dialo...
Sub Main()
	'Record the assembly name
	oAssembly = ThisApplication.ActiveDocument.fulldocumentname
	
	'Loop until user presses ESC
	Do
		'Select the part
		Dim oOcc As ComponentOccurrence
		oOcc = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select a component (Press ESC to exit select)")
		
		'Exit if the user presses ESC
		If oOcc Is Nothing
			GoTo ExitSelectLoop
		End If
		
		'Edit the selected part
		oOcc.Edit
		
		Dim oDoc As Document
		oDoc = oOcc.Definition.Document
		
		'Check file type
		If oDoc.DocumentType = kPartDocumentObject Then
			oCmd = "PartiPropertiesCmd"
		Else If oDoc.DocumentType = kAssemblyDocumentObject Then
		oCmd = "AssemblyiPropertiesCmd"
		Else If oDoc.DocumentType = kDrawingDocumentObject Then
		oCmd = "DrawingiPropertiesCmd"
		End If
		
		Dim oCommandMgr As CommandManager
		oCommandMgr = ThisApplication.CommandManager
		Dim oControlDef As ControlDefinition
		oControlDef = oCommandMgr.ControlDefinitions.Item(oCmd)
		
		Call oControlDef.Execute2(False)
		
		'Opens Iproperties and sends "right arrow" key 4 times and "TAB" key 2 times)
		SendKeys.SendWait("{Right 4}{TAB 2}{A}{DOWN}{TAB 2}")
		ThisApplication.UserInterfaceManager.DoEvents()
		
		'Exit editting the selected part / return to the assembly
		Try
			oOcc.ExitEdit(ExitTypeEnum.kExitToPrevious)
		Catch
			'ThisApplication.ActiveEditDocument.close
			ThisApplication.Documents.Open(oAssembly)
		End Try
	Loop
	ExitSelectLoop :
End Sub
Message 23 of 23

Curtis_Waguespack
Consultant
Consultant

Hi @Mike_Y2 

 

There is an option to "skip save" for the close method, that would work here also.

 

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

 

		'Exit editting the selected part / return to the assembly
		Try
			oOcc.ExitEdit(ExitTypeEnum.kExitToPrevious)
		Catch
			ThisApplication.ActiveEditDocument.close(true)
		End Try

 

Document.Close( [SkipSave] As Boolean )

Name Type Description
SkipSave Boolean Optional input Boolean that specifies whether to skip the save. If SkipSave is set to True, it indicates that the changes to the document should not be saved and that the document should be closed silently. If SkipSave is set to False, it indicates that the normal save process should be followed (including prompting a dialog to the user). In addition, if Application.SilentOperation is set to True, the default choice on the dialog should be accepted. The Close method will fail if the combination of SkipSave = False and SilentOperation = True is used for a previously unsaved document.

This is an optional argument whose default value is False.

EESignature