# prints LINE: L layer x1 y1 x2 y2 ; LWPOLYLINE: P layer x y x y ... ; ARC: A layer cx cy r a0 a1 function flush(){ if(ent=="LINE") print "L\t" lay "\t" x1 "\t" y1 "\t" x2 "\t" y2; else if(ent=="LWPOLYLINE") print "P\t" lay "\t" pts; else if(ent=="ARC") print "A\t" lay "\t" x1 "\t" y1 "\t" r "\t" a0 "\t" a1; ent="";pts="";lay="" } NR%2==1{c=$0; gsub(/ /,"",c); next} {v=$0; gsub(/^ +/,"",v) if(c=="0"){ flush(); if(v=="LINE"||v=="LWPOLYLINE"||v=="ARC") ent=v; if(v=="ENDSEC"||v=="BLOCK") inblk=(v=="BLOCK"); next } if(ent=="") next if(c=="8") lay=v if(ent=="LWPOLYLINE"){ if(c=="10") pts=pts " " v; if(c=="20") pts=pts "," v; if(c=="42") pts=pts "(b" v ")" } else { if(c=="10")x1=v; if(c=="20")y1=v; if(c=="11")x2=v; if(c=="21")y2=v; if(c=="40")r=v; if(c=="50")a0=v; if(c=="51")a1=v } } END{flush()}