For loop


#1

Using a

 

 

 

Using a for loop with double index (i, j) does not draw the exact curves
With a single for loop draws the exact
What is wrong ??
thanks

 

for-python2

 

 

 

 

 

 

 

 

for-python3


#2

If I move the phrase “c2 = NurbsCurve.ByPoints (puntinifor-python4);” then it becomes as shown in figure

 

 


#3

This is why it doesn’t work:

The first time you pass through the outer for-loop you make a curve of all the points in myXYZ. The next time you make a new curve that overwrites the previous curve. The new curve consists of all the points in myXYZ, which is now 40 points. Each time you loop through the outer for loop you make a new curve with even more points.

The curve doesn’t fit the points because it’s a NURBS curve which only approximates the points. You can imagine the points as small gravity centers which pull the curve towards them. I’m not sure, but you can maybe try HermiteSpline?

I’m not sure if the script does what you want, but I send you a modified version of your script. I added a list variable to keep each curve, and I moved the declaration of the point list variable into the outer loop, so it gets reset for each loop.

Sinecurves.dyn

2014-12-04_183855


#4

Thanks Thomas, for help … now works … I understood the meaning of your reasoning
Sorry, I’m a beginner, do not understand why ask:

curvelist = [] (after the for loop …)

This command does not cancel the list ??

how do you stay later for printing?

I hope I explained

Thanks again for your cooperation


#5

Hi

Sorry, but I don’t quite understand your question.

curveList = [] is the same as curveList = list().

Defining the pointList variable within the for loop will reset it for every loop iteration.

Do you want to print the curves?


#6

Hi Thomas

Sorry, I do not know English … however I understand … Thanks for your cooperation