Grasshopper

algorithmic modeling for Rhino

Hi 

I'm trying to remove duplicate lines in a list using a Python script in Grasshopper. I'm using start and end points to check for equality. Two lines are considered equal if 1) they have the same start and end points  or 2) One lines start point is equal to the another lines' end point and the end point of the first line is start point of the second line. I get a runtime error which I couldn't figure out:

import rhinoscriptsyntax as rs

for i in range(0,len(lns)):

....for nxtLine in lns:

........if ((rs.CurveEndPoint(lns[i]) == rs.CurveEndPoint(nxtLine)) and

........(rs.CurveStartPoint(lns[i]) == rs.CurveStartPoint(nxtLine))) or

........((rs.CurveEndPoints(lns[i]) == rs.CurveStartPoint(nxtLine)) and

........(rs.CurveStartPoint(lns[i]) == rs.CurveEndPoint(nxtLine))):
............del nxtLine

Here is the error:

Runtime error (TypeErrorException): len() of unsized object
Traceback:
line 3, in script

My input is a list of curves called "lns".

Thanks

Views: 1279

Replies to This Discussion

Thanks Marcus. But what if we have to equal lines which cross each other at their midpoints?

Do you mean before checking for start and end points or after that?  Please see the attached definition. In Rhino file, all the possible lines between 4 points are drawn ( 12 in total). My code is supposed to reduce them to 6 but the output is still 12 lines. Any idea? Thanks.

Attachments:

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service