Hi all,
This is a long standing problem which I had always hoped Rhino could solve - especilly RhinoCommon.
When you have a figure such as in the attached, the inner offset will result in two curves if the offset distance is large enough. With the Rhino native command, you don’t get both, you only get the one nearest your pick point.
However, the RhinoCommon method Curve.Offset() does not need a pick point, only a distance - whether this distance is positive or negative will determine the side. As this method is pick-point independent I had always hoped that it would return all valid results… Unfortunately, it doesn’t, as you can test with the 3dm file and the test script below. It returns one or other of the two inner curves, depending on the curve start point… Both V5 and WIP.
Is there any hope for this getting improved in the near future?
OffTest.3dm (30.3 KB)
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
def OffsetCrv1SideRC(crv,plane,dist,trans,side,tol):
#offset is list that could contain one or multiple curves or be None
return crv.Offset(plane,side*dist,tol,trans)
def TestOffsetInOrOut():
crvID=rs.GetObject("Select curve to offset",4,preselect=True)
plane=rs.CurvePlane(crvID)
dist=2.0
side=-1
trans=Rhino.Geometry.CurveOffsetCornerStyle.Sharp
tol=sc.doc.ModelAbsoluteTolerance
crv=sc.doc.Objects.Find(crvID).Geometry
offset_crvs=OffsetCrv1SideRC(crv,plane,dist,trans,side,tol)
offset_IDs=[]
for offset_crv in offset_crvs:
offset_IDs.append(sc.doc.Objects.AddCurve(offset_crv))
rs.SelectObjects(offset_IDs)
TestOffsetInOrOut()
–Mitch