Using M201 and Python to Lookup a CSV Table File and Using It's Values

More
4 years 2 months ago - 4 years 2 months ago #249564 by my1987toyota
  The working M201 Python script
 

File Attachment:

File Name: remap_11.0...08-12.py
File Size:14.21 KB



The CSV file
 

File Attachment:

File Name: feeder_V1....8-12.txt
File Size:1.85 KB
Last edit: 4 years 2 months ago by my1987toyota. Reason: correcting the major botch job from the forum software

Please Log in or Create an account to join the conversation.

More
4 years 2 months ago #249585 by my1987toyota
Now in readable format
M201
Code:
#remap version 11.02 import emccanon import sys import interpreter import csv feedersFile = open('feeder_V1.04.csv') coordinatesReader = csv.reader(feedersFile) locationData = list(coordinatesReader) fdrPos = locationData         # these codes can be changed to meet your machines needs endCoord = 'Z0.0 C0.0'    # G_codes to ensure Z and C axis are in there 0 position prefix1 = 'G53 G0 '    # machine coordinate system and G0 rapid move prefix2 = 'G53 G1 '    # machine coordinate system and G1 move feeds1 = ' F150'    # feed value for Z to pick up part vacOn = 'M7'    # M_code for turning on vaccum pTime = 'G4 P0.5'   # G_code for pause time to allow vaccum to asstablish retract = 'G53 G1 Z0.0 F150'    # Z retract speed with part attatched fdrCycl = 'M161 P'   # M_code to advance the feeder def M201(self, **words):     print(words)     P = words['p']     print(P)     if P < 0:         print("error, a P parameter must be passed") #side 1 feeders     elif P == 1:         self.execute(prefix1 + fdrPos[1][1] + ' ' + fdrPos[1][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos [1][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '1')     elif P == 2:         self.execute(prefix1 + fdrPos[2][1] + ' ' + fdrPos[2][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[2][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '2')     elif P == 3:         self.execute(prefix1 + fdrPos[3][1] + ' ' + fdrPos[3][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[3][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '3')     elif P == 4:         self.execute(prefix1 + fdrPos[4][1] + ' ' + fdrPos[4][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[4][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '4')     elif P == 5:         self.execute(prefix1 + fdrPos[5][1] + ' ' + fdrPos[5][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[5][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '5')     elif P == 6:         self.execute(prefix1 + fdrPos[6][1] + ' ' + fdrPos[6][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[6][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '6')     elif P == 7:         self.execute(prefix1 + fdrPos[7][1] + ' ' + fdrPos[7][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[7][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '7')     elif P == 8:         self.execute(prefix1 + fdrPos[8][1] + ' ' + fdrPos[8][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[8][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '8')     elif P == 9:         self.execute(prefix1 + fdrPos[9][1] + ' ' + fdrPos[9][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[9][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '9')     elif P == 10:         self.execute(prefix1 + fdrPos[10][1] + ' ' + fdrPos[10][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[10][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '10')     elif P == 11:         self.execute(prefix1 + fdrPos[11][1] + ' ' + fdrPos[11][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[11][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '11')     elif P == 12:         self.execute(prefix1 + fdrPos[12][1] + ' ' + [12][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[12][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '12')     elif P == 13:         self.execute(prefix1 + fdrPos[13][1] + ' ' + fdrPos[13][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[13][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '13')     elif P == 14:         self.execute(prefix1 + fdrPos[14][1] + ' ' + fdrPos[14][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[14][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '14')     elif P == 15:         self.execute(prefix1 + fdrPos[15][1] + ' ' + fdrPos[15][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[15][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '15')     elif P == 16:         self.execute(prefix1 + fdrPos[16][1] + ' ' + fdrPos[16][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[16][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '16')     elif P == 17:         self.execute(prefix1 + fdrPos[17][1] + ' ' + fdrPos[17][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[17][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '17')     elif P == 18:         self.execute(prefix1 + fdrPos[18][1] + ' ' + fdrPos[18][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[18][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '18')     elif P == 19:         self.execute(prefix1 + fdrPos[19][1] + ' ' + fdrPos[19][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[19][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '19')     elif P == 20:         self.execute(prefix1 + fdrPos[20][1] + ' ' + fdrPos[20][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[20][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '20')     elif P == 21:         self.execute(prefix1 + fdrPos[21][1] + ' ' + fdrPos[21][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[21][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '21')     elif P == 22:         self.execute(prefix1 + fdrPos[22][1] + ' ' + fdrPos[22][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[22][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '22')     elif P == 23:         self.execute(prefix1 + fdrPos[23][1] + ' ' + fdrPos[23][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[23][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '23')     elif P == 24:         self.execute(prefix1 + fdrPos[24][1] + ' ' + fdrPos[24][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[24][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '24') #side 2 feeders     elif P == 25:         self.execute(prefix1 + fdrPos[25][1] + ' ' + fdrPos[25][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[25][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '25')     elif P == 26:         self.execute(prefix1 + fdrPos[26][1] + ' ' + fdrPos[26][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[26][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '26')     elif P == 27:         self.execute(prefix1 + fdrPos[27][1] + ' ' + fdrPos[27][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[27][3] + feeds1)         self.executevacOn(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '27')     elif P == 28:         self.execute(prefix1 + fdrPos[28][1] + ' ' + fdrPos[28][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[28][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '28')     elif P == 29:         self.execute(prefix1 + fdrPos[29][1] + ' ' + fdrPos[29][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[29][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '29')     elif P == 30:         self.execute(prefix1 + fdrPos[30][1] + ' ' + fdrPos[30][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[30][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '30')     elif P == 31:         self.execute(prefix1 + fdrPos[31][1] + ' ' + fdrPos[31][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[31][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '31')     elif P == 32:         self.execute(prefix1 + fdrPos[32][1] + ' ' + fdrPos[32][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[32][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '32')     elif P == 33:         self.execute(prefix1 + fdrPos[33][1] + ' ' + fdrPos[33][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[33][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '33')     elif P == 34:         self.execute(prefix1 + fdrPos[34][1] + ' ' + fdrPos[34][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[34][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '34')     elif P == 35:         self.execute(prefix1 + fdrPos[35][1] + ' ' + fdrPos[35][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[35][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '35')     elif P == 36:         self.execute(prefix1 + fdrPos[36][1] + ' ' + fdrPos[36][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[36][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '36')     elif P == 37:         self.execute(prefix1 + fdrPos[37][1] + ' ' + fdrPos[37][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[37][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '37')     elif P == 38:         self.execute(prefix1 + fdrPos[38][1] + ' ' + fdrPos[38][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[38][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '38')     elif P == 39:         self.execute(prefix1 + fdrPos[39][1] + ' ' + fdrPos[39][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[39][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '39')     elif P == 40:         self.execute(prefix1 + fdrPos[40][1] + ' ' + fdrPos[40][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[40][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '40')     elif P == 41:         self.execute(prefix1 + fdrPos[41][1] + ' ' + fdrPos[41][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[41][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '41')     elif P == 42:         self.execute(prefix1 + fdrPos[42][1] + ' ' + fdrPos[42][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[42][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '42')     elif P == 43:         self.execute(prefix1 + fdrPos[43][1] + ' ' + fdrPos[43][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[43][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '43')     elif P == 44:         self.execute(prefix1 + fdrPos[44][1] + ' ' + fdrPos[44][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[44][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '44')     elif P == 45:         self.execute(prefix1 + fdrPos[45][1] + ' ' + fdrPos[45][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[45][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '45')     elif P == 46:         self.execute(prefix1 + fdrPos[46][1] + ' ' + fdrPos[46][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[46][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '46')     elif P == 47:         self.execute(prefix1 + fdrPos[47][1] + ' ' + fdrPos[47][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[47][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '47')     elif P == 48:         self.execute(prefix1 + fdrPos[48][1] + ' ' + fdrPos[48][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[48][3] + feeds1)         self.execut(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '48')     return interpreter.INTERP_OK


