×
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

NXOpen - How to Determine if a part is already open

NXOpen - How to Determine if a part is already open

NXOpen - How to Determine if a part is already open

(OP)
Dear Forum,

I am looking for a snippet of NXOpen code to determine if a part is already open.

I use the following lines of code to initially open the part:

Dim part1 As NXOpen.BasePart
Dim partLoadStatus1 As NXOpen.PartLoadStatus
part1 = theSession.Parts.OpenBaseDisplay(mWorkingFolder & "\" & "example.prt", partLoadStatus1)
partLoadStatus1.Dispose()

If I run this code of a part is already open NX blows up. I need to first check whether the part is open in NX before opening.

RE: NXOpen - How to Determine if a part is already open

The 'session' object has a .Parts collection that holds information on all the currently open parts in session. You could check the file names of the already open parts to see if your part is already in session before attempting to open it.

www.nxjournaling.com

RE: NXOpen - How to Determine if a part is already open

yeahh -
You can also use something like this:
((ufs.Part.IsLoaded(fileName))

CODE -->

If ((ufs.Part.IsLoaded(fileName)) <> 1) Then
                                ufs.Part.OpenQuiet(fileName, tags, ls) 'openQuiet
                                partTag = ufs.Part.AskPartTag(fileName)
                                ufs.Assem.SetWorkPartQuietly(partTag, pre_tags)
                            Else
                                partTag = ufs.Part.AskPartTag(fileName) ' replaced "Displayed part" to "Quiet open part"
                                ufs.Assem.SetWorkPartQuietly(partTag, pre_tags)
                            End If 

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