Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IFRs on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

NX Journal - Execute NXOpen DLL from within a VB.NET Journal

Status
Not open for further replies.

jmarkus

Mechanical
Jul 11, 2001
377
This might be a VB.NET question as opposed to an NX Journal specific question, but...

I am trying to call a standalone NXOpen DLL (that I would normally execute from File->Execute->NXOpen) from within an NX Journal. It is not supported by the journal record, so I am unsure how to do that.

For example (not real code):
Code:
...
Module NXJournal
Sub Main

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
Dim displayPart As Part = theSession.Parts.Display
...
Execute C:\files\myNXOpen.dll
....

Thanks,
Jeff
 
Replies continue below

Recommended for you

I've been reading various other forums here and there, and I'm wondering if this can only be done if I compile my journal, as opposed to running it from Journal->Play (ALT-F8). Is that the case? Is there no journal scripting for File->Execute->NXOpen?

Jeff
 
Yup that is correct, you cannot call dlls other than nxopen and .net from within journals. If you need to do that you have to compile it.
 
"Other than NXOpen & .Net"?

The DLL I wish to execute is an NXOpen DLL. Does that make a difference?

Jeff
 
No the following libraries are supported in journaling

NXOpen.dll
NXOpen.Utilities.dll
NXOpenUI.dll
NXOpen.UF.dll
mscorlib.dll
System.dll
System.Windows.Forms.dll
System.Drawing.dll

if you need any other library compiling it is the only option, atleast as far as i know.
 
Ahh ok, so you only want to launch the other program? not access specific methods of it? then look into the execute method belonging to the session instance.

You might find the following GTAC example helpful

Code:
'' This example demonstrates launching another VB .NET application's Main entrypoint.

'' The Launching application might look like this:

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module NXJournal
    Sub Main()

        Dim s As Session = Session.GetSession()
        Dim ufs As UFSession = UFSession.GetUFSession()
        Dim lw As ListingWindow = s.ListingWindow
        lw.Open()

        Dim libname As String = "launch_it.dll"
        Dim fullpath As String = Nothing
        ufs.UF.FindFile("application", libname, fullpath)

        If fullpath Is Nothing Then
            lw.WriteLine("application\" & libname & " not found")
        Else
            Dim nada() As Object = {}  ' Main doesn't take any arguments
            lw.WriteLine("Launcher will now attempt to Execute " & fullpath)
            s.Execute(fullpath, "NXJournal", "Main", nada)
        End If
    End Sub

    Function GetUnloadOption(ByVal arg As String) As Integer
        Return CType(Session.LibraryUnloadOption.Immediately, Integer)
    End Function
End Module

Code:
''Where the application being launched might look like this:

Option Strict Off
Imports System
Imports NXOpen

Module NXJournal
    Sub Main()

        Dim s As Session = Session.GetSession()
        Dim lw As ListingWindow = s.ListingWindow
        lw.Open()
        lw.WriteLine("  launch_it is running")
    End Sub

    Function GetUnloadOption(ByVal arg As String) As Integer
        Return CType(Session.LibraryUnloadOption.Immediately, Integer)
    End Function

End Module
 
Petulf,

Unfortunately, I don't know any details about the DLL. When I look at it with DLL explorer the only functions listed are:

ufusr
ufusr_ask_unload
?NXSigningResource@@YAXXZ

My understanding is that this means it is a C DLL, and not a VB.NET DLL so I can't use the Execute method.

Jeff
 
Are you certain? gtac has examples of executing java and c code from session.execute() so why dont you try;

s.Execute("path\library.dll", "library", "CallUfusr", nada)



 
I tried various methods ("callufusr", "ufusr", "call ufusr") and they all result in "object reference not set to instance of object" so I don't think I'm calling the right ones. I also assumed the class name is the same as the dll as in your example. As I said, I can only see the 3 functions in DLL explorer so I'm stuck. Maybe there is some other way I can probe the DLL for information to help?

Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor