×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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

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

(OP)
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
 

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

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

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

'echo the contents of the string array
i = 0
for i = LBound(ViewNames) to UBound(ViewNames)
    msgbox(ViewNames(i))
next


End Sub
End Module

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

(OP)
Ohh "for each vw as ModelingView in views" and vw.name.  That's what I was missing.

Works perfect.  Thanks so much!!
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources