UpdatePrefix()

This commit is contained in:
AJ
2021-10-12 20:51:40 -04:00
parent 15edbf6fec
commit d3f6791b53

View File

@@ -165,18 +165,12 @@ namespace ExportDXF.Forms
} }
private int SldWorks_ActiveModelDocChangeNotify() private int SldWorks_ActiveModelDocChangeNotify()
{
if (InvokeRequired)
{ {
Invoke(new MethodInvoker(() => Invoke(new MethodInvoker(() =>
{ {
SetActiveDocName(); SetActiveDocName();
UpdatePrefix();
})); }));
}
else
{
SetActiveDocName();
}
return 1; return 1;
} }
@@ -612,5 +606,31 @@ namespace ExportDXF.Forms
prefixTextBox.Text = string.Empty; 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;
}
}
} }
} }