hexagon logo

problems running script

Has anyone else tried to run this script from the Wilcox site "tracesheet.bas"? I added all the assignments per the instructions and I get no output to the variables at all. If I'm correct should I not see the selections from the menu in the assignments in my pcdims program?



Thanks Bill



PCDMIS 3.7 MR3
PCDMIS 4.3 MR1
Parents
  • I got it to write to the file.. Not sure it is done right Someone check it out please
    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
    
    
    
    '---------------------------------------------------------------------------------------
    
    
Reply
  • I got it to write to the file.. Not sure it is done right Someone check it out please
    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
    
    
    
    '---------------------------------------------------------------------------------------
    
    
Children
No Data