text:
Smooth Shade a Cone
Very simple question, but I cannot find a solution.
I added a Cone primitive to my scene, but I need it to be smoothly shaded so it looks perfectly round. My first instinct is to turn on smooth shading, like a lot of other people. I did this, but the bottom of the cone didn't look right so I turned on auto smooth.
The big problem is with the top vertex because now, no matter what I do, the smooth shading treats the cone as if it were flat producing a very unreal result. How can I smooth shade this cone? It would be best if the original geometry of the cone is minimally changed.
Other things I have tried:

Adjusting the smooth shading angle limit
Subdivision Surface
Making a Cylinder, but scaling the top to 0
Making a Cylinder, but scaling the top to a small number, like 0.1
Remesh Modifier

How many vertices does your cone have?

@moonboots does that matter?

I think I found a solution.

Add a cylinder
Scale top to 0
Add some edge loops (I used the cylinder because you can't add edge loops on a cone)
Merge the vertices by distance so you have only one top vertex
Edge slide the uppermost loop as close to the tip of the cone as possible
Turn on smooth shading
Turn on auto smooth
Select the bottom face of the cone and Edge Crease it to 1
Add a subdivision surface modifier

Prepare for a long answer. If you're not interested in the technical stuff scroll to the bottom for the solution.
Technical stuff
These are beautiful and healthy high-poly cones:

To duplicate the shading with low-poly geometry is mathematically impossible. You have to understand how normals work in order to smooth edges.
Normals are meant to be perpendicular to a surface. They are used to calculate the direction light bounces off them. A surface consists of tris and a tri has exactly 3 split normals at each vert. When light bounces off a tri the surface normal at impact is calculated as the average of the 3 normals based on distance.

You smooth out edges by having adjacent faces share their edge normals. On the left side the faces have their own normals, while on the right side the normals are shared. (The two cubes in edit mode let you see the normals in pink, the cubes in object mode above are the same and let you see the shading better)

If you move one vert (Note: vert/verts is common abbreviation for vertex/vertices) over to the other, one of the faces ends up getting squashed. The two visible faces are no longer adjacent, because you have a face inbetween which creates a "barrier" and you end up with a sharp edge.

This is exactly what happens when you create a Cone (in this example with only 4 sides). The squashed face acts as a barrier and you end up with a sharp edge at the top. (Click on picture to enlarge)

Logically you should remove the barrier by merging the 2 verts and removing the squashed face inbetween. However you cannot merge every pair of verts without merging all the verts at once. If you merge them all into one point you get a smooth tip:

You can merge them into groups of 2 respectively four as in this example but you will get sharp edges around the cone.

How to do it:
So now that you understand that it is not possible and why, lets try and use the most efficient process to simulate a high poly cone, using minimum geometry. You have to understand that it is a tradeoff between:

Good Pointy tip & Bad sharp sides
Bad blunt tip & Good smooth sides

Create a basic low poly cone and create an edge loop by subdividing the sides. The higher you move the loop the better the tip and the worse the sides. The lower it is the blunter the tip and the smoother the sides.

The most efficient solution is to split the cone by creating an edge loop in the middle and keep splitting the top part until you are satisfied with the result.


text:
How do I achieve this "hexagonal armor" animation effect in Blender?
I know this might be very specific, but I thought that maybe an expert here could help me out a bit here.
How, or what is the general workflow to replicate this "hexagonal armor" effect on surfaces in Blender?

If you mean the small shapes, there is a curve with the shape included in blender, then you just need an array to create copy...Or are you referering to the animation? You need to add mo re details

This can also probably be achieved with geometry nodes as well, similar to this https://youtu.be/_bdcQXMQ4e0?t=33

If this is from a game, this is almost certainly done via shaders (geometry/tesselation), since that allows the poly budget to be way lower.

Not sure how helpful this will be, but reading your question instantly made me remember this video I watched once. It is about Maya though. https://www.youtube.com/watch?v=0kjXzrGUgYQ

Enable addon Extra Objects
Add Object Shift+A > Mesh > Extras > Honeycomb in desired amount of cels setuped in properties panel (left-bottom corner of 3Dview) with max Edge Width that fills cells with central vertex
Duplicate Shift+D and Separate Ctrl+P one cell, add Solidify modifier
Parent to Honeycomb Ctrl+P
for Honeycomb object enable under Object Properties > Instances > from Vertices
Add Wave modifier to Honeycomb object

Or ... It can be done with Animation nodes in a more advanced way ... or in combination with Geometry nodes ... I like the old-school way :)

I guess there has to be a shader approach, although I think @vklidu's answer is maybe more practical? It's always tricky trying to reproduce an effect that someone else has more than likely reached by random walk :)
This uses the hex-grid cluster discussed at the bottom of this answer. It yields a hexagonal tiling of the UV space, with a (-0.5 to 0.5) UV-per-tile:'Cell UV', and a '2D Index', which is the original UV's coordinate at the center of each hex.
In addition, it borrows this group, from earlier in the answer, 'Dist.Hex':

..which, given the Hex UV, gives us the distance from the edge of the hex.
These can be used to bump / displace a surface:

In this version, a ramp of the 'Dist.Hex' is used to mask the overall displacement, set by the 'Per Hex Displacement' cluster.
..which gets us this far..

Looking at the original, I think, unlike here,  you would probably have to sync. the overall  displacement of the surface with the displacement-per-tile: (using the same texture for both). The overall displacement could be done in the geometry, per-tile in the shader.
Also there seems to be a lot of other jiggery-pokery going on in the reference. Depth of field? Looking at everything through a reflective, distorting, lens-like object? Or doing that in post?

Aaah, I knew there must be a simpler solution than mine! Though I searched this site for hexagons and couldn't find anything - proves the terribleness of titles like "How To Do UV Indexing Like This?"

@Markus Don't dis yourself! Personally,  I think that's a great result!. (Phew.. I snuck in just in time :) ) Yes.  We should go back and edit that other title. I have trouble finding that post, myself.

A little bit ashamed of this answer now that I've seen the simpler setup, but maybe someone will find it useful...
Shader solution
Strategy: snap the coordinates to the nearest hex and then apply the usual magic (some kind of animated gradient) to color / normal / displacement
Know your enemy
A regular hexagon is made of 6 equilateral triangles, which means the side is also the radius of the circumcircle. The diameter of the circumcircle is therefore 2s, and so is "the largest width" of the hexagon. The incircle's radius is also the height of the triangle or cos(30°)*R. You can find more formulas in the Hall of Hexagons.

The hexagonal tiling is also surprisingly simple, it's really brick tiling, but the bricks are deformed (the point is, the spacing is the same as in trivial brick tiling):

The algorithm
Treat the hexes as bricks. Snap to the nearest row of bricks. The height of the row of bricks is 1.5s (because that's the side s and half of the difference between that and the largest width). Now you can see on the picture below, that you actually may be a point belonging to a higher row of hexes - for example if you are in a triangle marked violet:

So you want to define two lines, the white line (vvvvv) on top of the image and the green line (^^^^^) on bottom of it, and calculate if you're below or a above the line. You choose the pattern (up-down-up... or down-up-down...) based on your "brick-row" being odd or even. Then you correct your actual row as the real hexagon row, and then you can snap to the nearest hexagon by simply using the smallest width (marked with a yellow arrow) as an increment.
Custom nodes
Hex dimensions:

Row number:

vvvv pattern:

Setup

The usual magic
You can wrap whole "setup" in a single custom node, and then just modify your coordinates with it so they are snapped to the nearest hex:

Displacement here needs this setting:

... and really nice presentation, too!

woooooooooooooow

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
How can I select the lowest left point in geometry nodes?
I have some polygons in the same geometry that are separated.

How can I get the point information of the lowest left corner of each face using geometry nodes?
I'm using Blender 3.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
How can I replace edges by gaps?
I have a solid door. I want to divide it along the current edges:

Here's a non-destructive proposal using Modifiers:

Add an Edge Split modifier set to angle 0
Add a Smooth modifier limited to the width axis
Add a Solidify modifier
Add a Bevel modifier

.. this makes my answer look so vulgar :D

@RobinBetts But still valuable - if someone doesn't need a non-destructive solution, yours is quick and easy.

A common strategy for creating adjacent planks, bricks, tiles, etc., is to divide regions before giving them thickness.
While the door is still a plane:

V Rip the edges between planks
Assign a Solidify modifier
Assign a Bevel modifier, by angle

@Chris :D.. now the Mirror modifier should come more naturally.. (rip, 'L' select linked under hover, delete faces on one side)

@RobinBetts Only that for the original design of the post you can't use the Mirror modifier that easy  ;)

The answers of @DredWolf and @RobinBetts are both good solutions if you're creating from a plane, these answers are how you should do it. Nevertheless, here's something additional to that solution. If you already have an extruded object like the one in your screenshot and you maybe want small grooves between those parts to separate them, you can do the following:

Select the edges where you want to create grooves.
Use Ctrl+B to bevel those edges so that each edge becomes a doubled edge.
Keep the selection of the new face loops, hit Alt+E > Extrude Faces Along Normals.
Scale them inwards to your liking (or outwards for ridges).

If you want to make real gaps so that there is space between them, you can use this method. It uses LoopTools (Preferences > Add-ons > Mesh: LoopTools).

Select edges as before.
Bevel as before.
Right-click on the object for the context menu. Choose LoopTools > Bridge. In this case it only deletes the faces, of course you can do it without LoopTools. Just hit X > Delete > Faces. The advantage of LoopTools is, it keeps the edges selected.
With the edges still selected after Bridge (or select them after deleting faces), now hit F to fill the open sides.
You've separated the door with gaps between the parts.

That's a really cunning use of the 'Remove Internal Faces' feature of LT > Bridge  which I've previously never bothered with. Now I'm going to have to resist my muscle-memory to work it in :)


text:
What am I doing wrong with shading and modeling?
How would you create the vines of the wood, because I'm not sure how to approach that before getting to sculpting, and what is the problem with the shading?
I still don't understand how to avoid shading problems like that.

https://blender.stackexchange.com/a/122563/110840 - i would lean towards curves for decorative vines or wire

This happens because you have a large ngon that Blender tries to shade smooth with the adjacent faces. Ngons, under the hood and like any other faces, are made of tris, but contrary to quads the tris organization can be messy, therefore the bad shading. You need to convert your ngon to a series of quads, see the difference:

On your topology it should give something like that:

There are some tricks though, like insetting the ngon (which will make it coplanar to its new adjacent faces), or using the Weighted Normal modifier:

thank you for the answer, I removed the ngon to see what happens but I still have all the shading problems, maybe I didn't understand what you meant?
https://imgur.com/a/qBVCrpI

I meant create quads instead of ngon, as you see on my picture, on the left there's a ngon, on the right I've made 2 quads instead

thank you so much :D

moonboots' answer is correct. Adding to that: For the vines, you can just use a spline all around the wood and add geometry to that spline so it will be like a cylinder all around.
Don't try to always add geometry to the same object if you don't know how to do that. Just add a new object and work with that one. Then you can see if it's useful to merge both in the same object or not.
Video game assets most of the time are not made of one primitive. It's a sum of various primitives.


text:
How can I animate a CNC cable track?
I tried to use the Curve modifier ...

... but the motion isn't the same as real one.

Hello ! It might be interesting to show us what it should look like for reference

Hi..i already added the real one

switch the curve direction, maybe. and/or move the curve instead of the object

nah, not working. one end should be fixed while the other moves. it should move like this : https://i.ibb.co/qJH2j2Q/1a.jpg

believe me it works https://i.sstatic.net/BtS2T.gif

wow dude! how you do that?

Add the curve modifier as you probably did and move the curve.
If it does not work as expected, invert the curve direction (in edit mode for the curve, use the menu "segments/switch direction").

thank you so much bro!!!! here as you said https://im7.ezgif.com/tmp/ezgif-7-91c20a329e29.gif

This may be easy solution for you, use curve as you did with your chain and use hook on the curve... set it to object that will be your CNC head and that 1 point of the curve next to the head will be hooked to it... Result is this:

By moving the cube you can easily control whole movement, it has some limitations of course, but you can solve them as well
Here is the file for you:

Check it if you understand and see if it works, if you need to limit other movement, you should use another objects to control that curve

Hi MikoCG! nice one.. i will take a look at it right now. thanks for the blend file

@MikoCG ... by moving Cube object you don't get desired movement ... it moves also the end of cable.


text:
How do I double bend an object?
I need to model this object. How can I do it?
I imagine that I should use the bend modifier... It seems that two bending steps are required.

If you start from scratch you can create a plane, stretch on X, tilt its edge with the Shear tool (AltCtrlShiftSX-1):

Extrude up:

Extrude on Y, flatten the tip with SY0:

Bevel the edges:

Bevel the vertices to round the tips if necessary:

Extrude faces along normals:

If you start with a flat surface and can solidify it later, you can do with a simple geonodes setup:

It's similar to rotating $180°$ around $(-1, -1, 0)$ axis.


text:
Realistic rigid body falling physics
In real life, some parts of an object are heavier than others, causing the object to rotate while falling or move slightly. But in Blender, it just falls perpendicularly till it reaches a surface. Is there a way to make an object fall in a more realistic way in Blender?

first of all you should lower your expectations. Blender is a graphic (!) software, not a real world simulation software. But...as usual, you can fake it. With forces. By interacting with other objects. By manual animation...and so on. And don't forget: Blender works in a "perfect" environment. There is no wind, no friction when objects are falling. So i am not totally sure if objects would rotate "automatically" in such an environment. At least a perfect cube falling just down wouldn't ;) Maybe you should improve your question and tell us what exactly you are trying to achieve...

