Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

NXOpen - How to Determine if a part is already open

Status
Not open for further replies.

EngProgrammer

Aerospace
Jan 14, 2015
150
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.
 
Replies continue below

Recommended for you

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
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor