Why is this object facing the wrong way when exporting to three.js? I'm working on a small project using the library three.js

We're using a plugin for Blender which allows us to export the model as a .json file, however the problem I am having is that when I export it and load it into the project, it's facing the wrong direction.

I've gone over the code and I'm sure it's not a coding error because

I have the green line, (y), the red line (x) and a blue line (z), z can't be seen because we're facing directly down at the camera.

In Blender, the model looks as such:

I am certain the error isn't from the coding side but an issue with the exporter add on which I found here: github.com/mrdoob/three.js/tree/master/utils/exporters/blender

So I think I am more or less looking for a solution to fix the importer, it seems to be written in python, I am still searching around for a solution for this but not yet come across one, hoping someone else has had this issue.

Nothing's necessarily wrong, your object just isn't going to be in the same position in ThreeJS as in Blender because the default orientation of the axes is different.

Now, the export system takes care of this. I suspect that your object rotated to make up the difference perfectly, and that the problem is in fact your camera! The same values will cause a different rotation in ThreeJS than in Blender.

You could go to the trouble of manually adjusting to your camera to compensate, but fortunately that isn't necessary. Blender and ThreeJS both have built-in "lookat" functions (here and here, respectively), so you can just export another object to orient them to accordingly (though Blender looks at the entire object while ThreeJS focuses on a single vertex, so make sure the object you use is a small one if you want precision!).


emission shader casting shadows - problem not solved There is already a post about it in here, but the problem is not solved, in fact it is not a solution to the problem. What can we do to avoid shadows from emission shaders?

There's a similar post about it in here, and still the problem is not solved, and it seems: LIGHT PATHS CANNOT BE USED FOR MESH LIGHTS.
Here is a blend file that contains a simple experiment that demonstrates that the aforementioned solution in the first link does not work:

So, how do we avoid mesh lights to cast shadows?

In your particular example case you could replace your emitter object with an area lamp - this does support suppressing shadows as shown :

3d View :

Cast Shadow disabled :

Cast Shadow enabled :

However, I don't think it's possible to suppress shadows from mesh-based emission materials due to the nature of the physics based rendering. ie, if you're suppressing light from emission surfaces then what about light reflected from a glossy surface - that could also cast shadows - as could light from a diffuse surface (albeit much more subtle, but it would still be a shadow).


How to get a list of vertices from a list of edges in bmesh? So if I have a list of edges,

selected_edges = [e for e in bm.edges if e.select]

How would I make an array of the vertices contained in the edges of that list?

For context: in my project I'm making a list of shared vertices between two lists of edges.

Use sets.
Will most likely be duplicates in the following vertex list, from any connected edges.
selected_verts = [v for e in bm.edges if e.select for v in e.verts]

Converting to set(...) will have only one member for each vertex.
 set(selected_verts)

or defining as set in first place.
selected_verts = {v for e in bm.edges if e.select for v in e.verts}

The set(...) sounds like the way go as you can check intersection between sets of vertices easily.
between sets.


Nested texture on all sides of cube I am a total beginner to Blender.

I want the checkered brick texture to be on all sides of the cube. How can I do this?

I have tried adding a texture coordinate with UV output connected to the brick texture's input vector.

Here is the rendered output and node setup:

The Checker texture is 3D. It divides the given texture space into blocks. The Brick texture is 2D. It's calculated in U and V, but just projected through W.

So you can map the checker in a 3D space, (here, Object space) but the bricks need some kind of mapping onto 2D surfaces to look like bricks. The default UV map of a cube will do, here.

If you'd like some kind of procedural mapping that rotates the brick texture to line up with surfaces without an explicit UV map, you can use an approach something like this one


Move connected elements along their individuals Nomals I saw that other users made almost the same question but always for a individuals faces, edges or vertex but, What happen when you select a connected faces, edges or vertex?
Like in Maya when you make your selection and move it with Ctrl+mmb

As I know in blender works for individual elements

But no for a selection of connected elements

AltS, the shink and fatten tool, will move vertices along their individual normals.


Why is the other side faded in mirror mode? This has happened before, and I'm in mirror mode just using a reference picture, and I now I notice that the other side is in a faded color. And I cannot click it or interact with it.

It is by design. The other side will only be available for direct manipulation after you have applied the modifier. Mostly, when a user attach a mirror modifier, it's purpose is so that the user could just focus on working on one side of the model until we need to break the model's symmetry.

The greying out give you a visual as to which side of the model you are currently suppose to work on as you rotate around the model. You can imagine it would be frustrating to be clicking on something that is inactive by design.


splitting edges around a ring I am attempting to model the London eye and I have made an edge where there should be two. Is there an easy way to split my edges into faces the whole way round the ring?

Select your object and delete everything but one "segment". Then use one of these ways to create a circular array of it.

Then editing just one segment will affect all others. It will also result in a lighter model, and future changes will be much easier.

To actually split the edge select it and then use Bevel in edit mode. It depends on the topology of your mesh but from what I can see, it looks like it should do what you intend.


How to improve the prismatic approximations to the cylinders (I am a beginner)
Hi all, I would to know how to fix the prismatic approximations to the cylinders in my future renders.
What I mean is to fix the parts I've highlighted with a yellow highlighter in the following image:

Thank you and sorry for my bad english.

Apart setting mesh shading to smooth (which fakes roundness using normals, see https://docs.blender.org/manual/en/dev/modeling/meshes/editing/smoothing.html?highlight=smooth) you should probably learn about subdivision surface modifier (see https://docs.blender.org/manual/en/dev/modeling/modifiers/generate/subsurf.html), which creates new interpolated geometry in a non-destructive way (unless you apply the modifier, of course):

here you see a simple example: a simple basic cylinder, where you see the "prismatic approximation"

using the smooth shading you get something better (but it's just a smoothing faked, somehow):

instead you could use a subsurf modifier which creates the "missing geometry", depending on the subsurf level (here is 2)

since the subsurf "smooths" all, you get this weird result, but adding some "corrective" edge loop it gets better:

and you get this

which still has some lesser "prismatic approximation", but now the "smooth setting" works better

which is really quite smooth (and you can improve setting subsurf to 3, 4 or higher levels).

Of course your example image is more complex to "solve" because those are more complex object which only partly have cylindric sides.

You need to learn starting from simpler shapes, and experiment adding some edge loop as I did above, to keep some geometry "straight" and some "smooth" with control. The provided links have much info about this process, but believe me, you need to learn by yourself, failing many times, until you find the way.

You can also upload your file here http://blend-exchange.giantcowfilms.com/ and add the resulting link editing the question, paste it in the text. Then we can help with your specific file and setup.


Setting origin of empty "group" object I have an object that consists of 2 meshes.
To group them, I have added an Empty object and added my 2 objects as children.

I have then put the 3D cursor where I would the origin of the grouped object like to be.

Then I click "Origin to 3D Cursor", but nothing happens. The orange dot stays where it is. I expected it to go where the 3D cursor is.

What am I doing wrong here?

Thank you!

You cannot set the origin for empties. They're just little more than an origin and a world matrix.
For Blender 2.82 and later:
In the header of the 3D View there is a drop down labelled Options. Within you can choose that the transform shall only affect the Parents. Select the empty, press SHIFT+S and click Selection to Cursor to move it to the cursor's location. The location of the children will not be modified.

Note that the "affect only" option already exists since Blender 2.81, but the Snap transform didn't support it before commit 3ba5461af0c8b1273d3daf87d050c24a690273be.
For Blender prior to 2.82:
If you want to have the empty at the 3D cursor's location, you will have to position the empty there. It is necessary to remove the parent relationship first ALT+P and add it back afterwards CTRL+P if you don't want the parented objects to move with the empty. With the empty selected, press SHIFT+S and click Selection to Cursor to move it to the cursor's location.


Can I increase the frame rate of an animation while keeping it the same length? I made an animation in 24 fps and when I render it, I see quite a few bits that are choppy, rendering in 30fps would improve this. The problem is that makes my movie shorter. To keep it the same length I would have to obviously increase the number of frames, but I would then have to shift all my keyframing by different amounts. Is there any way to automatically adjust this?

Beneath the Frame Rate dropdown in the render panel, there is a time remapping section. Set the old mapping to 24 and the new to 30. For more in-depth info, see here: http://www.ffnn.nl/pages/articles/media/blender-tips-and-tricks.php


Problem: Armature deforms mesh when after parenting I am fairly new to Blender and recently I've been working on a new character rig from scratch. I've got the character mesh all drawn out and right now I'm learning from online tutorials on youtube on adding armature to the character. It's been slow but steady progress, until I ran into some problems that I can't solve or find any solution to overcoming them.

This picture below shows my character mesh and the armature I've created before parenting them together.

As you can see, everything looks fine, the mesh is still perfectly normal and proportionate, the bones are all facing the right direction. I've added 4 IK bones to the back of the wrists and ankles and changed the chain length to 2 under bone constrains. Initially, the bones at the knees were bending at an awkward angle, but I've twisted them back to a normal position by adjusting the pole angle.

However, the problem arises when I did the parenting of the armature to the character mesh. Following instructions from a youtube armature tutorial, I went into object mode, clicked on the mesh, then on the armature, before using Ctrl+P to set parent with automatic weights.

The picture below shows the deformation.

As you can see, the Abdomen area is oddly twisted, the Upper Leg and Lower Legs are twisted and an unusual angle. Strangely, the feet are still facing the right way. The knees also bend the intended way, but the Upper legs joining to the Abdomen is twisted.

I know you guys can probably tell there's a stupid thing I overlooked (I'm a noob), but I'm literally at wit's end.

Please help me with some detailed explanation on how I can go about solving this problem. I've watched Sebastian Lague's video on The Basics of Character Rigging. Your help will be greatly appreciated!

I've managed to solve my own question :D

Turns out I found a useful tutorial which suggested that I first bend the bones slightly in edit mode before parenting the armature to the mesh.

It works now!


How to get a posebones global tail position I need to write a script, which makes sure, that the tip of my armature never gets under the ground, which will be a flat plane. how would i access the global position of the posebones tail?

If you have your armature object as arm, you can get its nth bone’s tail local position (i.e. its pose location in armature’s object space) with arm.pose.bones[n].tail, so to get that in world coordinates, just multiply it with the armature’s world matrix: arm.matrix_world * arm.pose.bones[n].tail.

Note however it may be simpler (in simple cases) to use a bone constraint like Floor or Limit Position ones…


Why do measurements change when switching from Global to Local in edit mode? Why does the edge length information shown after ticking Edge Info -> Edge Length under Mesh Display change after choosing Global or Local?

When you are using Local, you are looking at the dimensions relative to the scaling of the object (if scaled in object mode).

Global will show you the absolute measurements.

As an example. Here's a cube that has been scaled 2 times in the $Z$ axis.

If you switch between local and global coordinates in edit mode.

The measurements in local units are relative to the scaling and show that the cube is 2x2x2, whereas the Global units show the absolute measurements showing that the cube is no longer a cube, but a cuboid that is 4m tall.

Why should you care for local or global measurements?

Please read: Why is it important to apply transformation to an objects data?


delete one by one the vertices of a curve? I have a spiral shaped nurbsPath, and i need to delete each vertex from first to last, one for each frame of animation. Can anyone come up with a phyton script to acomplish this? Thanks.

You don't actually want a python script to delete points on your curve. If you delete the points on the curve they will be gone, you will need to create new points or reload the blend file if you want to run your animation a second time.

I think animating the curve's bevel factor is closer to what you want.


Difficulty selecting axis? can someone tell me what's happening here? I'm trying to scale along an axis by moving my cursor over it but it seems to be hit or miss. It just ends up scaling along all the axis'. It seems that with the 2.81 update it's harder to select the scale with the mouse? Is there a setting I am missing somewhere?

Thanks for your answer but through a bit more trial and error I figured it out. My Clipping Distance "END" was set to something stupid like 1000000m. Lowering it down to 10000m solved the problem.

I used a fresh startup file and things worked as they should so I compared the setting of the startup file to my own and found the discrepancy.

When the value was up that high, it had trouble highlighting the desired axis. I don't know if that's a bug or if that's how it's intended.


Blender fail to close if a process is forked from it! Hello I am writing an addon to ease the addon development with Emacs(and other editors... when it works well) and Blender. The goal isto make Blender reload  the addon on saving.

I use ipv4, TCP sockets for IPC. I had to fork a process from blender for the socket communication, because I could not close the socket any other way, the reason: I do not know a way to make a handler for closing in Blender (however it would be very handy).

With the child process I worked around it, when Blender (parent) terminates, the init process (pid = 1) will "adopt" the child, which can be detected with os.getppid(). It works now, but It has a side effect: Blender can not be closed from the GUI, but with SIGTERM. It is funny becuse blender is the most badass software when it comes to closing :) .

