an AutoLISP routine searches the current drawing for all designated blocks and layers and then creates a legend based on what it finds