-1

I am working on Ironpython in Revit application. This is the code below I was trying in python. Help would be appreciated. From the list of points, there is a first point and second point. I have created functions for them.

The script should check if the y coordinates are same and draw line if true. Its not working and returning unexpected error - new line error.

`The inputs to this node will be stored as a list in the IN variables.`

points = IN[0]

`# Place your code below this line`
lines = []

def fp(x)
    firstpoint = points[x]
    return firstpoint

def sp(x)
    secondpoint = points[x+1]
    return secondpoint

x = 0
while x <= points.Count:
    if (fp(x).Y == sp(x).Y) or (fp(x).Z == sp(x).Z):    
        setlines = Line.ByStartPointEndPoint(fp(x), sp(x))
        lines.append(setlines)
        x = x + 1

`# Assign your output to the OUT variable.`
OUT = lines
AcK
  • 2,063
  • 2
  • 20
  • 27
  • Please provide a minimal reproducible problem set consisting of sample input, expected output, actual output, and all relevant code necessary to reproduce the example. What you have provided falls short of this goal. Please edit your question to show a minimal reproducible set. See [Minimal Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example "Minimal Reproducible Example") for details on how to best help us help you. – itprorh66 Mar 04 '21 at 17:07

1 Answers1

0

As @itprorh66 points out, there's really not enough info here to definitively answer your question, but one issue is you're incorrectly comparing what I assume are floats.

fp(x).Y == sp(x).Y

Instead of comparing for direct equality, you'll need to compare for equality within a tolerance. Here is some discussion on how to do that, What is the best way to compare floats for almost-equality in Python?