hexagon logo

Pulling loop count as a variable

I've been working on a program off n on that runs with a variable part loop (can run 1 through 8 parts). How can I extract the loop count and assign it as a variable?

TIA
Duane
  • Is there an operator input as to how many parts are being ran?
  • Sounds do-able, please show us the code you're working with
  • Before your loop put this:
    ASSIGN/COUNTER=0

    After your initial loop line put this
    ASSIGN/COUNTER=COUNTER+1


    Use counter as your loop counter for reporting, logic, etc...
  • Using the actually loop function:

    
    LOOP1 =LOOP/START,ID=YES,NUMBER=FORM4,START=1,SKIP=,
    OFFSET:XAXIS=0,YAXIS=0,ZAXIS=0,ANGLE=0
    
    ASSIGN/LOOP_COUNT=LOOP1
    
    LOOP/END
    
    
  • We have a winner!! WOOHOO!

    Thank you for the input. Code is posted below
  • This is what runs like the wind, lets me set up and run multiple parts from 1 up to 8 (fixture holds up to 8 parts) so this can be modified to run any number of parts and this only offsets in the X axis but could easily be modified. Thank you for the loop count

    Operator inputs

    JOBNO =COMMENT/INPUT,NO,'
    ,
    ,Job Number
    ,
    ,'
    OPID =COMMENT/INPUT,NO,'
    ,
    ,Operator I.D.
    ,
    ,'
    RUN_NUM =COMMENT/INPUT,NO,'
    ,
    ,How many stations are loaded?
    ,
    ,Enter 1 through 8
    ,'
    SER_NUM1 =COMMENT/INPUT,NO,'
    ,Part number in Station 1
    ,'
    IF/RUN_NUM.INPUT==1
    GOTO/MENU
    END_IF/
    SER_NUM2 =COMMENT/INPUT,NO,'
    ,Part number in Station 2
    ,'
    IF/RUN_NUM.INPUT==2
    GOTO/MENU
    END_IF/
    SER_NUM3 =COMMENT/INPUT,NO,'
    ,Part number in Station 3
    ,'
    IF/RUN_NUM.INPUT==3
    GOTO/MENU
    END_IF/
    SER_NUM4 =COMMENT/INPUT,NO,'
    ,Part number in Station 4
    ,'
    IF/RUN_NUM.INPUT==4
    GOTO/MENU
    END_IF/
    SER_NUM5 =COMMENT/INPUT,NO,'
    ,Part number in Station 5
    ,'
    IF/RUN_NUM.INPUT==5
    GOTO/MENU
    END_IF/
    SER_NUM6 =COMMENT/INPUT,NO,'
    ,Part number in Station 6
    ,'
    IF/RUN_NUM.INPUT==6
    GOTO/MENU
    END_IF/
    SER_NUM7 =COMMENT/INPUT,NO,'
    ,Part number in Station 7
    ,'
    IF/RUN_NUM.INPUT==7
    GOTO/MENU
    END_IF/
    SER_NUM8 =COMMENT/INPUT,NO,'
    ,Part number in Station 8
    ,'
    IF/RUN_NUM.INPUT==8
    GOTO/MENU
    END_IF/


    Loop and assignments
    LOOP_RUN =LOOP/START,ID=YES,NUMBER=RUN_NUM.INPUT,START=1,SKIP=,
    OFFSET:XAXIS=0,YAXIS=0,ZAXIS=0,ANGLE=0
    ASSIGN/COUNTER=LOOP_RUN
    IF/COUNTER==1
    ASSIGN/SERNUM=SER_NUM1.INPUT
    ASSIGN/OFFSET_VAL=0
    END_IF/
    IF/COUNTER==2
    ASSIGN/SERNUM=SER_NUM2.INPUT
    ASSIGN/OFFSET_VAL=27
    END_IF/
    IF/COUNTER==3
    ASSIGN/SERNUM=SER_NUM3.INPUT
    ASSIGN/OFFSET_VAL=54
    END_IF/
    IF/COUNTER==4
    ASSIGN/SERNUM=SER_NUM4.INPUT
    ASSIGN/OFFSET_VAL=81
    END_IF/
    IF/COUNTER==5
    ASSIGN/SERNUM=SER_NUM5.INPUT
    ASSIGN/OFFSET_VAL=108
    END_IF/
    IF/COUNTER==6
    ASSIGN/SERNUM=SER_NUM6.INPUT
    ASSIGN/OFFSET_VAL=135
    END_IF/
    IF/COUNTER==7
    ASSIGN/SERNUM=SER_NUM7.INPUT
    ASSIGN/OFFSET_VAL=162
    END_IF/
    IF/COUNTER==8
    ASSIGN/SERNUM=SER_NUM8.INPUT
    ASSIGN/OFFSET_VAL=189
    END_IF/
    RECALL/ALIGNMENT,INTERNAL,MAN_AL
    FIXTURE_OFFSET=GENERIC/POINT,DEPENDENT,CARTESIAN,$
    NOM/XYZ,<0+0,0+0,0+0>,$
    MEAS/XYZ,<OFFSET_VAL,0+0,0+0>,$
    NOM/IJK,<0+0,0+0,1+0>,$
    MEAS/IJK,<0+0,0+0,1+0>
    MAN_AL_RECALL=ALIGNMENT/START,RECALL:MAN_AL,LIST=YES
    ALIGNMENT/TRANS,XAXIS,FIXTURE_OFFSET
    ALIGNMENT/END


    Reporting code
    ASSIGN/PATH="N:\63 - Metrology\CMM Reports\\"+PARTNUM+" Job"+JOBNO.INPUT+"_"+SERNUM+"_.PDF"
    PRINT/REPORT,EXEC MODE=END,$
    TO_FILE=ON,OVERWRITE=PATH,$
    TO_PRINTER=ON,$
    TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
    REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMEN SIONS=NO,$
    PREVIOUS_RUNS=DELETE_INSTANCES
    LOOP/END
  • Let me just say that I have no experience with looping and the above worked great for me and it fits the bill for what my customer is after. One more question though, If I wanted to do nested loops with differing amounts how would I look to achieve this?

    An example would be a 5x10 grid (so 50 parts max) If the customer has varying batch sizes e.g. 47 would I do a prompt for each row?

    Thanks for any input.

    Adam