15
$\begingroup$

I'm after an adjustable pie chart. Think of a circular box of cheese triangles. Each triangle is a separate object from the others (and variable in the .pct of the circle, but together form a thick disk - like a hockey puck.

$\endgroup$
  • $\begingroup$ By variable/adjustable do you mean set some values in a script then run it to generate the pie chart? Or do you mean that the values are adjustable in real time after the pie chart has been generated? Big difference. $\endgroup$ – Todd McIntosh Jul 28 '15 at 17:16
  • $\begingroup$ a script would be terrific, but way beyond my capabilities. The .blend file would be a template for reuse, with new data for the .pcts. It's important that the "wedges" be separate objects. Tks. $\endgroup$ – NeverGiveUp Jul 28 '15 at 17:48
  • 1
    $\begingroup$ Related answer: blender.stackexchange.com/questions/7283/… $\endgroup$ – Paul Gonet Jul 28 '15 at 18:16
17
$\begingroup$

You can also do this with a curve by adding a bevel object and changing the Start/End values of the bevel:

enter image description here

  1. Shift+A> Curve> Circle.

  2. In edit mode of the new curve press Alt+C to 'Toggle Cyclic' so the curve doesn't join its ends together:

enter image description here

  1. Select all the curve points and change their handle type to 'Free' in the side toolbar (T) under 'Handles' and move the curve points back into a circular shape (but the circle will now have a gap).

  2. Extrude the last curve point with E and place it exactly on top of the other end of the curve (a bit more carefully than I have):

enter image description here

  1. Now add a new curve in object mode and flatten it so it is a straight line:

enter image description here

  1. In the curve properties for the curve that is a circle set the 'Bevel Object' to be the curve that is a straight line:

enter image description here

  1. You can now adjust the 'Start' or 'End' values (shown in the first gif) to adjust the 'completeness' of the circle.

  2. As one final step, you can give thickness to the curve by adding a 'Solidify' modifier and then an 'Edge split' modifier to correct the shading:

enter image description here

Duplicate this curve and adjust the 'Start' and 'End' values for each new segment of the pie.

$\endgroup$
  • $\begingroup$ 2nd step 3. How do I flatten the curve? $\endgroup$ – NeverGiveUp Jul 28 '15 at 20:26
  • $\begingroup$ It will depend on which axis the curve gets added on, but select both curve points and then press either S,X,0 or S,Y,0 or S,Z,0. See blender.stackexchange.com/questions/140/… $\endgroup$ – Ray Mairlot Jul 28 '15 at 20:40
  • $\begingroup$ so 1 "wedge" is done, now how do I add the next one so it fits in the pie? $\endgroup$ – NeverGiveUp Jul 28 '15 at 22:03
  • $\begingroup$ You should be able to duplicate the wedge with Shift+D, rotate it with R,Z, then alter the 'Start' value to resize it. $\endgroup$ – Ray Mairlot Jul 28 '15 at 22:38
  • $\begingroup$ Tedious, but works great. Learned a lot! There should be an add on that does this by filling in .pcts, thickness, etc.. $\endgroup$ – NeverGiveUp Jul 29 '15 at 22:58
13
$\begingroup$

One could use Sverchok - node based parametric geometry addon. (Full disclosure, I co-write this addon - but it is free and open-source)

enter image description here

All you then do is change the values in the List Input node..

enter image description here

And set the materials..

enter image description here

Here an alternative with some of the sliders labeled to help you out.

enter image description here


Pros and Cons to doing this:

Cons

  • You have to install Sverchok Add-on
  • Making it fully reusable requires a bit of coding or node noodling
  • Sverchok doesn't have a functioning List Running Sum operator, the code exists but we never committed it. Questions like this reinforce why the extra operator should be added (thanks!)
  • I've not written an example of how to dynamically pick n new colours when the amount of list items is updated.

Pros

  • You get to experiment with Sverchok, and accidents lead to learning and the add-on has many more uses.
  • You can easily develop parametric tools (node trees) that can be every bit as good as an addon, but with often less setup code.

Here's a version that does create new random colors for new list items, this might be handy during the construction phase to help you see the individual slices, simply disconnect the input to the node once you have enough slices

enter image description here

The script inside the "maker_material" node looks like this, and makes only one assumption; the base name of the object (here Alpha - a default name)

import random
import bpy

