Your Products have been synced, click here to refresh
Sub main () 'Setup maching And assembly traceability 'Declare variables Dim PCDMISapp As Object Dim PCDMISPart As Object 'Get a pointer To the application Set PCDMISApp = CreateObject("PCDLRN.Application") 'Get the active part program (Assumes PC-DMIS is already running ' With an Open part program...) Set PCDMISPart = PCDMISApp.ActivePartProgram 'CREATE THE LIST OF MACHINE NUMBERS Dim MachList$ (41) For ml = 0 To 40 MachList(ml) = "Mach " & ml Next ml MachList$(0) = "N/A" MachList$(1) = "FP01" MachList$(2) = "FP02" MachList$(3) = "FP03" MachList$(4) = "A Deck" MachList$(5) = "B Deck" MachList$(6) = "C Deck" 'CREATE THE LIST OF PALLET NUMBERS Dim PalList$(31) For pl = 0 To 30 PalList(pl) = "Pallet " & pl Next pl PalList$(0) = "N/A" PalList$(1) = "CM 1" PalList$(2) = "CM 2" PalList$(3) = "CM 3" PalList$(4) = "CM 4" PalList$(5) = "CM 5" PalList$(6) = "CM 6" PalList$(7) = "TP02" PalList$(7) = "TP05" PalList$(7) = "TP06" PalList$(7) = "OTHER" 'CREATE THE REASON For CHECK LIST Dim ReasonList$(10) ReasonList (0) = "Production" ReasonList (1) = "Recheck" ReasonList (2) = "Tool Change" ReasonList (3) = "Setup Check" ReasonList (4) = "Quality Check" ReasonList (5) = "Startup Check" ReasonList (6) = "Capability Study" ReasonList (7) = "Dispositon" ReasonList (8) = "Engineering" ReasonList (9) = "Other" Dim OperatorList$(10) OperatorList (0) = "Otto" OperatorList (1) = "Terry" OperatorList (2) = "Eddie" OperatorList (3) = "John" OperatorList (4) = "Lori" OperatorList (5) = "Jeremy" OperatorList (6) = "Patrica" OperatorList (7) = "Dale" OperatorList (8) = "Juanita" OperatorList (9) = "Other" 'CREATE THE LIST OF SHIFTS Dim SHIFT$(5) 'SHIFT(0) = "First Shift" 'SHIFT(1) = "Second Shift" 'SHIFT(2) = "Third Shift" 'SHIFT(3) = "Other" 'SHIFT(4) = "N/A" '--------------------------------------------------------------------------------- 'BELOW: PULL a String variable from the PC-DMIS program '------------------------------------------------------------------------------------ Dim OptVal As Integer Dim SSEL As String Dim Capno As String Dim Answer As String Dim CMMID As String Dim SETID As String Dim objCMM As Object Set objCMM = PCDMISPart.GetVariableValue("SETID") CMMID = objCMM.StringValue 'CREATE THE Dialog BOX REDO1: Begin Dialog TraceDialog 200, 180, "Traceability Data Sheet: " OptionGroup.Group_1 OptionButton 15, 15, 48, 12, "& First" OptionButton 15, 25, 48, 12, "& Second" OptionButton 15, 35, 48, 12, "& Third" OptionButton 15, 45, 48, 12, "& N/A" GroupBox 5,5,60,55,"Shift",.GroupBox1 'ComboBox 15,5,50,55,SHIFT$( ),.CmboBox5 ComboBox 70,5,50,55,operatorlist$( ),.CmboBox6 ComboBox 15,80,50,40, MachList$( ),.CmboBox1 ComboBox 70,80,50,40, PalList$( ),.CmboBox3 ComboBox 125,80,70,40, ReasonList$( ),.CmboBox4 CheckBox 125,50,70,10,"&Manual",.ChkBox1 Text 125,20,80,10,.CMMID Text 125,40,80,10,"Manual Alignment: " Text 15,70,40,10,"Machine ID:" Text 124,70,70,10,"Options:" Text 70,70,50,10,"Pallet ID:" Text 15,125,36,10,"COMMENT:" TextBox 15,135,160,20,.TextBox2 OKBUTTON 12, 160, 40, 12 CancelButton 72, 160, 40, 12 End Dialog 'ADD DATA Dim Dlg1 As TraceDialog Dim Dgl2 As GroupBox1 Dim Testit As String Button = Dialog (Dlg1) OptVal = Dlg1.Group_1 'MAKE SURE ALL THE DATA IS INCLUDED Or Set DEFAULTS If OptVal = 0 Then SSEL = "First" End If If OptVal = 1 Then SSEL = "Second" End If If OptVal = 2 Then SSEL = "Third" End If If OptVal = 3 Then SSEL = "N/A" End If Testit$ = SSEL If Testit$ = "" Then MsgBox "Please select a Shift" 'GoTo redo1 End If Testit$ = Dlg1.CmboBox1 If Testit$ = "" Then MsgBox "Please select a Machine" GoTo redo1 End If Testit$ = Dlg1.CmboBox3 If Testit$ = "" Then MsgBox "Please select a Pallet" GoTo redo1 End If Testit$ = Dlg1.CmboBox4 If Testit$ = "" Then MsgBox "Please select a Reason" GoTo redo1 End If Testit$ = Dlg1.CmboBox4 NEWNUM: If Testit$ = "Capability Study" Then Capno = InputBox( "Please enter a Sequence Number") If val(Capno)<1 Or val(Capno)>999 Then GoTo NEWNUM End If End If Testit$ = Dlg1.CmboBox6 If Testit$ = "" Then MsgBox "Please enter an Operator Number" GoTo redo1 End If Testit$ = Dlg1.CmboBox6 If Testit$ = "Other" Then Answer = InputBox( "Please enter an Operator Number") Dlg1.Cmbobox6 = Answer End If Testit$ = Dlg1.TextBox2 If Testit$ = "" Then Dlg1.TextBox2 = "None" End If 'Set VARIABLE VALUES In THE CMM PROGRAM '--------------------------------------------------------------------------------- 'Below: pass variables back To the PC-DMIS Program '------------------------------------------------------------------------------------ 'Declare the variables Dim OPR1 As String Dim SFT1 As String Dim MAC1 As String Dim RSN1 As String Dim CMT1 As String Dim MAL1 As String Dim PID1 As String Dim MSC1 As String Dim Capno1 As String 'Assign data To the variables OPR1 = Dlg1.CmboBox6 SFT1 = SSEL MAC1 = Dlg1.CmboBox1 PID1 = Dlg1.CmboBox3 RSN1 = Dlg1.CmboBox4 CMT1 = Dlg1.TextBox2 MAL1 = Dlg1.ChkBox1 Capno1=Capno If MAL1 = "1" Then MAL1 = "YES" End If MSC1 = "N/A" 'Assign PC DMIS variables To Object variables Dim objOPR As Object Set objOPR = PCDMISPart.GetVariableValue("OPR") objOPR.StringValue = OPR1 Dim objSFT As Object Set objSFT = PCDMISPart.GetVariableValue("SFT") objSFT.StringValue = SFT1 Dim objMAC As Object Set objMAC = PCDMISPart.GetVariableValue("MAC") objMAC.StringValue = MAC1 Dim objRSN As Object Set objRSN = PCDMISPart.GetVariableValue("RSN") objRSN.StringValue = RSN1 Dim objCMT As Object Set objCMT = PCDMISPart.GetVariableValue("CMT") objCMT.StringValue = CMT1 Dim objMAL As Object Set objMAL = PCDMISPart.GetVariableValue("MAL") objMAL.StringValue = MAL1 Dim objMSC As Object Set objMSC = PCDMISPart.GetVariableValue("MSC") objMSC.StringValue = MSC1 Dim objPID As Object Set objPID = PCDMISPart.GetVariableValue("PID") objPID.StringValue = PID1 Dim objCapno As Object Set objCapno = PCDMISPart.GetVariableValue("Capno") objCapno.StringValue = Capno1 'Have the data In the variable, 'Now move it To the pass Object 'Pass back To PC-DMIS program PCDMISPart.SetVariableValue "OPR", objOPR PCDMISPart.SetVariableValue "MAL", objMAL PCDMISPart.SetVariableValue "SFT", objSFT PCDMISPart.SetVariableValue "MAC", objMAC PCDMISPart.SetVariableValue "PID", objPID PCDMISPart.SetVariableValue "RSN", objRSN PCDMISPart.SetVariableValue "CMT", objCMT PCDMISPart.SetVariableValue "MSC", objMSC PCDMISPart.SetVariableValue "Capno", objCapno '--------------------------------------------------------------------------------------- End Sub
Sub main () 'Setup maching And assembly traceability 'Declare variables Dim PCDMISapp As Object Dim PCDMISPart As Object 'Get a pointer To the application Set PCDMISApp = CreateObject("PCDLRN.Application") 'Get the active part program (Assumes PC-DMIS is already running ' With an Open part program...) Set PCDMISPart = PCDMISApp.ActivePartProgram 'CREATE THE LIST OF MACHINE NUMBERS Dim MachList$ (41) For ml = 0 To 40 MachList(ml) = "Mach " & ml Next ml MachList$(0) = "N/A" MachList$(1) = "FP01" MachList$(2) = "FP02" MachList$(3) = "FP03" MachList$(4) = "A Deck" MachList$(5) = "B Deck" MachList$(6) = "C Deck" 'CREATE THE LIST OF PALLET NUMBERS Dim PalList$(31) For pl = 0 To 30 PalList(pl) = "Pallet " & pl Next pl PalList$(0) = "N/A" PalList$(1) = "CM 1" PalList$(2) = "CM 2" PalList$(3) = "CM 3" PalList$(4) = "CM 4" PalList$(5) = "CM 5" PalList$(6) = "CM 6" PalList$(7) = "TP02" PalList$(7) = "TP05" PalList$(7) = "TP06" PalList$(7) = "OTHER" 'CREATE THE REASON For CHECK LIST Dim ReasonList$(10) ReasonList (0) = "Production" ReasonList (1) = "Recheck" ReasonList (2) = "Tool Change" ReasonList (3) = "Setup Check" ReasonList (4) = "Quality Check" ReasonList (5) = "Startup Check" ReasonList (6) = "Capability Study" ReasonList (7) = "Dispositon" ReasonList (8) = "Engineering" ReasonList (9) = "Other" Dim OperatorList$(10) OperatorList (0) = "Otto" OperatorList (1) = "Terry" OperatorList (2) = "Eddie" OperatorList (3) = "John" OperatorList (4) = "Lori" OperatorList (5) = "Jeremy" OperatorList (6) = "Patrica" OperatorList (7) = "Dale" OperatorList (8) = "Juanita" OperatorList (9) = "Other" 'CREATE THE LIST OF SHIFTS Dim SHIFT$(5) 'SHIFT(0) = "First Shift" 'SHIFT(1) = "Second Shift" 'SHIFT(2) = "Third Shift" 'SHIFT(3) = "Other" 'SHIFT(4) = "N/A" '--------------------------------------------------------------------------------- 'BELOW: PULL a String variable from the PC-DMIS program '------------------------------------------------------------------------------------ Dim OptVal As Integer Dim SSEL As String Dim Capno As String Dim Answer As String Dim CMMID As String Dim SETID As String Dim objCMM As Object Set objCMM = PCDMISPart.GetVariableValue("SETID") CMMID = objCMM.StringValue 'CREATE THE Dialog BOX REDO1: Begin Dialog TraceDialog 200, 180, "Traceability Data Sheet: " OptionGroup.Group_1 OptionButton 15, 15, 48, 12, "& First" OptionButton 15, 25, 48, 12, "& Second" OptionButton 15, 35, 48, 12, "& Third" OptionButton 15, 45, 48, 12, "& N/A" GroupBox 5,5,60,55,"Shift",.GroupBox1 'ComboBox 15,5,50,55,SHIFT$( ),.CmboBox5 ComboBox 70,5,50,55,operatorlist$( ),.CmboBox6 ComboBox 15,80,50,40, MachList$( ),.CmboBox1 ComboBox 70,80,50,40, PalList$( ),.CmboBox3 ComboBox 125,80,70,40, ReasonList$( ),.CmboBox4 CheckBox 125,50,70,10,"&Manual",.ChkBox1 Text 125,20,80,10,.CMMID Text 125,40,80,10,"Manual Alignment: " Text 15,70,40,10,"Machine ID:" Text 124,70,70,10,"Options:" Text 70,70,50,10,"Pallet ID:" Text 15,125,36,10,"COMMENT:" TextBox 15,135,160,20,.TextBox2 OKBUTTON 12, 160, 40, 12 CancelButton 72, 160, 40, 12 End Dialog 'ADD DATA Dim Dlg1 As TraceDialog Dim Dgl2 As GroupBox1 Dim Testit As String Button = Dialog (Dlg1) OptVal = Dlg1.Group_1 'MAKE SURE ALL THE DATA IS INCLUDED Or Set DEFAULTS If OptVal = 0 Then SSEL = "First" End If If OptVal = 1 Then SSEL = "Second" End If If OptVal = 2 Then SSEL = "Third" End If If OptVal = 3 Then SSEL = "N/A" End If Testit$ = SSEL If Testit$ = "" Then MsgBox "Please select a Shift" 'GoTo redo1 End If Testit$ = Dlg1.CmboBox1 If Testit$ = "" Then MsgBox "Please select a Machine" GoTo redo1 End If Testit$ = Dlg1.CmboBox3 If Testit$ = "" Then MsgBox "Please select a Pallet" GoTo redo1 End If Testit$ = Dlg1.CmboBox4 If Testit$ = "" Then MsgBox "Please select a Reason" GoTo redo1 End If Testit$ = Dlg1.CmboBox4 NEWNUM: If Testit$ = "Capability Study" Then Capno = InputBox( "Please enter a Sequence Number") If val(Capno)<1 Or val(Capno)>999 Then GoTo NEWNUM End If End If Testit$ = Dlg1.CmboBox6 If Testit$ = "" Then MsgBox "Please enter an Operator Number" GoTo redo1 End If Testit$ = Dlg1.CmboBox6 If Testit$ = "Other" Then Answer = InputBox( "Please enter an Operator Number") Dlg1.Cmbobox6 = Answer End If Testit$ = Dlg1.TextBox2 If Testit$ = "" Then Dlg1.TextBox2 = "None" End If 'Set VARIABLE VALUES In THE CMM PROGRAM '--------------------------------------------------------------------------------- 'Below: pass variables back To the PC-DMIS Program '------------------------------------------------------------------------------------ 'Declare the variables Dim OPR1 As String Dim SFT1 As String Dim MAC1 As String Dim RSN1 As String Dim CMT1 As String Dim MAL1 As String Dim PID1 As String Dim MSC1 As String Dim Capno1 As String 'Assign data To the variables OPR = Dlg1.CmboBox6 SFT = SSEL MAC = Dlg1.CmboBox1 PID = Dlg1.CmboBox3 RSN = Dlg1.CmboBox4 CMT = Dlg1.TextBox2 MAL = Dlg1.ChkBox1 Capno1=Capno If MAL1 = "1" Then MAL1 = "YES" End If MSC1 = "N/A" Dim App As Object Set App = CreateObject("PCDLRN.Application") Dim Part As Object Set Part = App.ActivePartProgram Dim Cmds As Object Dim Cmd As Object Set Cmds = Part.Commands For Each Cmd In Cmds If Cmd.Type = ASSIGNMENT Then If Cmd.GetText(DEST_EXPR, 0) = "OPR" Then bln = Cmd.PutText("""" + OPR+ """", SRC_EXPR, 0) Cmd.ReDraw End If If Cmd.GetText(DEST_EXPR, 0) = "Mac" Then bln = Cmd.PutText("""" + Mac + """",SRC_EXPR ,0 ) Cmd.ReDraw End If If Cmd.GetText(DEST_EXPR,0) = "RSN" Then bln = Cmd.PutText("""" + RSN + """", SRC_EXPR, 0) Cmd.ReDraw End If If Cmd.GetText(DEST_EXPR,0) = "CMT" Then bln = Cmd.PutText("""" + CMT + """", SRC_EXPR, 0) Cmd.ReDraw End If If Cmd.GetText(DEST_EXPR,0) = "MAL" Then bln = Cmd.PutText("""" + MAL + """", SRC_EXPR, 0) Cmd.ReDraw End If If Cmd.GetText(DEST_EXPR,0) = "Pid" Then bln = Cmd.PutText("""" + PID + """", SRC_EXPR, 0) Cmd.ReDraw End If If Cmd.GetText(DEST_EXPR,0) = "Msc" Then bln = Cmd.PutText("""" + Msc + """", SRC_EXPR, 0) Cmd.ReDraw End If End If ' End If Next Cmd End Sub '---------------------------------------------------------------------------------------
T. Miller Thank You so much this is working now with your changes. Now I can modify to my needs. This was becoming very frustrating to say the least. I tried something similar to what you changed but must have screwed it up. I wish Hexagon would have used VB6 or .NET. Cypress can be a pain and there is more help available for VB. This is a real cool script I have to say.
Bill
If Button = 0 then [COLOR=red](aparently 0 is the value for the cancelbutton according to an example I found in the help files...)[/COLOR] Dim App As Object Set App = CreateObject("PCDLRN.Application") Dim Part As Object Set Part = App.ActivePartProgram Dim Cmds As Object Dim Cmd As Object Set Cmds = Part.Commands For Each Cmd In Cmds If Cmd.Type = ASSIGNMENT Then If Cmd.GetText(DEST_EXPR, 0) = "BUTTON" Then bln = Cmd.PutText("Cancel", SRC_EXPR, 0) Cmd.ReDraw End If Next Cmd Exit Sub End If
© 2024 Hexagon AB and/or its subsidiaries. | Privacy Policy | Cloud Services Agreement |