@pgr1973 (pgr1973) posted a new topic, subject "PGR-Meandering-Paths - a script to make jumbled 3D-Paths". It read:

   Hi Forum,
    
    I needed some jumbled cables for a background and thought it might be a good reason to get to know the python-scripting-side of blender. So I started my first steps in python last week to build me a script, that can create “meandering paths”. Now the script does almost what I want it to do (a few things don't work at all yet, and one thing does not work the way I want it to work), so I'd like to share that script with the blender-community. Maybe it will be useful for some purpose or some other …
    
    Because I don't know, how to publish python-scripts “the common way”, I just make it public with this thread, hope nobody minds.
    
    You can find the script (and a short explanation in german, maybe I'll switch that to english some day; the script itself is in english) here:
    
    http://gadgets.grochowy.de/pgr-meandering-paths/  
    resp. here:  
    http://gadgets.grochowy.de/pgr-meandering-paths/pgr_meandering_paths.py.txt  
    (had to append a .txt to the file because of the webserver)
    
    If you'd like to, you may test it, use it, and if you even like it: … tellmeso. :eyebrowlift:
    
    Short description (the complete description can be seen by pressing the help-button):
    
    It creates a blender curve, type 3D, and also (when wanted) one of three kinds of objects (circle, ractangle, hexagon), that it uses as bevel-object for the created paths. It creates the paths within the bounding-box-area of a selected mesh (which you got to create beforehand). There are several different types of random “meandering” (and two types of spring-functions; wanted to try some of the math-stuff, I learned long time ago at school  ). You can set the amount (number? count?) of paths it will create, you can set the diameter of the bevelobject, you can set the type of “startpoint-distribution”, you can let the last point of the curve sit opposite of the startpoint, you can let it unlink the preselected bounding-box-mesh, you can let it unlink everything it created during one session and you can even let it create just the 3D-curves.
    
    It's V0.0.1 (and my first contact with python at all), and the main annoying disadvantage is, that it doesn't automatically assign a material to the created 3D-Curves. It seems as if one cannot set a material to a curve with an assigned bevelobject from the script-api?
    
    Also I'd initially planned to let it optionally make paths that don't intersect. The button is still there, but it's out of function at the moment; the math needed for that is a bit too far for my brain yet. I quarried the sourcecode of linux's “pipes-screensaver”, but I can't use their way, because I just create curves, they create gl-meshes and let gl find out if there are intersections. I don't know how to port that to my curve-method …
    
    Two other thing that need to be changed are the “startpoint distribution #2” (I had several ways for that, but neither one quite satisfied me), and also it might be a good idea to make all the created objects child to each other recursively, or create an empty which'll be parent to them or something like that. I'm not sure, what'll be the best way. At the moment it just creates it's objects, which kind of stuffs the outliner-view, when it made many curves.
    
    But it creates some nice stuff anyhow, so give it a try … :eyebrowlift:
    
    Regards …
    
    Paddy

@Meta-Androcto (Meta-Androcto) replied

    hi, that's a wonderful script, very interesting results.  
    well done.  
    m.a.

After which, @Atom (Atom) added

    Worked for me!  
    I thought it was odd that my geometry was “inside” the cube I selected. At first I thought the script did nothing until I moved the cube to another layer.  
    I like the fact that you can still edit the handles and reshape the curves. I don't mind intersections, I can always move them out of the way.
    
    What I would like to see is some kind of animation in the form of empties “hooked” into the curves and set into motion.  
    Also automatic material assignment would be nice as well. I have been looking for python code, myself, that would generate an image mapped material.

To which @pgr1973 (pgr1973) replied

    > I thought it was odd that my geometry was “inside” the cube I selected. At first I  
    > thought the script did nothing until I moved the cube to another layer.
    
    Ups, you're right. Good to hear that, that needs to be changed. I'll probably set the drawing mode of the preselected mesh to wire in the next version.
    
    **[update]** _I changed that quickly. so the version is now 0.0.2 and the pre-selected mesh's drawingType is set to wire_
    
    > What I would like to see is some kind of animation in the form of empties “hooked” into  
    > the curves and set into motion.
    
    Sounds kind of complicated to me … but i had an animation-functionality in mind. I have to get deeper in the Blender-API for finding out, how that works so it will probably take some time until I can struggle with that.
    
    > Also automatic material assignment would be nice as well.
    
    Yeah that no-material-assigning is really annoying. But it seems, as if there is no way of assigning material to curves from the script-api? In fact my script does assing the selected material (if any is selected) to the curves, and it does that without any errors, but the result is bare of any material. I searched the API-Doku and other scripts for that, but it seems as if everybody is just assigning material to meshes, not to curves with an bevelobject assigned to it.
    
    But I'll try to find a solution for that problem …
    
    regards Paddy

To which @UglyMike (UglyMike) replied

    Nice script!! Loads of fun to be had here!  
    Is the bevel object available for further manipulation? (circle,square,hex is a bit limiting)  
    I'd love to see non-intersecting paths… (pretty hard to pull off though…)  
    Keep up the good work!! I'm awaiting the new and improved v0.0.2! Oops… v0.0.3  
    Can't really think about other whishlist items that are relatively easy to pull off right now…

To which @pgr1973 (pgr1973) replied

    > Is the bevel object available for further manipulation? (circle,square,hex is a bit limiting)
    
    Yes. After the script has done it's job, the bevelobject sits 0.5 blenderunits to the left of the whole created stuff (on 0.5 bu less than the bounding-box's minimum x-value and in the center of the y- and-z values) and can be edited like any other normal blender-curve. That'll change the appearance of the meandering objects.

@pgr1973 (pgr1973) replied

    Version 0.0.3 is now the newest. You can set the DefResolU for the curves beforehand now and I also splitted the erasing function into two buttons, one erasing all created objects and the other erasing just the last created objects.
    
    Regards
    
    Paddy

Then @Atom (Atom) said

    About materials…
    
    You could simply convert the curves to meshes, then material assignment via code may be possible?  
    If you just want the curves, you could leave the Assign Material button unselected.
    
    This reminds me of the Neil Blevins “Wires” MaxScript for 3DSMax.

After which, @pgr1973 (pgr1973) added

    > […]  
    > You could simply convert the curves to meshes, then material assignment  
    > via code may be possible?  
    > […]
    
    Yes, it would be no problem then, but when the script converts the Curves to meshes, one could not quickly edit the result by just dragging around the curve-points and -handles (named CurNurbs within Blender). That's the reason why I wrote the script, because I wanted the result to be editable without deforming the extrusion-profile. Or better said: I want both to be editable separately.

Then @pgr1973 (pgr1973) said

    OK, the actual version is now 0.0.4.  
    The material assignment finally works and all created objects are now parented to an empty the script creates (what keeps the outliner a bit tidyer).
    
    Location is the same as before:
    
    http://gadgets.grochowy.de/pgr-meandering-paths/
    
    Have fun and goodnight …
    
    Paddy

To which @UglyMike (UglyMike) replied

    I tried deforming the Bevel CurveCircle, but all it did was deform that very circle, NOT the tubes… Am I missing something?

So @pgr1973 (pgr1973) replied

    Maybe you got to select the “tubes”, enter edit-mode once and leave it again?  
    Have you tried rendering your scene after deforming the bevel-object?  
    Technically the bevelObject is assigned to each 3D-Path as (you guess it) “BevOb” which stands short for bevel-object. That's to be seen under blenders editing-window (F9).
    
    Maybe it has something to do with your graphics-card that the screen is not updated? But at least after some time blender should update it's view and also render the scene with the changed bevelObject.
    
    Regards Paddy

Then @pgr1973 (pgr1973) said

    Ok the script skipped some version-steps but I hope that's OK. Now we got optionally animated 3D-Paths, yeah! _gg_ Version is V0.1.0. It seems to me, as if the GUI need's some tidying up … 
    
    Anyway: regards and have fun with the script … 
    
    Paddy

So @pgr1973 (pgr1973) replied

    V0.1.2 now:
    
      * origins of the 3D-Curves are at the center of the bounding box now.
      * animation-method is changed now, so that the Paths don't tangle up near the center of the bounding-box
      * also the animation-dampening system is kind of improved …
      * also fixed the chaotic deformation of the bevelled 3D-curves when the bounding-box was not located at the scenes center (did that in V0.1.1).
    
    
    
    greetings
    
    Paddy

After which, @KevinW (KevinW) added

    WOW! Thank you soooo much. This is __just_ _what I needed (doing it by hand was taking waaay too long). I hope this gets included in the regular blender distribution.
    
    This is also the perfect partner for the Discombobulator… greeble here I come!
    
    –  
    Kevin

So @pgr1973 (pgr1973) replied

    Hi KevinW,
    
    thanks for the compliments 
    
    > […] (doing it by hand was taking waaay too long) […]
    
    That's the reason, why I wrote the script _g_
    
    Feel free to post results. I'd like to see things that were made with it …
    
    Regards
    
    Paddy

Then @chela69 (chela69) said

    gurus,  
    the link turns up blank…firefox says it can't find the page???  
    chela69

Then @pgr1973 (pgr1973) said

    Site is up, link should work:
    
    http://gadgets.grochowy.de/pgr-meandering-paths/

So @chela69 (chela69) replied

    pgr1973,  
    thanx a lot just download the script…will have fun!!!  
    chela69

@SHABA1 (SHABA1) replied

    Very nice script I just tried it on the default cube and it worked without incident. I will do some detailed work with it later and let you know how it goes

@pgr1973 (pgr1973) replied

    Current version now: V0.1.3
    
      * optimized startpoint-distribution #2
      * optimized startpoint-distribution #3 (tries to avoid overlapping startpoints)
    
    
    
    Have fun
    
    Regards
    
    Paddy

After which, @pgr1973 (pgr1973) added

    Current Version now: V0.1.4
    
      * the script doesn't just use the bounding-box of a mesh as “meander-area” anymore, but tries (!) to follow the actual form of the mesh
      * the script now remembers it's last settings
    
    
    
    Same URL:
    
    http://gadgets.grochowy.de/pgr-meandering-paths/
    
    Have fun (and post results :yes:)
    
    Regards Paddy

After which, @pgr1973 (pgr1973) added

    Current Version is now: V0.1.5
    
      * renamed startpoint-distribution #3 to #4 and optimized its count-reducing; min. distance between two startpoints is bevelSize plus 0.002
      * made new startpoint-distribution #3; min. distance is sqrt((areaY*areaZ)/numbPaths)
      * fixed wrong registry key-name (changed ‘-' to ‘_')
      * did some code-cleanups
    
    
    
    Have fun.
    
    Regards Paddy

So @Meta-Androcto (Meta-Androcto) replied

    great work on this,  
    just letting you know that people are still here.  
    & yes having fun.  
    m.a.

After which, @pgr1973 (pgr1973) added

    thx …

@Bliz (Bliz) replied

    Hi Guys,  
    Bit of a bump here but the script doesn't work in 2.49.2
    
    If pgr1973 is still around the forum, could he have a quick look?

After which, @Meta-Androcto (Meta-Androcto) added

    It works for me.  
    ye bumper of old threads.  
    follow the instructions.

@SHABA1 (SHABA1) replied

    Meta-Androcto:
    
    > It works for me.  
    >  ye bumper of old threads.  
    >  follow the instructions.
    
    Meta-Androcto: Bliz is correct. I just tried the script in Blender v2.49 under windows xpSP2  
    Here is the error I got.  
    “Compiled with Python version 2.6.2.  
    Checking for installed Python… got it!  
    Traceback (most recent call last):  
    File “<string>”, line 1, in <module>  
    File “C:\Program Files\Blender Foundation\Blender249.blender\scripts\pgr_mean  
    dering_paths.py”, line 5  
    SyntaxError: Non-ASCII character ‘\xa9' in file C:\Program Files\Blender Foundat  
    ion\Blender249.blender\scripts\pgr_meandering_paths.py on line 5, but no encodi  
    ng declared; see http://www.python.org/peps/pep-0263.html for details”

@Meta-Androcto (Meta-Androcto) replied

    then best I upload my working version.  
    http://www.cdupload.com/files/61069_ojzpw/wizards_pgr_meandering_paths.py  
    or add >
    
    # - _\- coding: latin-1 -_ -
    
    below #!BPY  
    to the original code.
    
    I manually removed the error, so it did not appear broken to me.

Then @SHABA1 (SHABA1) said

    Meta-Androcto:
    
    > then best I upload my working version.  
    >  http://www.cdupload.com/files/61069_ojzpw/wizards_pgr_meandering_paths.py  
    >  or add >
    > 
    > # - _\- coding: latin-1 -_ -
    > 
    > below #!BPY  
    >  to the original code.
    > 
    > I manually removed the error, so it did not appear broken to me.
    
    Yes I just did the same thing I think. I manually went thru and replaces all the umlats and other non ascii characters with ascii ones. Now it runs fine.

@RickyBlender (RickyBlender) replied

    i'm trying to make it work but some problems with it
    
    i mean ii want to do the sprial wire as shonw in his web site Screw2 type
    
    but don't get any thing done
    
    i did add a cube at origin but don't get any cruve at all
    
    can somone explain some more to how it can work?
    
    thanks

@PKHG (PKHG) replied

    Old script to Bl 258: Revived nearby finished …
    
    ### Attachments

So @RickyBlender (RickyBlender) replied

    whre can we get the latest working version ?
    
    thanks

Then @pgr1973 (pgr1973) said

    RickyBlender:
    
    > i'm trying to make it work but some problems with it
    > 
    > i mean ii want to do the sprial wire as shonw in his web site Screw2 type
    > 
    > but don't get any thing done
    > 
    > i did add a cube at origin but don't get any cruve at all
    > 
    > can somone explain some more to how it can work?
    > 
    > thanks
    
    Hi Ricky.
    
    I see your question now for the first Time. If it's still current, with PGR-Meandering-Paths and Blender 2.4x  
    you select your cube, which will act as the bound-box for the distributed start- and end-points. Don't  
    be in editing mode.
    
    Now set the parameters the way you want them. To get the screwy-type, activate “Type of meander” “Screwy” or “Screwy2”  
    and set the “Steps along x-axis” to a higher value (the higher the more turns the screwing does).
    
    I attach a screenshot to this post where you can see parameters and result.
    
    pgr-meadnering-paths-example-screwy2.jpg1024×670 89.4 KB
    
      
    
    
    How it's gonna work in PKHGs ported version of my script, I don't now and I am really looking forward to his effort and how it's gone work out in the new Blender Version(s)
    
    Regards Paddy

Then @RickyBlender (RickyBlender) said

    well i'm now working with 2,5 and would definitibvely like to try it in 2.5
    
    thanks for clarifying it
    
    thanks  
    happy 2.5

So @PKHG (PKHG) replied

    You can see it here: http://www.petergragert.info/pmwiki/pmwiki.php/MeanderPath/Index  
    The Source is to be found there too. It is working but a lot of cleanup and add has to be done … Have to learn a lot  
    goes on … now I can already force the hexagon to the curves visible (not yet in the code because of other adjustments to the  
    first ‘straight' case have to be done (and today was " Oma und Opa Tag" …

@RickyBlender (RickyBlender) replied

    good luck with this one and let us know when it is completed!
    
    happy 2.5

Then @PKHG (PKHG) said

    Going forward: changing parameters (and deleting one face of the cube) I got

@PKHG (PKHG) replied

    Version 1 (usable already, with a lot of features transferred, some things are differently seen)
    
    http://www.petergragert.info/pmwiki/pmwiki.php/MeanderPath/MeanderSource
    
    Comments and errors found are appreciated!  
    Peter


{'source': 'discourse', 'url': 'https://blenderartists.org/t/pgr-meandering-paths-a-script-to-make-jumbled-3d-paths/401146', 'title': 'PGR-Meandering-Paths - a script to make jumbled 3D-Paths', 'views': 4640, 'has_accepted_answer': False, 'word_count': 2742, 'like_count': 0, 'reply_count': 10, 'participant_count': 10, 'posts': 39, 'tags': '', 'author': '@pgr1973 (pgr1973)', 'participants': '@pgr1973 (pgr1973), @Meta-Androcto (Meta-Androcto), @Atom (Atom), @UglyMike (UglyMike), @KevinW (KevinW), @chela69 (chela69), @SHABA1 (SHABA1), @Bliz (Bliz), @RickyBlender (RickyBlender), @PKHG (PKHG)', 'image_url': [None], 'created_at': '2007-10-23T18:45:50.000Z', 'last_posted_at': '2011-07-10T02:08:22.000Z'}