def sv_main(num_slices=0):
    dummy = []

    in_sockets = [
        ['s', 'num_slices', num_slices]
    ]

    prefix_name = "Alpha"

    if num_slices and (num_slices > 0):
        for s in range(num_slices):
            obj = bpy.data.objects.get(prefix_name + "_" + str(s))
            if obj:
                materials = obj.data.materials
                if None in materials[:] or len(materials) == 0:
                    print('has no colours! - adding!')

                    mat = bpy.data.materials.new('some_mat')
                    mat.use_nodes = True
                    nodes = mat.node_tree.nodes

                    obj.active_material = mat
                    diffuse = nodes.get("Diffuse BSDF")
                    diffuse.inputs['Color'].default_value = random.random(), random.random(), random.random(), 1.0
                else:
                    print(obj.data.materials[:])

    out_sockets = [
        ['s', 'dummy_out', dummy]
    ]

    return in_sockets, out_sockets
$\endgroup$
  • $\begingroup$ The proportion variable aspect (list input) of this is good. It would be great to have a dedicated pie chart add on, but this does not to answer my needs: no hole in center, individual objects for each portion, thickness variability. $\endgroup$ – NeverGiveUp Jul 29 '15 at 13:14
  • $\begingroup$ 1) they are separate Mesh Objects, 2) The hole in the middle is because I've translated the output of the Plane Node in the Y direction 3) thickness was never mentioned.. but I could make a quick version $\endgroup$ – zeffii Jul 29 '15 at 13:25
  • $\begingroup$ code/scripts, beyond my abilities at the moment. Not for me at this time, Tried to dl add-on w/o success, but many thanks for your efforts. $\endgroup$ – NeverGiveUp Jul 29 '15 at 17:53
  • $\begingroup$ That's OK, plenty of other good options here! $\endgroup$ – zeffii Jul 29 '15 at 18:06
10
$\begingroup$

Add a curve->Circle

enter image description here

Add a cube.

enter image description here

Edit the cube to something like this:

enter image description here

On the cube add an array modifier and a Curve modifier with the Bezeir Circle selected as the controling object.

enter image description here

By modifying the count on the array you can change how complete the pie is.

enter image description here

$\endgroup$
9
$\begingroup$

Here is a very simple, purely material based solution.

Plug the Object coordinates in to a Gradient Texture node.
Set the Gradient Texture to Radial.
Drop in a ColorRamp node between the Gradient and the shader node.
Set that color ramp to Constant and add color stops for each part of the pie chart.

Percent based pie charts are very easy because the color stops have a position field where you can type in the decimal equivalent.
cycles material nodes

Here is the result of the above nodes.
rendered result

$\endgroup$
  • $\begingroup$ this is brilliant :) i'll have a script for the gradient node soon $\endgroup$ – zeffii Aug 7 '15 at 15:45
  • $\begingroup$ gist.github.com/zeffii/a7d5c3b775024eb2d76b to autofill a named gradient node :) $\endgroup$ – zeffii Aug 7 '15 at 15:58
  • $\begingroup$ Great @zeffii! The only thing that's missing is an interface for adjusting and animating the values, but maybe that's too much for now... :) $\endgroup$ – p2or Aug 7 '15 at 16:17
  • $\begingroup$ yep could totally make it a Panel for the nodeview.. i'll make it :) $\endgroup$ – zeffii Aug 7 '15 at 17:25
  • 1
    $\begingroup$ while not animatable, does have the code to make the node group automatically gist.github.com/zeffii/174c1b348ce712e61a61 no time to go further $\endgroup$ – zeffii Aug 8 '15 at 10:45
1
$\begingroup$

I did it this way: https://youtu.be/Fd6xU8tUlWc

I created a vertical plane width a screw modifier set to Z Axis, then I animated the Angle or the Itertions...

Example Image

$\endgroup$
0
$\begingroup$

Use Array modifier with object angle offset.

Using a similar technique as in this answer

For example case,

  1. Add a default circle mesh to scene, choose "triangular fan" as fill type.
  2. Delete all but one segment, and extrude in z. Now have 1 wedge of pie. This is one thirtysecond of a whole circle, its wedge angle is 360 / 32 or 11.25 degrees.enter image description here

  3. Add an empty at same location as circle. Rotate this empty 11.25 degrees in z.

  4. Add an array modifier to the wedge, and choose object offset and the select the empty.

Can now animate the array modifier count to open close the wedge.

enter image description here

PS. this was originally an answer for this question seems a more pertinent for this question.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.