Hi all,
I’m trying to write a script that is able to see and output part of the object details that are shown when I click the “Details” button in the properties tab. I’m specifically looking for it to output the object description from the geometry section. The goal of the script is to quickly see whether a bunch of arcs are NURBS arcs or standard arcs. This is helpful for me to know when exporting to DXF.
#
# Test for a curve that is or looks like an arc
#
def _is_arc(curve):
closed = False
rc = curve is None
# Is curve an ArcCurve?
if not rc:
rc = isinstance(curve, Rhino.Geometry.ArcCurve)
if rc:
closed = curve.IsCompleteCircle
# Is curve a PolyCurve that looks like an arc?
if not rc:
if isinstance(curve, Rhino.Geometry.PolyCurve):
rc, arc = curve.TryGetArc()
if rc:
closed = arc.IsCircle
# Is curve a NurbsCurve that looks like an arc?
if not rc:
if isinstance(curve, Rhino.Geometry.NurbsCurve):
rc, arc = curve.TryGetArc()
if rc:
closed = arc.IsCircle
# Done
return rc, closed
Hi Dale,
One other question on this. How do I select the curve to input into the isinstance function. It doesn’t seem to be looking for the object ID obtained from rs.GetObject. It wants the type of data you get from initializing an object through Rhino.Geomtry.Arc for instance.
import Rhino
import scriptcontext as sc
def test():
filter = Rhino.DocObjects.ObjectType.Curve
rc, objref = Rhino.Input.RhinoGet.GetOneObject("Select curve", False, filter)
if not objref or rc != Rhino.Commands.Result.Success:
return
rc, closed =_is_arc(curve)
if rc:
if closed:
print("Curve is a circle")
else:
print("Curve is an arc")
Hey Dale,
I found a simple solution for this. There is actually a method in Rhino Script that does this, which is Rhino.IsNurbsCurve(). I checked it and it works for distinguishing between an actual arc and a NURBS curve that approximates an arc.
This is the test script I used.
Option Explicit
Call Main()
Sub Main()
Dim strArcEval
Dim strDescription
Dim boolIsArc
strArcEval = Rhino.GetObject("Select curves for evaluation")
strDescription = Rhino.ObjectDescription(strArcEval)
boolIsArc = Rhino.IsNurbsCurve(strArcEval)
Rhino.Print(strDescription)
Rhino.Print(boolIsArc)
End Sub