Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

VB Code Options? Lists?

Status
Not open for further replies.

Kenja824

Automotive
Nov 5, 2014
949
I am not sure of the correct way to word this. When you start a journal, you have the Imports at the top. For example, you might have Imports NXOpen.

Is there anyplace one can go to find a list of all the options that might be used with NXOpen? As well as other Import functions?
 
Replies continue below

Recommended for you

Just search 'journal' in this forum
and you will find many examples.
 
But wouldnt that only give me examples of the ones used here so far? Couldnt there be plenty of uses in NXOpen that are not used in this forum yet? And if they are used, that can be very difficult to scroll through pages and pages of posts in this forum when often the headlines dont fully explain what are in the posts. Is there not some kind of list created for everything you can use with NXOpen?

In all honesty, this is not for me. Another gentleman here is trying to create code and was frustrated that he couldnt find any kind of list of uses. I am such an amateur with code that I am only relaying what I believe he is looking for because I have been on here for my own help so much. He understands it more than I do but even he is pretty much self taught and still learning it. So if my question doesnt make full sense this is why.

For example, I am right now trying to manipulate some code to simply open "Information Object" and set the filter to "Point". Then just let the operator select a couple points and hit OK and it will give him the information window with everything on that point. This is easy enough to do without code, I know, but we have a group here that does it so much that it would save them the hassle of having to go in and set the filter every time. One click on a button, select your points, and hit OK. The problem is the code I have to manipulate was for selecting a cylindrical face and would automatically add specific attributes to the face. I have spent hours trying to make changes and get it to work but I get some kind of error every time. It would be so much easier if there were some lists out there that one could look up and see what functions or whatever they need to use or can use with different areas in the code. ..... I am sure you are probably chuckling by now at my terminology and how lost I seem. lol

Then once I get this code figured out, I have to manipulate that to select solid bodies. Which will be easier because at least the code will be using the same functions this time and just selecting different types.
 
When writing code, it is very common to make use of code that someone else has written. Assuming that I have an NX .net author license, I can open my code project and add a reference to other code such as Excel or windows media player and make use of the functionality it provides. After I add a reference, I can add an "imports" statement to my code to make those external objects easier to access. For instance, I often make use of List objects in my code. The list object is provided by the .net framework; in the .net library hierarchy, it is a System.Collections.Generic.List object. If my code imports the System namespace, I would declare a new list like so:
Code:
Imports System

dim myList as New Collections.Generic.List(of String)

However, I can shorten that if I import the System.Collections.Generic namespace:
Code:
Imports System
Imports System.Collections.Generic

dim myList as New List(of String)

The imports statement does not create the reference, it simply gives you an alias to make the code easier to read and write. If you do not have an NX author license and you are writing journals, NX will automatically link you to some of the .net libraries. You will be limited to those libraries and cannot add references to others. The ones you have access to can be found here (near the bottom of the page).

If you are looking specifically for NXOpen functionality, check out the .net reference guide. It lists all the objects and functions that the NXOpen API gives you access to. However, there is no single, comprehensive list of ALL other code that you could possibly link to (it would be huge, and much would not be relevant to use with NX).

Here is a few links about references and the imports statement:

www.nxjournaling.com
 
Thank you both of you. Hopefully this is what he is looking for. I know I am going to learn what I can from this info myself.
 
The question is hard to answer. On the one hand you can import any namespace or class that's in a library referenced by your project. So, if your project has a reference to NXOpen, then you can import any namespace or class in NXOpen. There are hundreds of them. They're listed in the NXOpen Reference Guide. Same with the SNAP Reference Guide.

On the other hand, you don't actually need to import anything. The import facility just lets you use shorter names. You can always type the full (long) names instead, if you want to. In fact some people recommend coding this way, since it makes it completely clear what functions are being called.

There is a simple explanation of this stuff in the "Getting Started with SNAP" guide that ships with NX. In fact, there is whole chapter that covers the basics of the VB language.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor