hexagon logo

SKIPPING OPS WITH IF AND STATEMENTS

Hey all,

A program begins with a basic alignment and then a DCC alignment. When the program starts it asks what op you're checking, 1, 2, or 3 for example. Depending on what you select the program should construct your alignments and then move on to that op. If you're only checking op2 for example, how do you first instruct pcdmis to run the alignment code before moving on to op2? 

It's been years since I've done this and I feel like Forrest Gump all of a sudden.

Thank You

  • You can have the input comment at the start of the program, but put your If Goto commands after directly after your alignment code.

  • INVALID_OP =LABEL/
    OP_INPUT   =COMMENT/INPUT,NO,FULL SCREEN=NO,
                ENTER A NUMBER CORRESPONDING TO THE CURRENT OPERATION
                 
                (1) OPERATION 10
                (2) OPERATION 20
                (3) OPERATION 50
                 
                ASSIGN/OPERATION=OP_INPUT.INPUT
                IF/OPERATION <> 1 AND OPERATION <> 2 AND OPERATION <> 3
                  COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,OVC=NO,
                  INVALID INPUT
                  GOTO/INVALID_OP
                END_IF/
                SELECT/OPERATION
                  CASE/1
    OP10_ALN       =ALIGNMENT/START,RECALL:MANUAL_ALN,LIST=YES
                    ALIGNMENT/END
                    GOTO/OP_10_LABEL
                  END_CASE/
                  CASE/2
    OP20_ALN       =ALIGNMENT/START,RECALL:MANUAL_ALN,LIST=YES
                    ALIGNMENT/END
                    GOTO/OP_20_LABEL
                  END_CASE/
                  CASE/3
    OP50_ALN       =ALIGNMENT/START,RECALL:MANUAL_ALN,LIST=YES
                    ALIGNMENT/END
                    GOTO/OP_50_LABEL
                  END_CASE/
                END_SELECT/
    OP_10_LABEL=LABEL/
    $$ NO,
                ENTER OPERATION 10 CODE
                 
                GOTO/END
    OP_20_LABEL=LABEL/
    $$ NO,
                ENTER OPERATION 20 CODE
                 
                GOTO/END
    OP_50_LABEL=LABEL/
    $$ NO,
                ENTER OPERATION 50 CODE
                 
                GOTO/END
                
    END         =LABEL/

    EDIT: Added actual PC-DMIS code with input error checking.

  • Jesse, this sounds so simple that I should have been able to guess and get it right! Why I didn't this never occurred to me I don't know. Thank you!

  • Use an operator comment of type Input, and explain what each input value does. Then have it GOTO where the first feature for that input value is.

    C1         =COMMENT/INPUT,NO,FULL SCREEN=NO,
                1 For Part Number xxxxx
                2 For Part Number xxxxx
                3 For Part Number xxxxx
                IF_GOTO/C1.INPUT == 1,GOTO = PART1
                IF_GOTO/C1.INPUT == 2,GOTO = PART2
                IF_GOTO/C1.INPUT == 3,GOTO = PART3
    PART1      =LABEL/
    $$ NO,
                Alignment data for Input 1
    PART2      =LABEL/
    $$ NO,
                Alignment data for Input 2
    PART3      =LABEL/
    $$ NO,
                Alignment data for Input 3

    What Jacob posted is also a very good solution for this.

  • You're welcome.  If you're using a different alignment for each operation you'll need to use one of the other solutions suggested here though.

  • I appreciate the answers, but I'm having the same problem with each. If I select op1 it will run through the alignments, and all the op1 features, but it continues on to op2, even though I have an END_IF/ after op1. This is just a sample I'm using while trying to work this out, so yeah, there really is just two diameters in op1.

    I did get it to skip op1 and jump to op2. 

    C1 =COMMENT/INPUT,NO,FULL SCREEN=NO,

    1
    2
    3

    IF/C1.INPUT == 1
    CIR3 =FEAT/CONTACT/CIRCLE/DEFAULT,CARTESIAN,IN,LEAST_SQR
    THEO/<4,-2,0>,<0,0,1>,2
    ACTL/<4,-2,0>,<0,0,1>,2
    TARG/<4,-2,0>,<0,0,1>
    START ANG=0,END ANG=360
    ANGLE VEC=<1,0,0>
    DIRECTION=CCW
    SHOW FEATURE PARAMETERS=NO
    SHOW CONTACT PARAMETERS=YES
    NUMHITS=4,DEPTH=0.0787,PITCH=0
    SAMPLE METHOD=SAMPLE_HITS
    SAMPLE HITS=0,SPACER=0.0197
    AVOIDANCE MOVE=NO
    FIND HOLE=DISABLED,ONERROR=NO,READ POS=NO
    SHOW HITS=NO


    CIR4 =FEAT/CONTACT/CIRCLE/DEFAULT,CARTESIAN,IN,LEAST_SQR
    THEO/<2,-4,0>,<0,0,1>,2
    ACTL/<2,-4,0>,<0,0,1>,2
    TARG/<2,-4,0>,<0,0,1>
    START ANG=0,END ANG=360
    ANGLE VEC=<1,0,0>
    DIRECTION=CCW
    SHOW FEATURE PARAMETERS=NO
    SHOW CONTACT PARAMETERS=YES
    NUMHITS=4,DEPTH=0.0787,PITCH=0
    SAMPLE METHOD=SAMPLE_HITS
    SAMPLE HITS=0,SPACER=0.0197
    AVOIDANCE MOVE=NO
    FIND HOLE=DISABLED,ONERROR=NO,READ POS=NO
    SHOW HITS=NO
    END_IF/

    L2 =LABEL/
    CIR5 =FEAT/CONTACT/CIRCLE/DEFAULT,CARTESIAN,IN,LEAST_SQR
    THEO/<6,-4,0>,<0,0,1>,2
    ACTL/<6,-4,0>,<0,0,1>,2
    TARG/<6,-4,0>,<0,0,1>
    START ANG=0,END ANG=360
    ANGLE VEC=<1,0,0>
    DIRECTION=CCW
    SHOW FEATURE PARAMETERS=NO
    SHOW CONTACT PARAMETERS=YES
    NUMHITS=4,DEPTH=0.0787,PITCH=0
    SAMPLE METHOD=SAMPLE_HITS
    SAMPLE HITS=0,SPACER=0.0197
    AVOIDANCE MOVE=NO
    FIND HOLE=DISABLED,ONERROR=NO,READ POS=NO
    SHOW HITS=NO

  • You need to have a label at the next part of the program each input needs to drive to. Since all the alignments are at the top, each one needs a GOTO to prevent PC-DMIS from going to them. Even if your input is to go to OP1, it will still execute all code below it. Including the OP2

    So at the end of your alignment feature you need to put a GOTO and whatever the label name you choose to continue the routine. If they all share the same program after the alignment, then just include 1 GOTO, if they do not, you'll need to include a GOTO for the reporting section as well

    ERROR1      =LABEL/
    C1         =COMMENT/INPUT,NO,FULL SCREEN=NO,
                1 For Part Number xxxxx
                2 For Part Number xxxxx
                3 For Part Number xxxxx
                IF/C1.INPUT <> 1 AND C1.INPUT <> 2 AND C1.INPUT <> 3
                  COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,OVC=NO,
                  Invalid entry
                  GOTO/ERROR1
                END_IF/
                IF_GOTO/C1.INPUT == 1,GOTO = PART1
                IF_GOTO/C1.INPUT == 2,GOTO = PART2
                IF_GOTO/C1.INPUT == 3,GOTO = PART3
    PART1      =LABEL/
    $$ NO,
                Alignment data for Input 1
                GOTO/ROUTINE1
    PART2      =LABEL/
    $$ NO,
                Alignment data for Input 2
                GOTO/ROUTINE2
    PART3      =LABEL/
    $$ NO,
                Alignment data for Input 3
                GOTO/ROUTINE3
    $$ NO,
                Routine 1 Data
    ROUTINE1   =LABEL/
    $$ NO,
                Routine 2 Data
    ROUTINE2   =LABEL/
    $$ NO,
                Routine 3 Data
    ROUTINE3   =LABEL/

  • I would put a label at the end of the program and then put a GOTO to that label at the end of each operation.

  • I need to revisit this topic. I have a program with 3ops. My comment asks the operator to select which op they're running, 1,  2,  3 or 4 for the full program. If they select either 1, 2 or 3, it runs fine. If they select 4 however, it has issues. FYI, this program only has one alignment. I'm assuming there doesn't need to be any code if they select op4, as it should skip 1, 2, and 3.

    This is the code below. If I select op 1, it will properly go to the XMINUS clearplane and run through op1. If however I select op 4, it will immediately try going through the part to XPLUS.

    My last issue with this is that the probe makes unintended and unnecessary rotations when selecting independent ops. We use a 90° probe on this part and at some points it will point the probe straight up to ZPLUS, then rotate back to it's correct position. It appears it's reading the angle from the probe above it, but that code is in a different op so I'm unsure why it's using it.


    A_B_C =ALIGNMENT/START,RECALL:BASIC_ALN,LIST=YES
    ALIGNMENT/LEVEL,XMINUS,DAT_A
    ALIGNMENT/TRANS,XAXIS,DAT_A
    ALIGNMENT/ROTATE_CIRCLE,YPLUS,TO,DAT_B,AND,DAT_C,ABOUT,XMINUS
    ALIGNMENT/TRANS,YAXIS,DAT_B
    ALIGNMENT/TRANS,ZAXIS,DAT_B
    ALIGNMENT/END


    DATDEF/A,FEATURES=DAT_A,,
    DATDEF/B,FEATURES=DAT_B,,
    DATDEF/C,FEATURES=DAT_C,,


    IF/C1.INPUT == 1
    GOTO/OP1
    END_IF/

    IF/C1.INPUT == 2
    MOVE/CLEARPLANE
    CLEARP/XMINUS,-4,XMINUS,0,OFF
    CLEARP/XMINUS,-25,XMINUS,0,ON
    TIP/T1A90B90, SHANKIJK=-1, -0.001, 0.003, ANGLE=89.773
    MOVE/POINT,NORMAL,<-4,0,0>
    MOVE/POINT,NORMAL,<-4,0,350>
    MOVE/POINT,NORMAL,<300,0,350>
    GOTO/OP2
    END_IF/


    IF/C1.INPUT == 3

    MOVE/CLEARPLANE
    MOVE/POINT,NORMAL,<-23.975,3.559,395.34>
    MOVE/POINT,NORMAL,<158.601,3.775,395.557>
    LOADPROBE/3MM_X_50MM_5
    TIP/T1A0B180, SHANKIJK=0.001, -1, -0.001, ANGLE=-0.15
    GOTO/OP3
    END_IF/

    OP1 =LABEL/
    CLEARP/XMINUS,-4,XMINUS,0,ON
    MOVE/CLEARPLANE

  • Setup one startup point, let each OP block share this beginning point, all alignments needed for OP do inside OP block

    Use goto command for navigating through operations.
    put Labels in each OP with START and END label, in the beginning of block check for operator input and navigate to labels according it.