from Rhino import *
from Rhino.DocObjects import *
from Rhino.Commands import *
from Rhino.Geometry import *
from Rhino.Input import *
from scriptcontext import doc
def RunCommand():
rc, obj_ref = RhinoGet.GetOneObject(“Select curve for radius dimension”, True, ObjectType.Curve)
if rc != Result.Success:
return rc
curve, curve_parameter = obj_ref.CurveParameter()
if curve == None:
return Result.Failure
if curve.IsLinear() or curve.IsPolyline():
print "Curve must be non-linear."
return Result.Nothing
# in this example just deal with planar curves
if not curve.IsPlanar():
print "Curve must be planar."
return Result.Nothing
point_on_curve = curve.PointAt(curve_parameter)
curvature_vector = curve.CurvatureAt(curve_parameter)
len = curvature_vector.Length
if len < RhinoMath.SqrtEpsilon:
print "Curve is almost linear and therefore has no curvature."
return Result.Nothing
center = point_on_curve + (curvature_vector/(len*len))
_, plane = curve.TryGetPlane()
radial_dimension = RadialDimension(center, point_on_curve, plane.XAxis, plane.Normal, 5.0)
doc.Objects.AddRadialDimension(radial_dimension)
doc.Views.Redraw()
return Result.Success
if name==“main”:
RunCommand()
Prompt error, because RadialDimension() does not require parameters!
Hint: “Message: RadialDimension() takes no arguments (5 given)”
Is it wrong? How to correct?
The code works fine in Rhino for Mac v.5.5.3, but doesn’t seem to work in RhinoWIP for Mac 6.
I don’t know which version of Rhino, Windows or Mac, beta or golden master, you are using, but the issue seems to be caused by Rhino.
from Rhino import *
from Rhino.DocObjects import *
from Rhino.Commands import *
from Rhino.Geometry import *
from Rhino.Input import *
from scriptcontext import doc
def RunCommand():
rc, obj_ref = RhinoGet.GetOneObject("Select curve for radius dimension", True, ObjectType.Curve)
if rc != Result.Success:
return rc
curve, curve_parameter = obj_ref.CurveParameter()
if curve == None:
return Result.Failure
if curve.IsLinear() or curve.IsPolyline():
print "Curve must be non-linear."
return Result.Nothing
# in this example just deal with planar curves
if not curve.IsPlanar():
print "Curve must be planar."
return Result.Nothing
point_on_curve = curve.PointAt(curve_parameter)
curvature_vector = curve.CurvatureAt(curve_parameter)
len = curvature_vector.Length
if len < RhinoMath.SqrtEpsilon:
print "Curve is almost linear and therefore has no curvature."
return Result.Nothing
center = point_on_curve + (curvature_vector/(len*len))
_, plane = curve.TryGetPlane()
radial_dimension = RadialDimension()
doc.Objects.AddRadialDimension(radial_dimension)
doc.Views.Redraw()
return Result.Success
if __name__ == "__main__":
RunCommand()
Please take a look at this guide. It shows you how to format code correctly in Markdown. I had to do some otherwise unnecessary clean-up, just to be able to run your code!
As mentioned above, it works fine in Rhino for Mac 5! It draws a little cross and annotates the curve with a radial dimension.
The RhinoCommon reference states that RadialDimension() is supported in Rhino for Mac 5.4
and Rhino for Windows 6.15.
I can only confirm that your script works in Rhino for Mac 5.4, beyond that I don’t know!
You simply might have discovered a bug in Rhino 6 (cf. @Helvetosaur’s comment)?