You could create the rotation with an invisible object, like this:

i can't see the invisible object in your animation... :D

Maybe one day you'll see it young padawan

@Chris wouldn't quite be invisible if you could see it now, would it? ;)

@MarkusvonBroady: depends on your vision capacities ♂

Lol. thanks guys that's a good idea

In real life, falling objects don't rotate much. It is a common misconception that heavier are more affected by gravity. But really, all objects (or all parts of objects, in this case) experience the exact same gravitational force no matter how much they weigh.
Occasionally, for objects that are light enough air resistance matters a lot, or fall long enough small changes have a large effect, or fall so fast air resistance is the main limiter of their speed, air resistance may cause some rotation. This is because air resistance disproportionally affects light objects and objects with greater area or speed.
In these cases, blender would be missing some rotation that occurs in real life, since blender doesn't simulate air resistance.
But these are unusual scenarios. Once you look at more normal objects, like a pen or a ball, air resistance becomes negligible and no rotation occurs.
There may sometimes be a spin on falling objects if you drop them imperfectly by hand, and accidentally spin them as you are dropping them. And objects that fall off a ledge rotate because the side still in contact with the ledge is pushed up by it. Most of the time, if you see an object spinning as it falls, one of those two reasons is why.
If you want to simulate that sort of effect, as if your object was dropped by hand or rolled off something, you can add it in manually, as others have said.

Galileo used balls for a reason, which is a strawman in the context of OP presenting a cube  A heavy object will rotate rapidly to minimize drag, as well as buoyancy will cause it to try to lower its center of mass (a box will fall with empty part pointing up even if contents aren't lose to fall within the box). While for some objects those effects are more prominent than for others, they happen always, not occasionally. And even though those effects can be very subtle, the simplest rigid body setup immediately breaks immersion for completely missing them.

Typically adding some noise is enough to get rid of the "uncanny valley"-like feeling, even though it doesn't simulate those phenomena, just like adding noise to a human movement masks well the artificial robotic animation lacking inefficiency of muscle twitching.


text:
How can I stretch a soft body like a real jelly?
I want to stretch a soft body like a real jelly.
I made cubes into the jelly and hooked to empty axes.
When I moved the axes to a different direction, the soft body stretched like this:
Picture:

But I want to stretch the cube like this:
Picture:

Is this possible in Blender?

https://blender.stackexchange.com/questions/124595/how-to-make-an-open-object-behave-like-rubber-when-penetrated-by-another

For such soft body distortion on stretching you’d need to add internal structure to your mesh. With real-world materials it’s the pulling of those internal bonds that pulls together the opposite outer surfaces.

You could try it with Cloth simulation: Hook each extremity to 2 empties (or bones), make each extremity part of the same group that you call Pin, give your object a Cloth simulation / Rubber and choose the group called Pin as Shape > Pin Group. Make sure that the Cloth modifier is under the 2 Hook modifiers. It probably needs some tweakings (you could also cheat a bit with some shape keys):

File:

could you upload that blender file? I will follow what you did ;)

I've edited my answer to share the file. I've used the Rubber settings and tweaked the Stiffness values a bit


text:
Animate triangles – rotate "roll" along all their sides
I'm animating a lot of triangles. Every triangle will roll along its edge over and over again.
I have tried animating the pivot point with an empty but that method is getting too complex with many triangles.
Is there any easier way to do it?

The Animation Replicator with Offset addon might help.

You can use animation nodes. Here you have a simple setpup on how to animate polys changing its pivot point.

please include a blend file at least, if this is intended to make someone interested in animation nodes you can give them something that will run and show what you mean. screenshots are such a pain to try to recreate in a nodeview (especially if someone hasn't used the add-on before).

If you don't provide more info, this is practically a non-answer. (even if animation nodes is a very good solution for this)

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
execution time for a program in python blender
I have a little problem :) I need to do a program in python , blender , in wich i must built a structure of many cubes. i am a absolutely beginner , and i have no experience in python. I realize a functional program in python and i succeded to built the structure , but i don't know how to make a mini-movie in which i would see how really my structure construct itself. this is the program i have made :
import bpy

for i in range(6):
    for x in range(-i,i+1):
        for y in range(-i,i+1):
            for z in range(-i,i+1):
                if(x<0):
                    xx=-x
                else:
                    xx=x

                if(y<0):
                    yy=-y
                else:
                    yy=y

                if(z<0):
                    zz=-z
                else:
                    zz=z

                if(xx+yy+zz==i):
                    bpy.ops.mesh.primitive_cube_add(radius=0.5,location=(x,y,z))

That is all.. I have been looking for a tutorial for more than a mouth , and i can't see one who would be useful for my program . Help meeee!!!

you want to render a frame for each new block being added?

yes , but i talk about more than 400 cubes

i was thinking about puting sleeptime after every iteration , but my program waited and show me nothing until the program is finished

related, possible duplicate: http://blender.stackexchange.com/questions/28673/update-viewport-while-running-script

sleep() wont work, but if you want to see this code running in 3dview in realtime then the above link shows a few approaches. it's not exactly clear what you want to produce as an outcome. Please elaborate.

and i should make

def modal(self, context, event):
if event.type in {'RIGHTMOUSE', 'ESC'} or self.limits > 30:
self.limits = 0
self.cancel(context)
return {'FINISHED'}

for every for i have ?

Starting from a cube i place an identical cube on each of its sides to obtain a crystal . Then i place cubes on each free sides of the crystal to obtain a bigger crystal , and so on . The rule is that cubes coordonate taken with positive sign , need to be equal with the number of iteration. I will show you an example : at iteration 1 i will have 6 cubes with coordonates :(0.0.1)(0.0.-1)(0.1.0)(0.-1.0)(1.0.0)(-1.0.0) . I want  exactly the model with sphere , but i don't know how to manipulate my functions for

i succeded !!!!!! Thanks you a lot @@@@ Five stars from me :) you're the best !!!!!

import bpy
from itertools import product

mesh = bpy.data.meshes['Cube']
objects_scene = bpy.context.scene.objects
objects_data  = bpy.data.objects
actions_data  = bpy.data.actions

def create_cube(name, location):
    obj = objects_data.new(name, mesh)
    objects_scene.link(obj)
    obj.location = location
    return obj

def create_animation(obj, time):
    obj.animation_data_create()
    obj.animation_data.action = action = actions_data.new("Action")
    fcurves = [action.fcurves.new(data_path) for data_path in ("hide", "hide_render")]
    for fcu in fcurves:
        fcu.keyframe_points.insert(   0, 1, {'FAST'}).interpolation = "CONSTANT"
        fcu.keyframe_points.insert(time, 0, {'FAST'}).interpolation = "CONSTANT"
        fcu.extrapolation = "CONSTANT"

n = 6
time = 1
for i in range(n):
    for indices in product(range(-i, i+1), repeat=3):
        if sum(abs(j) for j in indices) == i:
            cube = create_cube("Cube", indices)
            create_animation(cube, time)
            time += 1

The result rendered using the OpenGL Viewport Renderer:

Note
I scaled down the default cube manually and deleted it afterwards before i ran the script.

you are a genius ! Can i move my camera around the construction , while it is building?

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Create UI slider for each member in a custom vertex layer (floats)
I have a layer of vertex properties that I would like to expose through a Blender UI panel, so I can edit them. Through examples I learnt that you can expose the property and have it displayed and editable using props in the layout.
For example to display the cursor I could do
layout.column().prop(view, "cursor_location", text="Location")

