Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Vb.Net Addin - Show iProperties Dialog Box & Tab To "Physical"

isocam
Collaborator

Vb.Net Addin - Show iProperties Dialog Box & Tab To "Physical"

isocam
Collaborator
Collaborator

Can anybody help?

 

I have the following Inventor VBA macro that works great!

 

Public Function DisplayProperties()
ThisApplication.CommandManager.ControlDefinitions.Item("AppiPropertiesWrapperCmd").Execute2 (False)

 

Call SendKeys("{%}")

For Counter = 1 To TabCount
       Call SendKeys("{RIGHT}")
Next Counter
End Function

 

Does anybody know what the equivalent code for a Vb.Net AddIn would be?

 

I need to tab the iProperties dialog so that it shows the "Physical" tab. Please see the attached picture.

 

Many thanks in advance!

 

Kind Regards

 

Darren

0 Likes
Reply
258 Views
3 Replies
Replies (3)

WCrihfield
Mentor
Mentor

Hi @isocam.  The following code does that for me...when either a part or assembly is the visible, 'active' document.

I got the inspiration for that code at this other older forum post, where Mike Deck pointed this ability out.  However, using SendKeys is usually a last resort, due to stability issues.

Sub Main()
	Dim oCDs As ControlDefinitions = ThisApplication.CommandManager.ControlDefinitions
	Dim oCD As ControlDefinition
	Dim oDocType As DocumentTypeEnum = ThisApplication.ActiveDocumentType
	If oDocType = kPartDocumentObject Then
		oCD = oCDs.Item("PartiPropertiesCmd")
	ElseIf oDocType = kAssemblyDocumentObject Then
		oCD = oCDs.Item("AssemblyiPropertiesCmd")
	ElseIf oDocType = kDrawingDocumentObject Then
		oCD = oCDs.Item("DrawingiPropertiesCmd")
	End If
    Call oCD.Execute2(False)
	'send keyboard strokes to navigate to the Custom tab ( send "right arrow" key 4 times)
    System.Windows.Forms.SendKeys.SendWait("{RIGHT 6}")
	ThisApplication.UserInterfaceManager.DoEvents()
End Sub

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

WCrihfield
Mentor
Mentor

This version seems to work OK for me with the wrapper command you were using too.  (tested from an iLogic rule)

 

ThisApplication.CommandManager.ControlDefinitions.Item("AppiPropertiesWrapperCmd").Execute2(False)
System.Windows.Forms.SendKeys.SendWait("{RIGHT 6}")
ThisApplication.UserInterfaceManager.DoEvents()

 

...but if a drawing is visibly active, the physical tab is not available, so it ends up on the 'Save' tab, instead.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

WCrihfield
Mentor
Mentor

Also, don't forget that when using SendKeys, it is important to make sure the right 'target' is prepared to receive the keystrokes before sending them.  There are a couple of ways I have seen for doing this, that seem to work OK.  The simplest is the following:

Microsoft.VisualBasic.Interaction.AppActivate(ThisApplication.Caption)

...next is something I saw Mike Deck use in his response:

Imports System.Windows.Forms
Imports System.Runtime.InteropServices

<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function SetForegroundWindow(hWnd As IntPtr) As Integer
End Function

'then use this in your sub routine, before calling SendKeys
SetForegroundWindow(ThisApplication.MainFrameHWND)

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes