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

How to filter points based on distance from sphere center?

$
0
0

@Daniel_Fougere wrote:

Hey guys, so I have a sphere and three types of curves intersecting the sphere. I have populated the curves with points and would like to filter out those points based on their distance from the spheres center. Once I filter those points (between a radius of 40 and 50 from sphereCenter) I want to randomly connect 3 points with a crv. Right now I'm not sure how to filter the list of points...

script below

#Random Numbers
#Random Lines

import rhinoscriptsyntax as rs
import random as rnd

sphereCenter = [50,50,50]

sphere = rs.AddSphere(sphereCenter,45)

rs.EnableRedraw(False)

pts = []

for i in range(0,100):
    #coordinates
    x = rnd.uniform(0,100)
    y = rnd.uniform(0,100)
    z = rnd.uniform(0,100)
    pt = [x,y,z]
    
    pts.append(pt)
    
pl = rs.AddPolyline(pts)
crv = rs.AddCurve(pts)
intpcrv = rs.AddInterpCurve(pts)
 
color01 = [0,255,255]
color02 = [255,0,255]
color03 = [255,255,0]
 
rs.ObjectColor(pl, color01)
rs.ObjectColor(crv, color02)
rs.ObjectColor(intpcrv, color03)

pt = []

pt1 = pt.append(rs.DivideCurve(pl,5000,True,True))
pt2 = pt.append(rs.DivideCurve(crv,5000,True,True))
pt3 = pt.append(rs.DivideCurve(intpcrv,5000,True,True))













#rs.GetPoint(sphereCenter, [pt], 45)

#if pt.x or pt.y or pt.z <= 45:
#    rs.AddSphere([pt],5)
#else:
#    rs.DeleteObjects([pt])

#rs.GetPointOnSurface(sphere, None)

Posts: 5

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 5749

Trending Articles