Page 1 of 1

MegaLoop for my script?

Posted: Sat May 08, 2010 11:10 am
by Daross
I build a stack to create a report with the optimization of circuits with respect to the length and number of circuits (or parts).
In practice, the script must create the best combination of the circuit to select the coil with less waste.
I started with tablefield "Circuit" (where I put the ID and length of circuits) tablefield a "Coil" (where I put the length of the coils I have available)
and a field "Report" where I read the results (of course I created the report in attach. with hand! :D )

Any idea how can I do?

Thanks in advance

Davide

Re: MegaLoop for my script?

Posted: Sat May 08, 2010 9:18 pm
by Mark
Hi Davide,

What exactly is your question?

Best,

Mark

Re: MegaLoop for my script?

Posted: Tue May 11, 2010 4:12 pm
by Daross
Mark,

I need help on how to write the algorithm with Rev. Until now I have written small applications, and create this script is hard for me.

The script should create groups of combinations (in relation to the total length of the coils in the field “coils") summing the item 2 of the field "Circuit" and the script must prefer the combination with less waste (see field “Report”)

I do not know if what I said is clear now..

Thanks.

Davide

Re: MegaLoop for my script?

Posted: Tue May 11, 2010 4:50 pm
by dunbarx
I wrote a quick script that should show the way. I assumed you have your data in a field called "rawdata", and that the data contains both the ID and the length, one pair on each line separated with a comma. Not sure how optimal this is, and I only dealt with the 500 foot spools:

Code: Select all

on mouseUp
   Put fld "rawdata" into rawData
   put 0 into spools
   Sort rawData by item 2 of each
   
   repeat until the number of lines of rawdata = 0
      put 0 into balance
      add 1 to spools
      repeat with y = the number of lines of rawData down to 1
         if item 2 of line y of rawData + balance < 500 then
            add item 2 of line y of rawData to balance
            delete line y of rawData
         else
            next repeat
         end if
      end repeat
   end repeat
   
   answer spools
end mouseUp