×
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

How to obtain u, v, w information from an axis

How to obtain u, v, w information from an axis

How to obtain u, v, w information from an axis

(OP)
Hi,

How to obtain u, v, w information from all axis in a part with NX12

maybe with an nxopen application

Thanks in advance


Regards
Didier Psaltopoulos
http://www.psi-cad.fr

RE: How to obtain u, v, w information from an axis

Is this in regards to CAM or CAD?
Can you provide more information (perhaps an example) of what you are looking for?

I know what U and V are with regards to surfacing; but I've never heard of U, V, and W being used for an axis. Perhaps it would be similar to the i,j,k direction for a vector?

www.nxjournaling.com

RE: How to obtain u, v, w information from an axis

(OP)
Hi Cowski,

It's a mistake of course bigears. I need i, j, k thumbsup2

Regards
Didier Psaltopoulos
http://www.psi-cad.fr

RE: How to obtain u, v, w information from an axis

Do you have a datum axis?
If so, the information -> object command will report the base point and direction (normalized vector) of the axis w.r.t. the absolute csys and the current WCS.

www.nxjournaling.com

RE: How to obtain u, v, w information from an axis

(OP)
Thanks a lot Cowski

In fact I was looking in analyse or mesure because I would like to have those informations in Excel. Is it possible or do we need an NXopen application ?
Anyway, It's better than nothing

Regards
Didier Psaltopoulos
http://www.psi-cad.fr

RE: How to obtain u, v, w information from an axis

Some NX automation (a journal or application) could certainly export that info to Excel or copy it to the clipboard so you can paste it easily wherever you need it.

www.nxjournaling.com

RE: How to obtain u, v, w information from an axis

I have a journal that lets you select points and copies the coordinates to the clipboard so you can paste them into another application as needed. Below is a quick modification of that journal; this one lets you select a datum axis and copies the direction (w.r.t. absolute) to the clipboard. Hopefully it is helpful or can at least serve as a starting point for your own code.

CODE

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

Module vector_dir_to_clipboard

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


    Sub Main()

        lw.Open()

        Dim myDatumAxis As DatumAxis
        If SelectDatumAxis("select datum axis", myDatumAxis) = Selection.Response.Cancel Then
            Return
        End If

        Dim ptDir As New Point3d(myDatumAxis.Direction.X, myDatumAxis.Direction.Y, myDatumAxis.Direction.Z)
        ptDir.X += theSession.Parts.Work.WCS.Origin.X
        ptDir.Y += theSession.Parts.Work.WCS.Origin.Y
        ptDir.Z += theSession.Parts.Work.WCS.Origin.Z

        Dim newPt As Point3d
        newPt = Abs2WCS(ptDir)

        'lw.WriteLine("absolute dir:")
        'lw.WriteLine(myDatumAxis.Direction.ToString)
        'lw.WriteLine("")

        'lw.WriteLine("WCS dir:")
        'lw.WriteLine(newPt.ToString)

        Clipboard.SetText(myDatumAxis.Direction.ToString)

        lw.Close()
    End Sub

    Function WCS2Abs(ByVal inPt As Point3d) As Point3d
        Dim pt1(2), pt2(2) As Double

        pt1(0) = inPt.X
        pt1(1) = inPt.Y
        pt1(2) = inPt.Z

        theUfSession.Csys.MapPoint(UFConstants.UF_CSYS_ROOT_WCS_COORDS, pt1, UFConstants.UF_CSYS_ROOT_COORDS, pt2)

        WCS2Abs.X = pt2(0)
        WCS2Abs.Y = pt2(1)
        WCS2Abs.Z = pt2(2)

    End Function

    Function Abs2WCS(ByVal inPt As Point3d) As Point3d
        Dim pt1(2), pt2(2) As Double

        pt1(0) = inPt.X
        pt1(1) = inPt.Y
        pt1(2) = inPt.Z

        theUfSession.Csys.MapPoint(UFConstants.UF_CSYS_ROOT_COORDS, pt1, UFConstants.UF_CSYS_ROOT_WCS_COORDS, pt2)

        Abs2WCS.X = pt2(0)
        Abs2WCS.Y = pt2(1)
        Abs2WCS.Z = pt2(2)

    End Function

    Function SelectDatumAxis(ByVal prompt As String, ByRef selObj As TaggedObject) As Selection.Response

        Dim theUI As UI = UI.GetUI
        Dim title As String = "Select a datum axis"
        Dim includeFeatures As Boolean = False
        Dim keepHighlighted As Boolean = False
        Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
        Dim cursor As Point3d
        Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
        Dim selectionMask_array(0) As Selection.MaskTriple

        With selectionMask_array(0)
            .Type = UFConstants.UF_datum_axis_type
            .Subtype = 0
        End With

        Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt,
        title, scope, selAction,
        includeFeatures, keepHighlighted, selectionMask_array,
        selObj, cursor)
        If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then
            Return Selection.Response.Ok
        Else
            Return Selection.Response.Cancel
        End If

    End Function

    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

RE: How to obtain u, v, w information from an axis

(OP)
Thanks a lot Cowski,

Just on issue: I need to run the programm with a component work part in an assembly

And I tried to modify to analyse all datum axis without any selection but not success

What the syntax to get i, j, k information

Quote (code)


