×
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

Journaling to toogle LineWidth Display in Modeling or Drafting depending on current Application-Mode

Journaling to toogle LineWidth Display in Modeling or Drafting depending on current Application-Mode

Journaling to toogle LineWidth Display in Modeling or Drafting depending on current Application-Mode

(OP)
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?

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

RE: Journaling to toogle LineWidth Display in Modeling or Drafting depending on current Application-Mode

The .AskDisplayState method only works within the drafting application (by design). It does not tell you what application is running, it only tells you if a drawing sheet is displayed or not. If you switch to the drafting application normally a drawing sheet is displayed (if one exists), you can turn the drawing sheet off to view the model without leaving the drafting application. As long as you are in the drafting application, the .AskDisplayState method will tell you if a drawing sheet is displayed or a model view is displayed.

If you need to know what application NX is currently in, use the .AskApplicationModule method.

www.nxjournaling.com

RE: Journaling to toogle LineWidth Display in Modeling or Drafting depending on current Application-Mode

(OP)
Hi Cowski,

yes, this works great! Here is the new complete Code:

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

    Sub Main()
	
		Dim module_id As Integer = 0
		theUFSession.UF.AskApplicationModule(module_id)
		
		if module_id = UFConstants.UF_APP_DRAFTING 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

    End Sub

    Public Function GetUnloadOption(ByVal dummy As String) As Integer
	
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

    End Function				

End Module 

Thank you!
Michael

RE: Journaling to toogle LineWidth Display in Modeling or Drafting depending on current Application-Mode

I'm interested in this. How do I copy the code with carriage returns?
Thanks

RE: Journaling to toogle LineWidth Display in Modeling or Drafting depending on current Application-Mode

Open a plain text editor such as notepad (do not use MS Word or Wordpad), then copy and paste the journal code. Save the file to a convenient location changing the file extension to .vb. In NX, go to Tools -> journal -> play..., browse to the file and press "Run".

www.nxjournaling.com

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