My questions:
1. Why is this hapenning?
2. Are there any more suitable ways for IPC or socket closing?

I use 2.76b offical build on Gentoo Linux(kernel version 3.18.12)

I am not an expert programmer so maybe I miss something important

Well, I solved it with daemonizing the child process.

class serverProcess(mp.Process):
    def __init__(self, port=9012, timeout=5.0, host=socket.gethostname(), daemon=True):
        mp.Process.__init__(self, daemon=daemon)
        self.port = port
        self.timeout = timeout
        self.host = host

# many other stuff

RPCserverProcess = serverProcess(port=9010, timeout=3.0)


Very high contrast in indoor model I'm new to blender and am trying to create an indoor model. I've emulated fluorescent lighting with some point lights placed inside a glass cylinder. For some reason the contrast in my model is very high. This is a demonstration of the effect with a single point light. I have added a noise texture to the room.

I think the reason is that light isn't bouncing off the walls and other surfaces nicely. So would this problem be resolved once I add correct textures to the surfaces or do I need to tweak some setting in blender?

In the former case, how things do I need to keep in mind while adding the textures?

The contrast primarily depends on the light in the scene. If it's one strong small light source, there will be more contrast. If there was some light maybe coming from the windows, or other light sources, the lighting would be more uniform and there would be less contrast. Obviously to have ambient lighting you need the light to be able to bounce around the scene, so render settings should allow calculating enough of light bounces:

It does not have to be 128 bounces for everything, just make sure there are a few where it makes sense.


WATER and CLOTH simulation I am relatively new to BLENDER and I was wondering if there is an elegant chance of combining the water simulation with the cloth simulation.
I would like to simulate a washing machine like device, where clothes are interacting with water (and structure). I have done the water simulations and cloth simulations separately in blender before, but combining the two seems to be quite a challenge.
All the support is most appreciated.
Thanks, Uroš

What you want to achieve is coupling, where two physics simulations interact with each other. Unfortunately, Blender does not support this and can only, like you have said, run the individual simulations. You could try this, but note that the results won't be accurate:

Run the cloth simulation, maybe with some settings that make it look like it is floating in water (lower gravity, more air resistance)
After baking the cloth simulation (this is important), give the cloth object fluid physics and set to effector.
Run the fluid simulation.

Though this may produce some realistic results, it will look fake after closer analysis. This is because the fluid reacts to the movement of the cloth, but the cloth does not react to the fluid. There are some simulation programs that do support these physics interactions, most notably Houdini FX. Unfortunately, nearly all of those softwares will cost money.


Python code for Edge Data Bevel and Crease Weight? Anybody has an idea what the python code is to draw the edge data bevel and crease weight sliders?

It seems not to be part of "space_view3d.py"

EDITED:

OK, apparently the previous answer was pretty worthless. Although there is a meshedge.crease property and a meshvertex.bevel_weight property, they do not influence modifiers at all, and their values do not change when changing the corresponding values in the properties panel.

However, there is a way to access these values through custom layers via BMESH. The addon below adds a panel that allows you to influence selected verts / edges or all verts / edges' crease and bevel weight properties.

It does have one weird bug though, which seems to be a bug in Blender, as seen in the GIF above. Even though this does indeed update the respective mesh properites, Blender does not update the display until you also change any value of a modifier on the active mesh.

EDITED 2:

Thanks to a comment from batFINGER, found a solution to the weird behavior mentioned and seen above: adding a bmesh.update_edit_mesh( meshData ) after updating the crease / bevel values. Updated code below accordingly.

To use this, download the code and save it as a python (.py) file on your computer, then install it as an addon (File --> User Preferences --> Add-ons --> Install From File).

The panel appears in Edit Mode only in the Tools tab, under "Crease and Bevel".

bl_info = {
    "name"       : "Crease and Bevel weight panel",
    "version"    : (0, 0, 1),
    "blender"    : (2, 77, 0),
    "category"   : "Tools",
    "location"   : "3D View > Toolbox",
    "description": "Shortcut UI panel for Mesh edge crease and vertex bevel weight properties"
}

import bpy, bmesh

class creaseAndBevelPanel(bpy.types.Panel):
    bl_idname      = "creaseAndBevelPanel"
    bl_label       = "Crease and Bevel"
    bl_space_type  = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    bl_category    = 'Tools'
    bl_context     = "mesh_edit"

    @classmethod
    def poll( self, context ):
        ''' Only show panel if there is an active mesh object '''
        return context.object and context.object.type == 'MESH'

    def draw( self, context ):
            layout = self.layout
            props  = context.scene.creaseAndBevelPG # Create reference to property group

            box = layout.box()                    # Draw a box
            col = box.column( align = True )      # Create a column
            col.prop( props, "whoToInfluence"  )  # Add properites to panel
            col.prop( props, "bevelWeight"     )
            col.prop( props, "edgeCrease"      )

class creaseAndBevelPG(bpy.types.PropertyGroup):
    ## Update functions
    def update_bevelWeight( self, context ):
        ''' Update function for bevelWeight property '''

        o  = bpy.context.object
        d  = o.data
        bm = bmesh.from_edit_mesh( d )

        bevelWeightLayer = bm.verts.layers.bevel_weight['BevelWeight']

        if self.whoToInfluence == 'Selected Elements':
            selectedVerts = [ v for v in bm.verts if v.select ]
            for v in selectedVerts: v[ bevelWeightLayer ] = self.bevelWeight
        else:
            for v in bm.verts: v[ bevelWeightLayer ] = self.bevelWeight

        bmesh.update_edit_mesh( d )

    def update_edgeCrease( self, context ):
        ''' Update function for edgeCrease property '''

        o  = bpy.context.object
        d  = o.data
        bm = bmesh.from_edit_mesh( d )

        creaseLayer = bm.edges.layers.crease['SubSurfCrease']

        if self.whoToInfluence == 'Selected Elements':
            selectedEdges = [ e for e in bm.edges if e.select ]
            for e in selectedEdges: e[ creaseLayer ] = self.edgeCrease
        else:
            for e in bm.edges: e[ creaseLayer ] = self.edgeCrease

        bmesh.update_edit_mesh( d )

    ## Properties
    items = [
        ('All', 'All', ''),
        ('Selected Elements', 'Selected Elements', '')
    ]

    whoToInfluence = bpy.props.EnumProperty( # Material distribution method
        description = "Influence all / selection",
        name        = "whoToInfluence",
        items       = items,
        default     = 'Selected Elements'
    )

    bevelWeight = bpy.props.FloatProperty(
        description = "Bevel Weight",
        name        = "bevelWeight",
        min         = 0.0,
        max         = 1.0,
        step        = 0.01,
        default     = 0,
        update      = update_bevelWeight
    )

    edgeCrease = bpy.props.FloatProperty(
        description = "Edge Crease",
        name        = "edgeCrease",
        min         = 0.0,
        max         = 1.0,
        step        = 0.01,
        default     = 0,
        update      = update_edgeCrease
    )

def register():
    bpy.utils.register_module(__name__)
    bpy.types.Scene.creaseAndBevelPG = bpy.props.PointerProperty( type = creaseAndBevelPG )

def unregister():
    bpy.utils.unregister_module(__name__)


Rounding Evenly the Edges of a Scaled Cube I have a question about rounding the edges (of a cube). For example, I have a simple cube. What I don't get is how do I round the edges (like on an iPhone):

I tried to do something like this, but Picture 2 was the result.

How do I round the ends of my cube like in Picture 3?

A quick way to add rounded corners is to use the Bevel modifier to your cube or starting mesh:

Use the Width, Segments and Profile settings to control the shape of the curved corner or edges. Profile controls shape of the bevel, from concave to convex, but has no effect if your "Segments" settings is less than 2.

You can add a subsurf modifier, as well, to add additional smoothness:

Both of these modifiers  can be applied to your mesh by clicking the "Apply" button... this makes the changes a permanent part of your geometry. Or you can continue to use and render the items within Blnder with the modifiers in place and unapplied.

These are very basic ways to do bevels and rounded corners. Blender has a number of tools to give you control of specific aspects of the Bevel and to limit it to specific parts of the mesh. See here for examples:
Bevel specific edges


