i have finished another useless script, coil script
it rotates the selected object to make a coil
the object that is rotated must be modeled in side view(F3).
Shot at 2007-06-26
import Blender
from Blender import *
import math
obj = Mesh.New("Object")
sel = Blender.Object.GetSelected()
if sel:obj3=sel[0]
obj2 = obj3.getData(mesh = 1)
cubeVerts = obj2.verts
#defining variables
punktid = []
selected_faces = []
seledges = []
edge = obj.edges
verts = obj.verts
faces = obj.faces
radians=math.radians
selected = []
sin=math.sin
degrees = math.degrees
asin = math.asin
sqrt = math.sqrt
cos = math.cos
abs = math.fabs
#Data Of Circle
raadius = 0
oval = 90
resolution = 6
center = 0
CoilHight = 1
NrOfRotations=10
#/Data Of Circle
VertsPerCoil = (len(verts)/len(cubeVerts))
def vector(v1,v2):
vect = sqrt((v1[0]-v2.co[0]*v1[0]-v2.co[0])+(v1[1]-v2.co[1]*v1[1]-v2.co[1]))
return vect
def vector2to3(v1,v2):
vect = v1[2]+v2.co[2]
return vect
def circle(CenterShiftX,CenterShiftY,oval,resolution,center,steps,shiftX,shiftY,shiftZ,HightShift,Radius):
count = 0
centerZ = 1
while count < steps:
sektor = 0
count +=1
stepz = 0
stepx = oval
sektor = 1
centerX = 1
centerY = 1
while sektor < 2:
if sektor == 1:
centerX = centerX + raadius*sin(radians(stepx))
centerY = centerY + raadius*sin(radians(stepz))
centerZ = centerZ+(CoilHight/100.00)
verts.extend(((CenterShiftY+Radius)*sin(radians(stepz))),((CenterShiftX+Radius)*sin(radians(stepx)))+(CenterShiftY*sin(radians(stepx))),centerZ+HightShift)
stepz +=resolution
stepx +=-1*resolution
if stepz >= 360:
sektor = 2
for i in range(0,len(cubeVerts)):
currentVertX = cubeVerts[i].co[0]
currentVertY = cubeVerts[i].co[1]
currentVertZ = cubeVerts[i].co[2]
CenterShiftX = 0-cubeVerts[i].co[0]
CenterShiftY = 0-cubeVerts[i].co[1]
HightShift = (vector2to3([0.1,0.1,0.1],cubeVerts[i]))
circle(CenterShiftX,CenterShiftY,oval,10,0,NrOfRotations,currentVertX,currentVertY,currentVertZ,HightShift,raadius)
#FILLING
jump = (len(verts)/len(cubeVerts))
DelFace = 0
DelFace +=jump
print "Jump ",jump
for v in verts:
v.sel = 0
for i in range(0,len(verts)-1):
if (i+(len(verts)/len(cubeVerts))+1 < len(verts)) and ( i < (len(verts)/(len(cubeVerts))*(len(cubeVerts)-1))):
if i !=DelFace-1:
vert1=i
vert2=i+1
vert3=i+(len(verts)/len(cubeVerts))#(len(verts)/len(cubeVerts)) VERTS PER RING
vert4=i+(len(verts)/len(cubeVerts))+1
faces.extend(vert2,vert4,vert3,vert1)
if i == DelFace:
print "delface",DelFace
verts[DelFace].sel = 1
DelFace += jump
elif (i <= (len(verts)-1)) and (i-(len(verts)/(len(cubeVerts))*(len(cubeVerts)-1))>=0):
if i !=DelFace-1:
vert1=i
vert2=i+1
vert3=i-(len(verts)/(len(cubeVerts))*(len(cubeVerts)-1))#(len(verts)/len(cubeVerts)) VERTS PER RING
vert4=(i+1)-(len(verts)/(len(cubeVerts))*(len(cubeVerts)-1))
faces.extend(vert2,vert4,vert3,vert1)
if i == DelFace:
DelFace = DelFace+jump
scn = Scene.GetCurrent()
ob = scn.objects.new(obj,"Coil")
Blender.Redraw()
i just found a weird bug in the script.
the object that is being rotated, will be rotated 90 degrees.
and btw
the script is quite slow so be patient.(if anyone manages to use this script, post the result here), i doubt anyone will succeed.
How is this different from the existing Screw tool?
hey scorpion9, have you seen this>
http://blenderartists.org/forum/showthread.php?t=87553&highlight=spirals
Keep going, I look forward to more useless scripts.
m.a.
this would make a great Primitive for inclusion into Blender. I encourage you to contact BeBraw or someone; they recently did this for a script the Hoehrer wrote for UV/Face selection - see that thread for more info.
PapaSmurf, encouragement is one thing, suggesting an unfinished script with no interface, that may or may not work (i couldn’t get it to) be included in blender is another.
follow the link i provided, test out the fully functional Spirals script, with it’s easy to use interface, 4 different types of spiral curves, including torus knot type spirals, send a pm to Alexv or BeBraw & try to get that script included in blender. whilst your at it, let’s get A.N.T. Landscape, Gen3, Shells & the multitude of other finished, professional style scripts in first.
scorpion9, Sorry to put that on your thread, keep up the good work, with some time and a little more effort you will evolve into a great script writer. Already you are making much progress towards that result. Search the forum for script templates, there are a couple that make it easier to build your gui. Some of your code could even be integrated with the spirals script to build upon that further, it could allow both spiral curves & spiral objects. just a thought…
m.a.
oic. nvm. ScoripionGuyWiththeCyborgEar: keep working on it dude! someday it’ll be more than useless to many people! Maybe you could use the Spirals and make them both better, and then send a pm…
(<better, meta-andoctoro? from the pics it looked like it was working…even though he did use the default blue background…that should have been my clue.>)
Actually these scripts arent ment for “using”
it is more for a practice and feedback.
i learned blender python quite a bit by making this script.
Thanks for feedback.
S9
thanks fore the suggestions.
about the comments, you are right. actually im allready thinking of making it easier for others to read my code. Thats why im writing all the codes in English not Estonian.
and here is a .blend file with two example meshes.
just select a mesh and execute the script
http://www.savefile.com/files/848920
S9
I have not a clue how to “LOAD” a script or use a script. I tried various things. Can someone explain this step by step and pretend I’m an idiot? (which could be true)
I could only find existing scripts inside 2.49 but don’t even know how to use them.
Also my python came up with a message saying that some scripts may not run.
Just updated python after that and I still get that same message. wtf?
omegafold,
To run a script, you need to put the script into a Blender “Text Editor” window and press the button marked “Run Script”
Blender supports drag and drop. So once you have a “Text Editor” window in Blender just grab the file from your desktop, or wherever it is, and drop it in the window. You should see the text from the file now. Press “Run Script” and it will execute.
Alternately, you can copy the text from anywhere, and past it into a new text file in blender.
Press the “New” button with the “+” sign on it, and then paste in your text. Then press “Run Script.”
Some scripts require you to select the object, you are going to modify, in the 3-D viewport before you press “Run Script.”