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

Rhino script exceptions or bug?

$
0
0

@onrender wrote:

Hi,

Today I tried to repeat a python script by Jose Sanchez on Vimeo https://vimeo.com/29321808 and I found a bug in rhino script. The script actually works with any numbers except 50. It is about a tangent line distribution on a curve. It was fine with 10,20,40,49,51,150 but not with 50. Is it possible?

The error message was the following:

Message:

Could not convert None to a Vector3d

Traceback:
** line 398, in coerce3dvector, "C:\Users\An\AppData\Roaming\McNeel\Rhinoceros\5.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\utility.py"**
** line 467, in VectorUnitize, "C:\Users\An\AppData\Roaming\McNeel\Rhinoceros\5.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\pointvector.py"**
** line 20, in tanPoints, "C:\Users\An\AppData\Roaming\McNeel\Rhinoceros\5.0\scripts\Rhino Python Tutorial 11 - TangentsCrv_Parameters.py"**
** line 31, in , "C:\Users\An\AppData\Roaming\McNeel\Rhinoceros\5.0\scripts\Rhino Python Tutorial 11 - TangentsCrv_Parameters.py"**

import rhinoscriptsyntax as rs

class TanLines:

    def __init__(self, _curve, _numOfDivs):
        self.curve = _curve
        self.numOfDivs = _numOfDivs
    def tanPoints(self):
#        print("check")
        doms = rs.CurveDomain(self.curve)
#        print (doms)
        minDom = doms[0]
        maxDom = doms[1]

        for i in range (0,self.numOfDivs +1):

            param = (maxDom - minDom)/self.numOfDivs * i

            tan = rs.CurveTangent(self.curve, param)    #3D Vector
            tan = rs.VectorUnitize(tan)
            tan = rs.VectorScale(tan, 3)
            pt = rs.EvaluateCurve(self.curve, param)
            rs.AddPoint(pt)

            tanPt = rs.VectorAdd(tan, pt)

            rs.AddLine(pt,tanPt)

curve = rs.GetObject("pick curve", 4)
obj01 = TanLines(curve,50)
obj01.tanPoints()

Posts: 5

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 5785

Trending Articles