Arc can also be a 3 degree curve?

Hi,
I have a curve which is a 3 degree curve and also an arc according to SelCrvByDegree and SelArc.
If I check the cruve in rhino 6 it is only an 3 degree curve and not an arc with the same scripts.
What is going on, (I know it is a 3 degree whith a constant / same radius) because I get some problems when I save it as dwg.

arc and 3 degree curve.3dm (22.4 KB)

Hi Edward -

There is no SelArc command in Rhino - youā€™ll want to ask the author of that script.
-wim

Hi Wim,

Thatā€™s probably Pascal, although Mitch did a Python one too. Mitchā€™s shows the same difference between R6 and R7, and I think it may be attributable to a change in the Rhinocommon Curve.isArc() method between versions (it isnā€™t a big script and that looks like the only candidate). I think youā€™ll need to ask a McNeel dev if that is so.

Regards
Jeremy

Hello- that curve is selected in 7 with my version of SelArc, and not in 6ā€¦ let me tinker a momentā€¦
@E.O.Stam - see if this works better -
CurveAndArcUtilities.rhp (66.5 KB)

I donā€™t know how you had the script but here it is inside a plug-in that has a bunch of arc-related tools, some of which may even be useful.

3PtArcFromPoints
3PtArcFromPolyline
ArcFitToCurve
ArcFitToPoints
ArcFitToPolyline
DimCurveAngle
RadiusFrom3Pts
SelArc
SelArcByRadius
SelCircle
SelCircleByRadius
SetArcDegrees
SetArcRadians
SetCurveLength
SubCrvFromMid

Unblock then drag and drop the rhp file onto Rhino.

-Pascal

An arc can be exactly represented by a rational degree 2 NURBS curve with appropriate control point locations and weights. This is the form Rhino uses for arcs and circles.

Any NURBS curve can be exactly represented by a NURBS curve of any higher degree. So an arc can be exactly represented by a degree 3 curve. The degree 3 form of an arc will have more control points than the degree 2 form.

A user can transform an exact arc which is a rational degree 2 NURBS curve into an exact rational degree 3 NURBS curve using ChangeDegree with Deformable=No. The degree 3 form of an arc will have multi-knots even though curvature is continuous. It is not obvious to me when the rational degree 3 NURBS form of an arc would be preferable to the rational degree 2 NURBS curve form.

Added:
Removed due to error

2 Likes

Hi David,

Two points: for full disclosure, Rhino identifies a degree 3 arc as a ā€œNurbs Arcā€ as distinct from an Arc

And in Rhino 7 the SelArc scripts referred to, using the facilities provided by RhinoCommon, do now identify the degree 3 Nurbs arcs as arcs, without distinction from degree 2 arcs, whereas in R6 they didnā€™t. That was the gist of the original post. So, for the moment at least, Iā€™m sorry, but your statement is incorrect.

Hi Pascal,

I test it again but selarc is still telling me that this:
image
still is a arc but it isnā€™t according to my nesting program and acad when I export it

regards Edward
t042.dwg (93.5 KB)

Hi Edward - see if SimplifyCrv sorts it out.

-Pascal

Hi Pascal,

every day we have a few hundred off those and most of them are oke, hide the correct oneā€™s and the oneā€™s that are not arcs I can convert

Edward

Hi Edward, you donā€™t say if that helps or not, but if so, I donā€™t think there is any harm in simplifying accross the board.

-Pascal

We have had discussions about this kind of stuff in the past - I have generally argued for a strict interpretation of rs.IsArc() - which is what my script uses - but others have wanted curves that are near-arcs within tolerance to also be selected - which looks like it won in this case. This is the same with circles IIRC. Your ā€˜arcā€™ does select with my SelArc script in this case.

It calls the underlying code:


https://developer.rhino3d.com/api/RhinoCommon/html/Overload_Rhino_Geometry_Curve_IsArc.htm

The method doesnā€™t say anything about making sure that the object is of type Rhino.Geometry.ArcCurveā€¦

hi Pascal,
O sorry, yes SimplifyCrv it is doing the job and also convert to arc.
I will do all the arcā€™s in the futuru to be sure.
But when there is a command I can select arcs with (the real ones for me) it would be great.
Thanks Pascal
Edward

Here you goā€¦ (edit, small modification)
SelArcStrict.py (701 Bytes)

It will select your original curve after it is simplified to a true arc, but the original curve does not select.