But I can't do the same at all for selected list of vertices.
I have the following code.
class path_mesh_viewer_panel(bpy.types.Panel):
    bl_label = "Path Node"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "scene"

    @classmethod
    def poll(cls, context):
        return (context.active_object is not None and
                context.mode=="EDIT_MESH")

    def draw(self, context):
        layout = self.layout
        ob = bpy.context.active_object
        me = ob.data
        bm = bmesh.from_edit_mesh(me)

        node_width_key = bm.verts.layers.float['node_width']

        bm.verts.ensure_lookup_table()
        bm.edges.ensure_lookup_table()

        if bm.select_mode != {'VERT'}:
            layout.label("Vertex select only", icon = 'INFO')
            return

        selected = [vert.index for vert in bm.verts if vert.select]
        if not selected:
            layout.label("Nothing selected", icon = 'INFO')
        else:
            for i in selected:
                # I would like to have UI element here so I can edit the vertex layers
                layout.column().prop(bm.verts[i][node_width_key], "", text =     'INFO')

The last line immediately complains and gives out the following error in the System Console.
Traceback (most recent call last):
File "E:\paths-visualizer\blenderview.py", line 94, in draw
layout.column().prop(bm.verts[i][node_area_id], "", text = 'INFO')
TypeError: UILayout.prop(): error with argument 1, "data" -  Function.data expected a AnyType type, not int

location: <unknown location>:-1

Why am I getting the error? I have declared the vertex layer in code that creates the mesh, I can access it fine but not in the UI. Is there any way to do it?

I think you'd better use a CollectionProperty, and then display a UILayout.prop_enum in your panel. I believe Layout props() first argument must be a bpy.types.prop name you declared before.

@zeffii No, every new vertex would have its own layer property to be editable in the panel

Layout.prop() supports bpy.props and ID properties only. You can't use it for custom data layers such as bm.verts.layers of the Bmesh module.
You would have to create a (temporary) set of properties for (selected) bm.verts in order to display their custom data. Because there are no proper callbacks to detect changes to the mesh, the only way I see is to use brute force: re-fill a CollectionProperty on every panel redraw with as many elements as there are (selected) vertices. These elements can be displayed without problems, but it's highly inefficient.
It would be much better to have a button the user needs to press to update the template_list() with selected vertices, so that it doesn't happen all the time (i.e. 20x per second when moving the mouse over the panel).
import bpy
import bmesh

class MeshVertLayerList(bpy.types.UIList):
    def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
        if self.layout_type in {'DEFAULT', 'COMPACT'}:
            layout.label(item.name)
            layout.prop(item, "value", text="", emboss=False)

        elif self.layout_type in {'GRID'}:
            layout.alignment = 'CENTER'
            layout.label(text="")

class MESH_OT_vert_layer_add(bpy.types.Operator):
    """Tooltip"""
    bl_label = "Add Vertex Layer"
    bl_idname = "mesh.vert_layer_add"

    @classmethod
    def poll(cls, context):
        return (context.object is not None and
                context.object.type == 'MESH' and
                context.object.mode == 'EDIT')

    def execute(self, context):
        bm = bmesh.from_edit_mesh(context.object.data)
        try:
            bm.verts.layers.float['test']
        except KeyError:
            bm.verts.layers.float.new('test')
        else:
            return {'CANCELLED'}

        return {'FINISHED'}

class HelloWorldPanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Hello World Panel"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "data"

    @classmethod
    def poll(cls, context):
        return (context.object is not None and
                context.object.type == 'MESH' and
                context.object.mode == 'EDIT')

    def draw(self, context):
        layout = self.layout
        wm = context.window_manager

        ob = context.object
        me = ob.data
        bm = bmesh.from_edit_mesh(me)

        try:
            l = bm.verts.layers.float['test']
        except KeyError:
            layout.label("No custom data layer 'test'.")
            layout.operator("mesh.vert_layer_add")
            return

        wm.mesh_vert_layer.verts.clear()
        for v in bm.verts:
            if v.select:
                item = wm.mesh_vert_layer.verts.add()
                item.name = "Vertex #%i" % v.index
                item.index = v.index
                item.value = v[l]

        layout.template_list("MeshVertLayerList", "", wm.mesh_vert_layer, "verts", wm.mesh_vert_layer, "index")

def upd(self, context):
    try:
        me = context.object.data
        bm = bmesh.from_edit_mesh(me)
        bm.verts[self.index][bm.verts.layers.float['test']] = self.value
        bmesh.update_edit_mesh(me, tessface=False, destructive=False)
    except:
        pass

class MeshVertLayerVert(bpy.types.PropertyGroup):
    value = bpy.props.FloatProperty(update=upd)
    index = bpy.props.IntProperty()

class MeshVertLayer(bpy.types.PropertyGroup):
    index = bpy.props.IntProperty()
    verts = bpy.props.CollectionProperty(type=MeshVertLayerVert)

def register():
    bpy.utils.register_module(__name__)
    bpy.types.WindowManager.mesh_vert_layer = bpy.props.PointerProperty(type=MeshVertLayer)

def unregister():
    bpy.utils.unregister_module(__name__)
    del bpy.types.WindowManager.mesh_vert_layer

if __name__ == "__main__":
    register()

As a side note: custom data "propagates" on mesh operations such as extrude.  There's a patch in the making to disable it: https://developer.blender.org/T42865
edit: It's possible to bind an update operator to SELECTMOUSE RELEASE to update the CollectionProperty after a selection change. It will work for right-clicks only however. I'm not sure if it's possible to do the same for modal selection operators such as lasso.
import bpy
import bmesh

class MeshVertLayerList(bpy.types.UIList):
    def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
        if self.layout_type in {'DEFAULT', 'COMPACT'}:
            layout.label(item.name)
            layout.prop(item, "value", text="", emboss=False)

        elif self.layout_type in {'GRID'}:
            layout.alignment = 'CENTER'
            layout.label(text="")

class MESH_OT_vert_prop_update(bpy.types.Operator):
    """Tooltip"""
    bl_label = "Vertex Properties Update"
    bl_idname = "mesh.vert_prop_update"
    bl_options = {'INTERNAL'}

    @classmethod
    def poll(cls, context):
        return (context.object is not None and
                context.object.type == 'MESH' and
                context.object.mode == 'EDIT')

    def execute(self, context):
        ob = context.object
        me = ob.data
        wm = context.window_manager
        bm = bmesh.from_edit_mesh(me)

        try:
            l = bm.verts.layers.float['test']
        except KeyError:
            return {'CANCELLED'}

        wm.mesh_vert_layer.verts.clear()
        for v in bm.verts:
            if v.select:
                item = wm.mesh_vert_layer.verts.add()
                item.name = "Vertex #%i" % v.index
                item.index = v.index
                item.value = v[l]
        return {'FINISHED'}

class MESH_OT_vert_layer_add(bpy.types.Operator):
    """Tooltip"""
    bl_label = "Add Vertex Layer"
    bl_idname = "mesh.vert_layer_add"

    @classmethod
    def poll(cls, context):
        return (context.object is not None and
                context.object.type == 'MESH' and
                context.object.mode == 'EDIT')

    def execute(self, context):
        bm = bmesh.from_edit_mesh(context.object.data)
        try:
            bm.verts.layers.float['test']
        except KeyError:
            bm.verts.layers.float.new('test')
        else:
            return {'CANCELLED'}

        return {'FINISHED'}

class HelloWorldPanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Hello World Panel"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "data"

    @classmethod
    def poll(cls, context):
        return (context.object is not None and
                context.object.type == 'MESH' and
                context.object.mode == 'EDIT')

    def draw(self, context):
        layout = self.layout
        wm = context.window_manager
        layout.template_list("MeshVertLayerList", "", wm.mesh_vert_layer, "verts", wm.mesh_vert_layer, "index")

def upd(self, context):
    try:
        me = context.object.data
        bm = bmesh.from_edit_mesh(me)
        bm.verts[self.index][bm.verts.layers.float['test']] = self.value
        bmesh.update_edit_mesh(me, tessface=False, destructive=False)
    except:
        pass

class MeshVertLayerVert(bpy.types.PropertyGroup):
    value = bpy.props.FloatProperty(update=upd)
    index = bpy.props.IntProperty()

class MeshVertLayer(bpy.types.PropertyGroup):
    index = bpy.props.IntProperty()
    verts = bpy.props.CollectionProperty(type=MeshVertLayerVert)

addon_keymaps = []

def register():
    bpy.utils.register_module(__name__)
    bpy.types.WindowManager.mesh_vert_layer = bpy.props.PointerProperty(type=MeshVertLayer)

    wm = bpy.context.window_manager
    km = wm.keyconfigs.addon.keymaps.new(name='Mesh', space_type='EMPTY')

    kmi = km.keymap_items.new(MESH_OT_vert_prop_update.bl_idname, 'SELECTMOUSE', 'RELEASE', any=True)

    addon_keymaps.append((km, kmi))

def unregister():
    bpy.utils.unregister_module(__name__)
    del bpy.types.WindowManager.mesh_vert_layer

    for km, kmi in addon_keymaps:
        km.keymap_items.remove(kmi)
    addon_keymaps.clear()

if __name__ == "__main__":
    register()

Thanks very much. This is almost exactly what I needed. I tested this, However, it easily slows to a crawl when selecting large amount of vertices.
Isn't it possible to hook this on every vertex select operation or mouse click event instead?
I don't really mind the data "propagation" on mesh operations.

You can actually intercept the select event (on release) and run an update operator to refill the collection. You would need to do this for other operators such as Select All (A) as well. I have a feeling that this will not be possible for modal selection operators such as lasso or box select however. Mesh selection changes in general can not be determined, as I already said. Your best option is still a button to manually update the collection property (see my updated answer, you would basically remove the keymap stuff and add the update operator to the panel).

I am marking this as answer, I hope blender-dev community can do something about this.
I am choosing to go with your first answer, however I am restricting the collection list only up to certain elements to keep under performance.
Thanks again!!!


text:
Deselect Objects by Type with Python
I have a mesh, and it has children. One of it's children is an Empty. I know there is a way to select an object by type using Python (and there's a button for it too) and it's this:
bpy.ops.object.select_by_type(type='EMPTY')
I was wondering if there was a way to deselect an object by type. Basically, I want to select the children of the mesh, then deselect the empty.
Thanks!

How about select inverse, select by type, select inverse?

That won't work, because I have other models in the scene. I just want the children of the current mesh without selecting the parent. I'll try to use one of the answers below.

I would suggest not to use bpy.ops and instead access the selection directly.
# assume you the active object is the parent
for obj in bpy.context.object.children:
    if obj.type != 'EMPTY':
        obj.select = True

This is a little more clever, you can do it recursively (to select children's children).
def select_children_recursive(obj_parent):
    for obj in obj_parent.children:
        select_children_recursive(obj)
        if obj.type != 'EMPTY':
            obj.select = True
# call the function
select_children_recursive(bpy.context.object)

Similar to above but caller can define types not to select
def select_children_recursive(obj_parent, type_mask):
    for obj in obj_parent.children:
        select_children_recursive(obj)
        if obj.type not in type_mask:
            obj.select = True
# call the function
select_children_recursive(bpy.context.object, {'EMPTY', 'LAMP'})

The first code box did the trick!

Well, I am still having issues. It won't allow me to use bpy.context in my importer script. Any ideas?

Please elaborate on "It won't allow me"

Sorry, should have been more specific. :P I get an error that says "Context is incorrect". I've searched around, but no luck...

@rioforce, Id need to see a link to full script and full stack trace. but this is probably another question.

For your use case, something like this will work
import bpy

# go through the children of the parent object
for child in bpy.data.objects["Cube"].children:
    # if the child is not an empty, select it
    if child.type != 'EMPTY':
        child.select = True


text:
Check if a node exists using Python
Is it possible to check to see if a certain node exists on a material from within Python, for example a diffuse node? I am using Cycles Material Nodes, not Blender Internal or Post-Processing.

Can you be more specific, do you know the name of the node? is diffuse a name or a type of node?

You can use the bpy_prop_collection.get method which acts like pythons dict.get.
import bpy

mat = bpy.data.materials["MyMaterial"]
if mat.use_nodes:
    ntree = mat.node_tree
    node = ntree.nodes.get("Diffuse BSDF", None)
    if node is not None:
        print("We Found:", node)

This is similar to using:
node = ntree.nodes["Diffuse BSDF"]

However if the node isn't found you'll get an exception.

You can iterate through all the nodes in the node tree and check their properties.
For example, to find if a material node tree contains any diffuse shaders, you could do this:
import bpy

mat = bpy.data.materials['MyMaterial']
# Test if 'Use Nodes' is enabled:
if mat.use_nodes == True:
    nodes = mat.node_tree.nodes
    # Iterate through all the nodes in the node tree and test each one to see if it's a diffuse shader:
    for node in nodes:
        if node.bl_idname == 'ShaderNodeBsdfDiffuse':
            # Do stuff
        else:
            # Do other stuff

You can test any node property (e.g. label, location, name, etc.), to see a full list check the API reference.

I think this can be simplified to: if 'ShaderNodeBsdfDiffuse' in mat.node_tree.nodes:, No need to check every bl_idname.

@ideasman42 I couldn't get that to work.. Maybe that only works for the name attribute?

For example, check if node exists in material nodes by name:
if 'Material Output' in [node.name for node in bpy.data.materials['your_material_name'].node_tree.nodes]:
    print('Yes!')


text:
Cutting a circular hole in a hollow cylinder without distorting the cylinder
Whenever I try to cut out a circular hole in either a cylinder or sphere the polygons around the circular hole always have distorted normals after smoothing. Is there anyway to fix this. I've tried using the remesh modifier but wind up with some pretty ugly results.

Related https://blender.stackexchange.com/questions/5856/cutting-a-circular-hole-in-a-hollow-cylinder-without-distorting https://blender.stackexchange.com/questions/28103/creating-a-truck-exhaust-mesh/ https://blender.stackexchange.com/questions/226729/torus-pipe-joint-3d-printing https://blender.stackexchange.com/questions/51233/perforated-plate/ https://blender.stackexchange.com/questions/65395/repetitive-carving-holes-around-sphere https://blender.stackexchange.com/questions/58811/grid-similar-to-a-manhole-cover https://blender.stackexchange.com/questions/30996/is-there-an-easy-way-to-

you could use the Knife projection (in front mode of the circle )

select your cylinder and your circle  go into edit mode of your cylinder
and click while you are in Edit mode  in the T-panel on Knife Project

For more detail on how to use the Knife Project tool, see this question: How would you cut a shape out of an object using another object.

Enable LoopTools via menu Edit → Preferences → Add-ons → LoopTools:

In Edit Mode, press 3 to switch to Face Select mode and select a square area of faces where you want the circle to be. Click RMB > LoopTools > Circle. Make sure you uncheck Flatten in the Adjust Last Operation panel that appears in the lower left corner to avoid distortions on the curvature of the cylinder. I recommended to inset with i and to add edge loops.

I think not the cutting but the smoothing is the problem. So perhaps you need a way to cut the hole so you don't need to.
This is what I get when I use the Boolean modifier and apply it:

you need another circular edge loop on the surface of the cylinder just outside the hole(like the ones used to bevel a subsarfed edge), if you used the knife project tool , you can try and redo the operation with the circle slightly scaled up.

Could you maybe add a screenshot of what you mean?


text:
Why are my textures pink?
Basically, I applied my textures by taking each individual object, unwrapping it in the uv editor, then opening up an image in the uv editor and it would apply the texture in the 3D editor. However, when I render my project none of the textures appear and everything looks odd. I don't know how to set up the images properly with the bee.
For example, here's the uv layout image for the bee's Cube.001:

How do I get that applied properly to the Cube.001 in my project?
Here is the file for reference
Everything appears purple if the images aren't there and I don't know how to fix that either.

Pink means the image for the texture is missing. Make sure the image queenBee1.png is where blender thinks it is (which is in a directory called queenbee next to the .blend).
Unfortunately the textures are not included in the .blend by default (you must pack them), so if there are problems beyond this I can't tell what they are.
To pack all external textures, press Pack into .blend in Info > Header > File > External data.
I noticed that you changed the info panel (at the top of the window be default) into an image editor. You can change it back by clicking on the icon on the left and selecting Info:

There is also a operator in the External data submenu called Report missing files which will help you find what files are missing (if any).

If you have the image location right but it's still saying can't load image in Textures > Image and not appearing, some other common issues are:

If the location was set incorrectly but has since been corrected, try reloading it by pressing the arrows icon:

Make sure the texture is enabled:

Make sure the texture is allowed to influence the color of the material in Textures > Influence:

The reason everything looks odd is because the body mesh is duplicated, resulting in overlapping faces and z-fighting. If you select what appears to be the main body and press G to move it you'll see that there are actually two:

To fix it, just delete one of them. Note that one of the duplicates does not have UV selected for the mapping coordinates, so if you delete the other one make sure to set the coordinates to UV in Textures > Mapping:

Wonderful, that fixed all the odd looking stuff. My last question is, how exactly do I go about properly adding the textures? I've noticed if I press F12 the textures don't actually render. Thanks again!


text:
Align text with a curve
Simple file with one circle and one text object.
When I try to associate the text with the circle under F button there is no circle on the list.

Is this a bug?
Blender file:
http://www.pasteall.org/blend/31793
Thanks for any ideas.

Nope, it has to be a Curve object. BezierCircle works, Mesh does not.

It has to be a Curve object. BezierCircle e.g. works, while a mesh circle does not. If you add a BezierCircle:

It will show up and work as intended:


text:
How to create a circle with the Array Modifier
I was trying to create the same as in this tutorial:
https://www.youtube.com/watch?v=whjFb0xFoLk
But when I do exact the same my objects keep regrowing. So each next object will be even bigger then the one before.
Can someone please tell me what I did wrong here?

I don't think it's a duplicate. The user ask for a specific properites that make bigger the objects. If you refer to the title it's a duplicate but the question itself is different!

You have probably scaled your empty (the empty is the object that you use as offset object in the tutorial).
For correcting your error you can select your empty and then press alt+s for reseting the scale of your object.


text:
Mirror modifier not showing other half of mesh
I always have the same problem when I try to use my mirror modifier: nothing happens. It's very frustrating, and simply can't find how to fix this. Any ideas?

This is because you set the wrong mirror axis.
On your screenshot, we see that it's the Y axis you want to mirror (as the center point is on the edge which is on the side of the green arrow: Y axis)
So, try to set mirror axis to "Y" instead of "X".


text:
Smoke emitter not rendering in viewport
I'm following this tutorial and at 32:45 he tests out the smoke emitter, and I've followed every step to that point, and it doesn't work for me. He starts explaining how to do it at 30:15. Here's a link to my .blend file, can someone please explain to me (very simply) what I'm doing wrong here?
p.s. sorry for asking so many questions!

Please don't just post a blend file and ask someone to look at it for you. Write a detailed question outlining your specific problem.

Sorry! I'm new here and don't really know the rules and such. I'll give more details next time :)

Ok, thanks. You can always just run through the quick tour.

You have the domain settings on what should be the emitter object.
The domain should be the cube around the cylinder, and the emitter object should be the cylinder inside it (see the wiki).
Note that the smoke simulator was updated a bit in blender 2.64, so to get an the same effect in 2.70a:

Enable the smoke domain for the cube object:

Adaptive domain is a setting which was added in 2.64, and it basically just skips calculating parts of the domain which don't have smoke in or near them. Enabling it should speed up the simulation without affecting the result.
Enable the smoke flow physics on the cylinder (in your file this was set to domain)

Make sure Initial velocity is enabled. You may also want to up the number subframe smaples, but note that this will slow down the simulation.


text:
Can a Cycles/Blender Internal materials be shared on their own?
I would like to know how I can export a material to let a friend use, without sending them a huge .blend file just to append the material from.

Couldn't you just append the material into a new .blend and send them that?

While its possible to invent some file-format to store Blender materials, this is currently not a common way to share materials.
Typically for this would be done by appending materials into a new Blend file, saving it, and sending this to a 3rd party.
In rare cases a material may depend on objects (using empties for mapping), in those cases you could create a group of objects in your Blend file and append that instead of the materials (the materials will load in too).

There is one option for cycles materials - Online Material Library. It is in the contrib addons that is normally included with non-release builds.
Primarily this addon provides access to a collection of materials but also has tools to import/export cycles node based materials to an xml-based text file that can easily be shared. While there was mention of adding support for BI materials there hasn't been any support added for them.

What you could do is put the material on a cube in the original file. Maybe pack the file if it includes images. Then copy-paste the cube to an empty blend file and share this. I think this would be about the minimal space requirement.


text:
Run multiple Python scripts in Blender from the command-line
I have 8 python scripts and I need to lunch them at once. For one script, I used
blender --background --python script1.py

for the eight scripts, I tried this command but it does not work.
blender --background --python *.py

You can have multiple --python tags. For example:
blender --background --python script1.py --python script2.py

This will execute the scripts in the order they are added in the command above. Add as many --python arguments as you need (there is no limit on the number of scripts you can run).

I have already tried this but it did not work

Then I think you may need to add more information to your question as this method worked just now when I tried it. Are you getting any errors?

I think the problem is that they run in sequence and not in parallel, but they do all 'run at once' depending on your meaning of the term. They do not run 'simultaneously'


text:
Armature Deformations 'Squishing' Solid Objects
I have a door mesh that I am working on that needs to be able to swing open and closed (because it's a door...). I have finished modeling it, texturing it, etc. and now I am on to adding the armature and animations, but after adding an armature to the mesh, I'm getting some strange deformations.
Here is the door mesh:

Wireframe:

And here are heatmaps for each of the two "bones".
Right:

and Left:

So, as you can see, the bone on the left should move the entire left door with full weight, and vice versa for the door on the right. However, when I rotate the bones, this happens:

The door does not move completely with the movements of the bone. I want the door to move to the exact same position as the bone, but it appears to be lagging behind it and getting "squished" a bit. The effect gets worse as I turn the door even further.
How can I make sure that the door moves entirely with the bone and does not get "squished" like this?

Steps to recreate:

Create door mesh
Add armature
Move root bone to top of door.
Duplicate root bone twice and place duplicates on either side of door
Move bone joints as shown in the picture, so that the base of the bone is at the hinge of the door and the tip of the bone is at the center of the two doors.
Parent the duplicates to the root bone, keeping the offset.
Select door, then select armature.
Ctrl+P to parent, as Armature Deform with empty groups.
Select all vertices for the left door and assign to the Door.L bone VG (vertex group).
Select all vertices for the right door and assign to the Door.R bone VG.
Select all vertices and assign to the root bone VG.

Nothing too fancy. I just set up a basic armature.

This can be caused by the non-zero weighting of the root bone (select it while in weight paint mode to check)

@Polosson Ah brilliant! Thank you so much! If you'll put that into an answer, I'll accept it.

This is caused by the non-zero weighting of the root bone.
Select the root bone while in weight paint mode to check.
You can get rid of it by selecting the door, and remove the 'root' vertex group in the properties panel, object data tab.


text:
Why can't i get my undo history back?
This has got to be my most frustrating moment while using blender! Whenever i use blender for a long time (without saving too!), i happen to change the current mode i am in when i try to undo an action blender undoes the action that took place while i was in that specific mode (object, edit, sculpt).
And heres the super annoying part, i try to undo to the changes that where done in that mode and a huge change in my mesh occurs, then i switch to the mode that i had previously been doing my legit modeling, and still i can't manage to restore my previous session(Come on now!).
So(sigh) i look througth the history in the tools menu for every mode i was In, and NOPE, i just can restore my previous session.
Now i realise that blender store only a certain amount of actions in its history, so my previous action was deleted while i searched for last my session.
Is there any way to avoid this problem? It would be very appreciated :)

Save often and whenever you undo something you didn't want to just immediately hit redo ([Ctrl]+[Shift]+[Z]).

No, there is no way around this currently.
This is a limitation in Blender's undo stack. Each mode has its own undo history.
See: https://www.blender.org/manual/interface/undo_and_redo.html

authors: Анастасия Сергеевна


text:
How can I get curved reflections on flat surfaces?
I have a metal stripe wrapped around both the blue object and the pink object, and they both have the same material applied to them. The reflections/lighting on the blue object stripe appear rounded even if the surface is flat.

Modifiers applied to stripe on blue object are unknown. Presumably the same modifiers shown below are applied, and I tried applying them on the pink object, but results differ.

The cycles rendered image is below.

I am not sure if it's a lighting option or a modifier, but I'd like to get the same curved lighting on the pink object's stripe. How would I do that?

Hello, are you sure that the metal stripe is not curvy? Please share your file: https://blend-exchange.com/

@moonboots It's just Auto Smooth enabled vs. disabled.

Oh OK you must be right

@moonboots Actually I included the possibility of a rounded object into my answer as well (since "smooth" looks much more curvy in my example) because the question says, there are unknown modifiers applied to the curvy stripe. But to be honest, I would expect the minimum effort of a user who has the file to simply go into Edit Mode or maybe choose something less deceiving like Solid shading to just look at the mesh if there is a difference in curving - so I went for the smoothing variant first.

My goal was to create a rounded metal band to wrap around the objects, the simplest solution to reach that look in the other object was, stupidly enough, autosmooth and/or subsurf. Admitting I still have limited experience, there were definitely other, possibly better methods to reach the results I wanted!

If the metal band has to be flat, and you want it to shade round, then you'll have to mess with the normals, one way or another.
Here, that's done with a Data Transfer modifier.

The (blue) target is a loop stolen from the original model, converted to a curve, bevelled 'Round' in its Data > Geometry panel, and converted back to a mesh
The transfer modifier is aimed at a vertex-group comprising the metallic element of the model:

This isn't the only way.. you could use a bump-map in the metal material. That raises the question of how you'd like to map it. In turn, that would depend on whether the band is a separate object, or a separated surface.. we need a bit more information. There looks as if there's a very slight contact shadow from the band in your reference? That suggests it's a separate surface.
There is already enough topology in the model to AltS fatten the central loop to round the band in actual geometry, though. That would seem preferable.

Without examining the objects it is not so easy to say, but my first guess would be, the "flat" stripe is set to Shade Auto Smooth (or Auto Smooth enabled afterwards), while the "curvy" stripe is set to Shade Smooth i.e. Auto Smooth not enabled. If this is not the solution, I guess on the "curvy" stripe the Subdivision Surface modifier was placed after the Solidify modifier.
Here is an example for the Auto Smooth option, I've recreated the shapes:

To get the same look for the left one, either select it, then right-click in the viewport and choose Shade Smooth or go to the Object Data Properties and disable Normals > Auto Smooth there:

The Auto Smooth option lets you set an angle (30° by default) above which an edge is considered sharp and will not be shaped smooth anymore. So the top and bottom rim with 90° angles are sharp. If Auto Smooth is disabled, the shading of everything will be smoothed out, even the 90° angles on the border, that's why it looks rounded. This also means, if the stripes were flat and had no thickness, they would both look the same (flat), because then there would be no 90° angle over which the smooth shading would be extended.
And here is the option with the different order of modifiers. On the right you have a thinner light reflection than in the previous example, so maybe this is what happened there:

Enabling autosmooth was indeed the simplest solution, quite a novice oversight on my part. On the other hand, I noticed differences in the mesh and thought of subdividing more, but I was applying modifiers wrongly and were getting weird results, after trying the right order I got satisfying results. Thank you for the detailed help!

I didn't get it perfectly the same as with solidify, but here's a solution using a shader:


text:
A cube appears when I generate a skin
Consider:

I’m trying to make a tree model, but when I generate a skin a cube appears. I tried redoing it, but it didn’t work.

Hello, maybe you have floating vertices? Could you please share your file?

How do i share my file

Read the instructions here: https://blend-exchange.com/ or use another platform like workupload and share the link

https://workupload.com/file/gRUpznwvABM
this?

In Edit mode, press AltZ to see with transparency, and AltH to unhide this pixel, remove it:


text:
How can I make these swirling gradient spheres?
Consider:

I came across this. How can I make it?

Add noise to the input of your textures (using vector math > add).
By changing the input texture coordinates you can squash and stretch your texture along curved shapes.


text:
How can I invert image colors with the Python API?
I need to invert an image programmatically.
However, the command:
bpy.ops.image.invert(invert_r=True, invert_g=True, invert_b=True)

fails with
RuntimeError: Operator bpy.ops.image.invert.poll() failed, context is incorrect

What should I do to make it work?

According to this page
https://docs.blender.org/api/current/bpy.context.html
there are only two possible values for "Image Context": edit_image and edit_mask. And the first one worked for me.
bpy.ops.image.invert({'edit_image': bpy.data.images['texture_name']}, invert_r=True, invert_g=True, invert_b=True))

