Error code script link "Offset-Curve"

in Rh8 lasted update using new script editor, there are some problems with this code linked. . .

from Rhino import *
from Rhino.DocObjects import *
from Rhino.Geometry import *
from Rhino.Input import *
from Rhino.Commands import *
from scriptcontext import doc
import rhinoscriptsyntax as rs
 
def RunCommand():
    rs, obj_ref = RhinoGet.GetOneObject("Select Curve", False, ObjectType.Curve)
    if rs != Result.Success:
        return rs
    curve = obj_ref.Curve()
    if curve == None:
        return Result.Nothing
 
    rs, point = RhinoGet.GetPoint("Select Side", False)
    if rs != Result.Success:
        return rs
    if point == Point3d.Unset:
        return Result.Nothing
 
    curves = curve.Offset(point, Vector3d.ZAxis, 1.0, doc.ModelAbsoluteTolerance, CurveOffsetCornerStyle.None)
 
    for offset-curve in curves:
        doc.Objects.AddCurve(offset-curve)
 
    doc.Views.Redraw()
    return Result.Success
 
if __name__ == "__main__":
    RunCommand()

in Py2
the first problem, the editor pointed out to me:
this offset-curve syntax is not accepted
offset_curve or offsetcurve is accepted
the rest of the script then works

in Py3
aside from the above,

While adapting the code, it gave me a second error:

import rhinoscriptsyntax as rs
 
def RunCommand():
    rs, obj_ref = RhinoGet.GetOneObject("Select Curve", False, ObjectType.Curve)
    if rs != Result.Success:
        return rs

rs of the curve object, have been exchanged with the alias import rs

and correcting this is also simple

but still in Py3 I get this other error “I don’t understand why this happens”

This string doesn’t accept me:

curves = curve.Offset(point, Vector3d.ZAxis, 1.0, doc.ModelAbsoluteTolerance, CurveOffsetCornerStyle.None)

in Py3 I get an error with CurveOffsetCornerStyle.None while in Py2 this doesn’t happen

if I change the choice of option CurveOffsetCornerStyle.Smooth everything works fine in Py3 too

so choosing None is the cause. I also tried with other syntaxes but I don’t think I can do anything.

I’ve fixed this, thanks for reporting.

I don’t believe all of these samples have been fully tested with Python 3. Its on the to-do list.

https://mcneel.myjetbrains.com/youtrack/issue/WWW-2311

Thanks,

– Dale

1 Like

ok thanks Dale :+1: