Designing spiral or helix [SOLVED]

[quote=“Deppy, post:9, topic:1745”]
I’m not familiar with python. Although, I read the post but it’s not what I’m looking for in the moment but I’ll keep that in mind (when I’m in the mood for python). I prefer to create arcs in footprint editor and then convert them to copper in text editor.[/quote]

Well, I prefer to create copper spirals as tracks in python and copy&paste them into a kicad_pcb that has got the basic setup done and then enjoy myself :wink:

Code is here:

Have fun.

5 Likes

Thank you a lot @Joan_Sparky!!! :smiley:

You’re welcome.
The code might need some polishing for CW/CCW of those spirals and maybe something that would add 1/2 segments per turn as it get’s quite corner-y in the outer turns compared to the inner ones.

1 Like

What are words, right?

Upgrades:

  • adds 4 segments per turn to the base number
  • can rotate CW or CCW

4 Likes

Hello,

@Joan_Sparky
I’m trying to import your file but it seems that I’m doing something wrong.
I am using BZR 6245 on VM winXP.
Steps I followed :
-Save helix.py (your file) in the directory Program files/Kicad/bin/scripting/plugging.
-Then restart PCBnew and re-open it.
-opened scripting console and typed “import helix”.
-open footprint editor and select “new footprint using footprint wizard” and then select “wizard script to load and run” and nothing is to be shown.

What am I doing wrong?

Thanks,
Deppy

this is not a kicad-python script, sorry… this one runs on itself (or better just with a python interpreter) and the output is to be handled manually…

  1. use the command line and let it parse the output into a txt file like so (Windows)

“helix.py > helix.txt”

  1. have a project + kicad_pcb file where you want the helix to be part of, open the kicad_pcb in a text editor

  2. copy the content of helix.txt into that kicad_pcb file… right before the last braket closes


helix.txt stuff goes here
)

  1. close pcbnew if it was open and open it again to load the modified kicad_pcb

Ok. I’ll let you know for my progress on this.
Thank you Joan.

Sadly I can’t find a way to do this step. Could you please help me?
I have installed python 2.7 in VM and tried to use helix.py in shell and cmd.
Meaning, in cmd I changed the directory in order to read your file. Also, ran python.exe through cmd but I can’t do the “helix.py > helix.txt”… I did pretty much the same in the shell.

I am sorry but I am a dummy in python.

Thank you Joan

if you have a command line window open navigate to the folder where helix.py is located (btw, a helix is a 3d spiral :wink: )
Once you got the folder right, try to start the python script with this:

“python helix.py”

Do you see a couple of lines scroll by?
If yes, try this:

“python helix.py > helix.txt”

There then should be a helix.txt sitting next to helix.py in that same folder.

1 Like

WOW! It worked!
@Joan_Sparky Thank you!!! Thank you!!! Thank you!!!
You are right about the meaning of helix. I was using it all the time because of the Autocad tool.

Thank you again for you contribution!
Deppy

:smile:

just in case - as you said you’re not so fluent with python - you found how to manipulate the spiral (turns, track spacing, CW/CCW, etc.), by modifying the ‘helix.py’ code, yes?

1 Like

Yes, I have been modifying it since yesterday. :blush:
Your instruction where pretty clear, so from that point on I had no issues.

Thanks again Joan_Sparky

Hi, can you helpme to me please?
thanks you

I’m interested in creating a spiral but I need to know the steps one by one. I downloaded the code “KiCAD_CopperSpiral_v2.py” But I can not use it … not know how to use the original code (copy / paste) First use “Windows 10 x64bit” The file is located in C: \ KiCAD_CopperSpiral_v2.py
And I’ll kicad, I press “python scrips display console” and paste the code: siguiente…pero and appears not to do after eso…hacia where I point the mouse pointer or should I type to pop me the spiral?

execfile ( “C: \ KiCAD_CopperSpiral_v2.py”)

0 1 2 3 4 5 6

LIST_elmt = [ “(”, “(start”, “) (end”, “)”, “(layer”, “)”, “))”]
#LIST_elmt = [ “(Gr_line (start 131.571908 182.314571) (end 112.874456 120.68499) (angle 90) (layer Dwgs.User) (width 0.1))”]
#LIST_elmt = [ “(Segment (start 118.7 106.7) (119.4 end 106.7) (width 0.25) (layer B.Cu) (net 0))”]
DICT_elmt = { “s”: [ “segment”, “(width”, “(net”],
“Arc”: [ “gr_arc” “(angle”, “(width”],
“Lne”: [ “gr_line” “(angle”, “(width”],
}
DICT_lyr = { “dwg”: “Dwgs.User”
“Cmt”: “Cmts.User”
“Cut”: “Edge.Cuts”
“FCU” “F.Cu”
“BCU”: “B.Cu”
}

def FNC_string (element,
STR_start, # 1
STR_end, # 2
Angle, # 4
layer, # 5
width,
):
STR_line = “”
“” "
0 1 2 3 4 5
LIST_elmt = [ “(”, “(start”, “) (end”, “)”, “(layer”, “) (width”, “))”]
“” "
for i in range (len (LIST_elmt)):
STR_line + = LIST_elmt [i]
if i == 0:
STR_line + = DICT_elmt [element] [0]
if i == 1:
STR_line + = STR_start
if i == 2:
STR_line + = STR_end
if i == 3:
if element == “seg”:
STR_line + = DICT_elmt [element] [1]
STR_angle = “{: .1f}” format (width).

etc…[quote=“Dutsan_Rojas, post:25, topic:1745, full:true”]
Hi, can you helpme to me please?
thanks you
[/quote]

:sweat_smile:
etc…

segradius = td / sides

for i in range (turns * sides):
    # Central rings for HV and SNS
    startX = baseX + (radius + segradius * i) * math.sin (math.radians (segangle * (i) + startAngle))
    startY = baseY + (radius + segradius * i) * math.cos (math.radians (segangle * (i) + startAngle))
    EndX = baseX + (radius + segradius * (i + 1.0)) * math.sin (math.radians (segangle * (i + 1.0) + startAngle))
    Endy = baseY + (radius + segradius * (i + 1.0)) * math.cos (math.radians (segangle * (i + 1.0) + startAngle))
    STR_data + = FNC_string ( "seg", #type of line
                            "{: .6f}". Format (startX) + "" + "{: .6f}" format (startY), # start point.
                            "{: .6f}". Format (EndX) + "" + "{: .6f}" format (Endy) # end point.
                            net, or net value angle #
                            layer, layer on pcb #
                            tw, # track width
                            )
return STR_data

if name == ‘main’:

Center = [105.0,105.0] # x / y coordinates of the center of the pcb sheet
Radius = 1 # start radius in mm
Sides = 24
StartAngle = 0.0 # degrees
TrackWidth = 0.4
TrackDistance = 0.9
Turns = 8
Layer = "FCU"
Net = "1"

print FNC_spiral (Center,
                  Radius,
                  Sides,
                  StartAngle,
                  TrackWidth,
                  TrackDistance,
                  Turns,
                  Layer
                  Net,
                  )

(Segment (start 115.000000 106.100000) (end 114.708829 106.086667) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 114.708829 106.086667) (end 114.425000 105.995929) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 114.425000 105.995929) (end 114.169150 105.830850) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 114.169150 105.830850) (end 113.960770 105.600000) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 113.960770 105.600000) (end 113.816741 105.317053) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 113.816741 105.317053) (end 113.750000 105.000000) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 113.750000 105.000000) (end 113.768445 104.670006) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 113.768445 104.670006) (end 113.874167 104.350000) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 113.874167 104.350000) (end 114.063084 104.063084) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 114.063084 104.063084) (end 114.325000 103.830866) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 114.325000 103.830866) (end 114.644124 103.671852) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 114.644124 103.671852) (end 115.000000 103.600000) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 115.000000 103.600000) (end 115.368817 103.623556) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 115.368817 103.623556) (end 115.725000 103.744263) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 115.725000 103.744263) (end 116.042983 103.957017) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 116.042983 103.957017) (end 116.299038 104.250000) (width 0.4) (layer F.Cu) (net 1))

etc…
:sweat_smile:

(Segment (start 110.484539 103.129635) (end 110.756476 102.550000) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 110.756476 102.550000) (end 111.102652 102.009459) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 111.102652 102.009459) (end 111.517499 101.517499) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 111.517499 101.517499) (end 111.994240 101.082818) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 111.994240 101.082818) (end 112.525000 100.713174) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 112.525000 100.713174) (end 113.100933 100.415248) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 113.100933 100.415248) (end 113.712375 100.194519) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 113.712375 100.194519) (end 114.349001 100.055169) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 114.349001 100.055169) (end 115.000000 100.000000) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 115.000000 100.000000) (end 115.654263 100.030383) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 115.654263 100.030383) (end 116.300566 100.146223) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 116.300566 100.146223) (end 116.927768 100.345957) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 116.927768 100.345957) (end 117.525000 100.626572) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 117.525000 100.626572) (end 118.081855 100.983649) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 118.081855 100.983649) (end 118.588567 101.411433) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 118.588567 101.411433) (end 119.036185 101.902926) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 119.036185 101.902926) (end 119.416730 102.450000) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 119.416730 102.450000) (end 119.723334 103.043531) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 119.723334 103.043531) (end 119.950370 103.673552) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 119.950370 103.673552) (end 120.093548 104.329422) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 120.093548 104.329422) (end 120.150000 105.000000) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 120.150000 105.000000) (end 120.118334 105.673841) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 120.118334 105.673841) (end 119.998666 106.339389) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 119.998666 106.339389) (end 119.792625 106.985170) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 119.792625 106.985170) (end 119.503332 107.600000) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 119.503332 107.600000) (end 119.135354 108.173169) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 119.135354 108.173169) (end 118.694633 108.694633) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 118.694633 108.694633) (end 118.188388 109.155188) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 118.188388 109.155188) (end 117.625000 109.546633) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 117.625000 109.546633) (end 117.013872 109.861916) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 117.013872 109.861916) (end 116.365270 110.095259) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 116.365270 110.095259) (end 115.690157 110.242265) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 115.690157 110.242265) (end 115.000000 110.300000) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 115.000000 110.300000) (end 114.359765 110.272811) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 114.359765 110.272811) (end 113.726104 110.168398) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 113.726104 110.168398) (end 113.108319 109.987952) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 113.108319 109.987952) (end 112.515518 109.733784) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 112.515518 109.733784) (end 111.956484 109.409294) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 111.956484 109.409294) (end 111.439541 109.018927) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 111.439541 109.018927) (end 110.972436 108.568110) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 110.972436 108.568110) (end 110.562218 108.063180) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 110.562218 108.063180) (end 110.215132 107.511293) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 110.215132 107.511293) (end 109.936527 106.920322) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 109.936527 106.920322) (end 109.730773 106.298748) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 109.730773 106.298748) (end 109.601191 105.655534) (width 0.4) (layer F.Cu) (net 1))
(Segment (start 109.601191 105.655534) (end 109.550000 105.000000) (width 0.4) (layer F.Cu) (net 1))

I really think that writing on the front line “execute …” is unnecessary …
because of the way I hit the code to the console without changing anything
I do not know
sorry for my bad English
many thanks :sweat:

Those last lines of output… you need to put that into a .kicad_pcb file pretty much at the end.
Create a project with schematic and then create a track in pcbnew for that.
Save everything.
Then open the .kicad_pcb file in a text editor.
Study where the track element is and then add the output of the python script at that place.
Save the file.
Open in pcbnew again and the spiral should be there.

1 Like

Just curious as to what you are using the spiral for, inductor, antenna, …?

Why not create a module that can be saved to a library and manipulated like any other footprint, associated with a schematic symbol and be DRC friendly?

for inductor …
need create a spiral but…is so hard follow the steps when the english is not my strong

Have you considered a square inductor?

because, the pcb is neccesary circle form

second image:

h___erase.this___ttp://subefotos.com/ver/?f6ce983103d2811299cdd38c8941e1f2o.jpg

ammm … I did not succeed … something I need and I can not figure …
This is what I do: I explain better in the pictures with respective order of numbers and letters …
previously I tried to paste the original code at the end of spiral outline text, then save your changes, and does not appear Pcbnew opened spiral
Is it necessary to have the “KiCAD_CopperSpiral_v2” file in c :?


or in addition also I paste the same code in the console window kicad?
Thank you very much for your patience again