Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

NXOpen VB.net programs 1

Status
Not open for further replies.

fddd

Mechanical
Jan 19, 2011
4
Hi,

I made some GRIP prgms but now I would like to
switch to VB.NET . . .

To start learning I would like to create 1 point on the screen at x=10, y=20, z=30

In GRIP I write it in this way :
ENTITY/PT1
PT1=POINT/10,20,30

My question : How is it write in NXOpen VB.NET

remark : I have VB.NET Express 2010 Framework 4
Thanks very much for your help





 
Replies continue below

Recommended for you

A great way to start is to begin the journal recorder, create your point, close the journal recorder, and check out the code it generated.
 
Following is a VB code snippet for one method of creating a point object in NX.

Dim ufs As UFSession = UFSession.GetUFSession()
Dim pointTag As NXOpen.Tag = Tag.Null
Dim point1() As Double = {10.0, 20.0, 0.0}

ufs.Curve.CreatePoint(point1, pointTag)

FrankSwinks
 
Thanks cowski and FrankSwinks,
I am very novice with VB.NET . . .

Another question:

I tried to put this code into the journal

' NX 6.0.5.3

Option Strict Off
Imports System
Imports NXOpen

Module NXJournal
Sub Main()

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work

Dim displayPart As Part = theSession.Parts.Display

Dim coordinates1 As Point3d = New Point3d(10, 20, 30)
Dim point2 As Point
point2 = workPart.Points.CreatePoint(coordinates1)

point2.SetVisibility(SmartObject.VisibilityOption.Visible)

point2.RedisplayObject()

End Sub
End Module

And it works . . . I am happy

But when I put the same code into VB.NET Express 2010 IDE
At the debugging, I have this error !!!

Unable to load DLL 'libpart': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

The error is on this line : Dim theSession As Session = Session.GetSession()

What's wrong ???

Is there a special configuration to set into the IDE to use it with NX ?

Thank a lot in advance
 
To debug an NXOpen program you need to do the following:

1. Start NX
2. Start VS with the project you want to debug
3. Create one or more break points in the project
4. In VS choose Debug->Attach to Process...
5. Choose ugraf.exe from the list of processes.
6. In NX start running your project in whatever way you want (eg File->Execute->NX Open)
7. When one of the breakpoints gets reached NX will hang while you step through the code.
8. When you want to stop debugging, in VS choose Debug->Detach All

I find this rather painfull so that when developing programs I typically list out values (using the NX listing window and create points to see how things are going.

By the way the reason I used the wrapper function for creating the point object was to demonstrate it with the minimum number of lines of code.

FrankSwinks
 
I have the same problem when I try to run any thing...even the code generated by the nx7 wizard...am really stuck...can anyone help me please?

 
hi!
I have a problem accessing any kind of info from a session.

I always get a null ref exception whenever I try to access anything (part etc) from a session....

does anyone have any clue....???????
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor