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
  • Could you post the script contents in here?
  • 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
    
  • 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
    
    
    
    '---------------------------------------------------------------------------------------
    
    
  • it worked

    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
  • 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


    Your welcome but I must give the credit to vpt.se . I got the part of the code to get it work from another script he had done.
    Going to play with this one myself some
  • Using the the example *.bas above:


    How would I use the cancelButton to control a variable in my program? I want to put a variable in my pcdims program called "cancel" that will go to a label called "end" to kill the program if the cancelbutton is selected in the .bas program.

    If the cancel button is not selected this would continue to complete the .bas program and run the pcdims program.

    any thoughts?

    Bill
  • wrong file

    Sorry last zip had wrong test32.xls file
    These are the edits I have done to this file. See attached for the .bas and excel file. I use this to fill out the excel header information.
    These assignments must be in your part program
    [code\
    ASSIGN/CUST = ""
    ASSIGN/REV = ""
    ASSIGN/INSP = ""
    ASSIGN/CASTD = ""
    ASSIGN/FOUNDRY = ""
    ASSIGN/ITYPE = ""
    ASSIGN/WO = ""
    ASSIGN/COMMENT = "None"
    ASSIGN/REQ = ""
    ASSIGN/DISCRIP = ""
    ASSIGN/PARTN = ""
    [/code]

    Attached Files
  • Maybe I am not undersatanding your example.

    This would be if I select the "cancelbutton" on the dialog box ( CancelButton 72, 160, 40, 12 ). I know I need to assign a variable in the pcdims program, such as "cancel". How do I get a output from the .bas program for the "cancelbutton" when selected to the pcdims program?

    What code would I use so the .bas file would show I selected "cancelbutton" or the ok button. If I select the "cancelbutton" have the .bas file end and also give my pcdims program variable. If I select the "okbutton" the .bas file enters all the variable in my pcdims progam. I know how to do the pcdims part.

    Bill
  • Not sure - I'll play with it and see if I can come up with something. I do know that if you press the cancel button all of your assignments will be 0 - so maybe you could work something out with that
  • Ok, never having worked with this script and trying to avoid Cypress like the plague I can only make an assumtion here but here it is.

    I would guess that the Button = Dialog (Dlg1) line will return some sort of value for whichever button you pressed in the dialog box. You would need to test this to see what that value is depending on which button you pressed and then you can set a condition to pass some value back to your program based on that.

    I would imagine something like:

     
    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
     
    


    This is only a guess and I haven't had time to try any of this out so take it with a grain of salt...