×
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

Quickly copy measure result to clipboard

Quickly copy measure result to clipboard

Quickly copy measure result to clipboard

(OP)
Hi,

Would anyone be aware of a way (journal, nxopen) to quickly access the result of a measurement (distance, angle, etc.) and put it in the clipboard.
Currently I can expand the "measure" window, then click on "show information window" and select the result with the mouse cursor, but this process is time consuming when you routinely need to perform calculations on the measures.

regards,

Etienne
NX8.5.3.3 + TC9.1.2.2

RE: Quickly copy measure result to clipboard

Note that you can also save the content of an 'Info Window' to a text file which might prove even more useful longterm.

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.

RE: Quickly copy measure result to clipboard

The code below will prompt you to select points and copy their coordinates to the clipboard. I imagine you could do the same for measurements.

CODE

'NXJournaling.com
'April 3, 2014
'select points on screen, copy information to clipboard

Option Strict Off
Imports System
Imports System.Collections.Generic
Imports System.Windows.Forms
Imports NXOpen
Imports NXOpen.UF

Module Module1

    Sub Main()

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

        If IsNothing(theSession.Parts.Work) Then
            'active part required
            Return
        End If

        Dim workPart As Part = theSession.Parts.Work
        Dim pointValues As New List(Of String)
        Dim response1 As Integer = Nothing
        Dim mode1() As Integer = {0, 0}
        Dim pointDisplayMode As Integer = 0
        Dim objectpoint(2) As Double

        Do
            theUfSession.Ui.LockUgAccess(NXOpen.UF.UFConstants.UF_UI_FROM_CUSTOM)
            response1 = theUfSession.Ui.PointSubfunction("Select Point", mode1, pointDisplayMode, objectpoint)
            theUfSession.Ui.UnlockUgAccess(NXOpen.UF.UFConstants.UF_UI_FROM_CUSTOM)

            If response1 = 5 Then
                Dim myPtVal As String = "X = " & objectpoint(0).ToString & " Y = " & objectpoint(1).ToString & " Z = " & objectpoint(2).ToString
                If pointValues.Contains(myPtVal) Then
                    Exit Do
                Else
                    pointValues.Add(myPtVal)
                End If
            End If

        Loop Until response1 <> 5

        Dim myStringBuilder As New Text.StringBuilder
        For Each pt As String In pointValues
            myStringBuilder.Append(pt)
            myStringBuilder.AppendLine()
        Next

        Clipboard.SetText(myStringBuilder.ToString)

    End Sub

End Module 

www.nxjournaling.com

RE: Quickly copy measure result to clipboard

Many Thanks for uploading NXJournal on this site ,cowski

Can you please advise on journal if we need measure the DISTANCE not point.

RE: Quickly copy measure result to clipboard

Below is a very bare-bones journal that will prompt you to select 2 objects then place the minimum distance value on the clipboard.

CODE

Option Strict Off
Imports System
Imports NXOpen

Module Module1

    Sub Main()

        Dim theSession As Session = Session.GetSession()
        If IsNothing(theSession.Parts.Work) Then
            'active part required
            Return
        End If

        Dim workPart As Part = theSession.Parts.Work
        Dim lw As ListingWindow = theSession.ListingWindow
        lw.Open()

        Const undoMarkName As String = "measure to clipboard"
        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

        Dim obj1 As DisplayableObject
        Dim obj2 As DisplayableObject

        Try
            ' TODO: Add your application code here 
            If SelectAnObject("Select first object for distance measurement", obj1) = Selection.Response.Cancel Then
                Return
            End If

            If SelectAnObject("Select second object for distance measurement", obj2) = Selection.Response.Cancel Then
                Return
            End If

            Dim nullNXObject As NXObject = Nothing

            Dim measureDistanceBuilder1 As MeasureDistanceBuilder
            measureDistanceBuilder1 = workPart.MeasureManager.CreateMeasureDistanceBuilder(nullNXObject)

            measureDistanceBuilder1.Mtype = MeasureDistanceBuilder.MeasureType.Minimum

            measureDistanceBuilder1.Object1.Value = obj1

            measureDistanceBuilder1.Object2.Value = obj2

            Dim unit1 As Unit
            If workPart.PartUnits = BasePart.Units.Inches Then
                unit1 = CType(workPart.UnitCollection.FindObject("Inch"), Unit)
            Else
                unit1 = CType(workPart.UnitCollection.FindObject("MilliMeter"), Unit)
            End If


            Dim measureDistance1 As MeasureDistance
            measureDistance1 = workPart.MeasureManager.NewDistance(unit1, MeasureManager.MeasureType.Minimum, obj1, obj2)

            'measureDistance1.Information()

            System.Windows.Forms.Clipboard.SetText(measureDistance1.Value.ToString)

            measureDistance1.Dispose()

            measureDistanceBuilder1.Destroy()

        Catch ex As NXException
            theSession.UndoToMark(markId1, undoMarkName)
            MsgBox(ex.Message)

        Finally

        End Try

        lw.Close()

    End Sub

    Function SelectAnObject(prompt As String, _
           ByRef selObj As TaggedObject) As Selection.Response

        Dim theUI As UI = UI.GetUI
        Dim cursor As Point3d
        Dim typeArray() As Selection.SelectionType = _
            {Selection.SelectionType.All, _
                Selection.SelectionType.Faces, _
                Selection.SelectionType.Edges}

        Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject( _
                prompt, "Selection", _
                Selection.SelectionScope.AnyInAssembly, _
                False, typeArray, selObj, cursor)

        If resp = Selection.Response.ObjectSelected Or _
                resp = Selection.Response.ObjectSelectedByName Then
            Return Selection.Response.Ok
        Else
            Return Selection.Response.Cancel
        End If

    End Function

End Module 

www.nxjournaling.com

RE: Quickly copy measure result to clipboard

(OP)
Wow thank you Cowski! This is genius!

Etienne
NX8.5.3.3 + TC9.1.2.2

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