Tutorial: GUI formatting with python

Here a (paper) tutorial on creating and formatting GUI’s with Python.
It is the second in a series of GUI tutorials.
Here you find the first tutorial “Python dialog tutorial”.

In this tutorial you will find:

  • Grouping widgets
  • Border and layout Flags
  • Checkbox and Buttons
  • Static text
  • Edittext
  • MultiLine Edittext
  • Input numbers with EditNumber, EditNumberArrows , Slider or EditSlider
  • Selecting Color with Color, AddColorField or AddColorChooser
  • Radiogroup and Combobox
  • Separator Horizontal and Vertical

All with Python examples.
Here you can download the tutorial pfd file with all example Python sources.

For this tutorial I used this website (Japanese).

 

Update on “How to calculate intersections”

This little tutorial is an update on the Tutorial: “How to calculate intersections” posted on my blog August 17, 2012. It was a more complicated tutorial on “How to calculate intersections of 2 lines (splines) using Python and Cinema 4D”.

However, the part on how to check whether the intersection was on the line segment, was not fully correct. Here an update.

Here you can download the tutorial (PDF) and the c4d source file

Python dialog tutorial

This tutorial will explain how to create a ‘floating’ dialog using Python.

 

 

 

 

 

What you will learn:
–          Register the plugin
–          Define Tabs
–          Define, read and write a Link field using the AddCustomGui function
–          Define Separators
–          Define, read and write a Combo Box
–          Define and read File Input field using again the AddCustomGui function

Here you can download the zip with the tutorial (PDF), source and the plugin.

Everybody on the Plugin Cafe – Python Development, thanks for their help.

Posterize files

Here a script  (R13) + tutorial explaining the Python code behind it, to posterize files.
For example, this icon was ‘posterized’.

 

The script asks for an input file and some input variables.
Then, based on given input factor, the average pixel color is calculated, an object (Cube or Sphere) is created and a material with the calculated average color created and assigned.

 

 

 

 

 

 

Example: The file is 512×512 and the input factor is 32.
This means that the picture will be ‘divide / posterized’  in 512 / 32 = 16 parts.
Each part is sampled and the average color is calculated. For each part an new objects will be created with the calculated average color.
In total 16*16 = 512 objects will be created.

Here you can download the source and an tutorial explaining the use and the Python code behind it.

Tutorial: Calculate Voronoi using a brute method

This tutorial shows how to calculate (in Python) 2D Voronoi using a brute method. Voronoi is often used to scatter or explode objects.

Note: In mathematics, a Voronoi diagram is a special kind of decomposition of a metric space, determined by distances to a specified family of objects (subsets) in the space.

 

In this tutorial you will learn:
– Get all polygons of an object.
– Calculate distance between an object and a polygon
(between a Null object and a point of the polygon).
– Add polygon, based on distance, to a selection.

Here you can download the source used in the tutorial.

Note: This is only a 2D solution. I’m still investigation a 3D solution. Any help is welcome!