I agree this would be better over at the Customization Forum [not at all version-dependent], and by the way, a "LISP" and a "script" are different things in AutoCAD, but....
It sounds as if, by "length," you do not mean the length as AutoCAD would measure it of the Polyline entity that forms the rectangle [assuming that's what it is, and not, for example, a Block or Wipeout or 2D Solid or 3DFace or Trace or...], which would be the overall perimeter of the rectangle. But rather I assume you want one dimension of the rectangular shape it forms. If that's the case, some question arise:
Would you always want the longer dimension of every rectangle? [That wouldn't be too hard, depending on the answers to the other questions.] Or might some be shorter than their common width? For example, if they are all 4 units wide, with some of them 6 units long, some 11 units long, etc., for those you would want their longer dimensions, but if one is 3 units long, you would want its shorter dimension.
Would they always all be drawn orthogonally? [That would make it a lot easier.]
Would they always all be closed Polylines of 4 and only 4 vertices? Or might there sometimes be, for example, intervening vertices within rectangle edges, or Polylines that look closed but are not, and have 5 vertices with the first and last at the same place?
Would you want a routine to determine whether or not a selected object is actually rectangular?
Would you want a routine to determine whether or not multiple rectangles share a common width, and what that is, for example to only account for those that do? Or would you rely on the User to select only appropriate rectangles?
Kent Cooper, AIA