Name error

Hi, I’m new to dynamo and python.
While following the sample script, the name error keeps popping up, help please, ;_;

@panda888 given what you have posted, I have only one word for you:
" Indentation"

1 Like

Edit: this is wrong
@Elie.Trad mentioned indentation, but let me explain what goes wrong here.
At line 32, you’re trying to do something with the input “point”, but that one is only defined in the for loop above, so, it can’t find it.

@PauLtus this is not why it cannot find the variable ‘point’.

Point is only being defined within the conditional statement:

if d1<dist:
    dist = d1
    point  = p1

But if this conditional statement is not true i.e. if d1 > dist then point is never assigned a value and therefore, no parameter at point can be given.

Without more information about what you are trying to do with this script it is hard to help.

All I can suggest is including an else statement which will assign a value to point in the condition of d1 being greater than dist.

2 Likes

You are correct.
Am I right in saying that:
The problem is that variable “point” may or may not be defined within the for loop depending on conditions of the if statement ever being met. But when it doesn’t, it will cause an error.

Correct

It worked! I added more conditional statement and it worked… Thank you very much, I thought i wrote something wrong., thank you

1 Like

Not that I wrote it for you but if I helped you solve the problem, marking my comment as a solution would be appreciated :slight_smile:

Thanks @Elie.Trad

1 Like