What does the "F" mean in-front-of these Grease Pencil brushes? Anybody know what the leading "F" means on these brushes?

F is a "Fake user":

Fake User (shield icon) Keeps the data-block saved in the blend-file,
even if it has no Real User. When activated an “F” will be shown
before the name in the list.

Any data block with no users (for example, material that not used in scene) will be deleted after reloading scene. If you want to keep data block in scene (I think, you want to keep brushes!) you should mark it as "Fake user". In 2.80 version F replaced by shield icon,  but "F" still presents in lists


What are the appropirate axes for arm & hand rig with IK? My bones and mesh's arm get twisted badly after adding IK & FK in layers with -90 input and 2 chains.  I suspect the cause to be axes along the collar, arm and hand.  But, I just cant seem to get them right.

Can someone suggest me the right initial axes' angles form rigging and how to fix it please?
.blend here: http://pasteall.org/blend/index.php?id=51130
Thank you for your help.

Your arm is twisting because, in edit mode, your Arm UpperL bone has a roll of negative 92 degrees, while the corrisponding FK and IK bones have positive 90, leading to a nearly 180 degrees twist when copy rotation is applied.

FK and IK chains bones should be created as duplicates (Shift D) of the deforming bones, so to retain exactly location and bone roll.

I fixed the problem adjusting the bone roll and manually trimming the pole angle of the IK constraints (negative 160), but the correct way should be to delete and reconstruct the IK and FK chains using duplicates of the deforming bones.

The initial angle is generally choosen having the X rotation aligned with the main rotation that will be used, which can help a little when editing animations in the graph editor, but is something like an habit, not a rule; the rule for avoiding twisting is to have the bones exactly duplicated.

Another IK trick is (expecially on legs) avoiding having the bones perfectly aligned, moving the knee joint a little forward, in this way Blender will automatically bend the leg in the right direction.

I suggest you also to set the subsurf modifier after the armture modifier (and set the shading to smooth).


My Alpha/PNG background isn't working I downloaded a file for Blender that have the Sun animated, I only actually changed the animation parameters on the file, but nothing more than that.
Now i'm trying to render it with transparent background (not background at all) checking Transparent and then choosing PNG/RGBA, it works if i open a new file, but with this one, the alpha background isnt just working.

I uploaded the file (.blend) here, if someone finds a way to render it without any background (on this case, black):

http://www.mediafire.com/download/9kbom0wrwdxwpyp/sun.blend

You want to enable the 'Use Alpha' toggle in your output compositing nodes' properties (shown in their 'Properties' panel (N key) when they are selected).


How to enable Intel denoiser using python? I'm creating a scene from scratch in blender (2.83+) using python, and I'd like to turn on Intel denoiser for the Cycles render output.

I've got some code but it's not working yet:

  bpy.context.view_layer.cycles.denoising_store_passes = True
  bpy.context.scene.use_nodes = True

  tree = bpy.context.scene.node_tree # inputs, outputs, nodes, links
  comp = tree.nodes[0]               # result goes into here
  render = tree.nodes[1]             # render layers: images come from here
  denoise_node = tree.nodes.new(type='CompositorNodeDenoise')
  # Link it in:
  links = tree.links
  # links.new(output ---> input)
  link = links.new(denoise_node.outputs[0], comp.inputs[0])
  # XXX: find outputs by name
  # XXX: use "Noisy Image" output (31) rather than "Image" (0)?
  link = links.new(render.outputs[0], denoise_node.inputs[0]) # Image
  link = links.new(render.outputs[32], denoise_node.inputs[1]) # Denoising Normal
  link = links.new(render.outputs[33], denoise_node.inputs[2]) # Denoising Albedo

The problem is that even though I've enabled bpy.context.view_layer.cycles.denoising_store_passes = True it doesn't seem to have taken effect by the time the rest of my code runs; the render node still only has 31 outputs. It should have 39.

Anyone know how I can wait for that setting to take effect before continuing?

I don't think the problem is with the setting not taking effect.  I think the node is there, you just need to reference it by name instead of index since the numbers you are using aren't working.
This should fix it:
link = links.new(render.outputs['Denoising Normal'], denoise_node.inputs[1]) # Denoising Normal
link = links.new(render.outputs['Denoising Albedo'], denoise_node.inputs[2]) # Denoising Albedo

There is a plugin on GitHub that does this: blender_instant_denoise. That's where I found the answer.


Automatically modify primitive based on texture I have a cube with black and white squares on its surface (texture). Like this:

My question is: How can I reshape this cube in a way, that the black parts stick out? I could modify it manually with edge/face loops, but what if I have hundreds of black squares? That would take me days. There must be some automated method.

Thank you for your answer.

Array modifier

As long as the pattern is repeated in a Grid, you can replicate "N" times a mesh along the main axis with the Array modifier:

For your particular case, you'll have to build a mesh made by 3 cubes and stack one Array modifier for each axis, adjusting the Relative offset vector:


How do i get these cracks to disappear? How do i get these dreaded cracks in this sphere to go away? By the way i'm using the cell fracture add on to make a building crack when hit. I've tried to use the subsurf modifier but i am kind of a noob at blender. So can i get these cracks to go away? or am i approaching this animation the wrong way?

If you use the Cell fracture addon, there is an option called Margin. It sets the space ('cracks') between the fractals. If you see these cracks, the reason may be that your Margin is set too high.

Ensure, that it is not too small, because otherwise the physics engine thinks that the parts are intersecting each other, calculate a repelling force and this will tear the the ball apart.


Using blender as a video converter for multiple files? Can you use Blender to convert a bunch of, say, AVI files into .MP4 files? I need to convert about 17 .AVI video files into SEPARATE .MP4 files, but I cannot find any free video converters.

There is no direct conversion for this in Blender, but you can do this kind of thing using the Video sequencer/editor in the video editing tab of blender. First you open the video editing tab:
And then press SHFT+A to open a dropdown menu that will give you the option to add a movie. Press this, and Blender will take you to a browser. Select the movie (.avi) you want, and press 'select'. Now you have added a .avi (if you selected that) in your sequencer:
Now you can have the output of the video type set, and then sequence the video to a location of your choice:
Now you can render animation like you would any normal animation, and it will automatically sequence through the video editor, and output your video.


How to stop my cloth simulation from bouncing like a piece of rubber I looked into the two most recent questions with similar problems, but neither of them had an proper answer, here is my simulation. I applied smooth shading and solidify, has subdivision but not applied, all the other settings regarding collision and cloth simulation are shown in the video along side with the bake. I tried increasing the quality of both the cloth and collision, but would prefer a method which doesn't involve increasing too much of them again due to CPU capacity. I have no idea how to make the cloth do a free fall onto the objects, and then just fall off as normal cloth without bouncing around, please enlighten me, thank you very much!
the video
and the blend file

One thing is that you have the Speed multiplier in 6 meaning that your cloth simulation is progressing "times 6" you also need to take care of other setting but that will depend on the effect that you want.
https://docs.blender.org/manual/en/latest/physics/cloth/introduction.html
Hope that helps


How to create a Folder Dialog? So I need to allow the user of my script to choose a directory that contains images, and then run my script on each image. I already have my script made here. I looked at this question already, but that is about exporting, not importing.

It should look like this:

And should allow the user to choose the directory.

Thanks!

For directories or file paths on any panel it's key using a StringProperty. In order to get a File Dialog instead of a Folder Dialog, set its subtype from DIR_PATH to FILE_PATH.

path = StringProperty(
        name = "",
        description="Choose a directory:",
        default="",
        maxlen=1024,
        subtype='DIR_PATH')

As of Blender 2.8x properties should be assigned using a single colon :

path : StringProperty(
        name = "",
        description="Choose a directory:",
        ...
        subtype='DIR_PATH')

Following example adds a Folder Dialog to the Tool Shelf and prints the path to the console.

Blender 2.8x Update

import bpy

from bpy.props import (StringProperty,
                       PointerProperty,
                       )

from bpy.types import (Panel,
                       Operator,
                       AddonPreferences,
                       PropertyGroup,
                       )

# ------------------------------------------------------------------------
#    Scene Properties
# ------------------------------------------------------------------------

class MyProperties(PropertyGroup):

    path : StringProperty(
        name="",
        description="Path to Directory",
        default="",
        maxlen=1024,
        subtype='DIR_PATH')

# ------------------------------------------------------------------------
#    Panel in Object Mode
# ------------------------------------------------------------------------

class OBJECT_PT_CustomPanel(Panel):
    bl_idname = "OBJECT_PT_my_panel"
    bl_label = "My Panel"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_category = "Tools"
    bl_context = "objectmode"

    def draw(self, context):
        layout = self.layout
        scn = context.scene
        col = layout.column(align=True)
        col.prop(scn.my_tool, "path", text="")

        # print the path to the console
        print (scn.my_tool.path)

# ------------------------------------------------------------------------
#    Registration
# ------------------------------------------------------------------------

classes = (
    MyProperties,
    OBJECT_PT_CustomPanel
)

def register():
    from bpy.utils import register_class
    for cls in classes:
        register_class(cls)

    bpy.types.Scene.my_tool = PointerProperty(type=MyProperties)

def unregister():
    from bpy.utils import unregister_class
    for cls in reversed(classes):
        unregister_class(cls)
    del bpy.types.Scene.my_tool

if __name__ == "__main__":
    register()

Blender 2.7x

import bpy

from bpy.props import (StringProperty,
                       PointerProperty,
                       )

from bpy.types import (Panel,
                       Operator,
                       AddonPreferences,
                       PropertyGroup,
                       )

# ------------------------------------------------------------------------
#    UI (settings Class, Panel in Object Mode)
# ------------------------------------------------------------------------

class MySettings(PropertyGroup):

    path = StringProperty(
        name="",
        description="Path to Directory",
        default="",
        maxlen=1024,
        subtype='DIR_PATH')

class OBJECT_PT_my_panel(Panel):
    bl_idname = "OBJECT_PT_my_panel"
    bl_label = "My Tool"
    bl_space_type = "VIEW_3D"
    bl_region_type = "TOOLS"
    bl_category = "Tools"
    bl_context = "objectmode"

    def draw(self, context):
        layout = self.layout
        scn = context.scene
        col = layout.column(align=True)
        col.prop(scn.my_tool, "path", text="")

        # print the path to the console
        print (scn.my_tool.path)

# ------------------------------------------------------------------------
#    Registration
# ------------------------------------------------------------------------

