Is WCS equal to ACS

I need some help! Do you have a way to check if Work Coordinate System is equal to Absolute Coordinate System in a VB code?

The code below has a function that will check the WCS and return True if it is set at the absolute coordinate system.

Option Strict Off
Imports System
Imports NXOpen

Module Module3

Dim theSession As Session = Session.GetSession()
Dim lw As ListingWindow = theSession.ListingWindow

Sub Main()

lw.Open()

If IsNothing(theSession.Parts.Display) Then
'active part required
Return
End If

If WcsEqualsAbsolute() Then
lw.WriteLine("WCS is set to absolute")
Else
lw.WriteLine("WCS is NOT set to absolute")
End If

End Sub

Function WcsEqualsAbsolute() As Boolean

'create cartesian coordinate system at the absolute csys
Dim absXform As Xform = theSession.Parts.Display.Xforms.CreateXform(SmartObject.UpdateOption.WithinModeling, 1)
Dim absCsys As CartesianCoordinateSystem = theSession.Parts.Display.CoordinateSystems.CreateCoordinateSystem(absXform, SmartObject.UpdateOption.WithinModeling)

If theSession.Parts.Display.WCS.CoordinateSystem.Origin.Equals(absCsys.Origin) Then
'lw.WriteLine("origin is the same")
Else
'lw.WriteLine("origin is not the same")
Return False
End If

If theSession.Parts.Display.WCS.CoordinateSystem.Orientation.Equals(absCsys.Orientation) Then
'lw.WriteLine("orientation is the same")
Return True
Else
'lw.WriteLine("orientation is not the same")
Return False
End If

End Function

End Module

Thank you very much it works just as wanted.
The only thing I noticed is that it doesn't report correctly from drafting application. Therefore I added some code to change to modeling application and back to initial application.
That results in some graphical flashing during the application changes. Could this be avoide?

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module3

Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession
Dim lw As ListingWindow = theSession.ListingWindow

Sub Main()

lw.Open()

If IsNothing(theSession.Parts.Display) Then
'active part required
Return
End If

' find current application and store initial application
Dim currentModuleId As Integer
theUfSession.UF.AskApplicationModule(currentModuleId)
Dim initAppName As String = theSession.ApplicationName

' if not modeling then change to modeling
If currentModuleId <> UFConstants.UF_APP_MODELING Then
theSession.ApplicationSwitchImmediate("UG_APP_MODELING")
End If

If WcsEqualsAbsolute() Then
lw.WriteLine("WCS is set to absolute")
Else
lw.WriteLine("WCS is NOT set to absolute")
End If

' if initial application other than modeling then change back to initial application
If initAppName <> "UG_APP_MODELING" Then
theSession.ApplicationSwitchImmediate(initAppName)
End If

End Sub

Function WcsEqualsAbsolute() As Boolean

'create cartesian coordinate system at the absolute csys
Dim absXform As Xform = theSession.Parts.Display.Xforms.CreateXform(SmartObject.UpdateOption.WithinModeling, 1)
Dim absCsys As CartesianCoordinateSystem = theSession.Parts.Display.CoordinateSystems.CreateCoordinateSystem(absXform, SmartObject.UpdateOption.WithinModeling)

If theSession.Parts.Display.WCS.CoordinateSystem.Origin.Equals(absCsys.Origin) Then
'lw.WriteLine("origin is the same")
Else
'lw.WriteLine("origin is not the same")
Return False
End If

If theSession.Parts.Display.WCS.CoordinateSystem.Orientation.Equals(absCsys.Orientation) Then
'lw.WriteLine("orientation is the same")
Return True
Else
'lw.WriteLine("orientation is not the same")
Return False
End If

End Function

End Module

Best Regards
Gunnar

The API has a function to suppress display updates that might work here.

theUfSession.Disp.SetDisplay(UFConstants.UF_DISP_SUPPRESS_DISPLAY)

'Do stuff

theUfSession.Disp.SetDisplay(UFConstants.UF_DISP_UNSUPPRESS_DISPLAY)
theUfSession.Disp.RegenerateDisplay()

Thank you again.
I promise that this is my last question in this thread :-)
Do you know a way to get back to the same menu tab when returning to the initial application?

Best Regards
Gunnar

I know of no way to detect or change which tab you are on in the UI through the NXOpen API.

OK, thanks anyway. It was just a minor thing that we can live fine with.

Best Regards
Gunnar