Moving Notes (Annotation) via VB in NX7.5
Moving Notes (Annotation) via VB in NX7.5
(OP)
Hello,
Currently, I'm able to move notes (annotation) on a single sheet where the notes reside depending upon the x and y-coords. But if there are multiple sheets (i.e. "SH1", "SH2", etc.), is there a method to identify the sheets the notes are on?
My plan is to be able to have the user properly reposition the general notes on the first sheet ("SH1") with a single click that would automatically align notes (i.e. - "1", "2", "<%T03>", "<%T04>", “5”, etc., where the "<%T0xx>" represents that the note is a flag note) in one column based upon their x-coord. And then it would align notes in the second column first based upon their x-coords followed by their y-coords and number of lines. And finally, the program would adjust the first column's notes based upon the y-coords of the second column. I believe I can set up several if-then conditional statements as well as sub-routines and using the VB Array.Sort command to move notes having reviewed the auto-recorded VB code for moving notes by a specific value in NX7.5. But since there will be notes in the same x and y-coord zones other than on the first sheet, I would like to avoid moving notes on the preceding sheets accidentally.
Thank you for your help ahead of time.
Currently, I'm able to move notes (annotation) on a single sheet where the notes reside depending upon the x and y-coords. But if there are multiple sheets (i.e. "SH1", "SH2", etc.), is there a method to identify the sheets the notes are on?
My plan is to be able to have the user properly reposition the general notes on the first sheet ("SH1") with a single click that would automatically align notes (i.e. - "1", "2", "<%T03>", "<%T04>", “5”, etc., where the "<%T0xx>" represents that the note is a flag note) in one column based upon their x-coord. And then it would align notes in the second column first based upon their x-coords followed by their y-coords and number of lines. And finally, the program would adjust the first column's notes based upon the y-coords of the second column. I believe I can set up several if-then conditional statements as well as sub-routines and using the VB Array.Sort command to move notes having reviewed the auto-recorded VB code for moving notes by a specific value in NX7.5. But since there will be notes in the same x and y-coord zones other than on the first sheet, I would like to avoid moving notes on the preceding sheets accidentally.
Thank you for your help ahead of time.





