My first script

Hi everyone,
and firstly thankyou in advance!

I decided that it was finally time i learnt some simple scripting in blender.
I have no other experience, and found the wiki rather confusing.

from what I picked up, i got an idea of the basic structure of scripting, and how to explain things to the computer.

The best way to learn, i decided would be to try and make a simple script and learn my way through it. it is a simple code designed to remove uneeded verticies along a straight line (kind of like decimate), I will add the third dimension when i feel i can, but for now it’s just 2d. so far I have planned out what i think it will look like [just how it will work essentially]:



 
#get all the locations

location of vertex 1x = ax
location of vertex 1y = ay
location of vertex 2x = bx
location of vertex 2y = by
location of vertex 3x = cx
location of vertex 3y = cy

#if the percentage increase of the two values is the same, delete the middle vertex and connect the two remaining verticies

if  {(bx/cx) = (ax/bx)} and {(by/cy) = (ay/by)}
if 
true:{
     delete vertex 2
     select vertex 1
     select vertex 3
     make face
     goto [next bit]
}
else:{
goto [next bit]
}

 

but that’s only the start

my queries were:

  1. how can I make this into a real script? I’m still not familiar with the categories that each of these commands would come under, how to word my commands.

2.I know commands like “bpy.data.objects” and using them to move objects, but i could do with a big list of them all, where can i get this?

It’s quite frustrating, as I know what I want to do, hence the commands, but I can’t even start to put it into a script! :frowning:

thank you everyone, these really are my first blind footsteps, and in the meantime, i’ll keep reading things and try to make sense of them.

thanks!

I’ve just realised my set of instructions makes no sense, so ill work on a better method, but your links are great :smiley:

I’ve been meaning to write a script that does this, but i’ve found that dragging a vert and snapping it to another vert is fast enough for most operations. If you do write this script ( or i will eventually ) think how you want the tool to behave.

Do you want a ‘simplify’ script, to remove vertices that don’t contribute to curvature?
or simply be able to select 1 or more vertices and force their removal ( and connect the verts on either end )

I have also started to learn python and this http://www.ibiblio.org/g2swap/byteofpython/read/ has been very easy to understand and fun, I have been playing with the BGE for a while and had fun with the logic bricks but I can’t wait to get a grasp with python and apply it! Kudos on your first script.