From d3f6791b53759250f4ff20b8577ccffa94e83bf7 Mon Sep 17 00:00:00 2001 From: AJ Date: Tue, 12 Oct 2021 20:51:40 -0400 Subject: [PATCH] UpdatePrefix() --- ExportDXF/Forms/MainForm.cs | 38 ++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/ExportDXF/Forms/MainForm.cs b/ExportDXF/Forms/MainForm.cs index 6bd6893..b174779 100644 --- a/ExportDXF/Forms/MainForm.cs +++ b/ExportDXF/Forms/MainForm.cs @@ -166,17 +166,11 @@ namespace ExportDXF.Forms private int SldWorks_ActiveModelDocChangeNotify() { - if (InvokeRequired) - { - Invoke(new MethodInvoker(() => - { - SetActiveDocName(); - })); - } - else + Invoke(new MethodInvoker(() => { SetActiveDocName(); - } + UpdatePrefix(); + })); return 1; } @@ -612,5 +606,31 @@ namespace ExportDXF.Forms prefixTextBox.Text = string.Empty; } } + + private void UpdatePrefix() + { + var model = sldWorks.ActiveDoc as ModelDoc2; + + if (model == null) + return; + + var isDrawing = model is DrawingDoc; + var title = model.GetTitle(); + + if (isDrawing) + { + var drawingInfo = DrawingInfo.Parse(title); + + if (drawingInfo == null) + return; + + prefixTextBox.Text = $"{drawingInfo.JobNo} {drawingInfo.DrawingNo} PT"; + prefixTextBox.SelectionStart = prefixTextBox.Text.Length; + } + else + { + prefixTextBox.Text = string.Empty; + } + } } } \ No newline at end of file