The feeder_V1.04 csv file
Code:
Feeder Number,X-axis,Y axis,Z-axis,C-axis Feeder 1,X0.125,Y-0.5118,Z-0.0,C0.0 Feeder 2,X0.125,Y-1.0235,Z-0.0,C0.0 Feeder 3,X0.125,Y-1.5354,Z-0.0,C0.0 Feeder 4,X0.125,Y-2.0472,Z-0.0,C0.0 Feeder 5,X0.125,Y-2.5590,Z-0.0,C0.0 Feeder 6,X0.125,Y-3.0708,Z-0.0,C0.0 Feeder 7,X0.125,Y-3.5826,Z-0.0,C0.0 Feeder 8,X0.125,Y-4.0994,Z-0.0,C0.0 Feeder 9,X0.125,Y-4.6062,Z-0.0,C0.0 Feeder 10,X0.125,Y-5.1180,Z-0.0,C0.0 Feeder 11,X0.125,Y-5.6298,Z-0.0,C0.0 Feeder 12,X0.125,Y-6.1416,Z-0.0,C0.0 Feeder 13,X0.125,Y-6.6534,Z-0.0,C0.0 Feeder 14,X0.125,Y-7.1652,Z-0.0,C0.0 Feeder 15,X0.125,Y-7.6770,Z-0.0,C0.0 Feeder 16,X0.125,Y-8.1888,Z-0.0,C0.0 Feeder 17,X0.125,Y-8.7006,Z-0.0,C0.0 Feeder 18,X0.125,Y-9.2124,Z-0.0,C0.0 Feeder 19,X0.125,Y-9.7242,Z-0.0,C0.0 Feeder 20,X0.125,Y-10.2360,Z-0.0,C0.0 Feeder 21,X0.125,Y-10.7478,Z-0.0,C0.0 Feeder 22,X0.125,Y-11.2596,Z-0.0,C0.0 Feeder 23,X0.125,Y-11.7714,Z-0.0,C0.0 Feeder 24,X0.125,Y-12.2832,Z-0.0,C0.0 Feeder 25,X15.875,Y-0.5118,Z-0.0,C0.0 Feeder 26,X15.875,Y-1.0235,Z-0.0,C0.0 Feeder 27,X15.875,Y-1.5354,Z-0.0,C0.0 Feeder 28,X15.875,Y-2.0472,Z-0.0,C0.0 Feeder 29,X15.875,Y-2.5590,Z-0.0,C0.0 Feeder 30,X15.875,Y-3.0708,Z-0.0,C0.0 Feeder 31,X15.875,Y-3.5826,Z-0.0,C0.0 Feeder 32,X15.875,Y-4.0994,Z-0.0,C0.0 Feeder 33,X15.875,Y-4.6062,Z-0.0,C0.0 Feeder 34,X15.875,Y-5.1180,Z-0.0,C0.0 Feeder 35,X15.875,Y-5.6298,Z-0.0,C0.0 Feeder 36,X15.875,Y-6.1416,Z-0.0,C0.0 Feeder 37,X15.875,Y-6.6534,Z-0.0,C0.0 Feeder 38,X15.875,Y-7.1652,Z-0.0,C0.0 Feeder 39,X15.875,Y-7.6770,Z-0.0,C0.0 Feeder 40,X15.875,Y-8.1888,Z-0.0,C0.0 Feeder 41,X15.875,Y-8.7006,Z-0.0,C0.0 Feeder 42,X15.875,Y-9.2124,Z-0.0,C0.0 Feeder 43,X15.875,Y-9.7242,Z-0.0,C0.0 Feeder 44,X15.875,Y-10.2360,Z-0.0,C0.0 Feeder 45,X15.875,Y-10.7478,Z-0.0,C0.0 Feeder 46,X15.875,Y-11.2596,Z-0.0,C0.0 Feeder 47,X15.875,Y-11.7714,Z-0.0,C0.0 Feeder 48,X15.875,Y-12.2832,Z-0.0,C0.0

