Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Journal for X, Y, Z format 3

Status
Not open for further replies.

wackolacko

Automotive
Nov 16, 2011
56
0
0
US
Hello,

Does anyone have a journal out there so when you select a point (via Info -> Point) the output would be x=5186.790 y=-856.760 z=714.2

Somehow take the output from info - point and convert it to above

getfile.aspx



John L.
NX Support
Win 7 64bit NX 7.5.4.4 TC 8.3.1.1
 
Replies continue below

Recommended for you

Are you asking for the ability to create X,Y,Z expressions of a selected point?

If so, that capability was added in XN 9.0 as the new 'Measure Point' function. Note that the expressions created, either a single 'Point' expression or individual X, Y and Z expressions, are associated with the 'Measure Point' feature which will update if the model is modified and the referenced 'Point' is moved as a result.

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.
 
yes Cowski, all in one line would make it easier to copy and paste to another sheet.

John L.
NX Support
Win 7 64bit NX 7.5.4.4 TC 8.3.1.1
 
Attached is a GRIP program that will do what you want. You select the points (as many as you wish) and it will write the data, in the format that you're looking for, to a text file.

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.
 
 http://files.engineering.com/getfile.aspx?folder=0c6c20e9-ad88-4bcf-b992-27c2de983ed0&file=Point_to_File_program.zipper
Below is a journal that will allow you to select points and write the information directly to the clipboard.

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


    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        'Unloads the image when the NX session terminates
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

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

        'Unloads the image explicitly, via an unload dialog
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
        '-------------------------------

    End Function

End Module

www.nxjournaling.com
 
Thanks John...although I was unable to compile the grs (64bit) - saying we don't have license, but I know we do.
Thanks Cowski, the journal is great.

John L.
NX Support
Win 7 64bit NX 7.5.4.4 TC 8.3.1.1
 
I included the executable of the GRIP program. There was no need to recompile it. GRIP is not like other languages in that once you have an executable, it should run on any system.

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.
 
Thanks Cowski

Journal is very helpful. I've been looking something like this. Is it possible to get point WCS orientation and reduce number of decimal places to 2.
 
OK, for what it's worth, I've updated my GRIP program so that it now returns the X,Y,Z values set to 2 decimal places. Also, the method I used to get the coordinates of the points are returning the values in terms of the current WCS (GRIP almost always works in WCS space, which can be good or bad, but in this case, it's good). As before, after downloading the file, edit the extension from .zipper to .zip and then extract the files. I've included but the source and executable, and as before, there is NO need to recompile, it should run on any recent version of NX.

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.
 
 http://files.engineering.com/getfile.aspx?folder=2e6a7ade-f011-485e-8aa5-88c5cf8ce0b4&file=Point_to_File_program.zipper
rafl said:
Is it possible to get point WCS orientation and reduce number of decimal places to 2.

Yes it is possible and the changes are pretty easy, which means it is a great time to jump in and get your hands dirty!

To get the desired number of decimal places, you can use a format string in the .ToString method. It will look something like this: [variable].ToString("0.00"). Add the format strings as desired in the following line:

Code:
Dim myPtVal As String = "X = " & objectpoint(0).ToString & " Y = " & objectpoint(1).ToString & " Z = " & objectpoint(2).ToString

In thread561-325985 you will find some code to convert absolute coordinates to local (and vice versa). The functions as written expect a Point3D object as input, which we don't use in the journal above. You will need to either create a Point3D object to pass into the function or change the function so it accepts the array of doubles that we do have (either will work).

Happy coding!
Post back with any specific questions.

www.nxjournaling.com
 
Status
Not open for further replies.
Back
Top