Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

Journal DraftingNoteBuilder NX8.5

Status
Not open for further replies.

Scarpafico

Mechanical
Joined
Jan 30, 2014
Messages
1
Location
DE
Hi everyone,

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

Code:
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

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top