Please Log in or Create an account to join the conversation.

More
4 years 2 months ago #249586 by my1987toyota
Something I will have to try and figure out is a way to update the values of the csv file
while Linuxcnc is already running. That way if you change out a feeder and the part is offset
you can enter that new location into the csv table and the program will run with the new
location without reloading Linuxcnc.

Please Log in or Create an account to join the conversation.

More
4 years 2 months ago #249605 by my1987toyota
Well that didn't take long. LOL
The biggest problem was the csv reader was in the global region of the python remap script.
this time I was successful in placing it in the local M201 code so every time the M201 was called
the program would check the csv file. in effect you can update the table between M201 calls.
I will be placing the new remap python file in my next post in both readable text and a python file.
andypugh if you're reading this give this code a go and let me know what you think.

Please Log in or Create an account to join the conversation.

More
4 years 2 months ago #249606 by my1987toyota
remap_11.03
Code:
#remap version 11.03 import emccanon import sys import interpreter import csv def M201(self, **words):     print(words)     P = words['p']     print(P)     feedersFile = open('feeder_V1.04.csv')     coordinatesReader = csv.reader(feedersFile)     locationData = list(coordinatesReader)     fdrPos = locationData             # these codes can be taylored to your machine if needed     endCoord = 'Z0.0 C0.0'    # G_codes to ensure Z and C axis are in there 0 position     prefix1 = 'G53 G0 '    # machine coordinate system and G0 rapid move     prefix2 = 'G53 G1 '    # machine coordinate system and G1 move     feeds1 = ' F150'    # feed value for Z to pick up part     vacOn = 'M7'    # M_code for turning on vaccum     pTime = 'G4 P0.5'   # G_code for pause time to allow vaccum to asstablish     retract = 'G53 G1 Z0.0 F150'    # Z retract speed with part attatched     fdrCycl = 'M161 P'   # M_code for feeder advance          if P < 0:         print("error, a P parameter must be passed") #side 1 feeders     elif P == 1:         self.execute(prefix1 + fdrPos[1][1] + ' ' + fdrPos[1][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos [1][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '1')     elif P == 2:         self.execute(prefix1 + fdrPos[2][1] + ' ' + fdrPos[2][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[2][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '2')     elif P == 3:         self.execute(prefix1 + fdrPos[3][1] + ' ' + fdrPos[3][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[3][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '3')     elif P == 4:         self.execute(prefix1 + fdrPos[4][1] + ' ' + fdrPos[4][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[4][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '4')     elif P == 5:         self.execute(prefix1 + fdrPos[5][1] + ' ' + fdrPos[5][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[5][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '5')     elif P == 6:         self.execute(prefix1 + fdrPos[6][1] + ' ' + fdrPos[6][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[6][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '6')     elif P == 7:         self.execute(prefix1 + fdrPos[7][1] + ' ' + fdrPos[7][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[7][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '7')     elif P == 8:         self.execute(prefix1 + fdrPos[8][1] + ' ' + fdrPos[8][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[8][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '8')     elif P == 9:         self.execute(prefix1 + fdrPos[9][1] + ' ' + fdrPos[9][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[9][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '9')     elif P == 10:         self.execute(prefix1 + fdrPos[10][1] + ' ' + fdrPos[10][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[10][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '10')     elif P == 11:         self.execute(prefix1 + fdrPos[11][1] + ' ' + fdrPos[11][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[11][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '11')     elif P == 12:         self.execute(prefix1 + fdrPos[12][1] + ' ' + [12][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[12][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '12')     elif P == 13:         self.execute(prefix1 + fdrPos[13][1] + ' ' + fdrPos[13][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[13][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '13')     elif P == 14:         self.execute(prefix1 + fdrPos[14][1] + ' ' + fdrPos[14][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[14][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '14')     elif P == 15:         self.execute(prefix1 + fdrPos[15][1] + ' ' + fdrPos[15][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[15][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '15')     elif P == 16:         self.execute(prefix1 + fdrPos[16][1] + ' ' + fdrPos[16][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[16][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '16')     elif P == 17:         self.execute(prefix1 + fdrPos[17][1] + ' ' + fdrPos[17][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[17][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '17')     elif P == 18:         self.execute(prefix1 + fdrPos[18][1] + ' ' + fdrPos[18][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[18][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '18')     elif P == 19:         self.execute(prefix1 + fdrPos[19][1] + ' ' + fdrPos[19][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[19][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '19')     elif P == 20:         self.execute(prefix1 + fdrPos[20][1] + ' ' + fdrPos[20][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[20][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '20')     elif P == 21:         self.execute(prefix1 + fdrPos[21][1] + ' ' + fdrPos[21][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[21][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '21')     elif P == 22:         self.execute(prefix1 + fdrPos[22][1] + ' ' + fdrPos[22][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[22][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '22')     elif P == 23:         self.execute(prefix1 + fdrPos[23][1] + ' ' + fdrPos[23][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[23][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '23')     elif P == 24:         self.execute(prefix1 + fdrPos[24][1] + ' ' + fdrPos[24][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[24][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '24') #side 2 feeders     elif P == 25:         self.execute(prefix1 + fdrPos[25][1] + ' ' + fdrPos[25][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[25][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '25')     elif P == 26:         self.execute(prefix1 + fdrPos[26][1] + ' ' + fdrPos[26][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[26][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '26')     elif P == 27:         self.execute(prefix1 + fdrPos[27][1] + ' ' + fdrPos[27][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[27][3] + feeds1)         self.executevacOn(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '27')     elif P == 28:         self.execute(prefix1 + fdrPos[28][1] + ' ' + fdrPos[28][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[28][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '28')     elif P == 29:         self.execute(prefix1 + fdrPos[29][1] + ' ' + fdrPos[29][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[29][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '29')     elif P == 30:         self.execute(prefix1 + fdrPos[30][1] + ' ' + fdrPos[30][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[30][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '30')     elif P == 31:         self.execute(prefix1 + fdrPos[31][1] + ' ' + fdrPos[31][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[31][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '31')     elif P == 32:         self.execute(prefix1 + fdrPos[32][1] + ' ' + fdrPos[32][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[32][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '32')     elif P == 33:         self.execute(prefix1 + fdrPos[33][1] + ' ' + fdrPos[33][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[33][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '33')     elif P == 34:         self.execute(prefix1 + fdrPos[34][1] + ' ' + fdrPos[34][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[34][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '34')     elif P == 35:         self.execute(prefix1 + fdrPos[35][1] + ' ' + fdrPos[35][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[35][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '35')     elif P == 36:         self.execute(prefix1 + fdrPos[36][1] + ' ' + fdrPos[36][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[36][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '36')     elif P == 37:         self.execute(prefix1 + fdrPos[37][1] + ' ' + fdrPos[37][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[37][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '37')     elif P == 38:         self.execute(prefix1 + fdrPos[38][1] + ' ' + fdrPos[38][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[38][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '38')     elif P == 39:         self.execute(prefix1 + fdrPos[39][1] + ' ' + fdrPos[39][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[39][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '39')     elif P == 40:         self.execute(prefix1 + fdrPos[40][1] + ' ' + fdrPos[40][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[40][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '40')     elif P == 41:         self.execute(prefix1 + fdrPos[41][1] + ' ' + fdrPos[41][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[41][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '41')     elif P == 42:         self.execute(prefix1 + fdrPos[42][1] + ' ' + fdrPos[42][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[42][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '42')     elif P == 43:         self.execute(prefix1 + fdrPos[43][1] + ' ' + fdrPos[43][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[43][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '43')     elif P == 44:         self.execute(prefix1 + fdrPos[44][1] + ' ' + fdrPos[44][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[44][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '44')     elif P == 45:         self.execute(prefix1 + fdrPos[45][1] + ' ' + fdrPos[45][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[45][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '45')     elif P == 46:         self.execute(prefix1 + fdrPos[46][1] + ' ' + fdrPos[46][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[46][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '46')     elif P == 47:         self.execute(prefix1 + fdrPos[47][1] + ' ' + fdrPos[47][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[47][3] + feeds1)         self.execute(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '47')     elif P == 48:         self.execute(prefix1 + fdrPos[48][1] + ' ' + fdrPos[48][2] + ' ' + endCoord)         self.execute(prefix2 + fdrPos[48][3] + feeds1)         self.execut(vacOn)         self.execute(pTime)         self.execute(retract)         self.execute(fdrCycl + '48')     return interpreter.INTERP_OK

just remember to remove the _11.03 to make it usable and give it permission to run as a program
 

File Attachment:

File Name: remap_11.03.py
File Size:14.26 KB

Please Log in or Create an account to join the conversation.

More
4 years 2 months ago #249607 by Aciera
Thanks for sharing.
Surely there must be a way to build these commands in just one block using the value of parameter P?

Something along these lines:

self.execute(prefix1 + fdrPos[P][1] + ' ' + fdrPos[P][2] + ' ' + endCoord)
self.execute(prefix2 + fdrPos[P][3] + feeds1)
self.execute(vacOn)
self.execute(pTime)
self.execute(retract)
self.execute(fdrCycl + P)
The following user(s) said Thank You: my1987toyota

Please Log in or Create an account to join the conversation.

Time to create page: 0.077 seconds
Powered by Kunena Forum