Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Driving NX through VBA ?

Status
Not open for further replies.

John1984

Mechanical
Nov 22, 2016
2
Hi everyone,

I'm actually using a VBA code that allows to drive AutoCAD application directly through this code.

More precisely, the only need is to tick the AutoCAD library in the VBA references. After that, we have a simple VBA code that launches AutoCAD application, takes points coordinates that are in the excel streadsheet, and draw polylines, lines, and arcs using these coordinates. This allows to draw a sketch in AutoCAD, directly drived through Excel+VBA.

My company will be moving soon to NX software and I'd like to know if it is possible to do exactly the same, ie draw a sketch in NX using VBA code ?

Thanks for your help.
 
Replies continue below

Recommended for you

You can write code for NX that will retrieve values from an Excel spreadsheet and use them to create a sketch.

However, you will not be able to do it exactly as you are now. NX has API support for several languages, but VBA is not one of them. It does support Visual Basic .NET, which is probably the closest alternative to VBA. If you have a lot of processes that you would like to automate in NX, I suggest asking your reseller about a .NET author license. This license will allow you to write code for NX with few restrictions. If you only have an NX modeling license, you have access to "journaling", which can be powerful, but imposes several restrictions on what you can do. For instance, there are only a handful of .net libraries that you are allowed to reference with plain journaling. You would not be able to reference the Excel library; you can still work with Excel, but you would have to use late binding. The process you describe would still be possible with only journaling, but it would be more difficult to write and debug.

Also, you would want to get a decent IDE, as NX doesn't offer an editor worth using. MS offers some "express" or "community" versions of its Visual Studio editor that are free or low cost; these should work with NX (check the NX release notes for the recommended version).

www.nxjournaling.com
 
Thanks for your answer cowski.

Is there any documentation that I can find on the use of NX journaling with Excel for my use ? Or any tutorial ? And same question with the use of .NET to do this ?

One more question, what do you mean by "late binding" ?
 
If you currently have access to NX, take a look at the programmer's help files -> getting started with SNAP guide - it has some good information on using NX with Excel. Also, if you poke around the NX install folder, you will find some code examples in the "SampleNXOpenApplications" folder.

Other code examples for working with NX and Excel can be found on this site, the Siemens community site, and NXJournaling.com.

Early binding means that the compiler has a reference to the object at compile time, late binding means your code doesn't know the type of object until run time. There is a good overview here; I'm sure that a websearch will turn up much more if you are interested.

www.nxjournaling.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor