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.
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.
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.
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.
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.
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.
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
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()
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.