Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Tabular Note Coordinates - Journal 1

Status
Not open for further replies.

MI95SHO

Mechanical
Dec 20, 2012
35
Hello everyone,

I have a Journal file that allows me in drafting to click a point, and add a note with leader containing the X, Y, and Z value of that point (see below) that was based loosely off of another that created a table of points. Now I was asked to remove the "Point #" part, and list the XYZ coordinate values (stacked) with leader from the point. However the XYZ's need to be boxed, and I can only assume you need to use a tabular note to make the box possible. Could anyone help me to convert the journal below to a tabular note rather than just a note? Sadly it has been far to long since I have played with code, and am getting all spun around on this one.

UPDATED: ADDED SCREENSHOT FOR EXAMPLE OF OUTPUT

Thanks in advance.

Kyle
NX 11.0

Code:
' NX Version 11.0
' Version: 1
' Date: 04-19-2018

Option Strict Off

Imports System
Imports NXOpen
Imports NXOpen.Annotations
Imports NXOpen.UI
Imports NXOpenUI
Imports NXOpen.UF
Imports NXOpen.Utilities

Module create_tabnote_with_all_3d_points_coordinates
    Dim s As Session = Session.GetSession()
    Dim ufs As UFSession = UFSession.GetUFSession()
    Dim ui As UI = UI.GetUI()
    Dim workPart As Part = s.Parts.Work
	Dim pt1 As Point = Nothing

    Sub Main()
        Dim xvalue As Double = Nothing
        Dim response1 As Selection.Response = Selection.Response.Cancel
    ' Get a view for the IDs
        Dim dwgview As View = Nothing
        If select_a_drawing_member_view(dwgview) <> Selection.Response.Ok Then
            Return
        End If
    ' Set Point number starting value
        Dim jj As Integer = 0
        Dim id As Integer = 1
        jj = NXInputBox.GetInputString("Input Starting Point number", "Starting Point Value") - 1

start1:
    ' Add one row for each point
        response1 = select_a_point(pt1)
        If response1 <> Selection.Response.Ok Then GoTo end1
    ' For Each pt As Point In pcol1
        id = jj + 1
    ' Get the Coordinates
        Dim pt3d As Point3d = pt1.Coordinates
    ' Add ID notes to the points
        AddNoteToPoint(id, pt1, pt3d, dwgview)
        jj = jj + 1
        Dim markId2 As Session.UndoMarkId
        markId2 = s.SetUndoMark(Session.MarkVisibility.Invisible, "Note")
	If select_a_drawing_member_view(dwgview) = Selection.response.Cancel Then
		Return
	End If
        GoTo start1