Or the currently recommended way (without a deprecation warning):
with bpy.context.temp_override(**{'edit_image': bpy.data.images['texture_name']}):
    bpy.ops.image.invert(invert_r=True, invert_g=True, invert_b=True)

Probably, the same technique can be used with other image operators, and edit_image allows us to "select" an image we want to edit.

Thanks for the answer ! Maybe a bit easier to read, instead of unpacking a dictionary inside the arguments : with bpy.context.temp_override(edit_image=bpy.data.images['texture_name']): does the same thing

import bpy

image = bpy.data.images.get(name) # name = image.name
override = bpy.context.copy()
override["edit_image"] = image
bpy.ops.image.invert(override, invert_r=True, invert_g=True, invert_b=True)

Stumbled upon a numpy implementation that doesn't require using an operator :
https://blender.stackexchange.com/a/208589/86891
import bpy
import numpy

def invert(image, invert_r = False, invert_g = False, invert_b = False, invert_a = False):
    pixels = numpy.empty(len(image.pixels), dtype=numpy.float32)
    image.pixels.foreach_get(pixels)
    if invert_r:
        pixels[0::4] = 1 - pixels[0::4]
    if invert_g:
        pixels[1::4] = 1 - pixels[1::4]
    if invert_b:
        pixels[2::4] = 1 - pixels[2::4]
    if invert_a:
        pixels[3::4] = 1 - pixels[3::4]
    image.pixels.foreach_set(pixels)

image = bpy.data.images["Untitled.png"]
invert(image, invert_r=True, invert_g=True, invert_b=True)
image.update()


text:
Can I use Blender to set up game logic?
I want to create a game using Blender 2.93. I don't know if I can use Blender to create the game logistics.
I want to create a 3D game that's set up like Minecraft. An almost infinite world that's somewhat based on blocks. I'm not asking for modeling advice. I can do that later. I want to know if and how I can set up a system within Blender that sets spawning of biomes, animals, etc.

https://blender.stackexchange.com/questions/106972/what-will-happen-with-blender-2-8-game-engine

logic or logistics? Or both?

Note that Minecraft uses its own game engine because most game engines are not set up to handle almost-infinite worlds based on blocks. Minecraft is "not like the other games" and engines like Blender are designed to handle the other games. Most games consist of storylines and worlds created by the game designers, and that's what most game engines are designed for.

Technically you might be able to, with a lot of Python scripting & brain power. I would recommend using a real game engine, though, like Godot, which has excellent Blender integration.

I would recommend using UPBGE. So you don't have to "learn" two different systems and it's all inside Blender itself.
You can download it here: https://upbge.org/download
It's for free as Blender and my personal experience with the support/developers was excellent.

Blender can definitely be used to setup levels, tag game objects with properties. Since you mentioned blocks, you can use the remesh modifier set to "blocks mode", so that you can control the blockiness of your game objects.
Then you can export your game levels and objects to other game engines (Godot, Unity).
But as dr.Sybren and Chris mentioned, is will take quite a bit of programming and data adapting to get this done seamlessly and their recommendations are very apt.


text:
Is it possible to get a random number in the node editor?
Is it possible to generate a random number for use in the node editor?
I am aware of the Object Info node, but I want a random number which I have more control over.
Ideally I could change it with some sort of "seed" vale and be able to define limits for maximum and minimum values.
How is this possible?

Here is a good tutorial wich can help you http://cgcookie.com/blender/2013/10/03/tip-randomizing-leaf-color/

@lucblender I know about the object info node, I want a random number which I can change (e.g. with a seed).

There is now a White Noise Texture node, which takes input Coordinates and outputs a totally different value (either RGB or between 0 and 1) for even the slightest variation in input.
The input can be set to use 1D, 2D, 3D or 4D. If using 4D, the 4th input, W, can be used as an additional seed to the node.

Oops, just duped you. And in the wrong place. Will link here, and delete mine after a bit.

@RobinBetts No biggie !! I love me some seizure inducing GIFs :D

that's what i was looking for! +1

That would be through drivers. You can add an Input->Value node to feed into other nodes or add a driver to an editable value on any other node.
A simple way to get random values is edit the value and enter #noise.random() This will give random values between 0 and 1, you can expand the entry to multiply the value if you want it larger or add a minimum value.
To get more control over the generated value you can create a script and use bpy.app.driver_namespace["name"] = funcname to provide access to any function you define. The script name must end in .py so that you can register it and auto run python scripts also needs to be enabled.

I tried using noise.random() as a scripted expression, however the debug value stayed as 0 and it did not appear to work in a render.

You may need to update dependencies, but one thing I have seen stop this working is if the interpolation type of the driver is set to constant. The other is not enabling auto-run python scripts, you should see a notice if that is the case.

I got it working :) I had to save the file first. Something to do with auto run perhaps? I have it enabled but with some excluded directories.

Does this expression evaluate on each frame or on each sample?

@Matt If you use random for a colour input you get the same colour over the object, per sample would give you variation.

Yes, there are some cases where you want per-object consistency. I'm actually looking for per-sample variation (it would be a great way to feather the edges of some procedural inputs, like "pointiness"), but I suspect that making per-sample calls requires an OSL shader.

In blender 2.93.5 noise.random() is considered an invalid python statement

@Acebone It is not. You have to enable Automatic Execution of Python Scripts in User Preferences > Save&Load > Auto Run Python Scripts. Then just update the driver.
Expressions can call functions. This is why this works and it is limited by default, otherwise it could be unsafe to auto-execute code from unknown sources.

If you are texturing, there is a "random" value in the object info node
Not entirely sure what your application is, but there's more info on the object info node at http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/More
Also found this post here on stack exchange: Random maps in cycles

Please summarize the links you have referenced in your answer. If the link goes down, so does your answer.

gandalf3 already mentioned this.

There it is - a random number, no shenanigans. Best answer, at least for my purpose :)

I took a little different approach.  I added a "value" node.  Then key framed it to 0.5 at frame 1 and also to 0.5 at the last frame.  Then using the F-curve modifier, I added noise to the F-curve.  This has worked well for me to use with flickering lights and such.

Another approach, if you don't need it to be truly random, is to take the same random output from the object info node, pass it through math.multiply and multiply it by some quite large value (100?), then through a math.modulo with modulo 1.

I think for almost all purposes this is going to seem like a brand new random number. At least, when you wouldn't notice a minute difference of the main random number. We're essentially chopping up the digits of the random number we were given into chunks, and using each chunk as a different random number.
So say we got 0.9172352114 as our random number, we can use that is is for one purpose, then multiply and modulo it to get 0.72352114 as our second. We could do it again and get 0.352114 is our third one.


text:
Is there another way besides particles to make fire in the game engine?
I would like to make high pressure jets of flame for a character in the game engine.
Here is my question:
What would be/is the most time efficient manner to do this in since particles aren't available in 'Blender Game'.
computer resources are no problem; I'd just like a good looking, timely way for flames.

You can add a transparent animated plane.
First off, you must change the Shading from Multitexture to GSL.
it must be tiled and evenly spaced like the image below

Because there are four tiles you would check the animated button, and choose one tile along the Y and 4 along the X

you also need to input a frames per second, and how many frames the animation should run for.

Blend file with working animated transparent plane

You can have an empty emitting no collision planes (the texture is not animated, the object, however, has animated scale).
The planes here are animated so they start small, get larger, and then shrink back down again before disappearing. they also randomly rotate to make the fire look more realistic.

Notice that the object ends itself one logic tick After the animation finishes playing. This is only the logic for the plane with the fire texture to make it scale and rotate. it is parented to an empty that always tracks to the camera and moves along the global Z axis.

The emitters add that empty, and the empty is added with the fire plane.

Here I played around with the animation for scaling the flame, and the speed at which it rises. I am also using multiple emitters and I have adjusted the opacity on the flames to make them more transparent. I also having it randomly adding lamps that last for one logic tick to create the flickering effect.

(textures not packed, flames will be pink.)
Original blend file

Blend file with campfire

Very well done. Can you also mention what level of performance it gives?

for just a few fires it works fine, but if you have a Lot of fire, it starts to bog-down the game..

I can run the campfire at 60 FPS

I meant your you to add this info to your answer.

Not recommended for Blender > 2.71
There is a particle system addon easyEmit for the BGE which produces nice results:

Note: I tested it with 2.72 it throws exceptions due to changed API, it would need some update. There might be an update in the thread linked above. According to the posts it should still work in 2.71.
Another one X-Emitter I've not tested (might be outdated):

actually, i still use this circa 2.74 and haven't encountered any pain.


text:
Object reverts back to non-modified state after joining
I am attempting to make a tree but when I try to join the different components together ctrl J my decimated icospheres revert back to its original shape.  Any idea on how I can solve this?  I also forgot to mention that I am trying to create a low poly tree and that I am still in the learning stages.
The first image is the tree before joining and the second is the tree after joining

It looks like what is happening is this. On the two green objects of your tree, you added a Decimate modifier, but before joining the objects you did not apply the modifier. On the "trunk" of the tree you do not have a Decimate, so when joining the objects the modifier is removed.
To apply the modifier, in object mode, just click on the apply button on the modifier.

The object(s) that you select before the last object with the modifier will discard their modifier stack and inherit that (the last) object's modifier stack.
Easiest way to avoid any loss of modifiers is to apply them before doing any joins.


text:
camera settings to imitate my camera
Well, I want to imitate the same camera settings in blender as in photograph that I have taken, in order to edit rendered stills into the same picture I have captured. However I'm having trouble setting up the camera in blender to simulate my camera.
Maybe someone can tell me how to set up the camera?
The picture was taken with a large format camera on a 4x5 film format ( that is 4 inches by 5 inches) with a 121mm lens.
How would I set up a blender camera to simulate this perspective?

farge format film cameras are not included in the camera presets, how can I set them up in blender?

You can match a camera in blender.

Select your camera
Go into the camera properties.

Set the Focal length of your camera to 121.

Set the Sensor Fit to Horizontal

Set the width value to 127 (which is 5 inches in millimeters).

You will need to make your image resolution fit a 4:5 aspect ratio.

Enter the camera properties
Set the width and height accordingly.

To make a new Preset click on the plus sign next to cemera presets

Add a name to it (Click on save focal length if you want to include the lens in the preset).

Once created the preset will be available for future projects.


text:
Drag and drop importing of .OBJ files
This is a very old question, but I just lost track as to whether it has been done.
Is there a way to simply import an .obj file by dragging and dropping it onto your blender window?
This will make my workflow quite a bit faster, since I am just checking meshes.

Maybe you can view meshes by vtkplotter. link

This did not work the last time I tried it and I assume it still doesn't since you are asking.
The fastest way I know of to do this is to use the following script that someone posted on this site a while back for batch importing .obj files.  I modified it slightly to work with OSX but the necessary Windows code is just commented out.
import os
import bpy

# put the location to the folder where the objs are located here in this fashion
#path_to_obj_dir = os.path.join('C:\\', 'Users', 'YOUR_NAME', 'Desktop', 'OBJS') #<-WINDOWS_OS
path_to_obj_dir = bpy.path.abspath('//OBJ/')

# get list of all files in directory
file_list = sorted(os.listdir(path_to_obj_dir))

# get a list of files ending in 'obj'
obj_list = [item for item in file_list if item[-3:] == 'obj']

# loop through the strings in obj_list and add the files to the scene
for item in obj_list:
    path_to_file = os.path.join(path_to_obj_dir, item)
    bpy.ops.import_scene.obj(filepath = path_to_file)

It's supposed to look like the following.  It originally searched the directory where the .blend is but one of the changes I made has the script search for .obj files in a folder called OBJ.

Cheers, that works fine, when I give it the exact path (same for linux and osx), and this certainly speeds-up my workflow.
The inconveniences are that I need to give it a exact path each time (as i am not necessarily using a project file), and also it will load all objs in the directory unless you modify it...
It is better than nothing, but I actually cannot imagine that an arbitrary .obj drag-and-dropper does not exist for blender...
Just changed if item[-3:] == 'obj'] to [-4:] == '.obj'
as it causes problems if u have an obj folder.
Thanks for the help anyway.


text:
How to slide geometry past an edge?
I am trying to slide a bunch of selected edges past an edge, as is done at 19:27 of the blender guru tutorial on "how to make a beer".

AltRMB to select the edge loop
Press G twice
Move the mouse cursor up and down, while holding Alt

The edges only move down and also along the plane in which the circular loop resides (imagine for instance the top of the cylinder being the loop, and I'm trying to slide the edges to form a concavity in the cylinder)
I want the edges to move past the vertex loop.. Can someone help me?

as far as i can see from the image the geometry which you are trying to slide on, does not continue upwards... is that correct?

Yes that is correct.. if i keep moving the mouse cursor up , it slides along the top of the plane

With the vertices selected, press ShiftV to ensure that you are vertex sliding, not edge sliding. Pressing GG automatically picks between the two operators based on the selection, and you cannot edge slide geometry past adjacent edge loops (you can with vertex slide though).
Once you are in the vertex slide operator, press C to disable clamp (or hold Alt).

Note that disabling clamp locks the selected vertices to the edges which they are sliding on when you press C or Alt.

However in this particular situation I think GZ is a faster method, as mentioned by G.Rassovsky.

I never knew about G G, +1

Ah , awesome , seems to work !! :) :) Thank you !! . Can you also tell me what screen shot software you are using here.. i would like to make my questions and answers more informative as you have done so wonderfully ..

Lice is the screen capture software used by many people here. It creates .gif animations.

@SreekanthNarayanaswamy I use LICEcap, running in wine.

Shift+V? That's a dream! I have always wondered how I could do that. Thank you Gandalf!


