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
Link
--
Design Engineer
NX 11.0
TeamCenter 10
CATIA V5 R18-R26
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