end1:

    End Sub

     Public Function SelectScreenPos(ByRef pos As Point3d, ByVal view As View) As Selection.DialogResponse
         Dim letteringPrefs As LetteringPreferences = Nothing
         Dim userSymPrefs As UserSymbolPreferences = Nothing
     End Function

    Function select_a_drawing_member_view(ByRef dwgview As View) As Selection.Response
    ' Selecting the drawing view for points
        Dim mask(1) As Selection.MaskTriple
        mask(0).Type = UFConstants.UF_view_type
        mask(0).Subtype = UFConstants.UF_view_imported_subtype
        mask(0).SolidBodySubtype = 0
        mask(1).Type = UFConstants.UF_view_type
        mask(1).Subtype = UFConstants.UF_view_orthographic_subtype
        mask(1).SolidBodySubtype = 0
        Dim cursor As Point3d = Nothing
        Dim vw As View = Nothing
        Dim resp As Selection.Response = _
        ui.SelectionManager.SelectObject("Select a Drawing View", _
            "Select a Drawing View", _
            Selection.SelectionScope.AnyInAssembly, _
            Selection.SelectionAction.ClearAndEnableSpecific, _
            False, False, mask, vw, cursor)
        If resp = Selection.Response.ObjectSelected Or _
           resp = Selection.Response.ObjectSelectedByName Then
            dwgview = CType(vw, View)
            Return Selection.Response.Ok
        Else
            Return Selection.Response.Cancel
        End If
    End Function


    Public Sub AddNoteToPoint(ByVal id As Integer, ByVal pnt1 As Point, _
                              ByVal pt As Point3d, ByVal dwgview As View)
    ' Adding point leader to drawing
        Dim pt3d As Point3d = pt1.Coordinates
		Dim screenpos As Point3d
        SelectScreenPoint(screenpos)
        Dim nullAnnotations_SimpleDraftingAid As Annotations.SimpleDraftingAid = Nothing
        Dim draftingNoteBuilder1 As Annotations.DraftingNoteBuilder
        draftingNoteBuilder1 = workPart.Annotations.CreateDraftingNoteBuilder(nullAnnotations_SimpleDraftingAid)
        draftingNoteBuilder1.Origin.Plane.PlaneMethod = Annotations.PlaneBuilder.PlaneMethodType.XyPlane
        draftingNoteBuilder1.Origin.SetInferRelativeToGeometry(True)
        draftingNoteBuilder1.Origin.Anchor = Annotations.OriginBuilder.AlignmentPosition.MidCenter

        Dim text1(0) As String
		Dim text2(10) As String
    ' Point name + Point number
		pt3d.X = FormatNumber(pt3d.X, 3,,,False).ToString()
		pt3d.Y = FormatNumber(pt3d.Y, 3,,,False).ToString()
		pt3d.Z = FormatNumber(pt3d.Z, 3,,,False).ToString()
		text1(0) = "Point " & id.ToString & ";  X:" & pt3d.X & " Y:" & pt3d.Y & " Z:" & pt3d.Z 			

        draftingNoteBuilder1.Text.TextBlock.SetText(text1)
        Dim leaderData1 As Annotations.LeaderData
        leaderData1 = workPart.Annotations.CreateLeaderData()
        leaderData1.StubSize = 2.5
        leaderData1.Arrowhead = Annotations.LeaderData.ArrowheadType.FilledArrow
        draftingNoteBuilder1.Leader.Leaders.Append(leaderData1)
        leaderData1.StubSide = Annotations.LeaderSide.Inferred
        leaderData1.Leader.SetValue(pnt1, dwgview, pt)
        Dim assocOrigin1 As Annotations.Annotation.AssociativeOriginData
        assocOrigin1.OriginType = Annotations.AssociativeOriginType.RelativeToGeometry
        Dim nullView As View = Nothing
        draftingNoteBuilder1.Origin.Origin.SetValue(Nothing, nullView, screenpos)
        Dim nXObject1 As NXObject
        nXObject1 = draftingNoteBuilder1.Commit()
        draftingNoteBuilder1.Destroy()
    End Sub

    Public Function select_a_point(ByRef pt1 As Point) As Selection.Response
    ' Picking point selection
        Dim mask(0) As Selection.MaskTriple
        With mask(0)
            .Type = UFConstants.UF_point_type
            .Subtype = 0
            .SolidBodySubtype = 0
        End With
        Dim cursor As Point3d = Nothing
        ufs.Ui.SetCursorView(0)
        ufs.Ui.LockUgAccess(NXOpen.UF.UFConstants.UF_UI_FROM_CUSTOM)
        Dim resp As Selection.Response = _
   ui.SelectionManager.SelectObject("Select a Point", "Select a Point", _
       Selection.SelectionScope.AnyInAssembly, _
       Selection.SelectionAction.ClearAndEnableSpecific, _
       False, False, mask, pt1, cursor)
        ufs.Ui.UnlockUgAccess(NXOpen.UF.UFConstants.UF_UI_FROM_CUSTOM)
        If resp = Selection.Response.ObjectSelected Or _
           resp = Selection.Response.ObjectSelectedByName Then
            Return Selection.Response.Ok
        ElseIf resp = Selection.Response.Back Then
            Return Selection.Response.Back
        Else
            Return Selection.Response.Cancel
        End If
    End Function

    Function SelectScreenPoint(ByRef screenpos As Point3d)
        Dim displayPart As Part = s.Parts.Display
        Dim baseView1 As View = s.Parts.Work.Views.WorkView
        Dim point As Double() = {0.0, 0.0, 0.0}
        Dim response As Integer = 0
        Dim viewTag As Tag = Nothing
        Dim viewType As UFView.Type = Nothing
        Dim aView As View = Nothing
        Dim viewSubtype As UFView.Subtype = Nothing
        ufs.Ui.LockUgAccess(NXOpen.UF.UFConstants.UF_UI_FROM_CUSTOM)
        ufs.Ui.SetCursorView(1)
        Try
            ufs.Ui.SpecifyScreenPosition("Select Label Position", Nothing, IntPtr.Zero, point, _
                                                   viewTag, response)
        Finally
            ufs.Ui.UnlockUgAccess(NXOpen.UF.UFConstants.UF_UI_FROM_CUSTOM)
        End Try
        If (response <> NXOpen.UF.UFConstants.UF_UI_PICK_RESPONSE) Then Return Selection.Response.Cancel
        screenpos.X = point(0)
        screenpos.Y = point(1)
        screenpos.Z = point(2)
        Return Selection.Response.Ok
    End Function

    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        Return Session.LibraryUnloadOption.Immediately
    End Function

