Lawrence indicated that you will have to do some extra work to handle layer changes. This is not trivial and depends on whether your shapes are all at the top level or spread across multiple levels of hierarchy. It can actually be quite simple if your shapes are all at the top level and you are using VXL. In this case, all shapes on a given net will have the net attribute.
netShapes = setof(x geGetEditCellView()~>shapes x~>net~>name=="myNet")
If this is not the case, then you could expand Lawrence's script and run dbGetTrueOverlaps for the bounding box of each segment of the path. You could look for vias or contacts that transition to the next metal layer.
Here is some pseudo code (assuming only paths and all shapes/vias at top level of hierarchy):
shp = shape under the point ; Lawrence does this with enterPoint
shpList = list(shp)
totL = 0
while shp = car(shpList)
visited[shp] = t
shpList = cdr(shpList)
foreach segment on path ; Lawrence does this by looping through obj~>points
L = length of segment
bbox = bounding box of segment
totL = totL + L
connectedShapes = dbGetTrueOverlaps using shp~>lpp and bbox at level 0; find overlapping shapes on same layer
foreach newShp connectedShapes
shpList = cons(newShp shpList)
overlappingVias = dbGetTrueOverlaps using nil for the layer to only get instances at level 0
foreach via overlappingVias
check for overlapping shapes on the connecting metal (if shp is metal1 and via connects to metal2, look for overlapping metal2)
add new shapes to shpList unless they have already been visited
This is a very basic idea, but gives you an idea of the complexity involved. You mentioned that you wanted lengths of polygons and rectangles. This is very subjective. The length of a rectangle can be either its width or its height, but you really want to measure based on the direction of current flow which is not always the longer distance. A reasonable approximation for the length of a polygon might be taking the perimeter and dividing by two.
Keep in mind, this is a forum to help answer questions and provide help and ideas. It is by no means a design services group. For a complex request like this, don't expect to get a complete piece of working code.