Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

using a journal to call a grip program

Status
Not open for further replies.

smitty239

Automotive
Jan 4, 2007
60
0
0
CN
Hi Everyone
wondering if anyone can help me out. i am in need to call a grip program from a journal, and when it finishes have it pass control back to the journal. Is this possible ? If so does anyone have an example I could possibly use to get started. Appreciate anything you can tell me.

windows 7 and nx 8.0

Smitty
 
Replies continue below

Recommended for you

This is possible, you will need to use the ExecuteGrip method. Below is a code sample from Siemen's GTAC solution center

Code:
[COLOR=green]'Date:  09/19/2007[/color]
[COLOR=green]'Subject:  Sample NX Open .NET Visual Basic program : call grip from vb and print args[/color]
[COLOR=green]'[/color]
[COLOR=green]'Note:  GTAC provides programming examples for illustration only, and[/color]
[COLOR=green]'assumes that you are familiar with the programming language being[/color]
[COLOR=green]'demonstrated and the tools used to create and debug procedures.  GTAC[/color]
[COLOR=green]'support professionals can help explain the functionality of a particular[/color]
[COLOR=green]'procedure, but we will not modify these examples to provide added[/color]
[COLOR=green]'functionality or construct procedures to meet your specific needs.[/color]

[COLOR=blue]Option Strict Off[/color]    

[COLOR=blue]Imports[/color] System  
[COLOR=blue]Imports[/color] NXOpen  
[COLOR=blue]Imports[/color] NXOpen.UF  
[COLOR=blue]Imports[/color] NXOpenUI  
[COLOR=blue]Imports[/color] NXOpen.UI  
[COLOR=blue]Imports[/color] NXOpen.Utilities  

[COLOR=blue]Module[/color] call_grip_from_vb_and_print_args  

  [COLOR=blue]Dim[/color] s [COLOR=blue]As[/color] Session [COLOR=blue]=[/color] Session.GetSession()  
  [COLOR=blue]Dim[/color] ui [COLOR=blue]As[/color] UI [COLOR=blue]=[/color] GetUI()  

[COLOR=blue]Sub[/color] Main()  

[COLOR=blue]Try[/color]  
    [COLOR=blue]Dim[/color] num1 [COLOR=blue]As Double =[/color] 2.0  
    [COLOR=blue]Dim[/color] num2 [COLOR=blue]As Double =[/color] 55.2  
    [COLOR=blue]Dim[/color] text1 [COLOR=blue]As String =[/color] "Otto"  
    [COLOR=blue]Dim[/color] text2 [COLOR=blue]As String =[/color] "Karl"  
    [COLOR=blue]Dim[/color] inputArgs(3) [COLOR=blue]As Object[/color]  
    [COLOR=blue]Dim[/color] gripObj() [COLOR=blue]As Object[/color]  
      
    inputArgs(0) [COLOR=blue]=[/color] num1  
    inputArgs(1) [COLOR=blue]=[/color] num2  
    inputArgs(2) [COLOR=blue]=[/color] text1  
    inputArgs(3) [COLOR=blue]=[/color] text2  

    ui.LockAccess()  

    [COLOR=blue]Dim[/color] grip_executable [COLOR=blue]As String =[/color] "c:\print_api_args.grx"  

    gripObj [COLOR=blue]=[/color] s.ExecuteGrip(grip_executable, inputArgs)  

    ui.UnlockAccess()  

[COLOR=blue]Catch[/color] ex [COLOR=blue]As[/color] Exception  
    s.ListingWindow.Open()  
    s.ListingWindow.WriteLine("Error: ")  
    s.ListingWindow.WriteLine(ex.GetBaseException.ToString())  
End [COLOR=blue]Try[/color]  

End [COLOR=blue]Sub[/color]  

  [COLOR=blue]Public Function[/color] GetUnloadOption(ByVal dummy [COLOR=blue]As String[/color]) [COLOR=blue]As Integer[/color]  

      [COLOR=blue]Return[/color] Session.LibraryUnloadOption.Immediately  

  End [COLOR=blue]Function[/color]  

End [COLOR=blue]Module[/color]  


[COLOR=green]'-----------------------------------------------[/color]
[COLOR=green]'$$ GRIP Source called by VB.NET[/color]
[COLOR=green]'$$ Please remove the first character [/color]
[COLOR=green]'$$ in each line to compile![/color]
[COLOR=green]'$$[/color]
[COLOR=green]'$$ Declarations.[/color]
[COLOR=green]'    number / zahl1, zahl2[/color]
[COLOR=green]'    entity / object[/color]
[COLOR=green]'    string / text1(132), text2(132)[/color]
[COLOR=green]'    [/color]
[COLOR=green]'$$ Register and initialize the argument list[/color]
[COLOR=green]'    ufargs / zahl1, zahl2, text1, text2[/color]
[COLOR=green]'[/color]
[COLOR=green]'$$ Print the arguments[/color]
[COLOR=green]'    PRINT/ 'Argument1 = ' + FSTR(zahl1)[/color]
[COLOR=green]'    PRINT/ 'Argument2 = ' + FSTR(zahl2)[/color]
[COLOR=green]'    PRINT/ 'Argument3 = ' + text1[/color]
[COLOR=green]'    PRINT/ 'Argument4 = ' + text2[/color]
[COLOR=green]'[/color]
[COLOR=green]'$$ Return control to the VB program.[/color]
[COLOR=green]'    halt: halt[/color]
[COLOR=green]'-----------------------------------------------[/color]


www.nxjournaling.com
 
Status
Not open for further replies.
Back
Top