End Module

Link
--
Design Engineer
NX 11.0
TeamCenter 10
CATIA V5 R18-R26
 
Replies continue below

Recommended for you

You could use GD&T frames to create boxes around the values.

Code:
' NX Version 11.0
' Version: 1
' Date: 04-19-2018

Option Strict Off

Imports System
Imports NXOpen
Imports NXOpen.Annotations
Imports NXOpen.UI
Imports NXOpenUI
Imports NXOpen.UF
Imports NXOpen.Utilities

Module Module94
    Dim s As Session = Session.GetSession()
    Dim ufs As UFSession = UFSession.GetUFSession()
    Dim ui As UI = ui.GetUI()
    Dim workPart As Part = s.Parts.Work
    Dim pt1 As Point = Nothing

    Sub Main()
        Dim xvalue As Double = Nothing
        Dim response1 As Selection.Response = Selection.Response.Cancel
        ' Get a view for the IDs
        Dim dwgview As View = Nothing
        If select_a_drawing_member_view(dwgview) <> Selection.Response.Ok Then
            Return
        End If

start1:
        ' Add one row for each point
        response1 = select_a_point(pt1)
        If response1 <> Selection.Response.Ok Then GoTo end1
        ' Get the Coordinates
        Dim pt3d As Point3d = pt1.Coordinates
        ' Add ID notes to the points
        AddNoteToPoint(pt1, pt3d, dwgview)
        Dim markId2 As Session.UndoMarkId
        markId2 = s.SetUndoMark(Session.MarkVisibility.Invisible, "Note")
        If select_a_drawing_member_view(dwgview) = Selection.response.Cancel Then
            Return
        End If
        GoTo start1
