cancel
Showing results for 
Search instead for 
Did you mean: 

Simulation of Key Strokes

Pioneer
Pioneer

Hi,

 

 

I Need to switch to Drafting and Modelling as user interaction is needed in my application.

So i need to pass Ctrl+SHFT+D and CTRL + M alternatively.

Did not found any method to achive the same in NXOpen Documentation.

 

Found some code off net which uses WINAPIs. It does works on Notepad and other applications but not on NX Window.

 

Is there any way to send key strokes to NX window?. 

Does anybody achieved the same?.

 

Regards,

Maddy

Windows 7 x64
NX 8.5, NX 9.0. And also NX 7.5
Visual Studio 2010 SP1, 2012 Update 4
10 REPLIES

Re: Simulation of Key Strokes

Esteemed Contributor
Esteemed Contributor

You can't switch applications while a dialog is open, you could try switching views?

 

In drafting you can switch between the drawing and the modelling view.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: Simulation of Key Strokes

Pioneer
Pioneer

Hi Stefan

 

Yes, that is what i want to achive, similar to user interactions like how they swtich to drawing from Modelling (by pressing Ctrl+M) and from Modelling to drawing (by pressing Ctrl+Shift+D)

 

If there is an API Method/Command available to do the same, i would like to know in which namespace this Method is available.

 

And also, there is no dialog open, im checking the application module when the application starts (in the first statement itself) before running other method which starts the dialog.

 

Regards,

Maddy

Windows 7 x64
NX 8.5, NX 9.0. And also NX 7.5
Visual Studio 2010 SP1, 2012 Update 4

Re: Simulation of Key Strokes

Siemens Phenom Siemens Phenom
Siemens Phenom

Maddy,

 

Good morning.  In NX10 there is a new method that allows you to switch applications while a program is running.  It is called "ApplicationSwitchImmediate", and it is a member of the Session class.

 

For instance:

 

    theSession.ApplicationSwitchImmediate("UG_APP_MODELING")

 

Regards,

 

Steve

 

 

Re: Simulation of Key Strokes

Esteemed Contributor
Esteemed Contributor

You can't switch applications, but you can change the view.

 

So you can switch from a displayed drawing to a modeling view layout.

You don't even have to switch the application, since switching the view should be sufficient.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: Simulation of Key Strokes

Siemens Phenom Siemens Phenom
Siemens Phenom

 

Hi Stefan,

 

This is more than just switching from having a drawing displayed to having a modeling view displayed.  This actually allows you to switch to a different application while your program is running.

 

This was one of our most popular Enhancement Requests for the programming tools products for years and years, and it is finally available in NX10.  (Hooray!!)

 

Regards,

 

Steve

 

Re: Simulation of Key Strokes

Esteemed Contributor
Esteemed Contributor

Hi Steve,

 

yes, I know that the new method in NX10 is really switching applications, I have been one requester of that feature.

 

The OP doesn't use NX10 as shown in his signature, so he needs a solution for NX9 and below.

 

If things need to be selected from a drawing sheet or a modeling view the best way is to change the view layout.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: Simulation of Key Strokes

Pioneer
Pioneer

Hi

 

@Steve,

As stefan said, i dont use NX10, i need to achieve the switching of modelling and drafting when user opens a drawing file.

 

I looked for the same in NX Open documentation and could not found any method.

 

So i tried to pass the key strokes as user does interactively.

But this key strokes sent works on other windows but not on NX.

 

So i would want to know is there ay other method to achieve the same.

 

@Stefan,

I will try with changing the view layout, and revert with updates.

 

 

Regards,

Maddy.

 

 

Windows 7 x64
NX 8.5, NX 9.0. And also NX 7.5
Visual Studio 2010 SP1, 2012 Update 4

Re: Simulation of Key Strokes

Pioneer
Pioneer

Hi Stefan,

 

Could you guide me, which method i need to use to change the View Layout, 

I'm not able to find one.

 

Regards,

Maddy

Windows 7 x64
NX 8.5, NX 9.0. And also NX 7.5
Visual Studio 2010 SP1, 2012 Update 4

Re: Simulation of Key Strokes

Esteemed Contributor
Esteemed Contributor

Best is to record a journal in the latest release of NX you have access to, since the coverage of journaling is usually better than in an older release.

 

I have recorded the following journal in the gateway application, which should make sure it works in any application.

 

' NX 9.0.3.4
' Journal created by Stefan.Pendl on Wed May 06 09:41:34 2015 Mitteleuropäische Sommerzeit
'
Option Strict Off
Imports System
Imports NXOpen

Module NXJournal
Sub Main (ByVal args() As String) 

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work

Dim displayPart As Part = theSession.Parts.Display

' ----------------------------------------------
'   Menu: View->Layout->Open...
' ----------------------------------------------
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Open Layout")

Dim layout1 As Layout = CType(workPart.Layouts.FindObject("L1"), Layout)

layout1.Open()

Dim drawingSheet1 As Drawings.DrawingSheet = CType(workPart.DrawingSheets.FindObject("SH1"), Drawings.DrawingSheet)

drawingSheet1.Open()

' ----------------------------------------------
'   Menu: Tools->Journal->Stop Recording
' ----------------------------------------------

End Sub
End Module

I would not use FindObject, since it is not as flexible as using ForEach..Next on the respective collection.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community