RE: Moving Notes (Annotation) via VB in NX7.5
I am not at work now, so I can't get too much in detail.
RE: Moving Notes (Annotation) via VB in NX7.5
But my employer has strict guidelines, in which the general notes on the first sheet have to 1) be separated, 2) have a specific gap between each note depending on its contents, 3) not use sketches (can you believe it), and 4) not use tables (can you believe it again). Subsequently, writing a VB program would be incredibly helpful. And the last part of the program I'm attempting to build is figuring out if the note is on sheet 1 (or "SH1") or some other sheet. If you know how to make that differentiation with an NX7.5 variable, I would appreciate that very much.
Thank you for your help.
RE: Moving Notes (Annotation) via VB in NX7.5
www.nxjournaling.com
RE: Moving Notes (Annotation) via VB in NX7.5
I searched in several places for AskViewDependentStatus within NX7.5's help and could not locate this method. So then I performed a Google search and was able to locate it via http://www.nxjournaling.com/?q=content/w36754. The only issue is that the AskViewDependentStatus method appears to only work for NX8 and possibly higher versions. I'll definitely save this link if my company ever purchases NX8 or the latest version. But would you happen to know of a method or variable that will work with NX7.5, which indicates the drawing sheet a note resides on?
Thank you again for your help.
RE: Moving Notes (Annotation) via VB in NX7.5
Below is a sample journal (works in NX 7.5). For notes placed directly on the drawing sheet, the "view name" will contain the name of the sheet. For example, a note on "Sheet 1" will be reported something like: "view name: Sheet 1@0". If you drop the "@" character and everything after it, you will be left with the sheet name.
CODE
Option Strict Off Imports System Imports NXOpen Imports NXOpen.UF Module Module1 Sub Main() Dim theSession As Session = Session.GetSession() Dim theUfSession As UFSession = UFSession.GetUFSession Dim workPart As Part = theSession.Parts.Work Dim lw As ListingWindow = theSession.ListingWindow lw.Open() For Each tempNote As Annotations.Note In workPart.Notes lw.WriteLine("tempNote.Tag: " & tempNote.Tag.ToString) lw.WriteLine("note text (1st line): " & tempNote.GetText(0)) Dim status As Integer Dim viewName As String theUfSession.View.AskViewDependentStatus(tempNote.Tag, status, viewName) lw.WriteLine("status: " & status.ToString) lw.WriteLine("view name: " & viewName) lw.WriteLine("") Next End Sub End Modulewww.nxjournaling.com
RE: Moving Notes (Annotation) via VB in NX7.5
I also searched through the NX main help -> programming tools section and could not locate it. I'm thinking certain help files were simply not installed on the server. I'll have to ask the IT guys.
But while I was searching, I did come across something I've been searching for over a year, which is to finally be able to take a VB program and compile it into an .exe file so that the VB programs running in NX will start faster (already having been compiled) and not allow anyone to accidentially tamper with them. The only issue, here, is that I came across the actual command of vbc /libpath:%UGII_ROOT_DIR%\managed /t:exe /r:NXOpen.dll /r:NXOpen.Utilities.dll /r:NXOpen.UF.dll <application>.vb, which is in the below help. By any chance, would you be able to help me to decifer this since I was only able to get to the NX command prompt and enter vbc, which gives a diferent set of options?
Please see below and attached file.
Thank you again.
_______________________________________________________________________________________________________________________________
Compiling and linking NX Open for .NET
--------------------------------------------------------------------------------
All .NET libraries included with NX are found in: <NX install directory>\UGII\managed\
The following table show the library names and provides a description for when to use the library.
.NET Library Name
Purpose
NXOpen.dll
Contains base functionality that can be used in batch or interactive applications.
NXOpen.Utilities.dll
Contains utility functionality that can be used in batch or interactive applications.
NXOpenUI.dll
Contains User Interface functionality that can only be used in interactive applications.
NXOpen.UF.dll
Contains .NET wrapped user function for use in batch or interactive applications. Only use this library if the application requires access to the classic API.
The following table shows the types of executables that are used by .NET applications.
Executable Type
File Extension
When Used
Dynamically Loadable Library
.dll
Interactive Applications
Executable File
.exe
Batch Applications
Other .NET Libraries
Another library in the UGII\managed directory is ManagedLoader.dll. This library is for internal use and should not be included with any NX Open application.
Other files in the UGII\managed\ directory are: NXOpen.Utilities.xml, NXOpen.xml and NXOpenUI.xml. These files are used by Visual Studio and other development tools to provide documentation. For more information see: Browsing the Class Hierarchy
Command Line
The Microsoft .NET Framework SDK includes compilers for all of the .NET languages. For instance, vbc.exe is available to compile Visual Basic and csc.exe is available to compile C#. These compilers take .NET source files as input and produces a .dll file which can be loaded and executed interactively by NX. The .NET compilers can also produce .exe files, which are used for batch applications.
For example, assuming the directory for vbc.exe and csc.exe is included in the active PATH and that UGII_ROOT_DIR = <NX install directory>\UGII\, the following commands could be used to create .NET interactive executables (<application>.dll) on Windows:
Creating Class Library
vbc /libpath:%UGII_ROOT_DIR%\managed /t:library /r:NXOpen.dll /r:NXOpen.Utilities.dll /r:NXOpen.UF.dll <application>.vb
csc /libpath:%UGII_ROOT_DIR%\managed /t:library /r:NXOpen.dll /r:NXOpen.Utilities.dll /r:NXOpen.UF.dll <application>.cs
Creating Executable (Batch Program)
To create a batch application executable (<application>.exe) set the /t option to "exe" instead of "library". For example:
vbc /libpath:%UGII_ROOT_DIR%\managed /t:exe /r:NXOpen.dll /r:NXOpen.Utilities.dll /r:NXOpen.UF.dll <application>.vb
csc /libpath:%UGII_ROOT_DIR%\managed /t:exe /r:NXOpen.dll /r:NXOpen.Utilities.dll /r:NXOpen.UF.dll <application>.cs
Using Visual Studio for .NET Development
Visual Studio is a very popular development environment from Microsoft. The following is a check list for using Visual Studio to develop NX Open applications. For more information on Visual Studio see the Microsoft Developer Network webpage.
Make sure that the Microsoft .NET Framework SDK supported by your version of Visual Studio is compatible with that required by the target NX release. You can find the .NET Framework requirements for NX in NX Open System Information.
For interactive applications (.dll executable) use the Class Library or Windows Application project templates when creating the project.
For batch applications (.exe executable) use the Console Application template when creating a the project.
To add the .NET libraries found in UGII\managed (described above) select the project in the Solution Explorer. Using the right mouse button select the Add References... menu item. Using the Browse tab locate the NX Open .NET libraries and add the libraries required by the application.
By default Visual Studio will copy referenced libraries to the project directories. If copies of the NX Open libraries are not wanted then select each library from the list of project references and in the Properties window set the Copy Local property to False.
For batch applications make sure the entry point is set to the desired method. The Entry Point property is found under project properties → Linker → Advanced.
Using NX Open Visual Studio Wizard
NX provides visual studio wizard to build NX Open applications using visual studio. The wizard sets up the necessary options in visual studio for NX Open applications. For more information on how to install the wizard see: Visual Studio Application Wizard Setup