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

Rs. ExtendCurve keep giving "iteration over non-sequence of type int

$
0
0

I am trying to find the intersection of a line extension and a brep. It keeps to give the following error message. However, after I used print(type(line)) to check, “line” is not int.

The line “extension = rs.ExtendCurve(line, 0, 1, 1)” has an error message
“Runtime error (TypeErrorException): iteration over non-sequence of type int
Traceback:
line 2569, in ExtendCurve, “C:\Users\s.su\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\curve.py”
line 29, in script”

Many thanks.

The whole codes are as below.

import rhinoscriptsyntax as rs
import math

# create evenly distributed point on a sphere with a given center and a radius
def create_points_on_sphere(center, radius, num_points):
    phi = math.pi * (3 - math.sqrt(5))  # golden angle in radians
    points = []
    for i in range(num_points):
        y = 1 - (i / float(num_points - 1)) * 2  # y goes from 1 to -1
        radius_at_y = math.sqrt(1 - y * y)  # radius at y
        theta = phi * i  # golden angle increment
        x = math.cos(theta) * radius_at_y
        z = math.sin(theta) * radius_at_y
        point = [x * radius, y * radius, z * radius]
        point = rs.PointAdd(center,point)
        points.append(rs.AddPoint(point))
    return points

# Create evenly distributed points on the surface of the sphere
points = create_points_on_sphere(center, radius, num_points)

# Add lines from the center of the sphere to the points on the sphere and intersection points
lines = []
intersection_points = []
for point in points:
    line = rs.AddLine(center, point)
    extension = rs.ExtendCurve(line, 0, 1, 1)
    intersection = rs.FirstIntersectingObject(extension, [brep])
    if intersection:
        intersection_points.append(intersection[1])
        lines.append(rs.AddLine(center, intersection[1]))
    else:
        lines.append(line)

5 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 4125

Trending Articles