Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Do someone know how to use this method without using visual studio

Status
Not open for further replies.

Ehaviv

Computer
Jul 2, 2003
1,012
Hi
Do someone know how to use this method without using visual studio ?
using only nx journal

Thank you.

Code:
'In Visual Studio, you basically include this module in your project. You also include the
' .dlx file in your project and set the build action for the .dlx to "Embedded Resource".
' You make a small modification to the definition of the .dlx filename
' in your block styler code and the tool take care of the rest.
' 
'The function writeDlxResourceToTemp() loops through all of the resources
' in your project looking for a .dlx. When it finds it, it writes a copy
' to UGII_TMP_DIR, then returns the path to the file that it just wrote.
 
'File is attached. Full instructions are commented in the file and copied
' in the code block below (note that EmbedddedDLX_BS should be
' replaced with the name of your Block Styler Dialog):
' 
'Embedded_DLX.vb - Embed DLX file into application .dll
'
'  History: 
'    18-Oct-2014 / Jim Bernard / created / NX 8.5
'
'  Description:
'    This function will write a .dlx file contained in a project as an embedded
'    resource to a temporary directory. The resulting filename is set as a
'    global variable to be used when a .dll loads a block styler dialog.
'
'    This provides a custom fully qualified name for the .dlx file on any
'    machine that the NX Open .dll is executed on, regardless of the location
'    (pathname) of the .dll. This removes the requirement that the .dlx file
'    be distributed with the .dll and that the .dlx file must reside in a
'    UGII application folder.
'
'  Instructions:
'    1) Add Embedded_DLX.vb to your Visual Studio project
'    2) Add the .dlx file to your Visual Studio project
'         - Set the Build Action to "Embedded Resource"
'    3) Modify the dlx filename definition in your block styler code
'
'             theDlxFileName = "xyz_BS.dlx"
'             If IO.File.Exists(tempDlxFile) Then theDlxFileName = tempDlxFile
'
'    4) Add the following lines to your application code to write the temporary
'         .dlx file prior to launching the dialog and to delete the temporary
'         .dlx file prior to termination
'
'             Sub Main()
'
'                 tempDlxFile = writeDlxResourceToTemp()
'
'                 EmbeddedDLX_BS.Main()
'
'                 IO.File.Delete(tempDlxFile)
'
'             End Sub
'
'
'  Known Issues:
'
Option Strict Off
Imports System
Imports System.IO
Imports System.Reflection

Imports NXOpen

Module Embedded_DLX

    Public tempDlxFile As String = Nothing

    Function writeDlxResourceToTemp() As String

        Try

            Dim dlxResourceName As String = Nothing

            For Each resourceItem As String In Assembly.GetExecutingAssembly.GetManifestResourceNames
                If resourceItem.ToLower.EndsWith(".dlx") Then
                    dlxResourceName = resourceItem
                End If
            Next resourceItem

            Dim tempSysPath As String = IO.Path.GetTempPath
            Dim tempNxPath As String = theSession.GetEnvironmentVariableValue("UGII_TMP_DIR")
            Dim tempDlxFile As String = IO.Path.Combine(tempNxPath, dlxResourceName)

            Using DLXStream As Stream = New FileStream(tempDlxFile, FileMode.Create)

                Assembly.GetExecutingAssembly().GetManifestResourceStream(dlxResourceName).CopyTo(DLXStream)

            End Using

            Return tempDlxFile

        Catch ex As Exception
            theNXMessageBox.Show("writeDlxResourceToTemp", NXMessageBox.DialogType.Error, ex.ToString)
        End Try

        Return Nothing

    End Function

End Module
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor