I've thought about this a bit further and found something in a previous post in this thread that makes things a bit clearer, I'll try to explain -
problem =
you want to rotate a 3d solid to wcs from any orientation in space, let's say that the edge you use is the length property (it doesn't matter though but if it's an odd shape, you would naturally use the longest 'direction' as the length in this case).
When rotated, let's say you need the L (length direction) to follow the z world axis, this will give you both the x and y axes to extract width and height.
so far so good??
What you will need -
Some vector modification functions such as dot product, cross product, normalisation, add/subtract etc, do a search on vb vector math or similar to find them, they will be done already I guarantee it
A rudementary understanding of using matrices with acad, you will need to be able to set up a matix given 3 vectors(3 sets of doubles, they 'may' need to be normalised) and you need to know how to 'invert' it (reverse/negate it), if acad has a matrix class/method in vba, it will/should have an invert method.
Ok, given that, here's the solution -
1. Get your line/edge as a vector, to do this subtract the end point from the start point (not the other way around!)
2. Next you can use the line's normal, another point of the region or the regions' normal, I'll step out both methods. Either way they both 'should' be perpendicular to the plane of the region.
2a. Using the line or region's normal, get the cross product of the vector from the edge and the normal
zvec = edge.ep - edge.sp
yvec = edge/region.normal
xvec = yvec.cross(zvec)
that should give you three vectors along each x,y,z axis of that plane/region's face with the z vector being along the edge, a y vector normal/perp to plane (in the negative direction I think) and an x vector to the right and perp of z & y.
2b. Using another point of the plane - to do this you will need the 'previous' point before the start point of the edge that you have for L.
From this point, create another vec by subtracting the sp from this previous point, the difference here is we will need to do 2 cross products to make our axes orthoganal (square to each other).
zvex = edge.ep - edge.sp
xvec = prevpnt - edge.sp
yvec = zvec.cross(xvec)
now to square it up, yvec is already square to zvec from performing the cross product but xvec may not necessarilly be square to zvec, nor does it need to be yet but this will fix it.
xvec = yvec.cross(zvec)
this should give you the same result BUT - if the previous point is not to 'the right side' of the edge it may throw the resultant yvec in the other direction, no prob's, just 'negate' it (reverses the direction).
To do this you can get the first 2 vecs from 2b above and perform a dot product to see which side it's on, you may need to experiment but the result will either be +ive or -ive but it's easy to do once you know what you need.
Now, to rotate it to world, create a matrix loading in the numbers of your 3 vec axes into the appropriate matrix columns, get the object and transform it using this matrices 'to world' method or similar, get your data and rotate it back with the original matrix, it should put the object with the L direction along the z axis with the edge sp at 0,0,0 with the region plane along the x axis but you may need to experiment to get it how you like, easy peasy
Let's see what you can do with that