×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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

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

(OP)
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

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

(OP)
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

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

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.

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

(OP)
"Other than NXOpen & .Net"?

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

Jeff

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

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.

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

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 --> .NET

'' 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 --> .NET

''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 

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

(OP)
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

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

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)



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

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources