//scratchfile.inc //macros to allow execution of code described in strings, by writing to a scratchfile then including it. /*usage example: #declare myObjectPrefix = "box { -1, 1 translate "; #declare myObjectPostfix = " }"; #declare variablePosition = <7,7,7>; scratchBegin() scratchWrite("sphere { 0, 1 }") scratchWrite("sphere { variablePosition, 1 }") //expression will be evaluated when scratchLoad is called. scratchWrite(concat(myObjectPrefix,"variablePosition",myObjectPostfix)) //the values that are in quotes will be evaluated when scratchLoad is called, the other values will be evaluated immediately (before being passed to concat). scratchLoad() */ #declare scratchFileName = "scratch.inc"; #macro scratchBegin() #fopen scratchFile scratchFileName write //this implicitly empties the file #end #macro scratchWrite(string) #write( scratchFile, string ) #end #macro scratchLoad() #fclose scratchFile #undef scratchFile #include scratchFileName #end