hexagon logo

Creation of a script for a toolbar button to insert a command line

Hello all!!

How to create a script to insert this command lines in a program?
In the end i want to create a button for a toolbar that runs this script.


C1 =COMMENT/INPUT,NO,FULL SCREEN=NO,
Dimensional Numero: ?
C2 =COMMENT/INPUT,NO,FULL SCREEN=NO,
Molde Numero: ?
C3 =COMMENT/INPUT,NO,FULL SCREEN=NO,
Nome do Molde (Cliente): ?
C4 =COMMENT/INPUT,NO,FULL SCREEN=NO,
Referencia das peças: ?
C5 =COMMENT/INPUT,NO,FULL SCREEN=NO,
Quantidade de Peças: ?
C6 =COMMENT/INPUT,NO,FULL SCREEN=NO,
Teste Numero: ?
C7 =COMMENT/INPUT,NO,FULL SCREEN=NO,
Revisão do Relatório: ?
C8 =COMMENT/INPUT,NO,FULL SCREEN=NO,
Elaborado por: ?



Thank you in advanced for the help.

Lionheart1º
Parents
  • As noted above, it is fun and easy to make a script to automate the one-click addition of comments to a PC-DMIS program.

    The only downsides are these:
    - the repeated pop-ups of Input Comments make for an annoying user interface.
    - Input Comments retain their last-entered data, so the lazy operator will simply click OK and use the previous values. I visited a company where they had been doing this for a year since the programmer had quit.

    Here's a simple Basic Script that provides a single pop-up dialog box that you can customize to your liking.
    This is a case where the program has a Basic Script call to run this BAS every part run.
    Here is the text for the BAS script:
    Sub Main
    '''''Create Dialog with these input items:
    Begin Dialog DIALOG_1 50,10, 275, 300,      oOPERATORINPUT
      GroupBox 5,5,260,25
    Text 20,15,85,12, "Enter Operator:"
      TextBox 85,13,135,12, .EditBox_1
      GroupBox 5,35,260,25
    Text 25,45,85,12, "Enter Job Number:"
      TextBox 95,43,135,12, .EditBox_2
      GroupBox 5,65,260,25
    Text 32,75,85,12, "Enter Serial Number:"
      TextBox 105,73,135,12, .EditBox_3
      GroupBox 5,210,172,25
    Text 10,220,85,12, "Need Manual Alignment?"
      OptionGroup .GROUP_2
        OptionButton 105,220,25,12, "YES"
        OptionButton 145,220,25,12, "NO"
      OKButton 195,210,65,45
      CancelButton 120,275,48,16
    End Dialog
    
    ''''' Set the Dialog for access:
    Dim Dialg As DIALOG_1
    button1 = Dialog(Dialg)
    
    ''''' Declar VB variables:
    Dim Progtype As String
    Dim SerNum As String
    Dim MANUALQ As String
    MANUALQ= "YES"
    
    '''''Quit if dialog got canceled, or go on to take the operator inputs and put them into VB variables:
    If button1 = 0 Then
      Progtype= "END"
    Else
    
      Select Case Dialg.GROUP_2
        Case 0
          MANUALQ= "YES"
        Case 1
          MANUALQ= "NO"
      End Select
    
    
     Oper = Dialg.EditBox_1
     Job = Dialg.EditBox_2
     SerNum = Dialg.EditBox_3
    End If
    
    '''''Link up to PC-DMIS:
    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
    
    '''''Find the PC-DMIS variables and fill their values in with the current values of VB variables:
    For Each Cmd In Cmds
      If Cmd.Type = ASSIGNMENT Then
        If Cmd.GetText(DEST_EXPR, 0) = "OPERATOR" Then
          bln = Cmd.PutText("""" + Oper + """", SRC_EXPR, 0)
          Cmd.ReDraw
        End If
        If Cmd.GetText(DEST_EXPR, 0) = "JOB" Then
          bln = Cmd.PutText("""" + Job + """", SRC_EXPR, 0)
          Cmd.ReDraw
        End If
        If Cmd.GetText(DEST_EXPR,0) = "SERNO" Then
          bln = Cmd.PutText("""" + SerNum + """", SRC_EXPR, 0)
          Cmd.ReDraw
        End If
        If Cmd.GetText(DEST_EXPR,0) = "MANUAL" Then
          bln = Cmd.PutText("""" + MANUALQ + """", SRC_EXPR, 0)
          Cmd.ReDraw
        End If
      End If
    Next Cmd
    
    '''''Finish.
    End Sub
    


    Here's a snippet of code from PC-DMIS that works with the above BAS script:
                ASSIGN/TRY=0
    RETRY_INPUT=LABEL/
                ASSIGN/TRY=TRY+1
                IF_GOTO/TRY>3,GOTO = ENDOFTIME
    CS1        =SCRIPT/FILENAME= C:\\OPERATOR_INPUTS_BASIC_VERYBASIC.BAS
                FUNCTION/Main,SHOW=YES,,
                STARTSCRIPT/
                ENDSCRIPT/
                ASSIGN/OPERATOR="NAME"
                ASSIGN/SERNO="SERIALNUMBER"
                ASSIGN/JOB="JOBNUMBER"
                ASSIGN/MANUAL="YES"
                IF/OPERATOR=="" OR SERNO=="" OR JOB==""
                  COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
                  MISSING REQUIRED INFORMATION
                GOTO/RETRY_INPUT
                END_IF/
                COMMENT/REPT,
    
                "     Operator: "+OPERATOR
                "Serial Number: "+SERNO
                "   Job Number: "+JOB
                ------------------------------------------------
    


    So, to modify this system to meet your needs:
    1) Make sure new PC-DMIS variable is in PC-DMIS program:
    ASSIGN/SHIFT=0

    2) In script, add new input item:
    Text 20,15,85,12, "Enter Shift:"
    TextBox 85,13,135,12, .EditBox_4
    Note the 4 #s: these are X, Y, Width, and Length all in pixels. X+ is left-to-right, Y+ is top-to-bottom.
    Therefore that new edit box will appear at X 85, Y13, and it's 135 pixels long by 12 wide.
    These coordinates will take some adjustment to get looking good on the dialog!

    3) In script, add new VB variable declaration:
    Dim ShiftVB As String

    4) In script, add new code to take whatever the operator typed into your new EditBox_4 item and stuff it into the new VB variable:
    ShiftVB = Dialg.EditBox_4

    5) In script, add new code to take the current value of the VB variable and stuff it into the correct PC-DMIS variable:
    If Cmd.GetText(DEST_EXPR,0) = "SHIFT" Then
    bln = Cmd.PutText("""" + ShiftVB + """", SRC_EXPR, 0)
    Cmd.ReDraw
    End If

    6) Next level: make a BAS script that creates all the required and nice-to-have PC-DMIS commands in the program, and link it to a new icon.
Reply
  • As noted above, it is fun and easy to make a script to automate the one-click addition of comments to a PC-DMIS program.

    The only downsides are these:
    - the repeated pop-ups of Input Comments make for an annoying user interface.
    - Input Comments retain their last-entered data, so the lazy operator will simply click OK and use the previous values. I visited a company where they had been doing this for a year since the programmer had quit.

    Here's a simple Basic Script that provides a single pop-up dialog box that you can customize to your liking.
    This is a case where the program has a Basic Script call to run this BAS every part run.
    Here is the text for the BAS script:
    Sub Main
    '''''Create Dialog with these input items:
    Begin Dialog DIALOG_1 50,10, 275, 300,      oOPERATORINPUT
      GroupBox 5,5,260,25
    Text 20,15,85,12, "Enter Operator:"
      TextBox 85,13,135,12, .EditBox_1
      GroupBox 5,35,260,25
    Text 25,45,85,12, "Enter Job Number:"
      TextBox 95,43,135,12, .EditBox_2
      GroupBox 5,65,260,25
    Text 32,75,85,12, "Enter Serial Number:"
      TextBox 105,73,135,12, .EditBox_3
      GroupBox 5,210,172,25
    Text 10,220,85,12, "Need Manual Alignment?"
      OptionGroup .GROUP_2
        OptionButton 105,220,25,12, "YES"
        OptionButton 145,220,25,12, "NO"
      OKButton 195,210,65,45
      CancelButton 120,275,48,16
    End Dialog
    
    ''''' Set the Dialog for access:
    Dim Dialg As DIALOG_1
    button1 = Dialog(Dialg)
    
    ''''' Declar VB variables:
    Dim Progtype As String
    Dim SerNum As String
    Dim MANUALQ As String
    MANUALQ= "YES"
    
    '''''Quit if dialog got canceled, or go on to take the operator inputs and put them into VB variables:
    If button1 = 0 Then
      Progtype= "END"
    Else
    
      Select Case Dialg.GROUP_2
        Case 0
          MANUALQ= "YES"
        Case 1
          MANUALQ= "NO"
      End Select
    
    
     Oper = Dialg.EditBox_1
     Job = Dialg.EditBox_2
     SerNum = Dialg.EditBox_3
    End If
    
    '''''Link up to PC-DMIS:
    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
    
    '''''Find the PC-DMIS variables and fill their values in with the current values of VB variables:
    For Each Cmd In Cmds
      If Cmd.Type = ASSIGNMENT Then
        If Cmd.GetText(DEST_EXPR, 0) = "OPERATOR" Then
          bln = Cmd.PutText("""" + Oper + """", SRC_EXPR, 0)
          Cmd.ReDraw
        End If
        If Cmd.GetText(DEST_EXPR, 0) = "JOB" Then
          bln = Cmd.PutText("""" + Job + """", SRC_EXPR, 0)
          Cmd.ReDraw
        End If
        If Cmd.GetText(DEST_EXPR,0) = "SERNO" Then
          bln = Cmd.PutText("""" + SerNum + """", SRC_EXPR, 0)
          Cmd.ReDraw
        End If
        If Cmd.GetText(DEST_EXPR,0) = "MANUAL" Then
          bln = Cmd.PutText("""" + MANUALQ + """", SRC_EXPR, 0)
          Cmd.ReDraw
        End If
      End If
    Next Cmd
    
    '''''Finish.
    End Sub
    


    Here's a snippet of code from PC-DMIS that works with the above BAS script:
                ASSIGN/TRY=0
    RETRY_INPUT=LABEL/
                ASSIGN/TRY=TRY+1
                IF_GOTO/TRY>3,GOTO = ENDOFTIME
    CS1        =SCRIPT/FILENAME= C:\\OPERATOR_INPUTS_BASIC_VERYBASIC.BAS
                FUNCTION/Main,SHOW=YES,,
                STARTSCRIPT/
                ENDSCRIPT/
                ASSIGN/OPERATOR="NAME"
                ASSIGN/SERNO="SERIALNUMBER"
                ASSIGN/JOB="JOBNUMBER"
                ASSIGN/MANUAL="YES"
                IF/OPERATOR=="" OR SERNO=="" OR JOB==""
                  COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
                  MISSING REQUIRED INFORMATION
                GOTO/RETRY_INPUT
                END_IF/
                COMMENT/REPT,
    
                "     Operator: "+OPERATOR
                "Serial Number: "+SERNO
                "   Job Number: "+JOB
                ------------------------------------------------
    


    So, to modify this system to meet your needs:
    1) Make sure new PC-DMIS variable is in PC-DMIS program:
    ASSIGN/SHIFT=0

    2) In script, add new input item:
    Text 20,15,85,12, "Enter Shift:"
    TextBox 85,13,135,12, .EditBox_4
    Note the 4 #s: these are X, Y, Width, and Length all in pixels. X+ is left-to-right, Y+ is top-to-bottom.
    Therefore that new edit box will appear at X 85, Y13, and it's 135 pixels long by 12 wide.
    These coordinates will take some adjustment to get looking good on the dialog!

    3) In script, add new VB variable declaration:
    Dim ShiftVB As String

    4) In script, add new code to take whatever the operator typed into your new EditBox_4 item and stuff it into the new VB variable:
    ShiftVB = Dialg.EditBox_4

    5) In script, add new code to take the current value of the VB variable and stuff it into the correct PC-DMIS variable:
    If Cmd.GetText(DEST_EXPR,0) = "SHIFT" Then
    bln = Cmd.PutText("""" + ShiftVB + """", SRC_EXPR, 0)
    Cmd.ReDraw
    End If

    6) Next level: make a BAS script that creates all the required and nice-to-have PC-DMIS commands in the program, and link it to a new icon.
Children
No Data