Ma Self

Wednesday, March 17th, 2010

This script creates vertex colours based on the angle between the vertex’s normal and the edges connected to it.

It is written as a faster alternative to the Ma Baker script.

It is also a lot like Campbell Barton’s Self shadow script.

Hence the name.

The big difference is that this script has no settings, and thus should be really fast.


Downloads

Requirements

This script is written for blender 2.42


Running the script

There are no settings for this script and there is no interface! It is written to be quick and simple. If you have no mesh selected it will give an error message. Loose verts and edges will be ignored!


A nice comparison between the three scripts

The times it takes for the math part to run in the scripts on the suzanne model on my system (1ghz amd 768MB ram):

  • MaBaker: 0.5991s
  • SelfShadow: 0.1182s
  • MaSelf: 0.0944s

That’s all

Enjoy
Dolf

Attached Files:

Ma Baker

Wednesday, March 17th, 2010

This script bakes vertex colours into your mesh depending on the angle of the edges of the mesh.

Based on an idea by endi

Optimised by tedi


Downloads

Requirements

The script is written for use with blender 2.41 but should work with newer and older versions as well.


The interface


The header

Here you can see what version of the script you are currently using


Messages

Here helpfull messages will be printed. It will tell you if the bake was succesfull and if not what went wrong.


The settings

Here are all the functions of the script. The following options are available.

  • invert shading
    In regular mode the concave parts of the mesh are made dark and the convex parts of the mesh are made light. By selecting inverted shading mode the reverse will happen.
  • invert wind
    When wind is created basicly the faces facing the direction of the wind are made lighter.
  • wind direction
    Here you can set where the wind should come from. The direction is set relative to the global coordinates, not local.
  • concave
    When selected concave parts of the mesh are coloured. From the dictionary: Concave: hollowed or rounded inward like the inside of a bowl.
  • convex
    When selected convex parts of the mesh are coloured. From the dictionary: Convex: curved or rounded like the outside of a sphere or circle.
  • wind
    When selected the mesh is coloured relative to the wind direction.
  • min angle
    Edges with an angle below this value will be assigned the default colour value.
  • max angle
    Edges with an angle above this value will be assigned the maximum colour value.
  • BAKE
    When pressed this button starts the bake.
  • EXIT
    When pressed this button exits the script. Alternatively you can use the escape button on your keyboard.

Tips

If you find this script is too slow for you try the Ma Self script.

For the bake effect to show up in your 3d window you’ll have to view your model in “textured view mode” (Alt + Z). For the bake effect to influense your render you will have to assign a material to your model with VCol Light in the material buttons switched on.


Exporting the result

This based on a tip from patricks. Follow the following instructions

. Assign a uv layout to your object (unwrap it).

2. Open a script window.

3. Run the “texture baker” script you can find in the scripts menu under “UV”. This will export an image but not with the colors. The script will create an object and camera on layer 20.

4. Go to layer 20 (right bottom in the layer selection of your 3d window).

5. select the camera you can find there.

6. Hit CTRL + Numpad 0 to make this your current camera.

7. Set your rendersize to something square.

8. Render it!


Examples


That’s it

Enjoy!
Dolf

Inset

Wednesday, March 17th, 2010

This script Insets a selection of faces in your mesh.


Downloads

Requirements

This script is written for blender 2.45 but should work with older versions as well


Settings

There is only one setting for the script and it will appear as a popup in your script window. The value is in blender units.

You want to make sure that the length in this is shorter than the shortest edge of your selection!!!


Usage

Select one or more (but not all) faces in your mesh, then run the script.

Pre Inset example

Post inset example:


Known issues

The script does not like poles!

It also doesn’t like Kinks


That’s it

That’s all for right now… I hope it’s as usefull to you as it is to me.

enjoy!
Dolf

Attached Files:

Finding mesh angles

Wednesday, March 17th, 2010

Here I’ll try to explain a method for finding out the angle of a mesh at a specific point/edge in python.

