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 Class