Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

NX Open- get names of all model views (as string) 1

Status
Not open for further replies.

Ryan25

Mechanical
Sep 8, 2010
3
US
Hi,

I am trying to use NX Open/journal (with visual basic) to get the names of all my modeling views, and store it as a string array. This would be all the standard views and any custom views the user added. I am new to vb and nx open so bear with me.

This is what I have so far but this gives me errors:

Dim ViewNames() As String
Dim views As ModelingViewCollection
views = workPart.ModelingViews
ViewNames()=views

Thanks,
Ryan
 
Replies continue below

Recommended for you

Try this:
Code:
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 ViewNames() As String
Dim i as Integer
i = 0
Dim views As ModelingViewCollection
views = workPart.ModelingViews

[COLOR=green]'iterate through the view collection, adding each view name to the string array[/color]
for each vw as ModelingView in views
	redim preserve ViewNames(i)
	ViewNames(i) = vw.Name
	i = i + 1
next

[COLOR=green]'echo the contents of the string array[/color]
i = 0
for i = LBound(ViewNames) to UBound(ViewNames)
	msgbox(ViewNames(i))
next


End Sub
End Module
 
Ohh "for each vw as ModelingView in views" and vw.name. That's what I was missing.

Works perfect. Thanks so much!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top