end1:

    End Sub

    Public Function SelectScreenPos(ByRef pos As Point3d, ByVal view As View) As Selection.DialogResponse
        Dim letteringPrefs As LetteringPreferences = Nothing
        Dim userSymPrefs As UserSymbolPreferences = Nothing
    End Function

    Function select_a_drawing_member_view(ByRef dwgview As View) As Selection.Response
        ' Selecting the drawing view for points
        Dim mask(1) As Selection.MaskTriple
        mask(0).Type = UFConstants.UF_view_type
        mask(0).Subtype = UFConstants.UF_view_imported_subtype
        mask(0).SolidBodySubtype = 0
        mask(1).Type = UFConstants.UF_view_type
        mask(1).Subtype = UFConstants.UF_view_orthographic_subtype
        mask(1).SolidBodySubtype = 0
        Dim cursor As Point3d = Nothing
        Dim vw As View = Nothing
        Dim resp As Selection.Response =
        ui.SelectionManager.SelectObject("Select a Drawing View",
            "Select a Drawing View",
            Selection.SelectionScope.AnyInAssembly,
            Selection.SelectionAction.ClearAndEnableSpecific,
            False, False, mask, vw, cursor)
        If resp = Selection.Response.ObjectSelected Or
           resp = Selection.Response.ObjectSelectedByName Then
            dwgview = CType(vw, View)
            Return Selection.Response.Ok
        Else
            Return Selection.Response.Cancel
        End If
    End Function


    Public Sub AddNoteToPoint(ByVal pnt1 As Point,
                              ByVal pt As Point3d, ByVal dwgview As View)
        ' Adding point leader to drawing
        Dim pt3d As Point3d = pt1.Coordinates
        Dim screenpos As Point3d
        SelectScreenPoint(screenpos)
        Dim nullAnnotations_SimpleDraftingAid As Annotations.SimpleDraftingAid = Nothing
        Dim draftingNoteBuilder1 As Annotations.DraftingNoteBuilder
        draftingNoteBuilder1 = workPart.Annotations.CreateDraftingNoteBuilder(nullAnnotations_SimpleDraftingAid)
        draftingNoteBuilder1.Origin.Plane.PlaneMethod = Annotations.PlaneBuilder.PlaneMethodType.XyPlane
        draftingNoteBuilder1.Origin.SetInferRelativeToGeometry(True)
        draftingNoteBuilder1.Origin.Anchor = Annotations.OriginBuilder.AlignmentPosition.MidCenter

        Dim text1(0) As String
        Dim text2(10) As String
        ' Point name + Point number
        pt3d.X = FormatNumber(pt3d.X, 3,,, False).ToString()
        pt3d.Y = FormatNumber(pt3d.Y, 3,,, False).ToString()
        pt3d.Z = FormatNumber(pt3d.Z, 3,,, False).ToString()

        'text1(0) = "<&70><+>X:" & pt3d.X & "<+><&80><+>Y:" & pt3d.Y & "<+><&80><+>Z:" & pt3d.Z & "<+><&90>"
        text1(0) = "<&70><+>X:"
        If pt3d.X > 0 Then
            text1(0) &= " "
        End If
        text1(0) &= pt3d.X & "<+><&80><+>Y:"
        If pt3d.Y > 0 Then
            text1(0) &= " "
        End If
        text1(0) &= pt3d.Y & "<+><&80><+>Z:"
        If pt3d.Z > 0 Then
            text1(0) &= " "
        End If
        text1(0) &= pt3d.Z & "<+><&90>"

        draftingNoteBuilder1.Text.TextBlock.SetText(text1)
        Dim leaderData1 As Annotations.LeaderData
        leaderData1 = workPart.Annotations.CreateLeaderData()
        leaderData1.StubSize = 2.5
        leaderData1.Arrowhead = Annotations.LeaderData.ArrowheadType.FilledArrow
        draftingNoteBuilder1.Leader.Leaders.Append(leaderData1)
        leaderData1.StubSide = Annotations.LeaderSide.Inferred
        leaderData1.Leader.SetValue(pnt1, dwgview, pt)
        Dim assocOrigin1 As Annotations.Annotation.AssociativeOriginData
        assocOrigin1.OriginType = Annotations.AssociativeOriginType.RelativeToGeometry
        Dim nullView As View = Nothing
        draftingNoteBuilder1.Origin.Origin.SetValue(Nothing, nullView, screenpos)
        Dim nXObject1 As NXObject
        nXObject1 = draftingNoteBuilder1.Commit()
        draftingNoteBuilder1.Destroy()
    End Sub

    Public Function select_a_point(ByRef pt1 As Point) As Selection.Response
        ' Picking point selection
        Dim mask(0) As Selection.MaskTriple
        With mask(0)
            .Type = UFConstants.UF_point_type
            .Subtype = 0
            .SolidBodySubtype = 0
        End With
        Dim cursor As Point3d = Nothing
        ufs.Ui.SetCursorView(0)
        ufs.Ui.LockUgAccess(NXOpen.UF.UFConstants.UF_UI_FROM_CUSTOM)
        Dim resp As Selection.Response =
   ui.SelectionManager.SelectObject("Select a Point", "Select a Point",
       Selection.SelectionScope.AnyInAssembly,
       Selection.SelectionAction.ClearAndEnableSpecific,
       False, False, mask, pt1, cursor)
        ufs.Ui.UnlockUgAccess(NXOpen.UF.UFConstants.UF_UI_FROM_CUSTOM)
        If resp = Selection.Response.ObjectSelected Or
           resp = Selection.Response.ObjectSelectedByName Then
            Return Selection.Response.Ok
        ElseIf resp = Selection.Response.Back Then
            Return Selection.Response.Back
        Else
            Return Selection.Response.Cancel
        End If
    End Function

    Function SelectScreenPoint(ByRef screenpos As Point3d)
        Dim displayPart As Part = s.Parts.Display
        Dim baseView1 As View = s.Parts.Work.Views.WorkView
        Dim point As Double() = {0.0, 0.0, 0.0}
        Dim response As Integer = 0
        Dim viewTag As Tag = Nothing
        Dim viewType As UFView.Type = Nothing
        Dim aView As View = Nothing
        Dim viewSubtype As UFView.Subtype = Nothing
        ufs.Ui.LockUgAccess(NXOpen.UF.UFConstants.UF_UI_FROM_CUSTOM)
        ufs.Ui.SetCursorView(1)
        Try
            ufs.Ui.SpecifyScreenPosition("Select Label Position", Nothing, IntPtr.Zero, point,
                                                   viewTag, response)
        Finally
            ufs.Ui.UnlockUgAccess(NXOpen.UF.UFConstants.UF_UI_FROM_CUSTOM)
        End Try
        If (response <> NXOpen.UF.UFConstants.UF_UI_PICK_RESPONSE) Then Return Selection.Response.Cancel
        screenpos.X = point(0)
        screenpos.Y = point(1)
        screenpos.Z = point(2)
        Return Selection.Response.Ok
    End Function

    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        Return Session.LibraryUnloadOption.Immediately
    End Function

