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

Place circle at specific distance from endpoints of curve

$
0
0

@siemen wrote:

Hi guys, I got a bit stuck again.
I’m trying to make a script which asks for user input to select an object and asks for a distance. Then I’d like to explode the curve and make a circle at that specific distance from the start and end point of each line. In the end I’d like to have a list of all those circles which I will use for further processing. Can anybody point me in the right direction and see what I’m doing wrong? Or general feedback on improving this is also welcome.

import rhinoscriptsyntax as rs

def PlaceCircles(curve,len,circles):
    length = len
    
    domain = rs.CurveDomain(curve)
    parameter = domain[0]+len
    parameter2 = domain[1]-len
    
    curvepoint = rs.EvaluateCurve(curve,parameter)
    curvepoint2 = rs.EvaluateCurve(curve,parameter2)
    
    circle = rs.AddCircle(curvepoint,3)
    circle2 = rs.AddCircle(curvepoint2,3)
    
    circles.append(circle)
    circles.append(circle2)

def CircleDist():
    objs = rs.GetObjects("Select objects",0,False,True)
    
    if not objs: return
    Distance = rs.GetReal("Distance from edge?")
    if not Distance: return
    
    for obj in objs:
        circles = []
        crvs = rs.ExplodeCurves(obj)
        
        for crv in crvs:
            circles = PlaceCircles(crv,Distance, circles)

CircleDist()

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 5793

Trending Articles