Rs.command for offsetting polyline

Hi,
Greetings!!
I was working on offsetting the below cad profile

The offset i expected was (need solution which is fully automated in python),

@Michael_Pryor gave a solution using food4rhino clipper library that works very good for me, but its a rhino command, i wanted it like a python code, i coded it with rs.command but there is much complication, please help to get an answer

This is the code i have used,

import rhinoscriptsyntax as rs

def offset(curve, length = 5, direction = "Inside"):
    ##ProjectTo = FitToCurve
    rs.Command("_OffsetPolyline " + "_selid " + str(curve) + " _Enter" + " Distance" + " _Enter" + str(length) + " Side" + " _Enter" + str(direction) + " _Enter" + " _Enter" )


curve = rs.GetObject("select curve", rs.filter.curve)

print offset(curve)

Please find the attached cad file below,
find_corner_points.stp (9.9 KB)

Previous forum post : Offset Problem

Thanks in advance

It seems that you need to change construction plane before using _OffsetPolyline:

import rhinoscriptsyntax as rs
def offset(curve, length = 5, direction = "Inside"):
    rs.EnableRedraw(False)
    plane = rs.ViewCPlane()
    rs.ViewCPlane(None, rs.CurvePlane(curve))
    rs.SelectObject(curve)
    rs.Command("_OffsetPolyline Distance=" + str(length) + " Side=" + direction + " _Enter _Enter")
    rs.ViewCPlane(None, plane)

curve = rs.GetObject("select curve", rs.filter.curve)
offset(curve)

Sumukha.py (423 Bytes)

Thanks a lot :slight_smile: