 # Python script error on calculating point on a circle

Hi all,

I want to use Python to calculate the X and Y value’s on a circle.
I already have script set up but I get an error and my Python knowledge isn’t that good. I’m a beginner at that.
I looked on the net for a way to put the formula in Pyhton and I don’t think that the formula is the problem.
I think it’s one or more of the following:

• The import notation of “math”;
• The fact that the input is a list and the script needs value’s;
• the “OUT” notation.

Futher more I want to know if a Python script can have more then one “OUT’s”?
Or do I have to combine the X and Y first into a list and then use that as an out?
The X and Y are the coordinates of points for inserting elements on. Within dynamo the python coding has to have OUT and is the only output out, but to create more than one element out you have to make the elements into a list then put them as OUT.

EG(also see attached iamge)

OUT = [xCoord,yCoord]

Then you can use a code block and have the following to get the two elements seperatly.

a;
a;

Did you by any change also had a look at the coding itself?
I still get an error on line 11. That’s the range part. Well…I solved my problem!
I didn’t use a Python script. I took the coilByFunction.dyn from Colin McCrone from http://dynamobim.org/5-8_tips/
and altered it a bit so I have a code block instead of a Python script.

Original by Colin:

My version: 1 Like

Check this:

``````import math
NoPiles=32
r=16500
alpha=360/NoPiles
x,y=[],[]
for i in range(1,NoPiles+1):
alpha_i=alpha*i
x=r*math.cos(alpha_i)
y=r*math.sin(alpha_i)
OUT=x,y``````

WOW!!! I didn’t know that was possible!
Thanks for pointing this out to me. I’ll keep it in mind for the futher.

Not sure what you are trying to achieve but in Python would be something like that:

``````import clr
from Autodesk.DesignScript.Geometry import *
import math
NoPiles=IN
seq=IN
z=IN
r=8000
x=[r*math.cos(i*NoPiles*360) for i in seq]
y=[r*math.sin(i*NoPiles*360) for i in seq]
pts=[Point.ByCoordinates(i,j,k) for i,j,k in zip(x,y,z)]
OUT=pts
``````

1 Like

I’m trying to get the coordinates from a number of points on a circle/arc.
To put it in an excample: I’m looking for the insertion points (coordinates) for my piles.
And the number of piles is not a constant so the angle (alpha) changes per foundation.
In this case I have 32 piles that must be spread over a 360 degree circle. The radius is 8m. Or 8000mm.
So my output (in this case) will be a set of 32 points which I can use as insertion/starting points for my Piles.

@Mike_Wellink Do you have a foundation? Circular?

You could get the bottom face of your foundation, get the perimeter curve, offset, and divide by the number of spaces.
Would it work for you?

I could if I wouldn’t have to select the botom. I wan’t to have it all done autonomous.
I have an excel sheet with all the data And Dynamo must create the foundation and the (batter) Piles for me.
Basicly what I want is to get the data from excel en have Dynamo create the foundation, piles and rebar all in 3D.
And if possible to set up the drawings to as much as possible.
So I still have a long way to go, But the foundation part is ready. The Piles part is halve way there. And the rebar part I still have to examine. As well as the drawing part. I understand. Out of curiosity, how did you get the data in excel? Coordinates of your foundation?

I don’t understand your question. Can you be a bit more specific?
I still have a lot of work to do to get to the end result. But 'slowly I’m getting there. 