NX9 - Journal code to toggle edges hidden by edges
NX9 - Journal code to toggle edges hidden by edges
(OP)
To be clear from the start, this is for views already created. I need to create a button that will automatically select all views on a sheet and toggle "edges hidden by edges" on and off.
The reason I need this is because when they are left on, too often hidden hole diameters will look almost solid because it is showing the edge of both sides of the hole and the dashes do not line up. Yet, we need to turn them on while selecting the side view of a hole to place the origin of an ordinate dimension. Which we do a lot. Too often people will add the dims but never turn the edges hidden by edges off again and the prints end up making some hidden lines look solid. It would make it much easier for people to just select a button to turn this option on and off for all views on a sheet.
Any help with this would be appreciated.
Thanks
The reason I need this is because when they are left on, too often hidden hole diameters will look almost solid because it is showing the edge of both sides of the hole and the dashes do not line up. Yet, we need to turn them on while selecting the side view of a hole to place the origin of an ordinate dimension. Which we do a lot. Too often people will add the dims but never turn the edges hidden by edges off again and the prints end up making some hidden lines look solid. It would make it much easier for people to just select a button to turn this option on and off for all views on a sheet.
Any help with this would be appreciated.
Thanks





RE: NX9 - Journal code to toggle edges hidden by edges
RE: NX9 - Journal code to toggle edges hidden by edges
CODE --> VB
Option Strict Off Imports System Imports System.IO Imports System.Windows.Forms Imports System.Collections.Generic Imports System.Drawing Imports NXOpen Imports NXOpen.UF Imports NXOpen.Utilities Imports System.Environment Imports NXOpenUI Imports NXOpen.Annotations Imports NXOpen.Drawings <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso components IsNot Nothing Then components.Dispose() End If Finally MyBase.Dispose(disposing) End Try End Sub Public theStatus As Boolean Friend WithEvents ButtonON As System.Windows.Forms.Button Friend WithEvents ButtonOFF As System.Windows.Forms.Button 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button() Me.ButtonON = New System.Windows.Forms.Button() Me.ButtonOFF = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'Button1 ' Me.Button1.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.Button1.Location = New System.Drawing.Point(54, 96) Me.Button1.Margin = New System.Windows.Forms.Padding(2) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(81, 23) Me.Button1.TabIndex = 0 Me.Button1.Text = "Cancel" Me.Button1.UseVisualStyleBackColor = True ' 'ButtonON ' Me.ButtonON.Location = New System.Drawing.Point(12, 12) Me.ButtonON.Name = "ButtonON" Me.ButtonON.Size = New System.Drawing.Size(161, 23) Me.ButtonON.TabIndex = 16 Me.ButtonON.Text = "Turn ON" Me.ButtonON.UseVisualStyleBackColor = True ' 'ButtonOFF ' Me.ButtonOFF.Location = New System.Drawing.Point(12, 41) Me.ButtonOFF.Name = "ButtonOFF" Me.ButtonOFF.Size = New System.Drawing.Size(161, 23) Me.ButtonOFF.TabIndex = 17 Me.ButtonOFF.Text = "Turn OFF" Me.ButtonOFF.UseVisualStyleBackColor = True ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(188, 130) Me.Controls.Add(Me.ButtonOFF) Me.Controls.Add(Me.ButtonON) Me.Controls.Add(Me.Button1) Me.Margin = New System.Windows.Forms.Padding(2) Me.MaximizeBox = False Me.MinimizeBox = False Me.Name = "Form1" Me.Text = "Edges Hidden by Edges" Me.ResumeLayout(False) End Sub Friend WithEvents Button1 As System.Windows.Forms.Button Private Sub ButtonON_Click(sender As Object, e As EventArgs) Handles ButtonON.Click, ButtonOFF.Click Dim btn As Button = CType(sender, Button) If btn.Name = "ButtonON" Then theStatus = True Else theStatus = False End If Me.DialogResult = DialogResult.OK End Sub End Class Public Class MainMethod Private Shared theSession As Session Private Shared theUF As UFSession Private Shared theUI As UI Private Shared lw As ListingWindow private Shared turnOnEdgesHiddenByEdges As Boolean Public Sub New() Try theSession = Session.GetSession() theUF = UFSession.GetUFSession() theUI = UI.GetUI() lw = theSession.ListingWindow() turnOnEdgesHiddenByEdges = False Catch ex As Exception Throw ex End Try End Sub Public Shared Sub Main() Dim theMyClass As MainMethod = Nothing Dim theUndoMark As Session.UndoMarkId = Nothing Try theMyClass = New MainMethod() 'Call Show form theMyClass.showTheForm() Catch ex As Exception UI.GetUI().NXMessageBox.Show("MyForm", NXMessageBox.DialogType.Error, ex.ToString) End Try End Sub Sub showTheForm() Dim theForm As New Form1 If theForm.ShowDialog() = System.Windows.Forms.DialogResult.OK Then turnOnEdgesHiddenByEdges = theForm.theStatus processDrawingViews() End If End Sub Sub processDrawingViews() Dim workPart As Part = theSession.Parts.Work Dim markId1 As NXOpen.Session.UndoMarkId markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Toggle Edges Hidden By Edges") For Each vw As DraftingView In theSession.Parts.Display.DrawingSheets.CurrentDrawingSheet.GetDraftingViews() Dim views1(0) As NXOpen.View views1(0) = vw Dim editViewSettingsBuilder1 As NXOpen.Drawings.EditViewSettingsBuilder editViewSettingsBuilder1 = workPart.SettingsManager.CreateDrawingEditViewSettingsBuilder(views1) editViewSettingsBuilder1.ViewStyle.ViewStyleHiddenLines.EdgesHiddenByEdges = turnOnEdgesHiddenByEdges editViewSettingsBuilder1.Commit() editViewSettingsBuilder1.Destroy() Next End Sub End ClassSuresh
www.technisites.com.au
RE: NX9 - Journal code to toggle edges hidden by edges
tested on nx8.5
Run to flip/change setting
Run again to restore setting
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.Drawings
Imports NXOpen.UI
Imports NXOpen.Utilities
Module list_all_views_on_current_drawing_in_display_part
Dim s As Session = Session.GetSession()
Sub Main()
Dim workPart As Part = s.Parts.Work
Dim draftViews As DraftingView()
draftViews = s.Parts.Display.DrawingSheets.CurrentDrawingSheet.GetDraftingViews()
s.ListingWindow.Open()
For Each draftingView As DraftingView In draftViews
's.ListingWindow.WriteLine(" " & draftingView.Name.ToString)
If draftingView.Style.HiddenLines.EdgesHiddenByEdges = True Then
draftingView.Style.HiddenLines.EdgesHiddenByEdges = False
Else
draftingView.Style.HiddenLines.EdgesHiddenByEdges = True
End If
workPart.DraftingViews.SuppressViewBreaks(draftingView)
draftingView.Commit()
workPart.DraftingViews.RestoreViewBreaks(draftingView)
Next
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
Return Session.LibraryUnloadOption.Immediately
End Function
End Module
RE: NX9 - Journal code to toggle edges hidden by edges
CODE -->
Option Strict Off Imports System Imports NXOpen Imports NXOpen.Drawings Imports NXOpen.UI Imports NXOpen.Utilities Module list_all_views_on_current_drawing_in_display_part Dim s As Session = Session.GetSession() Sub Main() Dim workPart As Part = s.Parts.Work Dim draftViews As DraftingView() draftViews = s.Parts.Display.DrawingSheets.CurrentDrawingSheet.GetDraftingViews() s.ListingWindow.Open() For Each draftingView As DraftingView In draftViews 's.ListingWindow.WriteLine(" " & draftingView.Name.ToString) If draftingView.Style.HiddenLines.EdgesHiddenByEdges = True Then draftingView.Style.HiddenLines.EdgesHiddenByEdges = False Else draftingView.Style.HiddenLines.EdgesHiddenByEdges = True End If workPart.DraftingViews.SuppressViewBreaks(draftingView) draftingView.Commit() workPart.DraftingViews.RestoreViewBreaks(draftingView) Next End Sub Public Function GetUnloadOption(ByVal dummy As String) As Integer Return Session.LibraryUnloadOption.Immediately End Function End ModuleRE: NX9 - Journal code to toggle edges hidden by edges
Added 'Undo'
CODE -->
Option Strict Off Imports System Imports NXOpen Imports NXOpen.Drawings Imports NXOpen.UI Imports NXOpen.Utilities Module flip_on_off_edges_hidden_by_edges_of_current_drawing_views Dim s As Session = Session.GetSession() Sub Main() Dim workPart As Part = s.Parts.Work Dim draftViews As DraftingView() Dim markId1 As Session.UndoMarkId markId1 = s.SetUndoMark(Session.MarkVisibility.Visible, "Start EdgesHiddenByEdges") draftViews = s.Parts.Display.DrawingSheets.CurrentDrawingSheet.GetDraftingViews() For Each draftingView As DraftingView In draftViews If draftingView.Style.HiddenLines.EdgesHiddenByEdges = True Then draftingView.Style.HiddenLines.EdgesHiddenByEdges = False Else draftingView.Style.HiddenLines.EdgesHiddenByEdges = True End If workPart.DraftingViews.SuppressViewBreaks(draftingView) draftingView.Commit() workPart.DraftingViews.RestoreViewBreaks(draftingView) Next End Sub Public Function GetUnloadOption(ByVal dummy As String) As Integer Return Session.LibraryUnloadOption.Immediately End Function End ModuleRE: NX9 - Journal code to toggle edges hidden by edges
workPart.DraftingViews.SuppressViewBreaks(draftingView)
workPart.DraftingViews.RestoreViewBreaks(draftingView)
I do not know why
CODE -->
Option Strict Off Imports System Imports NXOpen Imports NXOpen.Drawings Imports NXOpen.UI Imports NXOpen.Utilities Module flip_on_off_edges_hidden_by_edges_of_current_drawing_views Dim s As Session = Session.GetSession() Sub Main() Dim workPart As Part = s.Parts.Work Dim draftViews As DraftingView() Dim markId1 As Session.UndoMarkId markId1 = s.SetUndoMark(Session.MarkVisibility.Visible, "Start EdgesHiddenByEdges") draftViews = s.Parts.Display.DrawingSheets.CurrentDrawingSheet.GetDraftingViews() For Each draftingView As DraftingView In draftViews If draftingView.Style.HiddenLines.EdgesHiddenByEdges = True Then draftingView.Style.HiddenLines.EdgesHiddenByEdges = False Else draftingView.Style.HiddenLines.EdgesHiddenByEdges = True End If Next For Each draftingView As DraftingView In draftViews draftingView.Commit() Next End Sub Public Function GetUnloadOption(ByVal dummy As String) As Integer Return Session.LibraryUnloadOption.Immediately End Function End ModuleRE: NX9 - Journal code to toggle edges hidden by edges
I will be honest, I didnt try them all, but this last one being the shortest I tried first and it worked great. Thank you very much. Hopefully I can learn from it and make similar codes on my own so I dont have to keep bothering people here.
RE: NX9 - Journal code to toggle edges hidden by edges
CODE
can be reduced to:
CODE
www.nxjournaling.com
RE: NX9 - Journal code to toggle edges hidden by edges
Thank you cowski
But what are those two lines that i removed
What they do.
RE: NX9 - Journal code to toggle edges hidden by edges
I'm going to go out on a limb and say that these lines suppress and restore the view breaks. I'd suggest testing the code on a drawing that has view breaks to see what the effect is (if any). Perhaps the view breaks need to be suppressed before updating the view (I'm not sure, I have not tested the code).
www.nxjournaling.com
RE: NX9 - Journal code to toggle edges hidden by edges
I tested both journals with and without these lines
on the attached part.
and the output is the same