text:
Can I import an image file so it can be used in grease pencil?
Can I import an image file so it can be used in grease pencil instead of drawing? I would have problems with hand drawn image in Blender due to a stroke.
Specifically I'll have difficulty drawing vertical and horizontal lines with grease pencil. I need to import some line drawings of buildings, and the way that Grease pencil enables you to draw in 3D space appeals to me.
If so How would I import exactly, into Blender generally?

are you comfortable making Curves? if so that would allow you to skip a lot of steps..

Now you've elaborated on the scenario, I'm less inclined to think that Grease pencil will be any faster than extruding vertices, and snapping to axes.

@bazzart If you can use something like Inkscape to "vectorize" an image, you could get a svg vector file from your image (neeeds some practice and it strongly depends from the image and desired result...). Then import the svg into blender. Just another (more convoluted) option, but...

yeah, once you have curves (easy to import from svg) then you can use scripts to convert to gp lines. see related question: http://blender.stackexchange.com/questions/36140/convert-curves-to-grease-pencil

HOW TO ADD BACKGROUND OR REFERENCE IMAGES IN BLENDER 2D GREASE PENCIL THIS EVEN APPLIES TO GENERAL MODE
When you start in 2D animation Mode. Your option will be set to "DRAW" mode instead of
"object mode" you need to Switch from Draw mode to object Mode.
When you switch to object mode you will notice new button options and one of them is "Add"
you can use that or just Shift A.
1 -shift+A to add background image or reference Image.
2 - Shift + A to add Grease Pencil then select blank or stroke or the monkey if you don't know what they each mean, google it. if you just want to draw select blank.
3 - now change mode from object mode to "DRAW MODE"
    enjoy.

Problem with this is that the images won't (obviously) be rendered, as they are reference/background images. But that's probably configurable some where as well.

Use snaping to create vertical lines.Select "line" snapping. Also, press shift+4 or shift 6 to rotate the view of the camera in camera view. That's how you can draw vertical lines.


text:
What does "Couldn't initialize streams, probably unsupported codec combination" mean?
What does this mean (boxed in a red box) Please help!! I have so many intros but cant use many because of this problem. Any help?

The error means that Blender can't read or write to a specific codec. Speculation based on the screen shot:
your on windows, and probably don't have Ogg/Vorbis codecs installed on your system. You can download the OpenCodecs package, which will allow you to play ogg/ogv (vorbis/theora) on windows.
It's generally included in Linux/osx, so your probably getting examples from someone who works in one of those systems.
Or you could try setting the output of your render to a codec you probably already have like Mpeg, h.264, or Windows Media?

I had this problem after having imported a screen recording into Blender.
The frame rate was set to 29.999. When I changed this to 30, it worked.


text:
infinite loop / ensure_lookup_table
what this script should do is add 1-3 little cubes to each side of a specific object (torus in my case for testing). then for each cube a random face within a section of the torus gets choosen and the upper 4 vertices of the cube are getting moved to the vertices of that face and a hook is applied. so far it's working for one side, but as i modify the function for the other side by adding arguments, blender crashes. i am almost sure to say this is due to memory issues. i am not into memory handling in python at all, therefore i tried del for every variable at the end of the function, sadly without success. so how do i free enough memory? or is there another approach? sorry if this code is hard to look at.. i'm a beginner.
edit: hope i got the indentation right now
import bpy
import bmesh
import random

# Delete old objects
for ob in bpy.context.scene.objects:
ob.select = ob.type == 'MESH' and ob.name.startswith("Cube")
bpy.ops.object.delete()

def addcube(name,bxtop,bxlow,posneg,v1,v2,v3,v4):
    # Deselect everything
    bpy.data.objects['Torus'].select = True
    bpy.context.scene.objects.active = bpy.data.objects['Torus']
    bpy.ops.object.mode_set(mode = 'EDIT')
    bpy.ops.mesh.select_all(action = 'DESELECT')
    bpy.ops.object.mode_set(mode = 'OBJECT')

    # Cube creation
    bpy.context.scene.cursor_location = (0.0, 0.0, 0.0)

    # set +- x,y-axis
    xco = random.randint(20,60)
    xco = (posneg * xco) / 10
    yco = random.randint(0,30)
    yco = (yco / 10) - 1

    ccverts = ((-0.2 + xco,-0.2 + yco,0), (0,0,1), (1,0,1), (0.2 + xco,-0.2 + yco,0), (-0.2 + xco,0.2 + yco,0), (0,1,1), (1,1,1), (0.2 + xco,0.2 + yco,0))

    ccfaces = ((0,1,2,3), (0,4,5,1), (4,5,6,7), (2,6,7,3), (3,7,4,0))

    ccmesh = bpy.data.meshes.new(name)

    ccobject = bpy.data.objects.new(name, ccmesh)

    ccmesh.from_pydata(ccverts, [], ccfaces)
    ccmesh.update(calc_edges=True)

    ccobject.location = bpy.context.scene.cursor_location
    bpy.context.scene.objects.link(ccobject)

    # Get the coordinates of the first vertices of 'Mapping' object
    firstObjData = bpy.context.scene.objects['Torus'].data
    bm1 = bmesh.new()
    bm1.from_mesh(firstObjData)

    # Set 'Mapping' object active
    bpy.data.objects['Torus'].select = True
    bpy.context.scene.objects.active = bpy.data.objects['Torus']

    # Store all Mapping verts locations
    allvertlocsx = []
    for v in bm1.verts:
        v.co.xyz * bpy.data.objects['Torus'].matrix_world
        allvertlocsx.append(v.co.x)
    allvertlocsy = []
    for v in bm1.verts:
        v.co.xyz * bpy.data.objects['Torus'].matrix_world
        allvertlocsy.append(v.co.y)
    allvertlocsz = []
    for v in bm1.verts:
        v.co.xyz * bpy.data.objects['Torus'].matrix_world
        allvertlocsz.append(v.co.z)

    # Bounding settings (adjustable)
    xtop = max(allvertlocsx) - bxtop
    ytop = max(allvertlocsy) - 0.5
    ztop = max(allvertlocsz) - 0.02
    xlow = min(allvertlocsx) + bxlow
    ylow = min(allvertlocsy) + 0.5
    zlow = min(allvertlocsz) + 0.02

    possiblevertsx = set()
    for v in bm1.verts:
        if v.co.x <= xtop:
            if v.co.x >= xlow:
                possiblevertsx.add(v.index)

    possiblevertsy = set()
    for v in bm1.verts:
        if v.co.y <= ytop:
            if v.co.y >= ylow:
                possiblevertsy.add(v.index)

    possiblevertsz = set()
    for v in bm1.verts:
        if v.co.z <= ztop:
            if v.co.z >= zlow:
                possiblevertsz.add(v.index)

    setverts = []
    for v in (possiblevertsx & possiblevertsy & possiblevertsz):
        setverts.append(v)

    # Selected verts in poll
    for int in setverts:
        bm1.verts[int].select = True

    linkfaces = []
    for v in bm1.verts:
        if v.select:
            for f in v.link_faces:
                linkfaces.append(f.index)

    # Set the coordinates of the first vertices of 'Cube' object
    secondObjData = bpy.context.scene.objects[name].data
    bm2 = bmesh.new()
    bm2.from_mesh(secondObjData)

    # Get random face
    f_index_max = len(linkfaces) - 1

    while True:
        randlinkindex = random.randint(0,f_index_max)
        randface = linkfaces[randlinkindex]

        bpy.ops.object.mode_set(mode = 'EDIT')
        bm1.select_mode = {'FACE'}
        bm1.faces[randface].select_set(True)

        # Get random face verts
        randfaceverts = []
        for v in bm1.faces[randface].verts:
            randfaceverts.append(v.index)

        # Update
        firstObjData.update()
        bpy.ops.object.mode_set(mode = 'OBJECT')
        bm1.to_mesh(firstObjData)

        # Convert local coorinates to world coordinates before assignment
        vertCoordinates1 = bpy.data.objects['Torus'].matrix_world * bm1.verts[randfaceverts[2]].co.xyz
        vertCoordinates2 = bpy.data.objects['Torus'].matrix_world * bm1.verts[randfaceverts[3]].co.xyz
        vertCoordinates3 = bpy.data.objects['Torus'].matrix_world * bm1.verts[randfaceverts[0]].co.xyz
        vertCoordinates4 = bpy.data.objects['Torus'].matrix_world * bm1.verts[randfaceverts[1]].co.xyz

        # Convert world coorinates to local coordinates before assignment
        bm2.verts[v1].co.xyz = bpy.data.objects[name].matrix_world.inverted() * vertCoordinates1
        bm2.verts[v2].co.xyz = bpy.data.objects[name].matrix_world.inverted() * vertCoordinates2
        bm2.verts[v3].co.xyz = bpy.data.objects[name].matrix_world.inverted() * vertCoordinates3
        bm2.verts[v4].co.xyz = bpy.data.objects[name].matrix_world.inverted() * vertCoordinates4

        bm2.to_mesh(secondObjData)

        # Trigger viewport update
        bpy.context.scene.objects.active = bpy.context.scene.objects.active

        # Loop break + max face angle
        if bm2.verts[5].co.z > bm2.verts[6].co.z:
            if (bm2.verts[5].co.x - 0.05) <= bm2.verts[6].co.x:
                break

    # Set cursor position
    bpy.context.scene.cursor_location = bpy.data.objects[name].matrix_world * bm2.verts[1].co.xyz

    # make sure everything is deselected before selecting vertex for hook
    bpy.data.objects[name].select = True
    bpy.context.scene.objects.active = bpy.data.objects[name]
    bpy.ops.object.mode_set(mode='EDIT')
    bpy.ops.mesh.select_all(action="SELECT")
    bpy.ops.mesh.normals_make_consistent()
    bpy.ops.mesh.select_all(action="DESELECT")
    bpy.context.tool_settings.mesh_select_mode = [True, False, False] # (Vertex,Edge,Face)

    # select vertex, add hook, rename to Hook1
    bpy.data.objects['Torus'].select = True
    bpy.data.objects[name].select = True
    bmesh.from_edit_mesh(bpy.context.object.data).verts[1].select = True
    bmesh.from_edit_mesh(bpy.context.object.data).verts[2].select = True
    bmesh.from_edit_mesh(bpy.context.object.data).verts[5].select = True
    bmesh.from_edit_mesh(bpy.context.object.data).verts[6].select = True
    bpy.ops.object.hook_add_selob()
    bpy.ops.object.mode_set(mode='OBJECT', toggle=False)

    # Save xco and randface for comparison
    addcube.xcoords = xco
    addcube.randomface = randface

"""
_______________

Function calls:
_______________

"""

"""
left side
"""

# Cube
addcube('Cube',2.2,0,-1,1,5,6,2)
save_cube = (addcube.xcoords,addcube.randomface)

# Cube2
condition2 = random.randint(0,1)
if condition2 == 1:
    addcube('Cube2',2.2,0,-1,1,5,6,2)
    save_cube2_list = [addcube.xcoords,addcube.randomface]
    while ((save_cube2_list[0] - 0.5) <= save_cube[0] <= (save_cube2_list[0] + 0.5)) or (save_cube[1] == save_cube2_list[1]):
        bpy.ops.object.select_all(action='DESELECT')
        bpy.data.objects['Cube2'].select = True
        bpy.ops.object.delete()
        addcube('Cube2',2.2,0,-1,1,5,6,2)
        save_cube2_list = [addcube.xcoords,addcube.randomface]

     # Confirm Cube2
     save_cube2 = (addcube.xcoords,addcube.randomface)

# Cube3
condition3 = random.randint(0,1)
if condition3 == 1:
    if condition2 == 1:
         addcube('Cube3',2.2,0,-1,1,5,6,2)
         save_cube3_list = [addcube.xcoords,addcube.randomface]
         while ((save_cube3_list[0] - 0.5) <= save_cube[0] <= (save_cube3_list[0] + 0.5)) or (save_cube[1] == save_cube3_list[1]) or ((save_cube3_list[0] - 0.5) <= save_cube2[0] <= (save_cube3_list[0] + 0.5)) or (save_cube2[1] == save_cube3_list[1]):
            bpy.ops.object.select_all(action='DESELECT')
            bpy.data.objects['Cube3'].select = True
            bpy.ops.object.delete()
            addcube('Cube3',2.2,0,-1,1,5,6,2)
            save_cube3_list = [addcube.xcoords,addcube.randomface]

        # Confirm Cube3
        save_cube3 = (addcube.xcoords,addcube.randomface)
    else:
        addcube('Cube2',2.2,0,-1,1,5,6,2)
        save_cube2_list = [addcube.xcoords,addcube.randomface]
        while ((save_cube2_list[0] - 0.5) <= save_cube[0] <= (save_cube2_list[0] + 0.5)) or (save_cube[1] == save_cube2_list[1]):
            bpy.ops.object.select_all(action='DESELECT')
            bpy.data.objects['Cube2'].select = True
            bpy.ops.object.delete()
            addcube('Cube2',2.2,0,-1,1,5,6,2)
            save_cube2_list = [addcube.xcoords,addcube.randomface]

        # Confirm Cube2
        save_cube2 = (addcube.xcoords,addcube.randomface)

"""
right side
"""

# Cube4
addcube('Cube4',0,2.2,1,5,6,1,2)
save_cube4 = (addcube.xcoords,addcube.randomface)

# Cube5
condition5 = random.randint(0,1)
if condition5 == 1:
    addcube('Cube5',0,2.2,1,5,6,1,2)
    save_cube5_list = [addcube.xcoords,addcube.randomface]
    while ((save_cube5_list[0] - 0.5) <= save_cube4[0] <= (save_cube5_list[0] + 0.5)) or (save_cube4[1] == save_cube5_list[1]):
        bpy.ops.object.select_all(action='DESELECT')
        bpy.data.objects['Cube5'].select = True
        bpy.ops.object.delete()
        addcube('Cube5',0,2.2,1,5,6,1,2)
        save_cube5_list = [addcube.xcoords,addcube.randomface]

    # Confirm Cube5
    save_cube5 = (addcube.xcoords,addcube.randomface)

# Cube6
condition6 = random.randint(0,1)
if condition6 == 1:
    if condition5 == 1:
        addcube('Cube6',0,2.2,1,5,6,1,2)
        save_cube6_list = [addcube.xcoords,addcube.randomface]
        while ((save_cube6_list[0] - 0.5) <= save_cube4[0] <= (save_cube6_list[0] + 0.5)) or (save_cube4[1] == save_cube6_list[1]) or ((save_cube6_list[0] - 0.5) <= save_cube5[0] <= (save_cube6_list[0] + 0.5)) or (save_cube5[1] == save_cube6_list[1]):
            bpy.ops.object.select_all(action='DESELECT')
            bpy.data.objects['Cube6'].select = True
            bpy.ops.object.delete()
            addcube('Cube6',0,2.2,1,5,6,1,2)
            save_cube6_list = [addcube.xcoords,addcube.randomface]

        # Confirm Cube6
        save_cube6 = (addcube.xcoords,addcube.randomface)
    else:
        addcube('Cube5',0,2.2,1,5,6,1,2)
        save_cube5_list = [addcube.xcoords,addcube.randomface]
        while ((save_cube5_list[0] - 0.5) <= save_cube4[0] <= (save_cube5_list[0] + 0.5)) or (save_cube4[1] == save_cube5_list[1]):
            bpy.ops.object.select_all(action='DESELECT')
            bpy.data.objects['Cube5'].select = True
            bpy.ops.object.delete()
            addcube('Cube5',0,2.2,1,5,6,1,2)
            save_cube5_list = [addcube.xcoords,addcube.randomface]

        # Confirm Cube5
        save_cube5 = (addcube.xcoords,addcube.randomface)

if your indentation is broken: edit your question, delete your code, paste the properly indented code, and indent it by pressing Ctrl+K (with all code lines selected). or link to a gist - don't be lazier than you need to be..

here's the link to the previous version without the implementation to do the same thing for the right side: https://gist.github.com/anonymous/224c9b1401788a584ae5

You must be using a version of blender that is older than 2.73 else you would be getting ensure_lookup_table errors.  Maybe this helps you (i'm not saying this is how I would code this..) but with a few modifications it runs on Blender 2.76 https://gist.github.com/zeffii/4d3bec9c16c7a6b05b0e

it's worth updating to Blender 2.76 - because several potential crashes in scripted BMesh manipulations were fixed since your version was released ( 2.71)

thanks a million! can't test it right now but i guess you answered my question

i finally found the solution to my problem.
i had a while loop that was set for outdated testing purposes, wich ran infinitely for the right side.
thanks zeffii for pointing out updated blender gets ensure_lookup_table errors.


text:
How to create a 3D figure with turtle graphic style commands
I'm new with Blender and I want to know if Blender has some "Turtle Graphics" style box.
I mean: the old Logo programming language used some commands like:
SETX=100 (put the cursor at X=100),
SETY=100 (put the cursor at Y=100),
FORWARD 45 (move the cursor 45 steps forward),
RIGHT 90 (change the forward direction to the right, 90 degrees)`,

etc.
Is there something like this in Blender?

You want to achieve it using the modeling tools or a script? If you want to simulate this kind of functionality you may add a curve with some Depth value and keep extruding it inputting the desired parameters. Otherwise you may need to create a specific script/add-on for that. BTW thanks for reminding me this program. Spent some time playing with it on my Atari 800XL as a child :)

Good old days! My first thought was the Profile Node (thanks @zeffi) in Sverchok add-on, but it is currently more coordinates-oriented (so I think you'll not be able to rotate the turtle)

Hahaha!!! I also used Logo with Atari XL/XE, and I still use one of the last computing universe version, called ElicaLogo. Unfortunately, Logo is still an interpreted language (you need an external compiler to get an "executable"). Blender could has something like that (there is some graphic software with it, but I don't remember its name). I'm talking about a box with the parameters for x, y and z of each point of the 3D figure, and others capabilities to animate it. Is there? Where? Thanks a lot for your time!!!

The Blender User Interface is written in Python, and Python 3.4 is included in the most recent (2.76b as of this writing) distribution of Blender. I see from this page that Python has up through release 3.5 included an implementation of Turtle graphics, so the answer to your question is a qualified "Yes", though it might be that you have to do some fiddling around with the Python implemented in Blender to obtain this capability.


text:
How do I remove redundant triangles?
I finished creating my mesh, and one of the faces looks like this:

But then when I export it, instead it ends up looking more like this:

Now, I'm aware that this face is not really a rectangle and Blender provides a convenient layer of abstraction between me and actual vertices/triangles. But clearly you could have two triangles here instead of ten. How do I get rid of them? If I press "f", they can be merged into a single rectangle, but pressing ctrl+t turns them into this mess again. I tried many things and nothing seems to work.

To which format do you export? Some might only be able to handle triangles.

.fbx, and yes, I want triangles, but this huge rectangle should be divided into two, not ten.

The initial rectangle probably isnt' a quad, but a Ngon. How many vertices are there in its boundary?

Yeah, there are actually more vertices than 4. How do I merge them now?

You could try to first triangulate the face and then use a limited dissolve on it: http://blender.stackexchange.com/questions/20920/how-to-merge-4-adjacent-coplanar-faces-into-a-single-face/20921#20921

Thanks a lot - I used dissolve on vertices, just had to select the redundant ones and it did what I wanted!


text:
How to resolve ugly artifacts bending joints after posing?
Just learning here... I created a model in Makehuman and imported it into Blender. When I pose the model I get really ugly creases where the mesh appears to overlap:

How do I clean this up or avoid it? I'm not worried about animating or anything I just want it to look smooth.

Proper weight painting will help avoid problems like this

Add another bone in between the 2 bones with average rotation

Typically its best to first attempt to resolve the issue by weight painting.
That is to adjust the weights around the joint to improve the deformation.

Adjust weight values by manually painting.
Use the smooth tool to automatically re-distribute weights (new in 2.76), eg:
Try the 'dual quaternion' option in the armature modifier(helps avoid volume loss),
When weight painting can't quite resolve all artifacts,try the  corrective smooth modifier (new in 2.75)
Corrective shape keysUsing a shape key to manually correct the distortion. While its involved to setup, it can be driven by bone and gives most control, This is typically used for more advanced rigging.

Thanks. I don't have the "corrective" smooth modifier (not sure why) but the regular smooth modifier appears to releave some of the distortion. I will play with the weight / quaternion values as well once I'm further along.

@mister martin, its in 2.75 which isn't released just yet, but suggest trying the release-candidate, since I think it does exactly what you need (assuming some simple tweaks to weights don't resolve).


text:
Blender Rigging: Mirrors Changes
I have a character body made and im getting it ready for animation in Iclone 6.Im at the Armature stage in blender.The problem is when i test it in pose mode.It mirrors the bone movements to the other side as well and it look all deformed.The left side of the arms and legs dont move with the armature.Im thinking its caused by the mirror modifier i put on the mesh but,Im not sure.  Please help.

Its not clear which mode you're in when the mirroring error occurs.

To prevent the bones from mirroring , you just have to uncheck "X-Axis Mirror" in the tool panel, while in armature edit mode.

It is unchecked but still it mirrors