Hello, I am new to scripting and I made a script for curve closest point in C# using the golden ratio, and I wanted to make it also in Python to train myself but I wasn’t able.
Please if anyone has some advice.
Thank you, everybody
Closest point on curve - plot distance.3dm (20.7 KB)
Curve_closest point.gh (28.2 KB)
Hello
Something else also looks a little weird, but …
I think what stops your script are the assignments inside print
at lines 42, 44, 46
AFAIK, in Python assignments are not expressions, at least not those assignments and not in Python 2.7.
HTH
Hi, there are actually a lot of errors in your codes.
The python component itself does not seem to be correctly set up (input parameters, output parameters)
In Python, the depth of the indentation represents the level of the depth of the code block.
So, in C#, because the indentation is not necessary (but preferred indeed,), this is okay.
if(nyah){
Hi;
if(myah){
Hello;
if(meh){
What's up;
}
}
}
But when this is translated to Python, you need to write
if nyah:
Hi
if myah:
Hello
if meh:
What's up
In Python, you are requested to maintain the consistency of the indentation by your own.
I corrected the code so that both Pyhton and C# codes produce the same outputs.
Curve_closest point.gh (25.9 KB)
Dear Emilio, Thank you for your reply.
i will implement your advice and try to solve the code to post it in the forum.
Thank you again
Dear Mikity,
thank you so much for your reply and explanation.
it is really useful.
Thank you so much