Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

UG NX 10 - Export or Link Measurements? 1

Status
Not open for further replies.

nkward

Automotive
Feb 7, 2013
34
Hey, is there a way to export a measurement value or multiple measurements to txt or xls file?

I have a linkage assembly together where I am changing the length of 1 part and when I do this, it automatically changes the entire assembly layout because it is fully constrained. As it changes, I am monitoring several measurements in the assembly and then recording them on a notepad.

Rather than manually record the measurements, could I somehow select all of the measurements and have them export or link to another document? Even if I have to copy/paste the output, it would still save a ton of time.
 
Replies continue below

Recommended for you

I don't know of a standard NX command that will do this efficiently.
How do you feel about using a journal? The journal below will look for measurement features in the work part and write them to the info window. You could then do a file -> save-as on the info window to save it to a text file or copy & paste values as needed.

Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module1

    Dim theSession As Session = Session.GetSession()
    Dim theUfSession As UFSession = UFSession.GetUFSession()

    Dim theUI As UI = UI.GetUI()
    Dim lw As ListingWindow = theSession.ListingWindow

    Sub Main()

        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "NXJ")

        lw.Open()

        For Each temp As Features.Feature In theSession.Parts.Work.Features
            If TypeOf (temp) Is NXOpen.Measure Then
                lw.WriteLine(temp.GetFeatureName)
                If Not String.IsNullOrEmpty(temp.Name) Then
                    lw.WriteLine("  " & temp.Name)
                End If

                Dim measureExps() As Expression = temp.GetExpressions
                For Each tempExp As Expression In measureExps

                    Select Case tempExp.Type
                        Case Is = "Number"
                            'lw.WriteLine("value (base part units): " & tempExp.Value.ToString)
                            Try
                                lw.WriteLine(tempExp.GetValueUsingUnits(Expression.UnitsOption.Expression).ToString & " " & tempExp.Units.Abbreviation)
                            Catch ex As NullReferenceException
                                'lw.WriteLine("expression is constant (unitless)")
                            Catch ex2 As Exception
                                'lw.WriteLine("!! error: " & ex2.Message)
                            End Try
                        Case Else
                            'lw.WriteLine("Type: " & tempExp.Type & " is not handled by this journal")
                    End Select

                Next
                lw.WriteLine("")
            End If
        Next

        lw.Close()

    End Sub


    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

    End Function

End Module

www.nxjournaling.com
 
Journal just flies right over my head. I turned into a stump as soon as journal was mentioned.
 
To use the code above, open notepad, start a new file, copy and paste the above code into the new file, save it with a meaningful name and make sure the file has the extension ".vb". In the NX menu, go to Tools -> journal -> play, press the "browse" button and find the .vb file that you saved earlier then press "run". NX will then run the code; the journal operates on the current work part. If there are any measurement features, the feature name and measurement value will be written to the info window. If you like what it does, you can create a custom button in NX to make it more accessible.

This version is proof of concept. It would be fairly easy to change the formatting of the output or write directly to a text file.

www.nxjournaling.com
 
If you make your measurements Associative, values will reside in your Expression Editor and, from there, you can use Export Expression to File.
You can then open this file with Notepad - the drawback is it seems to only exports all expressions.
Because you would be stuck deleting a bunch of unwanted information anyway, it's probably easier/quicker to do the following:
1) Make associative measurements
2) Double click measure feature from the Part Nav
3) Measure Distance dialog (Results Display group)-> pick Show Information Window
4) Notepad window -> highlight/delete all rows except for the desired row with the measured value
5) File -> Save As -> choose location -> Save -> leave window open
6) Make adjustments to you geometry
7) Double click measure feature again from the Part Nav
8) Measure Distance dialog (Results Display group)-> pick Show Information Window again
9) Notepad window (new information populates below the previous information) -> delete all unwanted rows (now you have 2 rows of measured values)
10)File -> Save As -> overwrite... or just keep the window open and keep going and save/overwrite at the end.

This seems nuts but if you're dealing with a lot of long, run-on values, with many decimal places, this will actually be of some value.

Good luck!





Regards,
SMO (NX10)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor