Submitted by uwe.a on Tue, 08/27/2013 - 07:31
Forums:
We can have several names for model reference set, model, detail, solid,result are some examples.
How can I determine what is the Model referenceset - part or solid or model... ?
hope you can help ;-)
re: model reference set
The following code will report the system "model" reference set. Special thanks go to Suresh Amberkar for pointing me to the correct subtype to test for.
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Module Module1
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()
Dim mRefSet As String = ReportModelRefSet(workPart)
If String.IsNullOrEmpty(mRefSet) Then
lw.WriteLine("model reference set not found")
Else
lw.WriteLine("model reference set: " & mRefSet)
End If
lw.Close()
End Sub
Function ReportModelRefSet(ByVal thePart As Part) As String
Dim theReferenceSet As ReferenceSet = Nothing
Dim type As Integer
Dim subtype As Integer
Dim ufs As UFSession = UFSession.GetUFSession
For Each myRefSet As ReferenceSet In thePart.GetAllReferenceSets()
ufs.Obj.AskTypeAndSubtype(myRefSet.Tag, type, subtype)
If subtype = UFConstants.UF_reference_design_model_subtype Then
Return myRefSet.Name
End If
Next
Return Nothing
End Function
Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image when the NX session terminates
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
'----Other unload options-------
'Unloads the image immediately after execution within NX
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
'Unloads the image explicitly, via an unload dialog
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
'-------------------------------
End Function
End Module
nice, UF_reference_design
nice, UF_reference_design_model_subtype