End Module

www.nxjournaling.com
 
Thanks cowski. I had not thought about utilizing GD&T frames.
However, is there any way to either keep the vertical walls inline and/or remove the horizontal middle lines? I think this actually may have better potential for my use in drafting if so.

Thank you

--
Design Technician
NX 9.0 with SmarTeam Integration.
TeamCenter 10
CATIA V5 R18-R24
 
If each coordinate string is the same length, the vertical lines will line up. You can add some checking and formatting code to make this happen.

I don't know of a way to remove the horizontal lines.

www.nxjournaling.com
 
Thanks again Cowski. I made it work with formatting except for an issue with trailing zeros. The string (or NX) keeps cutting them out which is causing issues with the formatting. Googling trailing zeros isnt getting me far. Any suggestions?

Thanks

--
Design Engineer
NX 11.0
CATIA V5 R26
 
Why does the above code want you to Select a drawing view to lay text down and even with GD&T Frames? I thought this would just lay text or a GD&T down at random on the drawing sheet OR what was ever in the program. I pick a drawing view and nothing happens. I am confused. The reason I ask is that I want to use the same program and from a premade Listing window pick a certain no. and Lay That number down. Can That be done? Please Help!!
 
When I first looked at the code, I thought it a bit odd that we were assigning a string value back to a Point3d structure; but it seemed to work so I didn't worry about it. However, it seems that this is the cause of the issue. The code below just formats the Point3d data and leaves the original alone. Also, I made use of the .ToString method rather than the FormatNumber function as it is a little more compact.

Code:
' NX Version 11.0
' Version: 1
' Date: 04-19-2018

Option Strict Off

Imports System
Imports NXOpen
Imports NXOpen.Annotations
Imports NXOpen.UI
Imports NXOpenUI
Imports NXOpen.UF
Imports NXOpen.Utilities

Module Module94
    Dim s As Session = Session.GetSession()
    Dim ufs As UFSession = UFSession.GetUFSession()
    Dim ui As UI = ui.GetUI()
    Dim workPart As Part = s.Parts.Work
    Dim pt1 As Point = Nothing

    Sub Main()
        Dim xvalue As Double = Nothing
        Dim response1 As Selection.Response = Selection.Response.Cancel
        ' Get a view for the IDs
        Dim dwgview As View = Nothing
        If select_a_drawing_member_view(dwgview) <> Selection.Response.Ok Then
            Return
        End If