This method can for instance be used to create effects like with the ma baker or ma self scripts;


Finding the angle between two faces in Blender

Now this isn’t really complicated.

Lets say you retrieve two faces from Blender’s python API that are connected by an edge.

Lets call them face1 and face2 and face1.no retrieves the face normal of face1.

Then we can simply do the following to find the angle:

  1. myAngle = Mathutils.AngleBetweenVecs(face1.no, face2.no)

Display clean python code for copying

myAngle = Mathutils.AngleBetweenVecs(face1.no, face2.no)

The result though is only an angle between 0 and 90 degrees, to find out if that is positive or negative continue reading below.


Finding out whether the angle between two faces is convex or concave

A lot of the time you also want to know whether the angle is concave or convex (positive or negative).

To get that we get the vector from the midpoint of face1 to the midpoint of face2.

The midpoint of a face is retrieved by getting face1.cent.

Then we get the dot product of the face normal of face1 and the vector we just retrieved.

In python that could be:

  1. dotProduct = Mathutils.DotVecs(face1.no, (face2.cent - face1.cent))

Display clean python code for copying

dotProduct = Mathutils.DotVecs(face1.no, (face2.cent - face1.cent))

The resulting dot product will be either positive or negative depending on whether the angle is concave or convex.

Euler filter

Wednesday, March 17th, 2010

On this page you can find the Euler Filter script for Blender 3D.

It is meant to clean up Rotation IPO curves recorded with the game engine.


Downloads

Requirements

This script is written for blender 2.48a


Use of the script

A lot of the time when you record motion in Blender’s game engine you get Curves that ‘Flip’.

This because Blender doesn’t like rotations above 180 or below -180 degrees.

Below here is an example of what a recorded curve may look like.

And here the result of a cleaned IPO curve


That’s basicly all there’s to it. It looks like the script does the job… enjoy!

Dolf

Attached Files:

Caliper

Wednesday, March 17th, 2010

This script measures the distance between 2 points, and converts it to a real world equivalent.

It also can create a mesh and text object to display the result in a renderable format.
The script was developed commercially for: Render Reality LLC.

A big thank you to the company for allowing the script to be released under the GPL license!


Downloads

Requirements

This script is written for use with blender 2.43 and up to 2.49.


The Gui


The Top

At the very top you can see what version of the script you are using.

In the results and messages block you normally get to see the measurement result.

In case of an error a message explaining the error should appear.


Object settings

Here you can set a nr of general things concerning the objects the script creates.

Text

When selected the script will create a 3d text object to display the measurement result.

Arrow

When selected the script will create a 3d mesh object to display what points were measured.

Clean

When selected the script will remove any previous measurement objects made between these two measured points.Will not work in case you renamed your objects after the last run of the script. May not work correctly if the object names are very long. May not work if you edited your meshes since the previous run. Cleaned objects won’t be truly removed until your save and reload your file twice!

Tip: if you deselect Text and Arrow but have Clean selected you can remove the measurement object and clean your scene.

Layers

In the block of small toggle buttons you can select on what layers the measurement objects should be created.

Color

In this dropdown box you can select what the initial color of the measurement material should be. The script will only create the material once. You can adapt the material after it has been created.


Arrow style

Arrow type

In the arrow type dropdown box you can select what arrow shape you want created.

Arrow alignment

Here you can set how the arrow and text objects for the measurement will align. The options are front, top, rear & bottom. If your measurement aligns to the left and you want it aligned to the right switch from front to rear or top to bottom to invert the objects.

Arrow scale

In the scale setting you set the relative size of the arrow object. The arrow will always stretch between the measured points. Changing the scale will make the arrow fatter or skinnier.


Text style

Bevel

Will set the bevel value for the created text object.

Ext

Will set the extrusion level (depth) of the created text object.

Size

Sets the size of the created text object.

Offset

Sets the offset of the created text object.

Tip:

if you create a larger arrow object you want to change this value.


Measurement settings

Measure the distance in

Here you can select what object types you want to measure between or in.

