hexagon logo

File Template Script

Do you need to change the default Part Name - Revision Number - Serial Number fields that are presented when creating a new PC-DMIS file?

Feel free to use this script in a template file. Just create a blank MM & Inch file with a call to this script after the header. When you open and run the template file a dialog similar to the Provided PC-DMIS dialog will appear promting you for three fields. In this version of the script the user is prompted for a "CMM #", "Part Number" & "TRC #" These prompts can be changed easily within the script. Now... change the Report Header Template to display the same custom field names as you promt for in the script. Enjoy...


Sub Main

Dim App As Object
Set App = CreateObject("PCDLRN.Application")

Dim Part As Object
Set Part = App.ActivePartProgram

Dim PartProg As Object
Set PartProg = App.ActivePartProgram

Dim Cmds As Object
Set Cmds = Part.Commands

Dim Cmd As Object

Dim Pname As String
Dim Rnum As String
Dim Snum As String

Dim CMMnum As String
Dim CusName As String
Dim PartNum As String
Dim TRCNum As String
Dim FileName As String

'Ask For part info from operator
'CustName = InputBox$("Please enter the 3 letter custumer prefix","Operator","",200,175)
'CMMnum = InputBox$("Please enter CMM Number","Operator","",200,175)
'PartNum = InputBox$("Please enter the Part Number","Operator","",200,175)
'TRCNum = InputBox$("Please enter the TRC Number","Operator","",200,175)

'Dialog Box instead of Input Boxes
Begin Dialog DLG_SAVE_AS 162,-3, 90, 149, "Please Enter Part Information"
TextBox 4,16,76,12, .EditBox_1
Text 4,4,60,12, "Customer Prefix"
TextBox 4,44,76,12, .EditBox_2
Text 4,32,60,12, "CMM Number"
TextBox 4,72,76,12, .EditBox_3
Text 4,60,60,12, "Part Number"
TextBox 4,100,76,12, .EditBox_4
Text 4,88,60,12, "TRC Number"
OKButton 22,116,40,14
CancelButton 22,132,40,14
End Dialog

Dim dlg1 As DLG_SAVE_AS
buttonval = Dialog(dlg1)

CustName = dlg1.EditBox_1
CMMnum = dlg1.EditBox_2
PartNum = dlg1.EditBox_3
TRCNum = dlg1.EditBox_4

'Creates the String For the filename
FileName = CustName & CMMnum & " - " & PartNum & " - TRC-" & TRCNum

'MsgBox FileName

'Check For file
Check = FileIO.FailIfExists

'MsgBox Check

'Dim Save As Object (not needed?)
Save = PartProg.SaveAs(FileName)

'This section changes the header values
Pname = CustName & CMMnum
Rnum = PartNum
Snum = "TRC-" & TRCNum

'MsgBox Pname
'MsgBox Rnum
'MsgBox Snum

PartProg.PartName = Pname
PartProg.RevisionNumber = Rnum
PartProg.SerialNumber = Snum

For Each Cmd In Cmds
Cmd.Marked = True
Next Cmd

End Sub