SelArcStrict.3dm (1.6 MB)

Here is one that does the same thing for circles:
SelCircleStrict.py (703 Bytes)

Another object to consider is a 1-segment PolyCurve containing an ArcCurve. It can be created by deleting segments from a PolyCurve.

SelArcStrict_WithPolyCurve.3dm (32.5 KB)

_What reports it as an ā€œArcā€.
_SimplifyCrv does not convert it to an ArcCurve.

I would say thatā€™s an bug in how Rhino handles this case - if you run What on your object, you get this:

image

Whereas rs.coercegeometry() still thinks itā€™s a polycurve:

Donā€™t know whoā€™s at fault hereā€¦

Thank you Helvetosaur,

it is working only the oneā€™s in the upload the script is not selecting.

curve

ID: 6f4b5017-e2da-4c9d-9f73-d0cd5b8ebef6 (1006)
Object name: (not named)
Layer name: cut
Render Material:
source = from layer
index = -1
Attribute UserData:
UserData ID: 563238F9-C201-411d-A7B1-13895A0317AD
Plug-in: Rhino
description: AutoPointsOn
saved in file: no
copy count: 1

Geometry:
Valid curve.
Arc
start = (145.342,0.163,0.000)
end = (145.339,8.242,0.000)
center = (145.578,4.203,0.000)
radius = 4.047
angle = 186.734 degrees

arc not selecting.3dm (19.9 KB)

I can reproduce this here by creating a polycurve containing one or more arc segments, then deleting some segments to leave just the arc portion(s). They will not select with the script because RhinoCommon still thinks they are polycurves. @pascal or @Alain ?

The following is a workaround to the problem, but really shouldnā€™t be necessary.

"""Selects only "true" arcs, not ones that can be converted via SimplifyCrv."""

import rhinoscriptsyntax as rs
import Rhino

entity="arc"
err_msg="No {} objects added to selection".format(entity) 
obj_ids=rs.ObjectsByType(4,state=1)
select=[]
if obj_ids:
    for obj_id in obj_ids:
        obj=rs.coercegeometry(obj_id)
        if isinstance(obj,Rhino.Geometry.ArcCurve):
            if not obj.IsClosed: select.append(obj_id)
        #workaround code (shouldn't be necessary)
        elif isinstance(obj,Rhino.Geometry.PolyCurve):
            if obj.SegmentCount==1:
                if isinstance(obj.SegmentCurve(0),Rhino.Geometry.ArcCurve):
                    if not obj.SegmentCurve(0).IsClosed: select.append(obj_id)
    if select:
        rs.EnableRedraw(False)
        rs.SelectObjects(select)
        if len(select)>1: s="s"
        else: s=""
        print "{} {} object{} added to selection".format(len(select),entity,s)
    else: print err_msg
else: print err_msg

I see that it is one segment polycurve, that seems wrongā€¦ but, overall, I need a recap - @E.O.Stam - what, exactly, would you like to happen with arcs?

fwiw, my SelArc is this, no idea if that helps anything or not -

import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc

def SelArc():
    tol = sc.doc.ModelAbsoluteTolerance
    atol = sc.doc.ModelAngleToleranceRadians
    
    ids = rs.ObjectsByType(4)
    if not ids:
        return
    rs.EnableRedraw(False)
    count = 0
    for id in ids:
        if rs.IsCircle(id): continue
        ARC = False
        crv = rs.coercecurve(id)
        
        if crv.IsArc():
            ARC = True
        else:
            sim = crv.Simplify(Rhino.Geometry.CurveSimplifyOptions.All, tol, atol)
            if sim.IsArc():
                ARC = True
        if not rs.IsObjectSelected(id) and ARC:
            rs.SelectObject(id)
            count += 1

    rs.EnableRedraw(True)
    
    strSel = " arcs added to the selection."
    if count == 1:
        strSel = " arc added to the selection."
        
    print str(count) + strSel
    
    
if __name__ == '__main__': SelArc()

-Pascal

Pascal.

I just want to select all the arcā€™s and no other curves that looks like a arc or have the excact same shape as a arc.
And when they are selected I just want to hide the arcā€™s who where in a curve contour so I can join the other crvā€™s without the arcā€™s
I hope I explained it correct so you understand.

Hi Edward - thanks - I guess Mitchā€™s script ought to do it then - heā€™s ;looking for objects that are Rhino.Geometry.ArcCurve()

-Pascal