def register():
    bpy.utils.register_module(__name__)
    bpy.types.Scene.my_tool = PointerProperty(type=MySettings)

def unregister():
    bpy.utils.unregister_module(__name__)
    del bpy.types.Scene.my_tool

if __name__ == "__main__":
    register()

To collect all images in a folder use os.listdir() to return a list containing the files in the folder and make sure that the file type is correct. Simplest way is using a list comprehension:

import os

# path to the folder
path = '/home/user/Desktop/'

# collect all OpenExr files
exr_list = [f for f in os.listdir(path) if f.endswith('.exr')]

# iterate through the list
for i in exr_list:
    print(os.path.join(path,i))

For more details about Property Appearance as well as on how to create Custom Interfaces, have a look into: How to create a custom UI?


How Can I Link My Bones With Mesh? I am 15 years old and I am a beginner in blender and I know how to link armature with mesh.
I downloaded some bones to animate the character, but when I try to link the bones with the character it deforms and I don't know what to do.
If I press with automatic weights that's what happens, it deforms.

You need to select the mesh first and then the bones. The bones need to be the brighter orange.
If you have a character with different sections you may also need to select "With Envelope Weights".
I hope this helps. It is hard to answer such a question without the actual file.


How can I convert Blender file for use by CAD/CAM? I found on YouTube tutorial about drawing cycloid rotor. It is piece of cake for the Blender but very difficult to do on CAD. Can I do it on Blender and transfer to CAD. I tried STL. but no luck.

Many CAD/CAM packages prefer "solid" objects, not the lighter weight mesh files usually exported from Blender. STL is common in additive manufacturing - hence there are many work flows that will convert STL to either STEP/STP or IGES.  OBJ files are also common for conversion,  and many packages allow their import.  Check the Import types for your Application, then export/convert accordingly.
I have many times used STL to STEP converters - then cleaned up in CAD.
Hope this helps. Good luck.


Using a single worker method for properties I am creating many boolean properties and want to be able to control the properties with a single worker function. The property name will be the logic driver. Is this possible? If so how? Or do I need to create a function for each property?

import bpy
from bpy.props import BoolProperty

def worker_func(self, context):
    r""" How to get the name of the envoked property"""
    print (self.name) #??
    """
        if prop_a:
            do stuff for prop_a
        if prop_b:
            do stuff for prop_b
        if prop_c:
            do stuff for prop_c
     """

bpy.types.Scene.prop_a = BoolProperty( update = worker_func )
bpy.types.Scene.prop_b = BoolProperty( update = worker_func )
bpy.types.Scene.prop_c = BoolProperty( update = worker_func )

class HelloWorldPanel(bpy.types.Panel):
    bl_label = "Hello"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'

    def draw(self, context):
        layout = self.layout
        layout.prop(context.scene, "prop_a", text="a")
        layout.prop(context.scene, "prop_b", text="b")
        layout.prop(context.scene, "prop_c", text="c")

def register():
    bpy.utils.register_class(HelloWorldPanel)

def unregister():
    bpy.utils.unregister_class(HelloWorldPanel)

if __name__ == "__main__":
    register()

Thanks you very much.
A.Kal

The update method only gets the reference to the ID-block who owns the property and the context passed. So you have to create a function for each property individually.

You can do this dynamically

import bpy

def callback(scene, prop):
    print("Property '%s' of %s updated to value %s" % (prop, scene.name, getattr(scene, prop)))

def create_update_func(prop):
    def update(self, context):
        callback(self, prop)
    return update

bpy.types.Scene.prop_a = bpy.props.BoolProperty(update=create_update_func("prop_a"))
bpy.types.Scene.prop_b = bpy.props.BoolProperty(update=create_update_func("prop_b"))
bpy.types.Scene.prop_c = bpy.props.BoolProperty(update=create_update_func("prop_c"))


How to bevel inside like Mario's coin I want to make Mario's coin. Now, I made it here so far.

I don't know how to bevel inside, like reference image.

Someone can help? Thank you.

Add a Plane and make it rectangular shape scaling in x axis

Apply scale Ctrl+A -> Scale

Select the plane in Edit mode -> Select the 4 verts and Press Ctrl+Shift+B to Bevel

Select all and press E to Extrude

Select all and press Ctrl+ N to normal faces

Select the circle and Add a Edge Modifier & a Boolean Modifier with the target of plane

Add Bevel Modifier

Watch this preview


Mesh changes its shape in game engine I'm learning to use the game engine and I don't know why a mesh change its shape when I press P key.

This happened when I subdivided the red mesh. I subdivided it because I want the ball collide the red wall but I don't want a rigid wall, I want a soft wall.

Here is the file: http://www.pasteall.org/blend/28811
(The ball moves with left and right arrows)

Thank you!

This is because you modified the mesh in some way after changing the physics Type. To fix, just simply apply the scale on the object, you can quickly do this with CtrlA > Scale or from the 3d view header choose Object > Apply > Scale.


Problem with Displacement in material I just added to my model some fast basics materials to see the preview result. However, it seems that Displacement node in material is curving one egde in strange way. It started to happen after some vertical subdivisions I added to the mesh. This effect is visible on the bottom edge on the render preview:

How can I get rid of this effect?

Displacement works by using existing geometry on the object.

It looks like your building has very little geometry, so only the small amount of existing vertices are moved causing this bending effect. To fix this, just select all of the edges in edit mode by pressing A, and subdivide a few times to create more geometry. As a little note, displacement often works best when the faces on the object are mostly squares.


How to connect mesh vertex groups with bones? I can't understand, how to connect mesh vertex groups to bones and I'm beginner in blender. In first step I've created a new one file (download) with Cylinder and added two connected bones. After that, I've added Armature object as Modifier to the Cylinder mesh.

After that I've created vertex group named g1 in Cylinder mesh.

And painted in Weight mode:

But I can't understand, how to assign connect this 'g1' vertex group to the bone named 'Bone.001'. After that manipulations, when I'am trying to rotate bone 'Bone.001' in Pose Mode, no mesh deformation applied.

How can I "glue" end of the 'Bone.001' to the 'g1' vertex group?

Thank you.

When using the Armature modifier with Vertex Groups enabled :

the vertex groups should have the same names as the bones so they can be bound together


Moving a bone moves only the first level of child, not all levels of children I have a cylinder, with a child piston coming off it. I made the piston by following this tutorial. The piston is stuck to the cylinder by making one of the "bearings" at the end of the cylinder into a child.

When I move the cylinder around in edit mode, the piston moves with it, which is what I want to happen.

I am trying to rig some bones up for this, and I have put a bone and set the cylinders parent to be the bone. When I move the bone in pose mode, the cylinder moves, but the piston does not. I rigged the cylinder to the bone by selecting "Armiture Deform -> With automatic weights". I tried to set it as a bone, but it teleports the cylinder somewhere else. No idea what is up with that.

Why does the piston not move with the cylinder when I am moving the bone? How can I make the piston move with the bone in pose mode?

You used automatic weights?  Click the cylinder and go to weight paint mode.
On the right side under Vertex Groups click on the bone in question. You will probably see that the cylinder is red and (depending on how many bones it has) green. But the piston is probably blue. There are two ways to fix this. You can extrude your current bone(s) so that you have a bone for the piston and then re-parent it with automatic weights. Or you could select the piston, in edit mode select all of the faces of the piston. Then find Vertex Groups on the right side of the screen. Click on the bone that you want the piston to move with. Make sure you are using a weight of 1.000 and then click assign.
Hope that this helps!


Can I use Blender like After Effects or Nuke for motion graphics? I was wondering if there's a way to use Blender's 3d Space (not the compositor!) similar to After Effects without adding additional lights to do 3d motion graphics.

I'd like to use the motion tracker to solve a camera from a video and add some flat titles coming to the camera. If I add lights, the appearance of the texture changes. In After Effects, as well as in Photoshop, there are no lights to be added and they both give a flat even look to all the items you import (photos, vectors, video clips). How can I get the same evenly lit effect in Blender?

In this video you can see the effect I'm trying to achieve:
https://youtu.be/kFLuiik8RC8?t=469

The guy tracks the chat to the camera but he doesn't need to add lights in AE to make the chat appear. Can I do the that by using Blender as well?

You can turn off the world strenght down to zero, delete all lights, set the color management as standard (sRGB), and use an emission shader set to 1 strenght instead of a principled BSDF.


Does the Grease Pencil Tool create Vertices? I wonder, it would appear from the demos showing how to use the tools that the points from creating grease pencil lines and fills basically behave like vertices.

So could I treat those points like vertices, that I can use all the tools and modifiers the same way as using vertex from shapes?

I hope I understand your question correctly... It seems like you want to convert your grease pencil to vertices?! When you convert Grease Pencil to geometry you can select path, bezier or polygon curve... It will convert it to curve stroke which you can convert to mesh object, and then you can apply all the modifiers you want...


How to install Blender on a Mac so that multiple user accounts have access to it? After I moving Blender to the 'Applications' directory it works fine. The trouble starts when another user with his/her own account on the Mac wants to run Blender too when logged-in to his/her account. Then it tells you that you don't have the right permissions to open the Application 'Blender'.

I am not new to Linux/Unix permissions and have tried to set the permissions, but even if I set it to world-readable/writable/executable, it still doesn't.

(Mac OS Sierra)

Having tried many more things, what finally worked was:

