OK … I had some time and … could not resist … I had to try to script that.

Obviously by iteration. Until an acceptable result is found.

( Furthermore I think it might be a useful tool for me )

After a lot of mistakes and confusion …

This one (still quite empirical … ) **seems** to work here …

Ah, it only can work on the XY plane.

```
import Rhino
import math
import rhinoscriptsyntax as rs
import scriptcontext
def betavecs( p0, p1, p2 ):
be = abs( Rhino.Geometry.Vector3d.VectorAngle( ( p0 - p1 ), ( p2 - p0 ) ) )
if be > math.pi:
be = math.pi * 2 - be
be *= 0.5
v1 = p1 - p0
v1.Unitize()
v2 = p2 - p0
v2.Unitize()
return ( be, v1, v2 )
def line( p0, be, v1, v2, wd, al ):
la = wd * math.sin( be - al ) / math.sin( be * 2.0 )
lb = wd * math.sin( be + al ) / math.sin( be * 2.0 )
aa = p0 + v1 * la
bb = p0 + v2 * lb
cc = ( aa + bb ) * 0.5
ve = v1 + v2
ve.Unitize()
ve.Rotate( - al, Rhino.Geometry.Vector3d.ZAxis )
lin = Rhino.Geometry.Line( cc, ve )
return lin
def guessalpha( p0, v1, v2, pt ):
bi = v1 + v2
ve = pt - p0
al = Rhino.Geometry.Vector3d.VectorAngle( ve, bi )
if al < 0.0:
al += math.pi * 2.0
cp = Rhino.Geometry.Vector3d.CrossProduct( ve, bi )
if cp.Z < 0.0:
al = -al
return al
def main():
p0a = rs.GetPoint( 'First vertex ?' )
if not p0a:
return
p1a = rs.GetPoint( '(First vertex) Point on one side ?' )
if not p1a:
return
p2a = rs.GetPoint( '(First vertex) Point on the other side ?' )
if not p2a:
return
p0b = rs.GetPoint( 'Second vertex ?' )
if not p0b:
return
p1b = rs.GetPoint( '(Second vertex) Point on one side ?' )
if not p1b:
return
p2b = rs.GetPoint( '(Second vertex) Point on the other side ?' )
if not p2b:
return
wd = rs.GetReal( 'Rectangle fixed width ?' )
if not wd:
return
# tol = rs.GetReal( 'Tolerance ?' )
tol = scriptcontext.doc.ModelAbsoluteTolerance
cp = Rhino.Geometry.Vector3d.CrossProduct( ( p0a - p1a ), ( p2a - p0a ) )
if cp.Z > 0.0:
p1a, p2a = p2a, p1a
cp = Rhino.Geometry.Vector3d.CrossProduct( ( p0b - p1b ), ( p2b - p0b ) )
if cp.Z > 0.0:
p1b, p2b = p2b, p1b
bea, v1a, v2a = betavecs( p0a, p1a, p2a )
beb, v1b, v2b = betavecs( p0b, p1b, p2b )
ala = guessalpha( p0a, v1a, v2a, p0b )
alb = guessalpha( p0b, v1b, v2b, p0a )
while True:
scriptcontext.escape_test()
lina = line( p0a, bea, v1a, v2a, wd, ala )
linb = line( p0b, beb, v1b, v2b, wd, alb )
dis = lina.DistanceTo( linb.From, False )
print( '%.3f' % dis )
if dis < tol:
break
nala = guessalpha( lina.From, v1a, v2a, linb.From )
nalb = guessalpha( linb.From, v1b, v2b, lina.From )
ala = ( ala + nala ) * 0.5
alb = ( alb + nalb ) * 0.5
lin = Rhino.Geometry.Line( lina.From, linb.From )
tan = lin.UnitTangent
ve = Rhino.Geometry.Vector3d( -tan.Y, tan.X, 0.0 )
pli = []
pli.append( lin.From + ve * wd * 0.5 )
pli.append( lin.From - ve * wd * 0.5 )
pli.append( lin.To - ve * wd * 0.5 )
pli.append( lin.To + ve * wd * 0.5 )
pli.append( lin.From + ve * wd * 0.5 )
print( 'Rectangle is long %.3f' % lin.Length )
scriptcontext.doc.Objects.AddPolyline( pli )
scriptcontext.doc.Views.Redraw()
main()
```

To use it, we have to pick the vertex points plus one point on each side … twice for the two vertices …

Regards