Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Extract Point 3D from Point Measurement Feature NX11

Status
Not open for further replies.

lklo

Industrial
Nov 24, 2010
226
Hi gyus -

I was just testing upfront a comming project...

I need to be able to extract the Coordinates from a Point Measurement Feature in NX...
This should be quite straight forward - but seems NOT to be, for me.....

My approach is to cycle through each feature...
If the Feature Type is "Point Measurement", then simply do the Job of extract Point Value from Feature....

Maybe another approcah can be using the workparts MeasureManager...*???

Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
'Imports NXOpen.Drawings
'Imports NXOpen.Assemblies
'Imports NXOpen.PDM
'Imports System.Collections
'Imports System.Collections.Generic
'Imports NXOpen.Annotations
'Imports System.Text
'Imports NXOpen.Utilities
'Imports System.Text.RegularExpressions
'Imports System.Diagnostics
'Imports NXOpen.Routing
Imports NXOpen.Features



Module Lkl_rename_My_MODULE

    Dim theSession As Session = Session.GetSession()
    Dim theUI As UI = UI.GetUI()
    Dim workPart As Part = theSession.Parts.Work
    Dim displayPart As Part = theSession.Parts.Display
    Dim ufs As UFSession = UFSession.GetUFSession()
    Dim output_To_NXListingWindow As Boolean = True
    Dim output_To_NXLogFile As Boolean = True

    Dim FeaturesInPart As Features.FeatureCollection = workPart.Features


    Sub Main()
        ufs.Ui.ExitListingWindow() ' close windows before displaying it again
        'START HERE

        For Each myFeature As Feature In FeaturesInPart
            If myFeature.FeatureType = "Point Measurement" Then
                NX("Type:  " & myFeature.FeatureType)
                NX("Need a 3D point or similar -  for this Point Measurement Feature")
            End If
        Next

    End Sub



    '=========================== NX LISTING WINDOW FUNCTION=======================================

    Public Sub NX(ByVal input As String) '' output variable listwindow - just for building VB

        If output_To_NXListingWindow Then
            Dim displayPart As Part = theSession.Parts.Display
            Dim lw As ListingWindow = theSession.ListingWindow()
            lw.Open()
            lw.WriteLine(input)
        End If

    End Sub
    '===============================================================================================

    '=========================== NX WRITE TO LOGFILE FUNCTION=======================================

    Public Sub NX_log(ByVal input As String) '' output variable listwindow - just for building VB

        If output_To_NXLogFile Then
            theSession.LogFile.WriteLine(input)
        End If

    End Sub
    '================================================================================================

    '=========================== NX UNLOAD FUNCTION ================================================

    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination ' typically used in Checkmate only

    End Function
    '================================================================================================

End Module

Thanks...

Regards Lklo

Point_Measurement_ltlyad.png
 
Replies continue below

Recommended for you

Hi guys...

Now it works.....
Feel free to have a look at code....
I simply extracted the expression from the Feature....

Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
'Imports NXOpen.Drawings
'Imports NXOpen.Assemblies
'Imports NXOpen.PDM
'Imports System.Collections
'Imports System.Collections.Generic
'Imports NXOpen.Annotations
'Imports System.Text
'Imports NXOpen.Utilities
'Imports System.Text.RegularExpressions
'Imports System.Diagnostics
'Imports NXOpen.Routing
Imports NXOpen.Features



Module Lkl_rename_My_MODULE

    Dim theSession As Session = Session.GetSession()
    Dim theUI As UI = UI.GetUI()
    Dim workPart As Part = theSession.Parts.Work
    Dim displayPart As Part = theSession.Parts.Display
    Dim ufs As UFSession = UFSession.GetUFSession()
    Dim output_To_NXListingWindow As Boolean = True
    Dim output_To_NXLogFile As Boolean = True

    Dim FeaturesInPart As Features.FeatureCollection = workPart.Features



    Sub Main()
        ufs.Ui.ExitListingWindow() ' close windows before displaying it again
        'START HERE

        For Each myFeature As Feature In FeaturesInPart
            If myFeature.FeatureType = "Point Measurement" Then
                NX("Type:  " & myFeature.FeatureType)

                Dim exprs() As Expression = myFeature.GetExpressions()

                For Each exp As Expression In exprs
                    NX("  Expression: " & exp.Equation & " - " & exp.GetDescriptor)
                    NX("X coordinate from this Point Measurement Feature: " & exp.PointValue.X.ToString)
                    NX("Y coordinate from this Point Measurement Feature: " & exp.PointValue.Y.ToString)
                    NX("Z coordinate from this Point Measurement Feature: " & exp.PointValue.Z.ToString)
                Next
            End If
            NX("")
        Next


    End Sub



    '=========================== NX LISTING WINDOW FUNCTION=======================================

    Public Sub NX(ByVal input As String) '' output variable listwindow - just for building VB

        If output_To_NXListingWindow Then
            Dim displayPart As Part = theSession.Parts.Display
            Dim lw As ListingWindow = theSession.ListingWindow()
            lw.Open()
            lw.WriteLine(input)
        End If

    End Sub
    '===============================================================================================

    '=========================== NX WRITE TO LOGFILE FUNCTION=======================================

    Public Sub NX_log(ByVal input As String) '' output variable listwindow - just for building VB

        If output_To_NXLogFile Then
            theSession.LogFile.WriteLine(input)
        End If

    End Sub
    '================================================================================================

    '=========================== NX UNLOAD FUNCTION ================================================

    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination ' typically used in Checkmate only

    End Function
    '================================================================================================

End Module

Lklo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor