Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5809

Could not convert Rhino.Geometry.Point3d object to a Point3d

$
0
0

@chiahsuanchao wrote:

Hello
I am a beginner of RhinoPython and learning through the book RhinoPythonPrimerRev3, Unfortunately. I encountered problems in the example exercises. the following is my code and return, please give me a point, and where can I understand Different similar issues…
I have been troubled for a long time, because the information searched in the forum is incomplete and I don’t understand much.

thank you very much~

> import rhinoscriptsyntax as rs
> 
> def smoothingvector(pt, prevpt, nextpt, s):
>     pm = (prevpt+nextpt)/2.0
>     va = rs.VectorCreate(pm, pt)
>     vm = rs.VectorScale(va, s)
>     return vm
>     
>     
> def smoothcurve(crv_id, s):
>     crv_pts = rs.CurvePoints(crv_id)
>     newcrv_pts = [  ]
>     
>     for i in range(len(crv_pts)-1):
>         vm = smoothingvector(crv_pts[i],crv_pts[i-1],crv_pts[i+1],s)
>         newcrv_pts.append(rs.PointAdd(crv_pts, vm))
>         
>     knots = rs.CurveKnots(crv_id)
>     degree = rs.CurveDegree(crv_id)
>     weights = rs.CurveWeights(crv_id,0)
>     newcrv_id = rs.AddNurbsCurve(newcrv_pts, knots, degree, weights)
>     if newcrv_id: rs.DeleteObject(crv_id)
>     return newcrv_id
> 
> 
> def iterativeshortencurve():
>     crv_id = rs.GetObject("open curve to smooth", 4, True)
>     if crv_id is None or rs.IsCurveClosed(crv_id): return
>     
>     min = rs.Distance(rs.CurveStartPoint(crv_id), rs.CurveEndPoint(crv_id))
>     max = rs.CurveLength(crv_id)
>     goal = rs.GetReal("Goal length", 0.5*(min+max), min, max)
>     if goal is None: return
>     
>     while rs.CurveLength(crv_id)> goal:
>         rs.EnableRedraw(False)
>         crv_id = smoothcurve(crv_id, 0.1)
>         rs.EnableRedraw(True)
>         if crv_id is None: break
>         
>         
> iterativeshortencurve()

return:

Message: Could not convert [<Rhino.Geometry.Point3d object at 0x0000000000000067 [-28,29,0]>, <Rhino.Geometry.Point3d object at 0x0000000000000068 [-4,34,0]>, <Rhino.Geometry.Point3d object at 0x0000000000000069 [2,-15,0]>, <Rhino.Geometry.Point3d object at 0x000000000000006A [22,-7,0]>] to a Point3d

Posts: 5

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 5809

Trending Articles