Rs.OffsetCurve() problem

Hello everyone,I encountered a strange problem.When I use rs.OffsetCurve () function is offset a polygon, rs.OffsetCurve () function does not offset negative.When the function returns a null offset negative.This is rs.OffsetCurve () function bug?

import rhinoscriptsyntax as rs

obj = rs.GetObject("Select a curve", rs.filter.curve)

if rs.IsCurve(obj):
     A = rs.OffsetCurve( obj, [0,0,0], 10.0 )
     B = rs.OffsetCurve( obj, [0,0,0], -10.0 )
     print A,B

I have using rhinocommon offset value no problem .

import Rhino as r
style = r.Geometry.CurveOffsetCornerStyle.Sharp
plane = r.Geometry.Plane.WorldXY
tolerance = r.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance

a = plot.Offset(plane,f,tolerance,style)

file: (16.2 KB)


To make it work, you might define a point in rs.OffsetCurve() to control the direction which must be either inside or ouside the rectangle.

rs.OffsetCurve (object_id, direction, distance, normal==None, style=1)

Below examle uses a point which is in the plane of the rectangle but far away to set the outside direction and the curve’s area centroid to set the inside direction. Both offset distances used can then be positive:

import Rhino
import rhinoscriptsyntax as rs

def OffsetRectangle():
    id = rs.GetObject("crv", 4, True, False)
    if id:
        plane = rs.CurvePlane(id)
        point = rs.XformCPlaneToWorld([10000,10000,0], plane)
        crv_1 = rs.OffsetCurve(id, point, 10.0, plane.ZAxis)
        ac = rs.CurveAreaCentroid(id)
        crv_2 = rs.OffsetCurve(id, ac[0], 10.0, plane.ZAxis)



Thank you,Perfect solution