vb.net question
vb.net question
(OP)
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
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





RE: vb.net question
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
www.xtremedotnettalk.com
Mark Benson
Aerodynamic Model Designer
RE: vb.net question
Bob
RE: vb.net question
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
RE: vb.net question
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
RE: vb.net question
www.xtremedotnettalk.com"
This site form my original post not the bbs. Sorry for the confusion.
Mark Benson
Aerodynamic Model Designer
RE: vb.net question
Thanks
RE: vb.net question
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
RE: vb.net question