In this publication titled how to count number of items in autocad, I have provided a complete image from start to finish ,Please look below