start1:
        ' Add one row for each point
        response1 = select_a_point(pt1)
        If response1 <> Selection.Response.Ok Then GoTo end1
        ' Get the Coordinates
        Dim pt3d As Point3d = pt1.Coordinates
        ' Add ID notes to the points
        AddNoteToPoint(pt1, pt3d, dwgview)
        Dim markId2 As Session.UndoMarkId
        markId2 = s.SetUndoMark(Session.MarkVisibility.Invisible, "Note")
        If select_a_drawing_member_view(dwgview) = Selection.response.Cancel Then
            Return
        End If
        GoTo start1
end1:

    End Sub

    Public Function SelectScreenPos(ByRef pos As Point3d, ByVal view As View) As Selection.DialogResponse
        Dim letteringPrefs As LetteringPreferences = Nothing
        Dim userSymPrefs As UserSymbolPreferences = Nothing
    End Function

    Function select_a_drawing_member_view(ByRef dwgview As View) As Selection.Response
        ' Selecting the drawing view for points
        Dim mask(1) As Selection.MaskTriple
        mask(0).Type = UFConstants.UF_view_type
        mask(0).Subtype = UFConstants.UF_view_imported_subtype
        mask(0).SolidBodySubtype = 0
        mask(1).Type = UFConstants.UF_view_type
        mask(1).Subtype = UFConstants.UF_view_orthographic_subtype
        mask(1).SolidBodySubtype = 0
        Dim cursor As Point3d = Nothing
        Dim vw As View = Nothing
        Dim resp As Selection.Response =
        ui.SelectionManager.SelectObject("Select a Drawing View",
            "Select a Drawing View",
            Selection.SelectionScope.AnyInAssembly,
            Selection.SelectionAction.ClearAndEnableSpecific,
            False, False, mask, vw, cursor)
        If resp = Selection.Response.ObjectSelected Or
           resp = Selection.Response.ObjectSelectedByName Then
            dwgview = CType(vw, View)
            Return Selection.Response.Ok
        Else
            Return Selection.Response.Cancel
        End If
    End Function


    Public Sub AddNoteToPoint(ByVal pnt1 As Point,
                              ByVal pt As Point3d, ByVal dwgview As View)
        ' Adding point leader to drawing
        Dim pt3d As Point3d = pt1.Coordinates
        Dim screenpos As Point3d
        SelectScreenPoint(screenpos)
        Dim nullAnnotations_SimpleDraftingAid As Annotations.SimpleDraftingAid = Nothing
        Dim draftingNoteBuilder1 As Annotations.DraftingNoteBuilder
        draftingNoteBuilder1 = workPart.Annotations.CreateDraftingNoteBuilder(nullAnnotations_SimpleDraftingAid)
        draftingNoteBuilder1.Origin.Plane.PlaneMethod = Annotations.PlaneBuilder.PlaneMethodType.XyPlane
        draftingNoteBuilder1.Origin.SetInferRelativeToGeometry(True)
        draftingNoteBuilder1.Origin.Anchor = Annotations.OriginBuilder.AlignmentPosition.MidCenter

        Dim text1(0) As String

        'text1(0) = "<&70><+>X:" & pt3d.X & "<+><&80><+>Y:" & pt3d.Y & "<+><&80><+>Z:" & pt3d.Z & "<+><&90>"
        text1(0) = "<&70><+>X:"
        If pt3d.X >= 0 Then
            text1(0) &= " "
        End If
        text1(0) &= pt3d.X.ToString("F3") & "<+><&80><+>Y:"
        If pt3d.Y >= 0 Then
            text1(0) &= " "
        End If
        text1(0) &= pt3d.Y.ToString("F3") & "<+><&80><+>Z:"
        If pt3d.Z >= 0 Then
            text1(0) &= " "
        End If
        text1(0) &= pt3d.Z.ToString("F3") & "<+><&90>"

        draftingNoteBuilder1.Text.TextBlock.SetText(text1)
        Dim leaderData1 As Annotations.LeaderData
        leaderData1 = workPart.Annotations.CreateLeaderData()
        leaderData1.StubSize = 2.5
        leaderData1.Arrowhead = Annotations.LeaderData.ArrowheadType.FilledArrow
        draftingNoteBuilder1.Leader.Leaders.Append(leaderData1)
        leaderData1.StubSide = Annotations.LeaderSide.Inferred
        leaderData1.Leader.SetValue(pnt1, dwgview, pt)
        Dim assocOrigin1 As Annotations.Annotation.AssociativeOriginData
        assocOrigin1.OriginType = Annotations.AssociativeOriginType.RelativeToGeometry
        Dim nullView As View = Nothing
        draftingNoteBuilder1.Origin.Origin.SetValue(Nothing, nullView, screenpos)
        Dim nXObject1 As NXObject
        nXObject1 = draftingNoteBuilder1.Commit()
        draftingNoteBuilder1.Destroy()
    End Sub

    Public Function select_a_point(ByRef pt1 As Point) As Selection.Response
        ' Picking point selection
        Dim mask(0) As Selection.MaskTriple
        With mask(0)
            .Type = UFConstants.UF_point_type
            .Subtype = 0
            .SolidBodySubtype = 0
        End With
        Dim cursor As Point3d = Nothing
        ufs.Ui.SetCursorView(0)
        ufs.Ui.LockUgAccess(NXOpen.UF.UFConstants.UF_UI_FROM_CUSTOM)
        Dim resp As Selection.Response =
   ui.SelectionManager.SelectObject("Select a Point", "Select a Point",
       Selection.SelectionScope.AnyInAssembly,
       Selection.SelectionAction.ClearAndEnableSpecific,
       False, False, mask, pt1, cursor)
        ufs.Ui.UnlockUgAccess(NXOpen.UF.UFConstants.UF_UI_FROM_CUSTOM)
        If resp = Selection.Response.ObjectSelected Or
           resp = Selection.Response.ObjectSelectedByName Then
            Return Selection.Response.Ok
        ElseIf resp = Selection.Response.Back Then
            Return Selection.Response.Back
        Else
            Return Selection.Response.Cancel
        End If
    End Function

    Function SelectScreenPoint(ByRef screenpos As Point3d)
        Dim displayPart As Part = s.Parts.Display
        Dim baseView1 As View = s.Parts.Work.Views.WorkView
        Dim point As Double() = {0.0, 0.0, 0.0}
        Dim response As Integer = 0
        Dim viewTag As Tag = Nothing
        Dim viewType As UFView.Type = Nothing
        Dim aView As View = Nothing
        Dim viewSubtype As UFView.Subtype = Nothing
        ufs.Ui.LockUgAccess(NXOpen.UF.UFConstants.UF_UI_FROM_CUSTOM)
        ufs.Ui.SetCursorView(1)
        Try
            ufs.Ui.SpecifyScreenPosition("Select Label Position", Nothing, IntPtr.Zero, point,
                                                   viewTag, response)
        Finally
            ufs.Ui.UnlockUgAccess(NXOpen.UF.UFConstants.UF_UI_FROM_CUSTOM)
        End Try
        If (response <> NXOpen.UF.UFConstants.UF_UI_PICK_RESPONSE) Then Return Selection.Response.Cancel
        screenpos.X = point(0)
        screenpos.Y = point(1)
        screenpos.Z = point(2)
        Return Selection.Response.Ok
    End Function

    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        Return Session.LibraryUnloadOption.Immediately
    End Function

End Module

www.nxjournaling.com
 
@designnewz
The code in this thread will label a point object with its coordinates in 3D space. When run, it will ask you to select a view, then select a point, and then select where on the drawing you want the label. The code won't do much if there is no point object visible in the drafting view that you select. The code uses the selected view to set the note leader data to the correct point object (the same point object could be shown in several views on the drawing).

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

Part and Inventory Search

Sponsor