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,
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
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
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 Modulewww.nxjournaling.com
RE: Quickly copy measure result to clipboard
Can you please advise on journal if we need measure the DISTANCE not point.
RE: Quickly copy measure result to 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 Modulewww.nxjournaling.com
RE: Quickly copy measure result to clipboard
Etienne
NX8.5.3.3 + TC9.1.2.2