MEichWey
Industrial
- Apr 16, 2014
- 39
Hello all,
I have written a small Journal to toggle the linewidth Display in drafting-mode or in modeling-mode with only one button. In this case, the tool has to be determine if we are in modeling-mode or in drafting mode, cause we have two variables - one for each of the applications:
workPart.Preferences.ColorSettingVisualization.ShowWidths -> for drafting-mode / -sheet
workPart.Preferences.LineVisualization.ShowWidths -> for modeling-mode / view
I have created the following code, witch is asking the display state (view type). I found it here. But it doesn´t work correct.
If I have open a specification (from Teamcenter) with a drawing sheet and run the tool, it works. But if I switch then to Modeling nothing happens, because the viewType is still 2, which means "drafting view". But I see the model-view. If I change the display part to the master-model, then the tool works right in modeling-mode.
Is there any other possibility to get or ask the current application-mode?
I also tried to use "UI.GetUI.MenuBarManager.ApplicationSwitchRequest("Application")". But I can only change the application with it, not asking the current state.
Michael
I have written a small Journal to toggle the linewidth Display in drafting-mode or in modeling-mode with only one button. In this case, the tool has to be determine if we are in modeling-mode or in drafting mode, cause we have two variables - one for each of the applications:
workPart.Preferences.ColorSettingVisualization.ShowWidths -> for drafting-mode / -sheet
workPart.Preferences.LineVisualization.ShowWidths -> for modeling-mode / view
I have created the following code, witch is asking the display state (view type). I found it here. But it doesn´t work correct.
If I have open a specification (from Teamcenter) with a drawing sheet and run the tool, it works. But if I switch then to Modeling nothing happens, because the viewType is still 2, which means "drafting view". But I see the model-view. If I change the display part to the master-model, then the tool works right in modeling-mode.
Is there any other possibility to get or ask the current application-mode?
Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Module ToggleThickness
Dim theSession As Session = Session.GetSession()
Dim theUFSession As UFSession = UFSession.GetUFSession
Dim theUI As UI = UI.GetUI
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim lw As ListingWindow = theSession.ListingWindow
Sub Main()
lw.Open()
Dim viewType As Integer = 0
'1 = modeling view
'2 = drawing view
'other = error
theUFSession.Draw.AskDisplayState(viewType)
lw.WriteLine(viewType)
if viewType = 2 then
'Toggles LineWidth-Display on Drawing Sheet in Drafting Mode
Dim ShowWDra As Boolean = workPart.Preferences.ColorSettingVisualization.ShowWidths
workPart.Preferences.ColorSettingVisualization.ShowWidths = Not ShowWDra
else
'Toggles LineWidth-Display in Modeling Mode and View
Dim ShowWMod As Boolean = workPart.Preferences.LineVisualization.ShowWidths
workPart.Preferences.LineVisualization.ShowWidths = Not ShowWMod
end if
lw.Close()
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
End Function
End Module
I also tried to use "UI.GetUI.MenuBarManager.ApplicationSwitchRequest("Application")". But I can only change the application with it, not asking the current state.
Michael