Changing the ACL permissions of the Applications/Blender directory through finder with the 'Get info' option and set use the 'Apply to enclosed items' option in there (cog wheel icon at the bottom, once you've changed a permission setting).

Even though in there I set the specific user to allow read and write (even using 'Apply to enclosed items' before, it did not do the trick. Only when I allowed staff to do this, it worked. Yet that user was not a member of the group 'staff'. So even though this worked, I don't really understand why this worked.


Equirectangular world-map UV layout - the sequel TL;DR: Is it possible to edit a UV projection with the same precision as one does a model in Edit Mode, or alternatively, can one export a UV projection as a new mesh?

The Details: So as mentioned in my previous post, ...

Equirectangular world-map UV layout

... I've been building a globe with adjustable continents to mess around with continental drift patterns as my first learning project, with the idea that I could somehow project the new continent configuration out as an equirectangular map - these are a standard for geographical mapping programs.

http://en.wikipedia.org/wiki/Equirectangular_projection

After a lot of tweaking I've gotten my globes clean enough to give me a semi-useable map:

it's not equirectangular however, and there is still a lot of distortion at the poles. I would like to be able to edit the projection itself, but I can't seem to figure out how (if it's even possible). UV sculpt is too imprecise, and Grab/Scale/Rotate seem to just affect the projection as a whole no matter what is selected. Ideally it would be nice to be able to edit the projection with all the flexibility of Edit Mode.

Is this possible, or alternatively, can one export a projection as a mesh and continue working on it that way?

Thanks lots for your time reading this and potentially helping me out. ^_^

FYI: The continental position pictured is earth in +- 100-150 million years' time. Some additional changes are predicted (such as East Africa breaking off from the mainland along the Rift Valley), but I'm not at the point where I can model THAT yet.

Following SixthOfFour's suggestion, I spent the evening trying to figure out how to bisect my globe along the previously defined seam (I discovered the knife tool! Yay! ... surprisingly hard to figure out how to cut a mesh in blender cleanly) and deform it in the reverse of the answer he linked. I got as far as to cut my globe cleanly, but I'm stuck at the deformation - I have no idea how to "unbend" in blender. The Simple Deformation modifier wasn't of any help, and I couldn't really manage with any of the other deformation modifiers either.

At least I've made some progress, so thanks SixthOfFour. Now I just need to figure out the deform itself.

For interest' sake, here's the cut now neatly disecting the continent formerly known as ... The cut runs all along the seam, from pole to pole along the int'l date line:

NoviceInDisguise helped me realize that I wasn't understanding transforms in edit mode fully, which lead me to discover proportional editing this morning. Turns out my selection circle in the UV Editor had gotten so large that I was grabbing everything and then some. Still not having much joy manipulating the UV map since the continental geometry doesn't want to behave according to the underlying grid's movement, but at least I have two avenues to explore now ...

So the UV mapping option is out. Despite finally figuring out how to remesh the globe properly using shrinkwrap, (negative projection of a UV Sphere onto the surface) thereby integrating the disparate bits of the object, deforming the projection to be equirectangular just doesn't work - there is simply too much squashing at the poles to accurately pull things into position according to the grid. So my only hopes now rest with an unwrap as suggested by SixthofFour.

Well, I've taken this project as far as I could. I'm out of ideas. I tried unwrapping the mesh itself as suggested by SixthofFour by using a cylinder cast which I then intended to unwrap along the previously cut break, but the cylinder didn't come out clean despite my best efforts. I've linked my final blender project below for anybody who'd be willing to give it a try:

http://s000.tinyupload.com/?file_id=65979981948334151059

Thanks lots if you do take the time to do so.

Since you say you don't require any texturing, I've tried to accomplish what you want without any UV unwrapping, and I think I've got it working.

Add a plane, tab into Edit mode, make sure everything is selected (it should be, but if it's not, hit A once or twice until it is), scale by 2 on the X axis and add a loop cut like this (CtrlR, place the mouse near one of the longer edges, left click to make the cut, then right click to release without moving the newly created edge).

Select everything (A twice) and make some subdivisions (W > S). If you have the tool shelf visible, the settings for the subdivisions should be available at the bottom of it, otherwise hit T to show it, or F6 to open a dialogue with those settings.

Extrude the continents. Since you explained your own method of doing this quite well in this question, I'm not going to go into details about that. What I've done here is simply selecting some vertices by dragging the circle select tool around randomly, then extruding.

Make sure the bottom vertices of the continents are selected. With the way I extruded the continents, I simply hit CtrlNumpad +, but with your method, you may need some more elaborate way.

Select also the rim of the plane.
If none of the currently selected vertices are on the rim, hold Shift while selecting one corner vertex, then hold Ctrl while selecting the other three corners, then finally click the first corner again while still holding Ctrl.
If some of the currently selected vertices are on the rim, hold Shift while selecting a currently unselected vertex on the rim, which is next to a selected one, also on the rim, then, while holding Ctrl, select another vertex on the rim, next to a selected one, also on the rim, and make sure the distance between the last selected one and the one you're about to select is covered by a straight line of only unselected vertices. If the distance between them passes a corner, first select that corner vertex while holding Ctrl.

Invert the selection (CtrlI) and delete the vertices that are now selected (X > V).

Switch to face select mode (CtrlTabNumpad 3). Now you need to select all the faces that are connected to the rim of the plane. Select a face at one end of a continous string of faces, then, while holding Ctrl, select the face at the other end of the same string of faces. While holding Shift, select a face at one end of another string of faces, then, while holding Ctrl, select the face at the other end of the same string of faces. Repeat this until all the faces that are connected to the rim of the plane are selected.

Delete the faces that you just selected (X > F).

Zoom in and pan around to see if there are any edges like in the image below. If there are, switch to edge select mode (CtrlTabNumpad 2), select and delete them (X > E).

Tab back to object mode. Add another plane and repeat steps 1 and 2 above on the new plane, possibly with fewer subdivisions if you so desire. This plane will be the ocean. In the following I will refer to the first plane as "the continents" and the second plane as "the ocean".

If you do require UV unwrapping, now is the time to do it. In that case, tab into Edit mode, select the vertices highlighted in the image (make sure the corner vertices are not selected), add them to a new vertex group (CtrlG > A) and mark them as seam (CtrlE > A). Do this for both the planes before unwrapping.

Add an empty and set its rotation to -90° on both the X and Z axes. Select both planes (select one, then hold Shift while selecting the other). Add a Simple Deform modifier, set it to Bend, set the Origin to the empty and the angle to 180°. This will add the modifier only to the last selected of the planes, so move the mouse to the 3D view and hit CtrlL > I to copy the modifier to the other plane. Apply the modifier to both planes. A workaround to apply modifiers to several objects at once, is to press AltC > M with all objects selected.

Change the rotation of the empty to 0° on the Z axis (but keep it to -90° on the X axis). Once again select both planes and add a Simple Deform modifier, set it to Bend, set origin to the empty and this time set the angle to 360°. Copy the modifier as above, and apply it to both planes as above. Now you can safely delete the empty if you wish.

The next step depends on whether you UV unwrapped or not.

If you did not UV unwrap:
Select the ocean, tab into Edit mode, make sure everything is selected and remove doubles (CtrlV > D).
Tab back to Object mode and select the continents. Tab into Edit mode, make sure everything is selected and remove doubles (CtrlV > D). If you have any vertices and/or edges that aren't connected to any faces, select those and delete them.

If you did UV unwrap:
Select one of the planes and tab into Edit mode. Make sure everything is deselected (CtrlA to deselect if anything is selected). Go to the Object Data tab, select the group and click Select. Remove doubles. The group can now be deleted by clicking the - sign next to the vertex group list. Repeat this for the other plane. Then follow the steps to delete vertices and/or edges that aren't connected to any faces as explained above under "If you did not UV unwrap.

If you simply select everything and remove doubles after UV unwrapping, the UV map will look like this.

If you follow the steps above, the UV map will look like this.

Tab back to Object mode and select the ocean. Set the origin to geometry (Object > Transform > Origin to Geometry).Scale it up slightly, to make the continents slightly sunken into the ocean. Snap the cursor to selected (ShiftS > U). Select the continents and set origin to the 3D cursor (Object > Transform > Origin to 3D Cursor).

Hit Z to go into wireframe view mode. Add a bone (ShiftA > A > S). Tab into Edit mode and make sure the whole bone is selected. Rotate the bone to point roughly to the centre of one of the continents, and scale it down a little so it doesn't reach the surface. This will be the control bone for an entire continent. Extrude it a few times (with the bone selected hit E; you will need to select the first bone before every extrusion, or the extrusion will come out of the new bone). Point the extruded bones to the edge of the continent. These extruded bones will control the deformation as the continents collide. The more bones you add, the better control you will have. While still in Edit mode, add a control bone for another continent, and make some extrusions.

Once you have all the bones, tab into Object mode and make the armature the parent of the continents. Select the continents, then hold Shift while selecting the armature. Hit CtrlP and select a suitable option from the drop down menu. I used "With Automatic Weights" in my example, but I strongly suggest you use "With Empty Groups" and manually weight paint. I'm not going to go into details about that, but basically you'll need the groups affected by the control bones for whole continents to have that continent all red, while the groups affected by the extruded bones should be red around the tip of the corresponding bone and fade to blue further away. There are several questions about weight painting here on Blender.SE that will most likely be helpful if you don't know how to do it. You may want to rename the bones before parenting, to make it easier to know which bones controls what.

Hit Z to go back to solid view.

And the result:

At this point you can join the two objects into one. Make sure they do not have any UV maps and/or vertex groups with the same name. Rename the UV maps and/or vertex groups if necessary, but keep in mind that if you rename any vertex groups that are controlled by bones, you need to rename the corresponding bones as well. If the two objects have identically named UV maps and/or vertex groups, these will be merged into one map or group in the joined object. Once you made sure about this, select both objects in Object mode (first select one, then, while holding Shift, select the other one), then press CtrlJ. Don't use the Boolean modifier, as this is sure to mess up the rig.

I have two reasons for using a plane for the ocean, rather than adding a sphere directly. The planes are easily scalable to equal size, so no need to calculate the radius of a sphere, and they will have the same origin.

Credit should go to @LeonCheung for this answer, which I used to create spheres from planes.


Fill gap after circular cut How can I fast make circular wall in mesh, which I've made using curve and Knife project tool?

The easiest way is to use the 'Bridge Edge Loops' tool in the specials menu, accessed by W.

Select the edges around your holes on both sides of the mesh (click to select an edge whilst holding Alt to select edge loops).
Open the specials menu W.
Select "Bridge Edge Loops" and you should end up with the result you desire.

Alternatively, you could simply use a boolean modifier with a cylinder. This will automatically create the internal faces.


How do you make a movie loop in the sequencer? I have a movie file that I want to loop thousands of times. It's a one-second background loop behind a podcast.

I tried stretching the video strip past the end of the content, but it just produces a still image of the final frame when I do that.

Work Fine 2.79
https://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Sequencer/Loop_Media

"Pick a Scene, Image, or Movie strip in the Video Sequence Editor, and use the Strip menu to find the Loop Media operator. A speed effect strip will be created to accomplish the looping effect"

Excelent Script


Add a Texture to an Object using Python and Blender 2.8 i have trouble to get a script working within Blender 2.8. The following function work perfectly for me in Blender 2.79, but not in 2.8.

def CreateMaterialFromImage(matName, imgPath):
    '''Creates and returns a material from an Image'''
    realpath = os.path.expanduser(imgPath)
    try:
        img = bpy.data.images.load(realpath)
    except:
        raise NameError("Cannot load image %s" % realpath)

    # Create image texture from image
    cTex = bpy.data.textures.new(matName, type='IMAGE')
    cTex.image = img

    # Create material
    mat = bpy.data.materials.new(matName)

    # Add texture slot for color texture
    mtex = mat.texture_slots.add()
    mtex.texture = cTex
    mtex.texture_coords = 'UV'
    mtex.use_map_color_diffuse = True
    mtex.use_map_color_emission = True
    mtex.emission_color_factor = 0.5
    mtex.use_map_density = True
    mtex.mapping = 'FLAT'
    return mat

It seems to be that the material.texture_slots were removed.

Under following Link https://lists.blender.org/pipermail/bf-blender-cvs/2018-April/106620.html i found the note:

  Texture slots for materials, lamps and world were removed. They remain   for brushes, particles and freestyle linestyles.

So my question is where do i find this property now or how could i change my code to get things done?

Thanks for your help!

EDIT:
https://en.blender.org/index.php/Dev:2.8/Source/Python/UpdatingScripts
This seems to be an interesting link for people run in to issues by updating their scripts to 2.8. Unfortunately there is no solution for my problem listed, yet.

I've been able to do this in blender 2.80 as follows:

mat = bpy.data.materials.new(name=name)
mat.use_nodes = True
bsdf = mat.node_tree.nodes["Principled BSDF"]
texImage = mat.node_tree.nodes.new('ShaderNodeTexImage')
texImage.image = bpy.data.images.load("C:\\path\\to\\im.jpg")
mat.node_tree.links.new(bsdf.inputs['Base Color'], texImage.outputs['Color'])

# Assign it to object
if ob.data.materials:
    ob.data.materials[0] = mat
else:
    ob.data.materials.append(mat)


Make particle hair affected by gravity? Using Blender 2.81, is there a way to make dynamic particle hair fall and hang like in real life, affected by gravity?

I have made a scalp with hair and combed it how I want it. If I then enable Hair Dynamics and rotate the scalp 40 degrees, the hair will also rotate 40 degrees and stay that way (after jiggling a bit, back to it's combed state). But in reality, the hair should keep hanging straight down due to gravity even when the scalp is rotated.

Is there a way to achieve this effect?

Physic simulations in Blender don't update at any time (and that's a good thing, so you don't melt down your computer and you keep a responsive software as long as you need).

In order to the gravity affect your hairs, you have to start the playback. You have the playback controls buttons on the bottom left of your screenshot.


Replace Mesh not working? I have a spaceship that I want to have "flames" come out when the spacebar is pressed. I have set up a replace mesh thing (I have a mesh with flames in a different layer and added some logic bricks to replace it when the spacebar is pressed), but for some reason, I can't select the "Spaceship with flames" mesh on the logic brick. This is the mesh I want to have replace the spaceship.

Here is what is happening when I try to replace the mesh.

There is no option to select the spaceship with flames.
If you can help, please do. Thanks!

Be aware object names are not mesh names!

(Blender) objects and (Blender) meshes are two different entities. They can but do not need to have the same name.

The replace mesh actuator allows you to search for meshes by (mesh name) within the same scene.

I suggest you select your flame object and check the mesh name at properties/mesh


How do I make a super oily surface? Like the patty in this burger :

As you can see, its looks very wet from the oil, its covered with liquid. How to achieve this?
And here is my patty and its nodes settings, it looks dry:

Comment echo: add better lighting. A flat grey background is a recipe for boredom. Try the HDR textures in blender’s own data files as environment textures.
As for the oil, try the clearcoat setting in the Principled shader. It was made for just such a purpose.
Also, nice burger


See-through faces, but just in game and probably not because of normals? I modelled and animated some low poly game characters with Blender and when I import them in Visual Studio MonoGame there are some parts of the modells see-through as you can see in the picture.
I read a lot about the normals for the faces and recalculating them or set them manually but it's not working for me. So please help.
Here are some pictures, sorry for the bad quality of the second.

As you can see the neck is see-through, but recalculating and manually flip the normals of the faces for the neck didn't helped.

This was actually my question, I managed to solve it.

The problem was, that there were some vertices, which haven't got any weight in the animation and therefore the game engine couldn't render their faces right.

I fixed it by editing more weight to this vertices.

The black area was the real face of the ape, for some reason you weren't able to see it even from backside.


Smoke Render Not showing Smoke but the Flow Source(Particle System) When I render the smoke simulation all I see is the particles not the smoke itself.

The Way I want it.

The Way I see it when I render.

You need to uncheck emitter in the render panel of the particle system.


Sorting Collections Alphabetically in the Outliner I have numerous objects categories that I used to organize in Groups through a script in Blender 2.79.

I'm now trying to switch to blender 2.8 and use collections, but in the outliner the only listing order that I can get is by their creation. There is an option "sort alphabetically" but it only works for objects. In Blender 2.79 Groups were listed in alphabetical order, I don't understand why this has been changed.

Anyway, does anyone have an idea on how to circumvent this problem? Would it be possible with a script? There is no way I can switch to Blender 2.8 if I don't fix this issue!
Thank you very much.

Federico

Fully recursive and optionally case-sensitive:

import bpy

def sort_collection(collection, case = False):

  if collection.children is None: return

  children = sorted (
    collection.children,
    key = lambda c: c.name if case else c.name.lower()
  )

  for child in children:
    collection.children.unlink(child)
    collection.children.link(child)
    sort_collection(child)

# case_sensitive sort, (default is False)
case_sensitive = True

for scene in bpy.data.scenes:
    sort_collection(scene.collection, case_sensitive)


How to make a realistic Pepsi material? I'm trying to make a realistic material of pepsi. I want it to look like this:

Without the ice cubes of course. I found this, but it doesn't look very good. It is also going to be a fluid simulation.
Thanks
Daniel

What I landed on was similar to boots, but using a Clearcoat.

I couldn't shade smooth here, I'm assuming you can at some later point in the process.
As far as the fluid sim portion, to me the main thing to aim for is pronounced and persistent bubbles.  I don't know if that can be fully achieved with these controls:

I think in the longer term an emitter/rigidbody system of some sort would be necessary to maintain the appearance.
All I can say is good luck, because baking these sims to test behavior is very time consuming.


Geometry Nodes instantiate mesh primitives at points I'm trying to instantiate line meshes with a random number of segments at the vertices of a mesh.
Blender 2.93 has shiny new mesh primitive nodes to instantiate meshes in your geometry nodes network. However the Point Instance only accepts the type Object or string and since all the mesh nodes have the output type of Geometry it seems to me that it's impossible to create a number of meshes at certain point locations.

Found a workaround:

Create an empty object that stays at the world origin.

Create a collection named lines.

Create a mesh object in the collection, and add a Geometry Node modifier.

Create a network that outputs the position of the mesh object.

Create a network that creates the geometry based on the location. I've used the x offset here to create a line segment with x offset count. The DeltaX input is the ratio for each increment.

Now duplicate the mesh object until you have enough variations. (You can do this quickly by doing duplicating once, offseting by DeltaX and pressing shift r).

Reference the lines collection with the Point Instance node to access the geometry points.

Hope this helps someone :)


OptiX CUDA out of memory error when rendering I'm getting the OPTIX Cuda error - out of memory, when trying to use OptiX for rendering. When I switch to normal CUDA, there's no issue.
Is it beause the OptiX is still work in progress and this is some random bug? My scene is not THAT crazy for it to run out of memory.
I'm using RTX 2080 Super Max-Q. I'm not sure which other information would be useful here.

The likely reason why the scene renders in CUDA but not OptiX is because OptiX exclusively uses the embedded video card memory to render (so there's less memory for the scene to use), where CUDA allows for host memory + CPU to be utilized, so you have more room to work with. I do know that OptiX isn't fully stable at the moment, Blender is still working on support for NVIDIA cards, so it could be that.
Things you could do to help make sure it renders:

Reduce your texture resolution. Bigger textures == a lot of memory eaten up
If you're using sub-surf modifiers like (especially adaptive subdivisions which are super costly) try to set them to lower # of subdivisions, or not use them at all.
Reduce the number of vertices in your scene

Personally, I've also tried:

Reducing the complexity of textures: Really intense procedural generated textures eat tons of memory too


Is there a way to generate an armature from a collection of points/vertices? So I have some data exported from OpenCV that captures human movement from videos, such that each joint is mapped to a point in 3d space for each frame of the video, and saved into a CSV for later use.

I have a rough idea about how to load these points through an import script in blender, and sequence the frames into an animation, but is there any way I could possibly take these points and turn them into a proper rig? Is there a plugin that does this already? I've done some googling with no luck, and the recent questions don't seem to ask about this specifically. I understand there might be some complication in describing relative rotations from translations alone. If this is the case, I'm fine trying to figure it out on my own.

I would do it this way, requiring Blender and Blender Add-On: Sverchok and/or maybe Animation Nodes (!).

Supposedly all this can be done using Python Script, but for artist, maybe Sverchok or AN Animation Nodes is A LOT easier.

You start with some kind of data of point cloud. In CSV or whatever. I supposed you have recorded the data for each frame. I will start with just a single frame, this will be for the Rest Bones.

Load the CSV data into Sverchok via Text In node. Right away here, I am turning the point cloud into group of edges, merge, and this will be for the Bones, via Skin Modifier.

Poly Edge -> Skin Modifier -> Create Armature -> Bones! Magic!

Here, sometimes you need to Clear Parent for the Bones.

Next, we simply pipe in the animation data into the Pose Bone, frame by frame using Animation Nodes or Sverchok. Here is Sverchok way:

So.... that's pretty much it the basic idea.


What are some useful ways to optimize my work flow while using blender? I am not sure exactly what I am missing when it comes to the optimization of Blender but I wonder if maybe there is some tips that may help me to better optimize my scenes to get a great output while also balancing performance.

I feel that lacking knowledge is the problem in this case. So I ask...

EXAMPLE: This image looks awesome in Blender but this is the output image at 500 samples and it looks like crap. Like a smudged charcoal painting or water color painting. Not what it looks like in Blender. In blender it looks great. Almost all my images come out like this. I add Light, I add occlusion, I reduce and raise Light bounces, I have 8 lamps in this scene as it sits. it feels to me like all the light is getting absorbed by the objects in the scene. But when I render the scene in blender. The image in blender is crisp clear and you can see it. I veiw the saved image, and it looks like this. like smudged water color....

NOTICE: There are very little fireflies. This is why I say this question is not a duplicate. I don't really have an issue with fireflies. Just poor quality output.

"Look great" is a term that means nothing (or means completely different things for everybody). "Beautiful scenes" How do we quantify that?

I happen to love Georges Seurat's drawings and Paul Signac's paintings. They are just a bunch of dots and unsharp images for others... Does Hyperrealism look great? Is this beautiful? I don't really care...

If you want to talk about noise and rendering time and concrete issues, then let's talk about them.

Noise is part of rendering with cycles, the more samples the less noise you will have, that simple.

The more samples the more computing time you need.

Every scene is different, depending on the complexity of your shaders you might need more or less samples to create an image with an amount of noise you can live with.

100 samples might be enough for certain things, some scenes need several thousands.

There is no magic button to render with low samples, fast and with no noise. Why would anyone not use it if it existed?

The closest thing to that is the new denoise option on 2.79, but even that comes at a price: it adds a bit more vRAM usage to the normal rendering, and still needs a decent amount of samples to work correctly.

Is your GPU not up to the task?

You have some choices: Get a better GPU, render in CPU or be patient.

Low Cost-Quality-Rendering Time... you can choose any two you want.

3D rendering is a fine balance of expectations vs the reality of your computing power. Cheat as much as you can, simplify, optimize, decimate, bake, do whatever it takes to get closer to what you want within the limitations of your hardware and the time you have on this earth to render something you like.


Blender Rigid Body Physics Trapdoor Effect I'm doing an animation in Blender where a bunch of cans are falling in an enclosed space. I give the cans a rigid body and enable collision on the bottom plane that they land on.

What I'm trying to do is make it so after the cans land on the platform there's a trapdoor that animates open causing them to fall through the floor. When I tried to do this by detaching part of the plane and animating it the cans don't fall through.

Can you guys help me figure out how to achieve this effect? Thanks. I feel like i'm missing a key element in these physics.

For completeness, far fetched problem sources are included.

The cans should be set to active and dynamik. Since they are cylinder-shaped, I will set the shape to cylinder.
The enclosing platform should be set to passive. The shape property is set to mesh.
The trap door should be set to passive and animated.


Can Cycles renders be done from the command line? It seems that Cycles is mainly built in the form of Python scripts (as far as I can tell). Is it still possible to use Cycles to render a .blend file from the command line?

Yes you can, This will render a single frame

blender --background filename.blend --render-output //test_ --engine CYCLES --render-format PNG --use-extension 1 --render-frame 5

This will output a file named test_0005

While experimenting, I more or less substituted CYCLES with the parameters I found here. You can check the link to see what they mean and or do.


Texturing - Best approach to apply textures from photos I'm modeling a piece of furniture that I have in my house, so I have full access to the model. I'm starting with Blender only for a couple of weeks so I started with simple geometric forms.

My question is related with texturing. I really wanted to mimic the look of the furniture that I have so, what is the best way to extract those textures from photos? Or, how to take those photos? Is there any kind of software to help preparing these textures? Or is this approach the wrong one? Should I use generic textures?

It seems these are many questions but I think it's all related.

Thanks in advance!

UPDATE:

As mentioned by Greg Zaal taking photos to use in textures can be full time project on it's own, especially if you want to take the time to make them reusable elsewhere in other projects, which frankly is the only situation I would see it being worth the trouble to make new textures from scratch.

As mentioned, textures should have as generic as possible lighting as to avoid visible shadows, lighting gradients and shading artifacts that would ruin tiling, an no reflections at all, since those will be added by the software from the virtual 3D scene at render time.

Besides that if you want them to have any value besides the very specific scope of the current project, reusable wood textures are generally desired to be tileable or repeatable. That means they are edited in image editing software in specific ways so they can be repeated side by side without noticeable seams or borders and avoiding repeating patterns.

So unless for some reason you want a very very realistic, down to specific wood features in the right places, and very true to the original recreation of your furniture (which is a perfectly valid goal, if that is what you want) I would recommend downloading some "off the shelf" generic textures from the internet.
There are plenty good quality tileable textures everywhere, I am sure you can find some that suit your need, with the same wood type or one that is similar enough.

One other desirable alternative you may be interested in, since your goal seems to be learning Blender, is to go the procedural way and try to use computer generated materials and textures which can have a high reuse value.


where can I get ADDONs for 32 bit blender due to my PC's 32 bit OS, I had to download blender 8.0 32-bit. After I tried to install an add-on on the face build, it didn't work saying "you are trying to install a 64-bit add-on into a 32-bit blender". Then I browsed a lot trying to find a 32-bit add-on but in vain. Can anyone suggest a solution, please?

This depends on the add-on you are trying to install.
Most add-ons are ‘python code’ only. Python is a programming language that is ‘text only’ and this means that it does not care whether it is running on a 32 or 64 bit system or whether on Windows, Mac or whatever - the code will still run regardless.
Some add-ons, however (such as Animation Nodes or Molecular) include additional libraries to perform some functions. These libraries have to be built for the specific system and it is those that are specific to 32 or 64-bit or Windows, Mac, etc. You need to contact the developer of such an add-on to determine whether a version exists for your particular system.


HDRI? Sun Lamp? Or Emitter Objects? I am stuck with a problem I can't find an all-over-board solution for.

I have a simple room(see the image) with a few windows. Now I would like to actually film an animation in this room (not in the image yet). To create a nice filmic look, I also need good lightning.

As far as I know I have following options to light up my scene.

Use HDR Images
Use Lamps (Sun, Spot, Hemi)
Use Emitter Objects

In the screenshot below I used the first method, an HDRI Image. But I want to place some more planes arround the windows with JPegs on it to keep the Illusion of having buildings arround the room and using HDR Images is causing a massive time of rendering.

Another step I think of is of course letting the lamp at the ceiling emitt some light.

the actual question is:
Woudl you light up the scene like i did (or will), or do you have any other suggestions regarding the light and scene set up?

Thanks in advance!

Download Blend File

(Disclaimer: subjective answer based on my own opinions)
Depending on the look you want to go for and the render engine:
1. The Internal Render Engine
You want a daylight scene
I would recommend setting the sky to a generated type. (Have a look in World > Sky. Enable Generated and Blend. Try changing the color swatches, especially the Horizon one) If this works for you, good. Place the jpg:s where you want. In their material settings enable Shadeless (if my memory isn't failing it's under Specular) and disable Traceable (near the very bottom). Oh, and to simplify your life, have a look at the Import Images as Planes add-on. It sets up the UVs, the aspect ratio and the materials automatically.
You want a scene lit by the lamp.
I'd consider using an area lamp (add > lamp > area) that is near the actual lamp's position and shape (See in properties > lamp). You could try to move it down a bit to better light the ceiling of that's what you want to go for. Playing with the lamp's color can also yield interesting results.
2. The Blender game engine
Please consider trying baked light. Andrew Price made a good tutorial about it here: http://www.blenderguru.com/tutorials/introduction-baking-cycles/
You want a daylight scene
This could be tricky. Your best bet could be to use spot lamps that shine through the windows. You could have the jpg:s in the way as they don't cast shadows by default. I am not sure that the results would in any way be convincing.
You want a scene lit by the lamp
The best I can think of is using a spot to illuminate the floor. Maybe combine it with point lamp to fake indirect lighting of the roof.
3. The Cycles render engine
You want a daylight scene
You want to use your HDRI
Crank up the emission's strength. Making the jpg:s work requires some extra trickery, refer to this: https://m.youtube.com/watch?v=8auLtssTkEg
You probably want to disable the planes blocking light. Simply replace the diffuse by a transparent node.
You want to use the JPG:s as a source of light
Simply use them as they come out of the Images as Planes add-on. Maybe strengthen the emission. In this scenario you can discard the HDRI
You want to make a scene lit by the lamp
Simply make the neon tubes emissive.
I hope this helps.


Does Blender continue to work in the background despite "No responding", the blue loading circle and the "milky" picture, and is it worth waiting? I'm currently trying out the Smart UV Project function and haven't quite got the hang of it yet. After pressing OK in the Smart UV Project window, the blue loading circle of Windows 10 appears. Blender itself seems to have hung up somehow. The second time I press on the Blender window, I get "No responding" at the top of the window bar of the program and the image becomes "milky".
My question is now: Does Blender continue to work in the background despite "No responding", the blue loading circle and the "milky" picture, and is it worth waiting? If this does not work, what alternative do I have?
And why is there actually no loading bar with this function?

Yes indeed it does. No progress bar is because of threading: Blender was expecting the script or whatever to run quickly, or simply can't run multiple threads with the process for whatever reason (EEVEE is an example as Blender cannot multithread OpenGL to EEVEE render and GUI render at the same time), and the GUI updater is waiting for the process to finish.*
*In some rare cases, something could have gone wrong that was also causing the hold-up.


Array along a curve that is made up of loose parts I want to lay out several pieces of a barrier along a race track, but the barrier must have openings and it is generally made up of multiple non-connected pieces. So I thought of making a Bezier curve in which certain segments are missing, then making a mesh representing a single barrier unit, and finally applying the classic Array-Curve modifier trick.
However, when applying the modifiers, only the length of the first part of the curve is considered. Even if I switch to "Fixed Count" to set the number of items manually, the Curve modifier only considers the first part, then goes on in a straight line.
Do I have a way to keep the Bezier curve intact (a single object with many non-connected parts) and use it as the base of my repeating mesh object?
EDIT
Here is a file that demonstrates the issue:

I'd like "Cube" to follow along "BezierCurve", but only the first part of it is used by both modifiers.

You can't use multiple, separate curve segments to curve modify an object.  The curve modifier will only use the first curve it finds.  This is just not a technique that works with Blender.
You can create divisions between barriers by giving it both a relative and a constant offset:

If you want regular intervals of undivided, divided, you can have a relative array followed by a relative + constant array:

You could make a boolean cutter, with a curve modifier to follow the same curve, and use it to cut shapes out of your boundary with a boolean modifier:

It wouldn't be impossible to make an array that followed multiple curves-- you'd need to UV offset the arrays, then use the UV as a mask texture for a vertex group edit modifier to divide the array into multiple bits with different vertex group weights, then use those vertex groups to specify which particular curve object to follow for a particular bit of the array.  Not impossible.  It would be complicated and totally impractical though.


Generate random ellipsoids I have a problem to generate random ellipsoids inside a cubic space.

This is the script I wrote:

# How many Sphere you want to add
count = 25

# Sphere properties
size = 1

# The sphere will be created between -domain <--> domain
domain = 1

My problem in this script is that the spheres are away from each other and I cant get ellipsoid.

So, My first question how can I change these spheres into ellipsoidal, starting with the ellipsoid dimension statement: size_x =, = size_y, size_z =
the second question, How to make them close to each others without getting them overlapped.

Cobbled together a test script, that has parts that answer both of your q's.  Scale a sphere on x, y, z to make ellipsoids. (set sphere_only=False in script)

The 'within_touch' method looks at two spheres and if they are closer than the sum of their two radii, they are overlapping.  The distance between the spheres is the length of the vector created by subtracting ones location from the other.

If a pair of spheres are found to be overlapping the method returns the required vector to move to make them touch (with a bit of tol)

While testing added an object color, the bluer the harder to place.

import bpy
context = bpy.context
from random import uniform
from mathutils import Vector

count = 200

# random scale
min_scale = 0.001
max_scale = 1
# scale_factor .. scale down to help fit
scale_factor = 0.1
domain = 1
only_spheres = True

tries_per_sphere = 256

use_context_object = False
obj = context.object

def random_vector(a, b):
    return Vector([uniform(a, b) for c in "xyz"])

def checkbounds(sphere, fix):
    #return True
    loc = sphere.location + fix
    #dm = max(sphere.dimensions) / 2
    dm = max(sphere.scale)
    _min = -domain + dm
    _max =  domain - dm
    for i, v in enumerate(loc):
        if v < _min:
            loc[i] = _min
        if v > _max:
            loc[i] = _max
    return loc

def inbounds(sphere, loc):
    #return True
    dm = max(sphere.scale)
    return -domain + dm < min(loc) and  max(loc) < domain - dm

def random_sphere(sphere):
    # random scale and rotation for sphere based on settings
    if only_spheres:
        scale = uniform(min_scale , max_scale) * Vector((1, 1, 1))
    else:
        scale = random_vector(min_scale, max_scale)
    scale = Vector([min(s, domain) for s in scale])
    dom = domain - max(scale)
    sphere.scale = scale

    sphere.location = random_vector(-dom, dom)

scene = context.scene

mat = bpy.data.materials.get("randobjcol")
if not mat:
    mat = bpy.data.materials.new("randobjcol")
    mat.use_object_color = True

boundbox = bpy.data.objects.get("BoundBOX")
if not boundbox:
    bpy.ops.mesh.primitive_cube_add()
    boundbox = context.scene.objects.active
    boundbox.name = "BoundBOX"
    boundbox.draw_type = 'WIRE'
    boundbox.hide_select = True
    boundbox.location = (0, 0, 0)

if not scene.objects.get("BoundBOX"):
    scene.objects.link(boundbox)

boundbox.scale = domain * Vector((1, 1, 1))

spheres = []
if use_context_object and obj:
    sphere = obj
else:
    bpy.ops.mesh.primitive_uv_sphere_add()
    sphere = context.scene.objects.active
    bpy.ops.object.shade_smooth()
    scene.objects.unlink(sphere)

sphere.active_material = mat

for i in range(count):
    spheres.append(sphere)
    random_sphere(sphere)
    sphere = sphere.copy()
    #context.scene.objects.link(sphere)

# update the spheres dimensions
#context.scene.update()

tries = 0
t_count = 0
r_count = 0
moves = 0
resets = 0
pfix = Vector()

def within_touch(s1, s2):
    def r(s):
        return max(s.scale)
        #return max(s.dimensions) / 2
        #return sum(s.dimensions) / 3 #  average.

    d = (s2.location - s1.location)

    r1, r2 = r(s1), r(s2)

    radsum = r(s1) + r(s2)
    if d.length <= 0.0001:
        print("SAME")
        return Vector((r1, r1, r1))
        # same position
    elif d.length < radsum:
        # return a vector to move away
        d.length = radsum - d.length
        return  -d
    return Vector()

sphere = spheres.pop()
arranged_spheres = [sphere]
sphere = spheres.pop()

while sphere and tries < tries_per_sphere * count:
    if t_count > 5 and abs(min_scale - max_scale) > 0.00001:
        v = scale_factor * sphere.scale
        sphere.scale = Vector([max(s, min_scale) for s in v])
    #scene.update()
    touchers = [s for s in [within_touch(sphere, s) for s in arranged_spheres] if s.length > 0]
    if len(touchers):
        fix = Vector()
        for v in touchers:
            if sphere.color[0]:
                sphere.color[0] -= 0.1
            elif sphere.color[1]:
                sphere.color[1] -= 0.01
            else:
                sphere.color[2] -= 0.001
            fix += v

        #if fix.length < 0.0001 or not inbounds(sphere, loc) or r_count > tries_per_sphere:
        if (fix < 0.0001) or r_count > tries_per_sphere / 2:
            r_count = 0
            random_sphere(sphere)
            resets += 1
            #sphere.color[1] = 0
        else:
            loc = checkbounds(sphere, fix)
            sphere.location = loc
            moves += 1
        t_count += 1
        r_count += 1
        tries += 1
    else:
        print("Arranged ", sphere.name, "moves:", moves, "rand moves", resets, "fixes:", t_count)
        moves = 0
        t_count = 0
        r_count = 0
        resets = 0
        arranged_spheres.append(sphere)
        sphere =  spheres.pop() if len(spheres) else None

for s in arranged_spheres:
    if not scene.objects.get(s.name):
        scene.objects.link(s)

print("Arranged % d of %d" % (len(arranged_spheres), count))
print("TRIES", tries)

Edit

Following shows size 0.142 spheres placed in a domain 1 cube.  Placed 197 of 200 on this run, with settings shown.

Update for 2.8

import bpy
context = bpy.context
from random import uniform
from mathutils import Vector

count = 200

# random scale
min_scale = 0.1
max_scale = 0.1
# scale_factor .. scale down to help fit
scale_factor = 0.1
domain = 1
only_spheres = True

tries_per_sphere = 256

use_context_object = False
obj = context.object

def random_vector(a, b):
    return Vector([uniform(a, b) for c in "xyz"])

def checkbounds(sphere, fix):
    #return True
    loc = sphere.location + fix
    #dm = max(sphere.dimensions) / 2
    dm = max(sphere.scale)
    _min = -domain + dm
    _max =  domain - dm
    for i, v in enumerate(loc):
        if v < _min:
            loc[i] = _min
        if v > _max:
            loc[i] = _max
    return loc

def inbounds(sphere, loc):
    #return True
    dm = max(sphere.scale)
    return -domain + dm < min(loc) and  max(loc) < domain - dm

def random_sphere(sphere):
    # random scale and rotation for sphere based on settings
    if only_spheres:
        scale = uniform(min_scale , max_scale) * Vector((1, 1, 1))
    else:
        scale = random_vector(min_scale, max_scale)
    scale = Vector([min(s, domain) for s in scale])
    dom = domain - max(scale)
    sphere.scale = scale

    sphere.location = random_vector(-dom, dom)

scene = context.scene
view_layer = context.view_layer
mat = bpy.data.materials.get("randobjcol")
if not mat:
    mat = bpy.data.materials.new("randobjcol")
#    mat.use_object_color = True

boundbox = bpy.data.objects.get("BoundBOX")
if not boundbox:
    bpy.ops.mesh.primitive_cube_add()
    boundbox = context.object
    boundbox.name = "BoundBOX"
    boundbox.display_type = 'WIRE'
    boundbox.hide_select = True
    boundbox.location = (0, 0, 0)

if not scene.collection.objects.get("BoundBOX"):
    scene.collection.objects.link(boundbox)

boundbox.scale = domain * Vector((1, 1, 1))

spheres = []
if use_context_object and obj:
    sphere = obj
else:
    bpy.ops.mesh.primitive_uv_sphere_add()
    sphere = context.object
    #bpy.ops.object.shade_smooth()
    context.collection.objects.unlink(sphere)

sphere.active_material = mat

for i in range(count):
    spheres.append(sphere)
    random_sphere(sphere)
    sphere = sphere.copy()
    #context.scene.objects.link(sphere)

# update the spheres dimensions
#context.scene.update()

tries = 0
t_count = 0
r_count = 0
moves = 0
resets = 0
pfix = Vector()

def within_touch(s1, s2):
    def r(s):
        return max(s.scale)
        #return max(s.dimensions) / 2
        #return sum(s.dimensions) / 3 #  average.

    d = (s2.location - s1.location)

    r1, r2 = r(s1), r(s2)

    radsum = r(s1) + r(s2)
    if d.length <= 0.0001:
        print("SAME")
        return Vector((r1, r1, r1))
        # same position
    elif d.length < radsum:
        # return a vector to move away
        d.length = radsum - d.length
        return  -d
    return Vector()

sphere = spheres.pop()
arranged_spheres = [sphere]
sphere = spheres.pop()

while sphere and tries < tries_per_sphere * count:
    if t_count > 5 and abs(min_scale - max_scale) > 0.00001:
        v = scale_factor * sphere.scale
        sphere.scale = Vector([max(s, min_scale) for s in v])
    #scene.update()
    touchers = [s for s in [within_touch(sphere, s) for s in arranged_spheres] if s.length > 0]
    if len(touchers):
        fix = Vector()
        for v in touchers:
            if sphere.color[0]:
                sphere.color[0] -= 0.1
            elif sphere.color[1]:
                sphere.color[1] -= 0.01
            else:
                sphere.color[2] -= 0.001
            fix += v

        #if fix.length < 0.0001 or not inbounds(sphere, loc) or r_count > tries_per_sphere:
        if (fix < 0.0001) or r_count > tries_per_sphere / 2:
            r_count = 0
            random_sphere(sphere)
            resets += 1
            #sphere.color[1] = 0
        else:
            loc = checkbounds(sphere, fix)
            sphere.location = loc
            moves += 1
        t_count += 1
        r_count += 1
        tries += 1
    else:
        print("Arranged ", sphere.name, "moves:", moves, "rand moves", resets, "fixes:", t_count)
        moves = 0
        t_count = 0
        r_count = 0
        resets = 0
        arranged_spheres.append(sphere)
        sphere =  spheres.pop() if len(spheres) else None

for s in arranged_spheres:
    if not context.collection.objects.get(s.name):
        context.collection.objects.link(s)

print("Arranged % d of %d" % (len(arranged_spheres), count))
print("TRIES", tries)