Measurement Constraint

Here you can constrain the measurement to a specific axis. So if you select X for instance only the distance along the x axis will be measured.

Tip Remember that when you do a “closest/furthest” measurement the script will first get the location and then constrain the result to that axis! So if you constrain along the x axis, you will still get the closest points but perhaps not the closest along the x axis!

Constrain objects

This option is only available if the measurement constraint option is active. When selected the created objects displaying the measurement will also align on the axis to which the measurement was constrained. The objects will be positioned relative to the point measured in the object/vert/edge/face you selected second. This selection can give you multiple options in the next box. Two objects Selecting this allows you to measure the distance between two object centers of selected objects.

Two meshes

Selecting two meshes gives you a nr of choices that should explain themselves. One mesh Selecting one mesh allows you not only to measure between some preset defaults but selected parts as well. You must select the parts in edit mode. Edit mode will be exited by the script!


Output style

In this section you set what measurement result format you want.

Measurement output type

Here you set the largest value you want to measure in.

Measurement levels

Only available if your largest value isn’t the smallest available or blender units. Here you set the smallest increment in your measurement result. So if your output type is in km and you set the levels to mm you might get: 1 km 1 m 1 cm 1 m

Measurement detail

Here you can select how much detail you want in the smallest increment of your measurement. If the smallest measurement is in inches the selector will allow you to set divisions, otherwise it’s how many digits behind the comma.


Input style

Here you set how a blender unit is interpreted by the script.

Measurement input type

You can set here to what base value the blender unit should be converted.

Scale

The scale value what a blender unit converts to in the base value.


Major functions

Here you can set what action the script should undertake.

Measure

When clicked the script will measure accoring to your settings and selections.

Exit

When clicked the script will exit. Alternatively you can click the escape button on your keyboard.


That’s it

Dolf

Bezier export

Wednesday, March 17th, 2010

This script exports bezier shapes from blender to an svg vector file.


Downloads

Requirements

This script is written for blender 2.43


Running the script

There are no settings for the script. Set the Camera to your preferred angle. Select the bezier shapes you wish to export and run the script. A file selection screen will be generated where you can set, where you wish to export to and what filename it should be under.


Things to know

Remember that the export is orthagonal. This means that even though the camera angle is taken into account, there is no perspective in the exported result! Also all selected bezier shapes will be exported in their entirety. This means that the image size (camera area) is not used! One blender unit is translated to 100 points. A closed curve (circle) is exported with a solid black inside and no borders. A non closed curve is exported as a black line (1 point wide).


Examples

A bunch of bezier circles in blender

The exported result in inkscape


That’s all

Enjoy!
Dolf

Attached Files:

Using python scripts

Wednesday, March 17th, 2010

This page is here to help you understand how to use basic python scripts in blender 2.4x.

It’s not about writing scripts, just using them.

I assume you know enough about blender to open windows, find menus, and open files in it.

I will only cover Windows on this page. I don’t have the other Operating systems handy. Also using scripts in the Game engine can be a bit different than how I explain here.


What is python?

If you really want to know everything about python you should go to python.org but I’ll give a simple description here.

Python is a programming language released originally by yet another Dutchman. I know they’re everywhere! You can read more about it’s history on this page if you want.

The thing that makes python unlike C or C++ for instance is that you don’t have to actually compile your programs. Basicly all programming languages are written in basic text. Programs written in C you would ’compile’, which would turn your code into a program that you can use and give to people. So for example with python you don’t generate a blender.exe file.

In stead the programming code stays in it’s basic text format, in what is really just a textfile, nothing more. This textfile can be read by a ‘real’ program which is called python as well (just like the language). This program then does all the things that it’s told to do in the textfile.

These textfiles are called python scripts. And scripts are files that tell programs what to do, they are not programs themselves. There are lots of other languages that work in the same way… like asp, php, and javascript.


The infamous blender startup message!

You may have seen this screen before and it scares a lot of people at first. I mean… it’s an actual bonafide error message…. or is it?

Do not close this screen!

This screen is used by blender to show you messages, if you close it you will close blender as well.

Let me try to explain where the message comes from.

We can use python scripts in blender. Now we can only do so because inside blender is a small version of the python program that can read these scripts, and do what they say. That’s where the first line comes from. Apparently the copy of blender that I took this screenshot from had python 2.5 put in it. The actual line of text is created by the python program in blender when it’s started. Now as the python program in blender is started (when you start blender) it has a look at itself and your computer to see what it can do, where it is, and basicly everything I do every morning when I wake up.

So it wakes up and finds out it’s the small version. Then it has a look to see if there’s a big version of itself on your computer that would allow it to do everything the big version can do. In this case it can’t find it, and all the other messages you see basicly mean: ’Hey I am only the small version inside blender, and I can’t do everything I could do if my big brother was here’. This is no reason for anyone to worry! Really it isn’t. The small version inside blender can do pretty much everything you want. Only for the really advanced stuff like communicating with big databases and such, would you need the complete version of python.

So we have blender, and we can use pretty much all python scripts released for blender in it. You can install a full version of python if you really need it, or if you want to get rid of those messages, but normally there really is no need. I use python all the time and don’t need a full version at all.


I downloaded a script… now what?

Ok so you have a script. Lets call it myScript.py, and remember that really all it is is a textfile. You can use the script inside blender in two basic ways.


One: Put the file in the blender scripts folder

If you put the script you downloaded in the same folder as all the scripts you get with blender you can use it as if its one of those official scripts. If you are on windows find the folder that has the blender.exe program file in it and there should be a folder called ‘.blender’. In that folder should be another folder called ’scripts’. This is where all the official scripts are.

Once you put the file in there you can find it in the blender scripts menu. Don’t forget to use the ‘Update menus’ function at the top of the menu if you had blender already running when you put the script in the folder. As soon as you select the script in this menu it will ‘run/be executed’

If you are not sure where to find the script in this menu you can open it in a text editor (notepad for instance) and near the top it should say what group it’s in. That is where you’ll find it in the menu. If you can’t find the group, you’ll have to use the second way.


Two: Open the script as a textfile.

Save the script anywhere on your computer. Then in blender open a text window, and in there open the file like a textfile.

Now if you have your mouse pointer over the text window and you click ALT + P the script will run.


Having the right blender version.

Every script should tell you for what blender version it was written at the top of the script itself. There is no guarantee that a script will work if you have a newer or older version of blender than the one for which the script was written.


That’s it.

You should now know enough to use most python scripts in blender.

Have fun!
Dolf

Autosave Render

Wednesday, March 17th, 2010

This script will automaticly save every render you do as a sepparate version.

I wrote the script because I do a lot of test renders when working on a project. With this script every test render is automaticly saved, which makes for a nice progress storyboard.


Downloads

Requirements

This script is written for blender 2.45


using the script

First you will want to open the script as a text file in a text window like below.

Now we set up a scriptlink that triggers the script to run whenever you render an image.

So at this point the script is ready to run, but we want to tell it where to save the images and with what filename.

I set it on windows, and I used a relative path (relative to the current file).
Notice also that I didn’t put in an extension, I set the filename as “myfilename” NOT as “myfilename.jpg”.
The extension will automaticly be added when a render is saved.
Also the script will automaticly add a number to the end of the filename and increment that number.
So you may get filenames as the following.

myfilename_0001.jpg

myfilename_0002.jpg

myfilename_0003.jpg

and so forth

If you change your image type or filename it will start counting over.

Unless you change it back ;) It just looks at what’s in the folder already.


things to be aware of

BE AWARE NOT TO ANIMATE WITH THIS SCRIPT ENABLED!

If you have the script linked and you animate it will save an image for every rendered frame!

As far as I know there’s no way to automaticly disable the script when animating, so you have to be carefull yourself!


That’s all.

enjoy,

Dolf

Attached Files:

3D stills

Monday, March 15th, 2010