# Abort during animation

I am running an animation with the following command:

files = FileNames[NotebookDirectory[] <> "*.dat"];
MTnumbers = FileNames[NotebookDirectory[] <> "MTnumbers.txt"];

data = Import[#, "Table"] & /@ files
MT = Import[#, "List"] & /@ MTnumbers

coords = {{#1 - (#3/2), #2 - (height/2)}, {#1 + (#3/2), #2 + (height/
2)}} & @@@ #[[All, 2 ;;]] & /@ data;

height = 2;

colors = {Blue, Blue, Blue, Blue, Blue, Blue, Blue, Blue, Blue, Blue,
Blue, Blue, Blue, Blue, Blue, Blue, Blue, Blue, Blue, Blue, Blue,
Blue, Blue, Blue, Blue, Blue, Blue, Blue, Blue, Blue, Blue, Blue,
Blue, Blue, Blue, Blue, Blue, Blue, Blue, Blue};
Animate[Graphics[{Sequence @@ {colors[[#]],
Rectangle @@ (coords[[#]][[t]])} & /@ MT[[1]]},
PlotRange -> {{-1000, 1000}, {-200, 200}},
ImageSize -> {1000, 200}], {t, Range[0, 7000]}]

Export["tubuli.avi", %];


As soon as I try to export this output Mathematica crashes. When I increase the number of rectangles to about 150 the simulation crashes without giving an output. Is my computer too weak or am I doing something wrong?

EDIT:

The data is in the following zip archive you just need the notebook and the data in the same folder and it should work.

https://www.dropbox.com/s/iegdb1a031i4mn6/data.zip

-
IMO you should just provide the lists of coords and MT. You can put them on pastebin so Mathematica can Import them. If not, you can paste them here and I will put them on pastebin. –  Öskå Jun 3 '14 at 10:47
I edited the post. Gif export also crashes or returns a non moving gif. Do you know if it is possible add the command from this Answer mathematica.stackexchange.com/questions/48971/animating-arrows into the animation or can't I combine sequence and thread in one graphic? –  user3683367 Jun 3 '14 at 13:01
yeah I thought so... But basically my data is equal to what is written in the file and the animation works but the export aborts. –  user3683367 Jun 3 '14 at 13:12
what i mean is: When I type data the output looks like the one in the file. Should I provide another format? –  user3683367 Jun 3 '14 at 13:33
@user3683367 You should test the code you post here ...:) –  belisarius is forth Jun 3 '14 at 13:33

I don't really understand what is your issue here and your goal but tell me if that fits you:

datfiles=ToString@StringForm["MT_mathematica_.dat",#]&/@Range@40;
MT=Range@40;
data=ToExpression@Import["Your/Path/Here"<>#]&/@datfiles;
height=2;
rect=Rectangle[Sequence@@#]&;
coords={{#1-(#3/2),#2-(height/2)},{#1+(#3/2),#2+(height/2)}}&@@@#[[All,2;;]]&/@data;
frames=Table[Graphics[{Blue,rect@coords[[1,t]]},PlotRange->{{-100,100},{-200,200}},Frame->True],{t,1,Length@First@coords,100}];
Export["~/MT.gif",frames,"DisplayDurations"->.1]


I reduced the number of frames and the ImageSize/PlotRange to see something.

-
Ok it worked like this for one rectangle. I will try to export all rectangles in 1 file now to see if it works. –  user3683367 Jun 3 '14 at 18:04
If it doesn't work it won't be because of Mathematica but because of your computer I'm afraid. –  Öskå Jun 3 '14 at 18:13
Ok thats fine I just needed to know if it it works before I put it on some better computer. So basically I can switch Blue => colors[[#]] and add & /@ MT[[1]] behind the"}" bracket and a gif involving all rectangles will be made? –  user3683367 Jun 3 '14 at 18:14
Just make sure that colors has the correct Length. But basically {colors[[#]],rect@coords[[#,t]]}& /@ MT[[1]] should do it. –  Öskå Jun 3 '14 at 21:19