Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

NX1969 - Help adapting a Journal Please

Status
Not open for further replies.

Kenja824

Automotive
Nov 5, 2014
949
I have a journal that automatically looks for any notes on the drafting sheet that says "PRELIMINARY" and deletes them.

I am trying to adapt it to look for the "AUTH" note and instead of deleting it, to change it to...
AFFECTED
TEMPLATES

It also needs to change the settings to be centered and have a 2.0 height instead of Left and 2.88 hgt.

I recorded making such a change manually and have been trying to make the changes accordingly.

Currently, I keep getting this error....

Line 39 : Value of type '1-dimensional array of String' cannot be converted to 'NXOpen.Annotations.SimpleDraftingAid'.

My understanding is that the original journal used simple one line of text and it is not able to handle two lines?

Could someone help me with what else I need to change?

Code:
Option Strict Off
Imports System
Imports NXOpen

Module Module1

    Sub Main()

        Dim theSession As Session = Session.GetSession()
        If IsNothing(theSession.Parts.Work) Then
            'active part required
            Return
        End If

        Dim workPart As Part = theSession.Parts.Work
        Dim lw As ListingWindow = theSession.ListingWindow
        lw.Open()

        Const noteText As String = "AUTH"

        For Each tempNote As Annotations.Note In workPart.Notes


            'Dim tempText() As String = tempNote.GetText
            'If tempText(0) = noteText Then


            Dim text1() As String = tempNote.GetText
            If text1(0) = noteText Then


                Dim draftingNoteBuilder1 As NXOpen.Annotations.DraftingNoteBuilder = Nothing

                '            Dim text1(1) As String
                text1(0) = "AFFECTED"
                text1(1) = "TEMPLATES"
                draftingNoteBuilder1.Text.TextBlock.SetText(text1)

                draftingNoteBuilder1 = workPart.Annotations.CreateDraftingNoteBuilder(text1)

                draftingNoteBuilder1.Text.TextBlock.CustomSymbolScale = 1.0

                draftingNoteBuilder1.Origin.SetInferRelativeToGeometry(True)

                '***************************************************************
                'Dim notifyOnDelete1 As Boolean
                'notifyOnDelete1 = theSession.Preferences.Modeling.NotifyOnDelete

                'theSession.UpdateManager.ClearErrorList()

                'Dim markId1 As Session.UndoMarkId
                'markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Delete")

                'Dim nErrs1 As Integer
                'nErrs1 = theSession.UpdateManager.AddToDeleteList(tempNote)

                'Dim notifyOnDelete2 As Boolean
                'notifyOnDelete2 = theSession.Preferences.Modeling.NotifyOnDelete

                'Dim nErrs2 As Integer
                'nErrs2 = theSession.UpdateManager.DoUpdate(markId1)
                '**************************************************************

            End If
        Next
        lw.Close()

    End Sub
End Module

Ken
My brain is like a sponge. A sopping wet sponge. When I use it, I seem to lose more than I soak in.
 
Replies continue below

Recommended for you



Hi
Below is the C# journal finds an annotation text "REPLACEME" and replaces it with "NEWTEXT". Let me know
if you need more help
ramkan8@gmail.com

=============================================================================================================================

using System;
using NXOpen;
using NXOpen.Drafting;
using NXOpen.Drawings;
using NXOpen.Annotations;

public class NoteReplace
{
public static void Main(string[] args)
{
Session theSession = Session.GetSession();
Part workPart = theSession.Parts.Work;
Part displayPart = theSession.Parts.Display;
ListingWindow lw = theSession.ListingWindow;

NoteCollection allNots = workPart.Notes;
lw.Open();

foreach (Note n in allNots)
{
string[] sts = n.GetText();

foreach (string s in sts)
{

if (s.ToString()=="REPLACEME")
{
lw.WriteFullline(s.ToString());
repl(n);
}

}

}


}
public static void repl (Note m){

string[] nt = { "NEWTEXT" };

m.SetText(nt);


}
public static int GetUnloadOption(string dummy) { return (int)NXOpen.Session.LibraryUnloadOption.Immediately; }
}
 
Thanks Ram K

Unfortunately, I am feeling like I stepped on a land mine and all the vultures (bosses) are digging at me for my scraps. Things have gotten so chaotic I feel wrong for even spending the time responding to this much less digging into that button. As soon as things settle a little, I will dig in and see how it works. The sad part is this would only make my job quicker, but I dont have time to play with it. lol Doesnt it figure? lol

Thank you for your help.

Ken
My brain is like a sponge. A sopping wet sponge. When I use it, I seem to lose more than I soak in.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor