Convert Particles to Mesh

jms, cambo, and possibly others have done work which has made the following script possible in CVS version of blender. cambo had made this code from that work ->

# Converts particles into a mesh with edges for strands
from Blender import Scene, Mathutils, Effect, Mesh, Object
scn= Scene.GetCurrent()
ob= scn.getActiveObject()
me= Mesh.New()
     
effects= Effect.Get()
for eff in effects:
    for p in eff.getParticlesLoc():
        # p is either a vector or a list of vectors. me.verts.extend() will deal with either
        print p
        me.verts.extend(p)
     
        if type(p)==list: # Are we a strand or a pair, then add edges.
            if len(p)>1:
                edges= [(i, i+1) for i in range(len(me.verts)-len(p), len(me.verts)-1)]
                me.edges.extend( edges )
     
print len(me.verts)
ob= Object.New('Mesh')
ob.link(me)
scn.link(ob)

I have done a quick blend where I went one step further by converting the resulting mesh to a bunch of curves with “Edge to Curve”, and then applied a BevelObject and a Taper to those curves.

http://eaemedia.com/blender/tutorials/particleCurves.jpg

Grab the blend here. Again, you need a current build to use the script but you can play with the resulting mesh in 2.42.

Thanks again jms and cambo!

Hi, lucidMonkey.
I’ve grab the blend file you shared and tried to run python script but it didn’t worked. I’m a windows user and didn’t work with CVS build. Where can I find it CVS? or maybe there is anothere way to run script?

I wrote the implementation of the particles location :
https://projects.blender.org/tracker/index.php?func=detail&aid=3328&group_id=9&atid=127
http://projects.blender.org/tracker/index.php?func=detail&aid=4852&group_id=9&atid=127
the script by cambo is just an derivative work of my own example

The enhancement of the particles location is just one week old . Use a Blender CVS version or try this with the old implementation .

2jms thnx, finaly I understood how it works, I downloaded CVS version now the script converts my particles into the mesh for about 25 min.
How long it’ll be to convert 1000.000 particles?

Depend on the CVS you downloaded . If it is the win32 located on the zoo-logique.ord web site, there is, in the NMesh module, the undocumented and absoloutly not official function : getRawFromRender , http://blenderartists.org/forum/showthread.php?t=62245
(if you need more explanations upon this function, please, post on the getRawFromRender thread)
A bit faster, but non completly “finalized” . In fact, it works but it also needs to be completly rewritten from scratsh to give a right acces to certain texture tools .

I’ll take a look, thnx.

jms, apologies sir. I have updated my first post, hopefully it is a bit more accurate now.

Some more experiments I have planned are to use this as a curve guide for hair/fur. If you use a percentage of the particle strands as guides, I think you will be able to quickly get lots of control over the system…

Some time ago, I wanted to convert particles to curves with a script- is this possible now, or have you done that manually?

lol… I dont mind about who did what-
JMS recently made a patch and I modified it to work with strands,
so the improvements are from both of us.

:slight_smile:
The original patch for particles location is dated from november 2005 . Is this that you call “recently” ? And you did not modified anything in this code . This patch was for Object module but Khugues moved it to the Particles one .

:slight_smile: :slight_smile:
For the second patch , to be more precise, you have just added a list separation in the code to avoid to get the particles life and step values, and to do not have to build these lists in the python side of a script . Static locations (that you call “strands”) was already given without your modif . So say that you have “modified it to work with strands” is a bit exaggerated although not completely false : one can say that your small addition facilitates the work with strands .

http://projects.blender.org/tracker/index.php?func=detail&aid=4891&group_id=9&atid=127

Hi Lucid monkey, nice work… some things that could be added for fun…

changing the taper of a curve per point (woth brokens recent addition)
Radius could be set from the angle difference between points…
Or it could be derived from a texture.

was thinking of adding a python function to
texco= cloud_tex.evaluate(vec)
so you could use clouds say to vary the taper.

another thing would be to vary the tilt of a curve…

if you mixed tilt with an offset the extruded curve you could make curly hair :wink:

jms- lets not hijack this thread, you can always email me. esp for patch additions.

another thing would be to vary the tilt of a curve…

if you mixed tilt with an offset the extruded curve you could make curly hair :wink:

Now that is seriously interesting… I am going to test “curve guide from twin particle system at a lower display setting” right now to see how well that combs hair. That is the first time I originally thought something like this would be useful. Throw Tilt( i like to call it twist) into the mix and … sweetness!

A reference to the Step parameter is in the topic, I think .

My hair experiment failed. A curve guide can not be more than one strand. Each individual strand must be converted to individual curves and have Curve Guide and Maxdist and possibly Tilt settings applied for this technique to work.

Ok this is all well and good. But how do you USE this script. All I see in the blend file is those leaf type things.

sorry to bring this up again but no one answered. LucidMonkey where is that “Edge to Curve” Script that you mentioned? I did a search here and came up with nothing. Also is there a way of turn the edges into actual faces that can be exported. All I see is a blank screen when I run the script by itself on a grid that I have added static particles to.

I face a similar problem. The script doesn’t work. Surely there must be some way to do something as simple as converting strands to actual meshes ? I mean, this must be done anyway to render them! :eek: