×
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

DatumPlane

DatumPlane

DatumPlane

(OP)
How do I get a handle on the DatumPlane that is in the workpart. I developed this code and having a problem debugging it.

CODE --> vb.net

Function GetDatumPlanes(ByVal in_part As Part) As DatumPlane()
        Dim a_DatumPlane As Tag = NXOpen.Tag.Null
        Dim type, subtype As Integer
        Dim bList As ArrayList = New ArrayList

        Do
            theUFsession.Obj.CycleObjsInPart(in_part.Tag, _
                UFConstants.UF_datum_plane_type, a_DatumPlane)
            If Not a_DatumPlane.Equals(NXOpen.Tag.Null) Then
                theUFsession.Obj.AskTypeAndSubtype(a_DatumPlane, type, subtype)
                If subtype = UFConstants.UF_datum_object_subtype Then
                    bList.Add(Utilities.NXObjectManager.Get(a_DatumPlane))
                End If
            End If
        Loop While Not a_DatumPlane.Equals(NXOpen.Tag.Null)

        Return bList.ToArray(GetType(DatumPlane))

    End Function 

RE: DatumPlane

Below are two methods:

CODE

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

Module Module1

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

    Sub Main()

        If IsNothing(theSession.Parts.BaseWork) 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 = "report datum planes"
        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

        Dim myPlanes As New List(Of DatumPlane)
        myPlanes = GetDatumPlanes(workPart)
        lw.WriteLine("number of datum planes: " & myPlanes.Count.ToString)

        Dim myPlanes2 As New List(Of DatumPlane)
        myPlanes2 = GetDatumPlanes2(workPart)
        lw.WriteLine("number of datum planes: " & myPlanes2.Count.ToString)

        lw.Close()

    End Sub

    Function GetDatumPlanes(ByVal thePart As Part) As List(Of DatumPlane)

        Dim theDatumPlanes As New List(Of DatumPlane)

        For Each temp As DisplayableObject In thePart.Datums
            If TypeOf (temp) Is DatumPlane Then
                theDatumPlanes.Add(temp)
            End If
        Next

        Return theDatumPlanes

    End Function

    Function GetDatumPlanes2(ByVal thePart As Part) As List(Of DatumPlane)

        Dim theDatumPlanes As New List(Of DatumPlane)
        Dim a_DatumPlane As Tag = NXOpen.Tag.Null

        Do
            theUfSession.Obj.CycleObjsInPart(thePart.Tag, UFConstants.UF_datum_plane_type, a_DatumPlane)
            If Not a_DatumPlane.Equals(NXOpen.Tag.Null) Then
                theDatumPlanes.Add(Utilities.NXObjectManager.Get(a_DatumPlane))
            End If
        Loop While Not a_DatumPlane.Equals(NXOpen.Tag.Null)

        Return theDatumPlanes

    End Function

    Public Function GetUnloadOption(ByVal dummy As String) As Integer

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

    End Function

End Module 

www.nxjournaling.com

RE: DatumPlane

(OP)
How about just "workpart.Datums"? I just looked at that and it gives me all the datums within the workpart. Sorry for the post. I was making it more complicated than it needed to be.

RE: DatumPlane

That's the method I used in the GetDatumPlanes function above; the Datums collection holds datum planes and axes (possibly csys and points as well), you'll need to sort out the planes from the rest.

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!


Resources