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!

vb.net question

Status
Not open for further replies.

smitty239

Automotive
Jan 4, 2007
60
Hi Guys
Just starting to look at vb.net to change all the grip we have and need some help from all the programmers out there. How do I take an assembly write all the names to memory or a file and then begin to make each part the displayed part while I do other things to it and then cycle to the next file. this was very easy in grip and in vb or kf or c+ it seems very longwinded and criptic not to mention the documentation on all of this *****. sorry I don't want to ofend anyone. If anyone can help or point me in the right direction it would be appreciated.


Bob
 
Replies continue below

Recommended for you

Here's a stripped down version of something I've used.
Think it originally came from the GTAC website

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.Assemblies
Module NXJournal

Dim Session As Session = Session.GetSession()



Sub Walk(c As Component, level As Integer)
Dim children As Component() = c.GetChildren()
Dim child As Component
Dim prototype As Part
If TypeOf c.Prototype Is Part Then
prototype = CType(c.Prototype, Part)
session.ListingWindow.WriteLine(New String(" "C, level) & prototype.FullPath & " " & prototype.Leaf & " " & c.Name)
msgbox("do stuff here") ' add lines to write to a file or an array

For Each child In children
Walk(child, level + 1)
Next


Else
session.ListingWindow.WriteLine(New String(" "C, level) & c.Name & " is not loaded")
End If
end sub

Sub Main
session.ListingWindow.Open
Dim part1 As Part

part1 = session.Parts.Work
Dim c As ComponentAssembly = part1.ComponentAssembly


Walk(c.RootComponent, 0)
End Sub





End Module




A good vb.net website for help on non UG .net stuff



Mark Benson
Aerodynamic Model Designer
 
thank you it will get me started I appreciate it. Is there anywhere else to get info on vb.net for ug other than the gtac doc's? Is it better to learn vb.net first and then start writing for ug apps? your comments would be appreciated


Bob
 
Understanding. net will help. I knew a little VB6 before I started journalling and a little grip as well.
There are some examples on the UG answers part of the UGS website. If you have a webkey you can access this.
There's also the UGS BBS website. There's a seperate area for programming languages there and some very helpful people who helped me out a great deal.
There are a few examples of .net programs in your install directory "\UGS\NX3.0\UGOPEN\SampleNXOpenApplications"
some of which you can disect and graft into your own apps.

Some basics that you'll probably need to look at on the website I posted are :
i)arrays
ii)system i/o commands (streaming to files and general file maintainance)

These aren't really covered in the UG docs.

Hope that all helps,


Mark Benson
Aerodynamic Model Designer
 
thanks for the info however I was not able to find anything on the bbs covering
Some basics that you'll probably need to look at on the website I posted are :
i)arrays
ii)system i/o commands (streaming to files and general file maintainance

can you be a little more specific as to it's location


Thanks
Bob
 
would you have a sample program that does more than just cycle the components I am trying to get my head around how to do multiple things and keep the code simple. most ug samples do only one thing and it's pretty hard to see how you put it all together. Also what about taking the code you gave me and putting it in an exe file or dll so you can use the full function of windows forms and the .net type of programing instead of just the journal entry. The ug help files don't tell you much about making forms. again any help would be great


Thanks
 
Smitty,

I don't have anything with that code with extra routines in it. I just stripped it down from an example I found on the uganswers website.
The key to simplifying your code is to break things down into more and more sub routines. This way you can re-use the subs over and over again and you only need to modify the code in one place.
I often write my code and then go through simplification exercises as it evolves, breaking out areas of code into subs as I go along.

As for compiling the journal. The only things I've found that you gain from compiling is being able to use the journal as a user exit and being able to run the journal outside of UG. As far as I'm aware you can get the full use of forms in journals uncompiled. I've used forms for GUI's on a few occasions to help when entering larger amounts of user inputs. Uncompiled journals are not limitted to specific UG code. Commands and examples you find on other .net sites should work (you may just need to declare something in the "imports" section to make them available)
You need to buy a license to compile journals.

Have a look at the sketch shape example in the ugopen directory. It uses multiple sheets and has combo boxes and images but is a single uncompiled journal.

The example is quite complicated especially the way it passes variables from one area of the code to another.
To create my first bit of code with a form I stripped out what wasn't required from this example and eventually created a very simple form with 2 buttons (an option box).

Hope that's helpful,


Mark Benson
Aerodynamic Model Designer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor