Cancel
Showing results for 
Search instead for 
Did you mean: 

Automatically change drawing notes

Creator
Creator

Is there a way to change all the notes on a drawing that use or have <W@DB_PART_NAME> in it to something else, using Journal functionality?

10 REPLIES

Re: Automatically change drawing notes

Esteemed Contributor
Esteemed Contributor

I have a journal "Replace_Text_In_Note.vb" that (from my comments in the file header) I stole from Frank Swinkels at

http://www.eng-tips.com/viewthread.cfm?qid=311028

 

You should be able to modify it to search for your fixed string easily enough (or just use it "as is")

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Re: Automatically change drawing notes

Creator
Creator

I'll try it out it

Thanks Ken!

Re: Automatically change drawing notes

Creator
Creator

Unfortunately that didn't seem to want to work on  <W@DB_PART_NAME> but did on simple text.

Re: Automatically change drawing notes

Legend
Legend

The drafting note for <W@DB_PART_NAME> is linked to an attribute DB_PART_NAME.  Correct me if I am wrong but if we change the attribute then all notes using that attribute would be changed.  IF, however, you need to select certain notes that use this attribute and change some but not all then a journal is possible to do that.  The reason that the tried journal does not work because the journal checks the note text for the input word which in this case is not the part name.  Also you need to let me know what version of NX you are working on because of different formats for  <W@DB_PART_NAME>

 

Frank Swinkels

Re: Automatically change drawing notes

Esteemed Contributor
Esteemed Contributor

Frank -

Does the program check the "displayed text" or the "actual text" (i.e. what you see in the note editor window)?

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Re: Automatically change drawing notes

Creator
Creator

Currently using NX9.  What I like to do is take a note that has something like <W@DB_PART_NAME>  and change it to something like <W@DWG_NUMBER>.  Then these attribute would populate the text.  I would say something that checks the actual text would work.

Re: Automatically change drawing notes

Legend
Legend

Ken

Yes the original program used the displayed text.

 

Below is a journal which I tested against notes only.  When asked for the text to change I show the default value as DB_PART_NAME and the replacement name as DWG_NUMBER.

 

If you have other names then the names to use would be everything after the "@" in the note text.

If the input text string does not exist as an attribute then no notes would be found.  If the output text string does not exist as an attribute the the note would become empty.

 

This is a first approach.  I think it might be more useful to have a program in which a user selects a note.  The program would check if it is linked to an expression.  If it is then a list of DB attributes could be shown to all the user to select one of the attributes.  Finally the program would then check for any other notes with the same text string.

 

Remember it only works on notes.

 

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Imports NXOpen.Utilities
Imports NXOpen.Annotations

Module Module1
    Dim s As Session = Session.GetSession()
    Dim ui As UI = UI.GetUI()
    Dim ufs As UFSession = UFSession.GetUFSession()
    Sub Main()
        Dim s As Session = Session.GetSession()
        Dim dp As Part = s.Parts.Display
        Dim nc As NoteCollection = dp.Notes
        Dim notetext1 As String = "DB_PART_NAME"
        notetext1 = NXInputBox.GetInputString("Change Note", "Note word to be changed", notetext1)
        Dim notetext2 As String = "DWG_NUMBER"
        notetext2 = NXInputBox.GetInputString("Change Note", "New note word", notetext2)
        Dim notestring() As String
        Dim nolines As Integer = 0
        Dim found1 As Boolean = False
        Dim m1 As Session.UndoMarkId = s.SetUndoMark(Session.MarkVisibility.Visible, "M1")
        For Each a_note As SimpleDraftingAid In nc
            notestring = a_note.GetText()
            nolines = notestring.Length
            For i As Integer = 0 To nolines - 1
                found1 = notestring(i).Contains(notetext1)
                If found1 = True Then
                    notestring(i) = notestring(i).Replace(notetext1, notetext2)
                End If
            Next
            a_note.SetText(notestring)
        Next
        s.UpdateManager.DoUpdate(m1)
    End Sub


    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

    End Function

End Module

Frank Swinkels

 

Re: Automatically change drawing notes

Creator
Creator

Frank,

Thanks for your help on this also.  This seems to be working pretty good for me now.

Re: Automatically change drawing notes

Creator
Creator

I recent got this running that program:

 

Runtime error:

NXOpen.NXException: Invalid text

at NXOpen.Annotations.SimpleDraftingAid.SetText(String[] lines)

at Module1.Main() in C:\Temp\AppData\Local\Temp\NXJournals10708\journal0.vb:line 38

 

Any thoughts?