×
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

Journal DraftingNoteBuilder NX8.5

Journal DraftingNoteBuilder NX8.5

Journal DraftingNoteBuilder NX8.5

(OP)
Hi everyone,

I gathered a small Journal from a couple of Threads together:

CODE --> Basic

Option Strict Off
Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.Globalization
Imports System.Threading
Imports NXOpen
Imports NXOpen.Annotations
Imports NXOpenUI
Imports NXOpen.UF
Imports NXOpen.Utilities

Module PosNr
    Dim ui As UI = ui.GetUI()
    Dim ufs As UFSession = UFSession.GetUFSession()
    Dim theSession As Session = Session.GetSession()
    Dim workPart As Part = theSession.Parts.Work


    Sub Main()
        Dim mode1() As Integer = {0, 0}
        Dim pointDisplayMode As Integer = 0
        Dim Hinweislinie As Integer = Nothing
        Dim objectpoint(2) As Double
        Dim cursor As Point3d
        Dim text1(0) As String
        Dim pnt1(1) As Double
        Dim i As Integer = 1

        Dim dwgview As Drawings.DraftingView = Nothing
        select_a_drawing_member_view(dwgview)


Start1:
        dwgview.Expand()
        ufs.Ui.LockUgAccess(NXOpen.UF.UFConstants.UF_UI_FROM_CUSTOM)
        Hinweislinie = ufs.Ui.PointSubfunction("Geben Sie das Ende der Hinweislinie an.", mode1, pointDisplayMode, objectpoint)
        ufs.Ui.UnlockUgAccess(NXOpen.UF.UFConstants.UF_UI_FROM_CUSTOM)
        workPart.Views.UnexpandWork()

        Dim Ausgabe As ListingWindow = theSession.ListingWindow
        Ausgabe.Open()
		Ausgabe.WriteLine("Punkt Hinweislinie")
        Ausgabe.WriteLine("X: " & objectpoint(0))
        Ausgabe.WriteLine("Y: " & objectpoint(1))
        Ausgabe.WriteLine("Z: " & objectpoint(2))
		Ausgabe.WriteLine(" ")
        Ausgabe.Close()

        If Hinweislinie = 2 Then GoTo End1

        Dim PosNr As Integer = i
        PosNr = InputBox("Bitte geben Sie die Positionsnummer ein:", "Eingabe", PosNr)

        Dim Pos_PosNr As Selection.DialogResponse = SelectScreenPos(cursor)

        Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences
        lineAndArrowPreferences1 = workPart.Annotations.Preferences.GetLineAndArrowPreferences()
        lineAndArrowPreferences1.FirstArrowType = Annotations.ArrowheadType.FilledDot
        lineAndArrowPreferences1.DotArrowheadDiameter = 1.25
        workPart.Annotations.Preferences.SetLineAndArrowPreferences(lineAndArrowPreferences1)
        lineAndArrowPreferences1.Dispose()

        ufs.View.MapModelToDrawing(dwgview.Tag, objectpoint, pnt1)
        Dim nullAnnotations_SimpleDraftingAid As Annotations.SimpleDraftingAid = Nothing
        Dim draftingNoteBuilder1 As Annotations.DraftingNoteBuilder
        draftingNoteBuilder1 = workPart.Annotations.CreateDraftingNoteBuilder(nullAnnotations_SimpleDraftingAid)

        draftingNoteBuilder1.Style.LetteringStyle.GeneralTextSize = 5.0
        Try 
            draftingNoteBuilder1.Style.LetteringStyle.GeneralTextColor = workPart.Colors.Find("YELLOW")
        Catch
            draftingNoteBuilder1.Style.LetteringStyle.GeneralTextColor = workPart.Colors.Find("Yellow")
        End Try
        draftingNoteBuilder1.Style.LetteringStyle.GeneralTextLineWidth = Annotations.LineWidth.Thick


        text1(0) = PosNr
        draftingNoteBuilder1.Text.TextBlock.SetText(text1)
        draftingNoteBuilder1.Origin.SetInferRelativeToGeometry(True)
        Dim leaderData1 As Annotations.LeaderData = workPart.Annotations.CreateLeaderData()
        leaderData1.StubSize = 0
        leaderData1.Arrowhead = Annotations.LeaderData.ArrowheadType.FilledArrow

        draftingNoteBuilder1.Leader.Leaders.Append(leaderData1)
		Dim coordinates1 As Point3d = New Point3d(pnt1(0), pnt1(1), 0.0)
        Dim point1 As Point = workPart.Points.CreatePoint(coordinates1)
		Dim assocOrigin1 As Annotations.Annotation.AssociativeOriginData
        Dim nullView As View = Nothing 
		leaderData1.Leader.SetValue(point1, nullview, Nothing)
		Dim point2 As Point3d = New Point3d(cursor.X, cursor.Y, 0.0)
		draftingNoteBuilder1.Origin.Origin.SetValue(Nothing, nullView, point2)
	
        Dim nXObject1 As NXObject
        nXObject1 = draftingNoteBuilder1.Commit()
        draftingNoteBuilder1.Destroy()

        i = i + 1
        GoTo Start1
End1:
        workPart.Preferences.ObjectPreferences.SetWidth(Preferences.PartObject.ObjectType.General, Preferences.PartObject.WidthType.NormalWidth)
    End Sub


    Public Function SelectScreenPos(ByRef pos As Point3d) As Selection.DialogResponse
        Dim view As NXOpen.View = Nothing
        Dim letteringPrefs As LetteringPreferences = Nothing
        Dim userSymPrefs As UserSymbolPreferences = Nothing
        Return ui.SelectionManager.SelectScreenPosition("Geben Sie die Position der Pos.Nr. an!", view, pos)
    End Function



    Function select_a_drawing_member_view(ByRef dwgview As Drawings.DraftingView)
        Dim mask(0) As Selection.MaskTriple
        With mask(0)
            .Type = UFConstants.UF_view_type
            .Subtype = UFConstants.UF_all_subtype
            .SolidBodySubtype = 0
        End With
        Dim cursor As Point3d = Nothing
        Dim vw As View = Nothing
        Dim resp As Selection.Response = ui.SelectionManager.SelectObject("Wählen Sie eine Ansicht aus.", "Wählen Sie eine Ansicht aus.", 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, Drawings.DraftingView)

            Return Selection.Response.Ok
        Else
            Return Selection.Response.Cancel
        End If
    End Function

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

End Module 


In NX6 the Journal worked fine, but in NX8.5 it always puts the Terminating Object of the Leader into the buttom left corner of the drawing sheet.
Do you have an idea what I have to change?
I tried a lot with pnt1 etc. but without any luck...I'm stuck now.
I hope someone can give me a hint :)

Cheers,
Christian

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