Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Journal VB Select Symbol in Drawing

Status
Not open for further replies.

Steve_Looud

Computer
Jul 4, 2019
2
Hey,
i am fairly new with VB and journals for NX.
But i have modified many codes found in the internet, to my needs.
Will say, i have some experience in reading and understanding the VB code and also modifieing it.

But now i came to a point, where i found no solution.

I want to have a Journal that should do the following (absolute minimalized) in a Drawing:
1. Start the Journal
2. Give the User a Selection only for Symbols
3. .... Do something

We use Symbols out of the Symbol-Library (next to the Reuse Library) in our Drawings.
The Symbols are placed manually directly in the Drawing-Sheet (SHEET-1) and also placed combined to a Drawing-View.
If you add a Symbol to a Drawing, there is a Button where you can say to with View this Symbol should be added.
The same effect came up, if you place the Symbol in the View with expand mode.

Every Code out there will allow the selection of Symbols that are placed in the Drawing-Sheet (Sheet-1).
But all of the Codes will not allow the selection of a Symbol that is combined to a Drawing-View.
If i go in expand mode, all of the codes will select the Symbols ...
But i want to open a Drawing, start my journal and select a Symbol that is placed in the expand mode.

If i do this manually i can select everything. Recording this will give me some crap code. I can not read out anything for my selection problem.

So, did anyone here have an idea, how to select a Symbol in a Drawing-View?
If you have questions to me .... I will answer shortly ;)
Thank you.

Regards, Steve

 
Replies continue below

Recommended for you

To be honest I have no idea...
Just curious why you would want to place a symbol in the expand mode of a view...

Ronald van den Broek
Senior Application Engineer
Winterthur Gas & Diesel Ltd
NX9 / TC10.1.2

Building new PLM environment from Scratch using NX12 / TC11
 
Hello,
thank you for your feedback.

@Ronald:
You can place a Symbol with an "Annotation View". Please see my attachement.
The right Symbol without defining the Annotation View can be selected with nearly every code i found.
The left Symbol with a defined Annotation View can not be selected. This one is my problem.

For information: defining a Annotation View or placing a Symbol in expand mode will result in the same situation. Doing it in expand mode, the annotation view will defined automatically.

@ Ehaviv:
Thank you for your link. I know this ... and it will not help me out. Really i spend a lot of time, searched and read everything i found, before i wrote this thread.

Anyone else with a good idea?

Regards, Steve
 
 https://files.engineering.com/getfile.aspx?folder=2cb11b93-805e-4a40-8a0d-e0d1f3e5a703&file=annotation_view.jpg
Try using the .SetCursorView method; .SetCursorView(0) will allow you to select from any view (not just the work view, which is the default). Below is GTAC sample nx_api4849; I modified it by adding a call to .SetCursorView in the selection function. It seems to do what you want.

Code:
'GTAC example nx_api4849
'author Frank Berger

Imports System

Imports NXOpen
Imports NXOpen.Annotations
Imports NXOpen.Assemblies
Imports NXOpenUI
Imports NXOpen.Utilities
Imports NXOpen.UF

Module report_selected_custom_symbol

  Dim s As Session = Session.GetSession()
  Dim ufs As UFSession = UFSession.GetUFSession()
  Dim ui As UI = UI.GetUI()
  Dim lw As ListingWindow = s.ListingWindow
  Dim wp As Part = s.Parts.Work

    Sub Main()
        Dim cs1 As CustomSymbol = Nothing
        Dim comp As Component = Nothing
        lw.Open()

        While select_a_custom_symbol(cs1) = Selection.Response.Ok

            Dim dcsb1 As Annotations.DraftingCustomSymbolBuilder
            dcsb1 = wp.Annotations.CustomSymbols.CreateDraftingCustomSymbolBuilder(cs1)
            lw.WriteLine(vbCrLf + "MasterSymbolName: " & dcsb1.MasterSymbolName )
            lw.WriteLine("MasterSymbolPath: " & dcsb1.MasterSymbolPath)
            lw.WriteLine("Scale: " & dcsb1.Scale.Value.ToString)

            Dim textlist As MasterSymbolListItemBuilderList = dcsb1.Texts
            lw.WriteLine(vbCrLf + "MasterSymbolListItemBuilderList Length: " & textlist.Length.ToString() )

            Dim contents() As MasterSymbolListItemBuilder = textlist.GetContents()
            Dim count = contents.Length
            lw.WriteLine(vbCrLf + "Number of MasterSymbolListItemBuilderList Contents: " & count.ToString() )

            For ii As Integer = 0 to count-1

                lw.WriteLine(String.Format(vbCrLf + "{0,-10}{1,-30}{2,-30}{3,-20}", 
                    "Content", "NoteTitle", "NoteText", "TextType"))

                lw.WriteLine(String.Format("{0,-10}{1,-30}{2,-30}{3,-20}", 
                    ii.ToString, contents(ii).NoteTitle, 
                    contents(ii).NoteText,contents(ii).TextType.ToString))

                lw.WriteLine(vbCrLf + "  MultilineStrings:")
                Dim multiText() As String = contents(ii).GetMultilineString()
                For jj As Integer = 0 To multiText.Length-1
                    lw.WriteLine("  " + jj.ToString + ". MultilineString: " & multiText(jj))
                Next

            Next

            Dim nXObject1 As NXObject = dcsb1.Commit()
            dcsb1.Destroy()

        End While

    End Sub

    Function select_a_custom_symbol(ByRef obj As CustomSymbol) As Selection.Response

        ufs.Ui.SetCursorView(0)

        Dim mask(0) As Selection.MaskTriple
            With mask(0)
            .Type = UFConstants.UF_drafting_entity_type
            .Subtype = UFConstants.UF_draft_user_defined_subtype
            .SolidBodySubtype = 0
            End With
        Dim cursor As Point3d = Nothing
        Dim prompt As String = "Select a custom symbol"

        Dim resp As Selection.Response = _
            ui.SelectionManager.SelectObject(prompt, prompt, _
            Selection.SelectionScope.AnyInAssembly, _
            Selection.SelectionAction.ClearAndEnableSpecific, _
            False, False, mask, obj, cursor)

        If resp = Selection.Response.ObjectSelected Or _
           resp = Selection.Response.ObjectSelectedByName Then
            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

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

Part and Inventory Search

Sponsor