|
|||||||
![]() |
|
|
Thread Tools |
|
|||
|
hello all
![]() i have just started learning python, and i want to write a script that would create an object that consisted of a single edge and then extrude this edge along a curve. The distance to which the extruded vertices would be moved would be a random number, but would fit within a set of parameters. Also, each set of extruded verts would be scaled ( also at a random amount within a set of parameters). i have been reading a few newbie tutorials and looking at the script templates and library, but i am still pretty much clueless as to how i might do this. basically, i need to know how i would make the object be created at the beginning of the curve, how i would make it extrude along the curve at a random distance, and make each set of extruded verts be scaled at a random amount. (essentially, i know nothing that i need to). hopefully someone could give me some advice on how to do this, and perhaps direct me to some newbie blender-oriented tutorials? thanks for your time cuervo |
|||
|
#1
|
|||
|
|
|
|||
|
...*bump*
|
|||
|
#2
|
|
|||
|
Could you post a screen shot of what the result should basically look like?
Also just wondering what exactly are you going to be using this for, do you have a specific project in mind? Have you looked at the blender API doc yet? I've only written one script myself, but I found it helpful to nose around the api doc, and also to find any scripts that sound similar or might simulate parts of what I wanted my script to do.
............................................
i make stuff |
|||
|
#3
|
|
|||
|
the end result would (ideally) be like so:
![]() and where exactly is the api doc? yes, it does seem like a rather worthless script. I want to use it in order to make borders for a few renders of mine for display in a mini slideshow. and of course, to help me learn python. |
|||
|
#4
|
|
||||
|
............................................
Rocket Scientists and Squirrel Preserves... Some Scripts I've Written |
||||
|
#5
|
|
|||
|
thanks for the link forTe. thats a very good resource.
my main questions are: -when i am creating vertex coordinates for an object, how do i ensure that the location i am entering is local? does blender automatically assume that they are, or do i have to somehow notify it? -how do i set the location and rotation of the object i am creating to fit the curve? the location should be the first vertex of the curve, and the rotation should go along the curve's track axis.i will continue to read through the documentation, but i figure i will still need some help. |
|||
|
#6
|
|
||||
|
Quote:
Quote:
For getting points along a curve, take a look here: http://blenderartists.org/forum/showthread.php?t=108542
............................................
Rocket Scientists and Squirrel Preserves... Some Scripts I've Written |
||||
|
#7
|
|
|||
|
i cant say i understood all of that
![]() im thinking that it might be a good idea to have a look at the source code for blender functions like bevelOb to see how blender calculates it. well, what i understand so far is that i want to create an object (me = Mesh.New('extrudeMesh')) and define coordinates for the objects vertices (coords=[[-.5, 0, 0], [.5, 0, 0]]) and then define the edge between them (edges=[[0, 1]]) and then add these variables to the mesh (me.verts.extend(coords) and me.edges.extend(edges)). Then link this object to the current scene (scn = Scene.GetCurrent()) and link the mesh to a new object (ob = scn.objects.new(me, 'extrudedObject')). Then i want to use ob.setLocation () to put the object at the beginning of hte path, but im not sure as to exactly how i would do that. Then i would assume there exists a similar command for object rotation, like so: ob.setRotation() and orient the object along the paths track axis, but i'm still not sure how. i'm certain that even those small bits of code that i typed contain some large errors, but oh, well... |
|||
|
#8
|
|
||||
|
Quote:
To calculate where you will need to place your following vertices (so that you have an edge), you need to get the point on the curve and calculate a vector from your current position to that point (There may be an additional calculation or two here). Then you need to extrude your vertices in the direction of that vector. You can then build the face. This will not have it positioned properly, so from there its about getting the location of the beginning of the curve (which should be the 0th element of the curnurb object (you'll have to strip off a little information)) and then transforming it by the rotation of the curve object to line it up. Looking up the bevOb (or perhaps the taper) code could help, but I don't know anything about that code internally so, I'm not sure...
............................................
Rocket Scientists and Squirrel Preserves... Some Scripts I've Written |
||||
|
#9
|
|
|||
|
sorry for taking so long to reply. there was a death in the family and i was distracted for a while.
thanks for the information again, forTe. i'm about to go have some lunch, but i'll do some work on this when i get back. |
|||
|
#10
|
|
|||
|
alright... i downloaded the blender source code and am currently searching for the bevOB script but the directory tree is HUGE and im having some trouble in locating it.
The immensely unimpressive code I have so far: Code:
![]() some help, please?
|
|||
|
#11
|
|
|||
|
...or would I use
Code:
and will that work on paths? Last edited by cuervo; 09-May-08 at 23:02. |
|||
|
#12
|
|
||||
|
Glad to see your back on this.
To get the curve I'd do something like: Code:
For extruding the mesh you've got a good start with creating the vertices (you could eventually change the .05 's into width parameters I think). From what you've got so far in the way of creating a mesh it looks good, you just need to go through creating a list of points based off that earlier post about getting the points from a bezier curve and then extending/extruding properly with faces. To set the location, rotation and size you could use setMatrix() (although it's not suggested by the API) or you could do: Code:
I'd also take a look at the work Campbell (IdeasMan42) put into the tree making script used for Peach (it should be in some SVN somewhere). Its close to what you want to do I think.
............................................
Rocket Scientists and Squirrel Preserves... Some Scripts I've Written Last edited by forTe; 10-May-08 at 05:11. |
||||
|
#13
|
|
|||
|
allright...
question: when i use Code:
i suppose after that i would have to do something like Code:
and also, what about my question on this bit: Code:
Last edited by cuervo; 11-May-08 at 01:49. |
|||
|
#14
|
|
||||
|
Quote:
Code:
Quote:
Code:
Quote:
............................................
Rocket Scientists and Squirrel Preserves... Some Scripts I've Written |
||||
|
#15
|
|
|||
|
that was an immensely helpful post. thank you.
i must have failed to notice the bCurve = curveData[0] part. it all makes sense now. although it is far from complete, i decided to run the script and see what i would get. my current code: Code:
|
|||
|
#16
|
|
||||
|
I always forget that the object sequence doesn't have the active attribute.
It should be: Code:
............................................
Rocket Scientists and Squirrel Preserves... Some Scripts I've Written |
||||
|
#17
|
|
|||
|
okay. i changed that and added a small text explanation for the script aborting. The frist bit of the code looks like:
Code:
i also canged the initial vertex coordinates to variables. they are assigned vales in the format aNumber <= a <= anotherNumber. will this work in python? edit: i would assume that it does not work, because i got an error. how do you give a variable parameters, then? Last edited by cuervo; 11-May-08 at 16:31. |
|||
|
#18
|
|
||||
|
Quote:
For the last part you could just do: width =.05 Right? and then assume y and z are both 0. Or you could do: coord = [x, y, z] (and replace x, y, and z with what coordinates you want) and use them later.
............................................
Rocket Scientists and Squirrel Preserves... Some Scripts I've Written |
||||
|
#19
|
|
|||
|
well, i assumed that since bCurve contains all the data of the 0th element of the curNurb object, then the first edge would need something like
Code:
|
|||
|
#20
|
![]() |
| Bookmarks |
| Thread Tools | |
|
|