For Each feat In theSession.Parts.Work.Features
If feat.GetType.ToString = "NXOpen.Features.DatumAxisFeature" Then
lw.WriteLine(feat.GetType.ToString)
lw.WriteLine("i=" & feat.direction.x)
lw.WriteLine("j=" & feat.direction.y)
lw.WriteLine("k=" & feat.direction.z)
End If
Next


Thanks in advance

Regards
Didier Psaltopoulos
http://www.psi-cad.fr

RE: How to obtain u, v, w information from an axis

The code below should allow you to select a datum axis from a component of the displayed assembly. Also, the X, Y, and Z values will each be on a separate line when pasting the values to a text file.

If you have a reference to a datum axis feature, you'll need to get the actual datum axis object from it; the datum axis feature has a .DatumAxis property that will return the datum axis object.

CODE

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

Module vector_dir_to_clipboard

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


    Sub Main()

        lw.Open()

        Dim myDatumAxis As DatumAxis
        If SelectDatumAxis("select datum axis", myDatumAxis) = Selection.Response.Cancel Then
            Return
        End If

        Dim ptDir As New Point3d(myDatumAxis.Direction.X, myDatumAxis.Direction.Y, myDatumAxis.Direction.Z)
        ptDir.X += theSession.Parts.Display.WCS.Origin.X
        ptDir.Y += theSession.Parts.Display.WCS.Origin.Y
        ptDir.Z += theSession.Parts.Display.WCS.Origin.Z

        Dim newPt As Point3d
        newPt = Abs2WCS(ptDir)

        'lw.WriteLine("absolute dir:")
        'lw.WriteLine(myDatumAxis.Direction.ToString)
        'lw.WriteLine("")

        'lw.WriteLine("WCS dir:")
        'lw.WriteLine(newPt.ToString)

        'Clipboard.SetText(myDatumAxis.Direction.ToString)

        Dim myStringBuilder As New Text.StringBuilder
        myStringBuilder.AppendLine(myDatumAxis.Direction.X.ToString)
        myStringBuilder.AppendLine(myDatumAxis.Direction.Y.ToString)
        myStringBuilder.AppendLine(myDatumAxis.Direction.Z.ToString)
        'myStringBuilder.AppendLine()


        Clipboard.SetText(myStringBuilder.ToString)


        lw.Close()
    End Sub

    Function WCS2Abs(ByVal inPt As Point3d) As Point3d
        Dim pt1(2), pt2(2) As Double

        pt1(0) = inPt.X
        pt1(1) = inPt.Y
        pt1(2) = inPt.Z

        theUfSession.Csys.MapPoint(UFConstants.UF_CSYS_ROOT_WCS_COORDS, pt1, UFConstants.UF_CSYS_ROOT_COORDS, pt2)

        WCS2Abs.X = pt2(0)
        WCS2Abs.Y = pt2(1)
        WCS2Abs.Z = pt2(2)

    End Function

    Function Abs2WCS(ByVal inPt As Point3d) As Point3d
        Dim pt1(2), pt2(2) As Double

        pt1(0) = inPt.X
        pt1(1) = inPt.Y
        pt1(2) = inPt.Z

        theUfSession.Csys.MapPoint(UFConstants.UF_CSYS_ROOT_COORDS, pt1, UFConstants.UF_CSYS_ROOT_WCS_COORDS, pt2)

        Abs2WCS.X = pt2(0)
        Abs2WCS.Y = pt2(1)
        Abs2WCS.Z = pt2(2)

    End Function

    Function SelectDatumAxis(ByVal prompt As String, ByRef selObj As TaggedObject) As Selection.Response

        Dim theUI As UI = UI.GetUI
        Dim title As String = "Select a datum axis"
        Dim includeFeatures As Boolean = False
        Dim keepHighlighted As Boolean = False
        Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
        Dim cursor As Point3d
        Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
        Dim selectionMask_array(0) As Selection.MaskTriple

        With selectionMask_array(0)
            .Type = UFConstants.UF_datum_axis_type
            .Subtype = 0
        End With

        Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt,
        title, scope, selAction,
        includeFeatures, keepHighlighted, selectionMask_array,
        selObj, cursor)
        If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then
            Return Selection.Response.Ok
        Else
            Return Selection.Response.Cancel
        End If

    End Function

    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

RE: How to obtain u, v, w information from an axis

(OP)
Hi Cowski

Ok for the selection in work part from an assembly.

Could just explain me how to get the datum axis object from datum axis feature ?

Thanks in advance

Regards
Didier Psaltopoulos
http://www.psi-cad.fr

RE: How to obtain u, v, w information from an axis

The datum axis feature object has a .DatumAxis property that will return the actual datum axis object. Where my code looks like this:

CODE

myStringBuilder.AppendLine(myDatumAxis.Direction.X.ToString) 

Yours would look something like:

CODE

myStringBuilder.AppendLine(myDatumAxisFeature.DatumAxis.Direction.X.ToString) 

Substitute your variable name in place of "myDatumAxisFeature".

www.nxjournaling.com

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! Already a Member? Login


Resources

White Paper – Data Security and Know-How Protection
Our data is constantly exposed to the danger of being intercepted or stolen as it wends its way over global data networks. Data security measures and measures for protecting intellectual property should not, however, first be implemented when data is exchanged – companies must lay the foundation for these measures within their own organization. Download Now
White Paper – Collaboration in the PLM Context
The influence exerted by the Internet of Things (IoT) means that there is a steadily growing need for collaboration in industry. Partners from new industries and areas of application need to be integrated in cross-company business processes to ensure that the lifecycle of smart, connected products can be managed from end to end. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close