How to implement a custom ray tracing algorithm in Blender?

A very broad question. I know there is functionality in OSL for this but OSL equals Cycles. So if it should be possible in OSL it is possible with nodes. OSL does not have that much of references. The people who explored this field are Blender Sushi and the blog Small Blenderthings.

You do not exactly state what you are after so I can not help you that much further.


Animation nodes, barchart, I can generate the bars, but how do I animate them?

Click on the image to enlarge it.

I prefer to do the math on single values with Math nodes, which is why I have moved the Combine Vector to the back.

To get the time offset in the scaling animation, we start with the index of each cube from the Index output. With the Time Info node, we can get the current frame.

If we subtract the index from the frame we can get an offset for each element. If we multiply the index with an arbitrary factor before that, we'll get a bigger or smaller offset

frame   -   index  *  3   =  result
  9     -     0    *  3   =  9
  9     -     1    *  3   =  6
  9     -     2    *  3   =  3
  9     -     3    *  3   =  0
  9     -     4    *  3   =  -3

We can clamp the result from 0 to 1 and use it as the input to a MapRange node. The MapRange node also has the advantage of having an interpolation mode input. As you can see with the frame offset by the index, the first bars from left to right switch from 0 to 1 earlier.

This switch from 0 to 1 plays back the animation in the MapRange nodes output, so make sure to set the OuputMin to 0 and the OutputMax to our desired height of the value which you obtain from the ParseNumber node. (This part remains as in your original node graph.)

Because this switch from 0 to 1 only takes a single frame the animation of the bars change from one frame to another (and thus is not visible as an animation). Simply add another multiply node after our previous result, scaling the time downwards so that the 0-1 happens over multiple frames. I named this multiplier StrechAnimTime.

You may have noticed that this animation takes the same time for all bars making the longer bars move faster than the shorter bars. To make the animation time more proportional, use a multiplied version of the height (Parse Number result) for the InputMax of the MapRange node.

Much more dramatic.


You can key-frame the location field(s) in the Mapping node.

At the moment you are mapping in Camera space, (i.e. the space of the whole rendered screen in XY, and Z in and out of it.) Maybe one of the spaces associated with your object would suit your purposes better, it depends what you want to do.

Select 'Texture' in the Mapping node, and right-click in any of the  Location fields to set keyframes, and  animate the position of the texture in X/Y/Z.

Frame 5:

Frame 40:


reduce diffuse light on shadow catcher (Cycles Render)

try to reduce size to 0 where sun light has option max bounces below,but reduce size of the shadow of the sun to 0


How can I remove artifacts from a flat surface after using a boolean modifier?

The problem was solved by setting Shading to flat in the Object Tools Panel  T


Blender keeps adding "limit location" bone constraint to an entire armature?

Maybe you're confusing bone constraints with object constraints? To give a bone a constraint, you need to switch your armature to Pose mode, then you'll have access to the Bone Constraints tab, which is not the same as the Object Constraints tab.

Shortcut ctrlshiftC


Use the console to orient the camera plane exactly parallel to the x-y plane?

The question suggests that you are using the manipulator widgets or mouse to position and rotate your assets.

Blender provides numerous input methods for performing transform operations upon assets.

To specifically answer your question:
Typing (or pasting) the following into the console will center the camera 3 blender units above the world origin, and orient it so that it is looking directly at the x-y plane.

bpy.data.objects['Camera'].rotation_euler[0] = 0
bpy.data.objects['Camera'].rotation_euler[1] = 0
bpy.data.objects['Camera'].rotation_euler[2] = 0
bpy.data.objects['Camera'].location[0] = 0
bpy.data.objects['Camera'].location[1] = 0
bpy.data.objects['Camera'].location[2] = 3

However, there are simpler methods for achieving the same results;
With the camera selected, you can input the numerical values directly into the input fields shown here

or even simpler; with the camera selected;
press [Alt + G] (to reset the camera position)
press [Alt + R] (to reset the camera rotation)
then drag on the blue manipulator arrow to raise the camera to any height you like.

Or you can set the camera to the view plane as suggested by NoviceInDisguise


File Output node ignores inputs and exports all render layers

I guess the file output results were overridden by the Composite node, so I deleted the Composite node and changed the file type to OpenEXR Multilayer from the node properties rather from the render settings tab. Now it works as expected.


when ever i move/pose a bone blender lags/freezes

Your mesh is either very complicated, you have a bad PC, or both. I suggest disabling or lowering the quality of subdivision modifiers in the viewport if you have them on the mesh, or upgrading your PC


I figured out the problem, and the answer to said problem, and it is so much simpler than I thought.

When you have a Numpy array such as:

y = np.array(([75], [82], [93]), dtype = float)

The array is actually a matrix of numbers, and the above array is a matrix of size 3x1.
Therefore, in order to set a game property (or any other variable if you so choose), you must pass in two numbers to specify the row and the column of the value you desire.

This means that instead of having;

own["y1"] = y[1]

In order to make the property equal "82" as the above code is trying to do, you should instead have:

own["y1"] = y[1, 0]

This new code will then specify the second row and the first column as the desired value.

Another example:
If you have the numpy array;

y = np.array(([26,72,54], [46,82,37], [36,67,81]), dtype = float)

You can select the value "36" by specifying the third row and the first column, as done here:

own["y1"] = y[2, 0]

Hopefully this makes sense, and you can understand its implementation through the above examples.


My Donut sprinkles not showing in rendering my blender?

You have set the Particle-System > Children > Simple:

Change this option to None:

But if you also want to use Children particles then adjust the Size and to see them in the viewport, set Display > 0 or Display = Render,


You can solve this easily in Blender 2.82+.

In the Solidify Modifier

Set Mode to Complex.
Set Boundary to Flat.


This script renames all the objects and assigns a number.

import bpy

objects = bpy.context.scene.objects

for i in range(0, len(objects)):
    print(objects[i].name)
    objects[i].name = "object" + str(i)
    objects[i].data.name = "object" + str(i)


It sounds like you want the Dope Sheet view.  From there you can move/copy/paste key frames to different times.  It looks like this:

You might also want to look into Actions.
https://www.blender.org/manual/animation/actions.html


Align origin and axis to custom vertices

Here is a solution:

In Edit mode select right vertices.

Go to Transform Orientation - Plus icon to create new orientation based on your selection

Back to Object Mode check ‘Origins’ box

In Object Mode use ‘Align to Transform Orientation’ operation

Enjoy!

I hope it was useful! Happy holidays everyone!


Cycles hair particles disappear after I comb the hair?

Particles will not render in particle edit mode, due to a limitation:

  This is intentional, it's a limitation in the particle system code that both Blender Internal and Cycles suffer from. Not considered a bug at the moment.

So make sure you are not in particle edit mode when rendering.

In case you are wondering what the suffering is about, blender's particle code is known to be inefficient and filled with issues. (I can't seem to find any sources for this, but I know I read it somewhere..)

A "looking into" is being talked about as part of the Gooseberry project, and a rewrite (with nodes support!) is also being worked on.


Apply Transform and Rest Pose Not Working After Restart Blender

I determined the cause of the problem! I must have accidentally set a keyframe for the the armature scale and rotation! The strange part is that I never once placed the armature in that strange position, but I checked the graph editor and found keyframes on all joints. Once I deleted the keyframes everything looked good after saving and re-opening blender.


How to position the center of the Glare Node effect (in ghost mode) off center?

This is how lens flare actually works, its an internal reflection of the lens and describes the aperture that the path of light enters. All light passing through a lens goes through the centre at some point. So moving the flare centre around doesn't make physical sense.


Model does not move with bones after auto weights are applied

Bones don't know how to deform the mesh until you give them instructions on how to, basically. This is done by parenting the mesh object to the armature. Select the mesh object, then the rig, and use the hotkey ctrl + P to bring up the parenting types. You should choose "with automatic wieghts". By doing this, blender calculates distances from bones to vertices of the mesh, and pretty accurately decides which bones will move which parts of the mesh. Keep in mind, you may have to paint some wieghts manually if the mesh deforms in an undesired way.

Anyway, once you've parented the mesh to the armature, you can select the armature, go into pose mode, and move the bones, which should move character as well.

If you'd like to see another good video about all these things, give this a look: https://youtu.be/mhQY2_gVoVg


A mesh objects data contains lists for vertices, edges and polygons. Each edge and polygon has a list of vertex indices that it uses.

Python's csv.writer is included with blender's python install.

import bpy
import csv

obj_data = bpy.context.active_object.data

with open('out.csv', 'w') as csvfile:
    data = csv.writer(csvfile, delimiter=',')
    for f in obj_data.polygons:
        face_data = []
        for i in f.vertices:
            face_data += [obj_data.vertices[i].co]
        face_data += [f.normal]
        data.writerow(face_data)


how to remove block effect from bump node with textures

First thing is you have your image texture set to 'color', that should be 'non color' data. plus looking at your image it looks too low res, you need a 16bit image to make good bump maps.


I'm making a table Rounded Edges - Noob question

In the 3D view, switch to Edge Select mode.
Select both top and bottom circles.
Press ctrl B to create a bevel, change the parameters on the bottom of the Tools panel of the 3D view (T).
Add a Smooth Shading and a Subsurf modifier.


Changinng in-game Armature Object's Armature Data

If you are talking about Armature datablock, it is similar as changing the mesh data for mesh object:

If you are talking about changing Action Data for armature, there are two places to go, depends on your actual need:

For BGE action, you may take the 2nd one.

PS: Action Data exchanging between armatures requires high similarity, in other words, same hierachy, same bone count, same bone names, etc. Otherwise it will not work as expected.


Boolean Union vs Difference Error - Swapped Behaviour

I had this exact problem about a week ago.  IRC told me that the face normals on one of my objects were probably backwards.  It turns out they were correct.

You can turn on the display of face normals in EDIT mode using one of the icons in the Mesh Display section of the N pop-out panel.

You can reverse the direction of the normals of the currently selected faces using the Mesh > Normals > Flip Normals operator.  There are also some "smarter" operations in that same menu.


I can't tell you how to import voxel data into Blender, but if there's no dedicated importer, you can try MeshLab to convert to a supported format. For example, PLY or STL to import as vertices. If there's no real surface yet, you may use MeshLab's pointcloud triangulation capabilities and export as .OBJ.

Once you have a mesh object in Blender with a surface, try the Laplacian Smooth Modifier, which lets you smooth mesh surfaces while retaining a lot of detail.  Go to Properties Editor > Modifiers and add it to your object.

More information: official documentation


I am writing a script to change a bone position on all my animations. Why doesn't my script work?

While the outline of your idea is right, altering the animation data takes a bit more. Firstly armatures contain two sets of bone data, one is the rest position that we change in edit mode when creating the rig, the second set is the pose bone data that we animate. The object.data.bones that you are using is the edit bone data. Using the pose bones found at object.pose.bones you could position and keyframe the bones but you will find that altering the keyframe data directly to be easier for your task.

An action contains a list of fcurves with each fcurve containing the animation data for one value, so there is one fcurve for the x location and another for the y location and so on, so you need to alter each value separately. Each curve has a list of keyframes that contains the frame and value used for the property that is keyframed. This leads to going through the fcurves of an action and looking at the data_path and array_index to decide if it is a value you want to alter.

If you are unsure of the data_path or array_index values, you can find them in the graph editor properties region.

To adjust the location of a bone in every action you could use the following.

import bpy

target_bone = 'ikHeelRight'

# Adjustments in (x, y, z) direction
adjustments = (1, 1, 0)

for act in bpy.data.actions:
    for fc in act.fcurves:
        if target_bone not in fc.data_path or 'location' not in fc.data_path:
            continue

        assert 0 <= fc.array_index < 3  # always good to make your assumptions explicit
        for p in fc.keyframe_points:
            p.co[1] += adjustments[fc.array_index]

The p.co[0] value is the frame number, so if you wanted to retime your animation you would change that.


Is it possible to animate geometry nodes?

In Blender 2.92, parameters are not displayed in the graph editor.
They are displayed in Blender 2.93.


Modeling hexagon pinhole lens for 3D printing

Here is Modifier version you asked for ...
... add a Circle 6 sided, extrude E, scale S - to create a segment with a hole

Array - use two of them to create like "rhombus" shape
Mirror X and Y - mirroring does some parts overlapping, but no problem ...
Weld is used to merge double vertices

Big thanks and credit goes to @Robin Betts. He added two drivers to a second Array modifier. So now just simply increasing/decreasign a count of the first Array automatically changes a count of second Array ... and more of that second driver maths correct distance for segments on X axis.
You don't have to use drivers to make this modifier stack to work. They just make a life easier :)

Notes: When you are happy with a number and size of holes you can easily continue with other modifiers ... Subsur, Solidify, Bevel all with a nice topology that wouldn't be happen (I guess) if you would use Boolean operation.
To get Circle shape around - apply modifiers (in case of version using drivers
search for Convert to Mesh to apply modifiers). In edit mode select outer loop, extrude, scale and
search for To Sphere set 1

Anyway, even Arrays / Mirror / Weld modifiers are applied you can any time select one hole loop and with Select Similar Shift+G > Length to select all holes and with Pivot Point > Individual Origins you can still adjust size of holes.


Use the convex hull.

The routine to find the minimum volume bounding box involves the creation of the convex hull. It occurs that the extreme points will be vertices on the convex hull.

Test script. Uses BMesh.ops.convex_hull(...) to create a convex hull mesh where the extreme points will coincide with vertex locations. The two furthest from the origin are chosen and an empty added at those locations. (Assumes the origin is already at center of geometry)

import bpy
import bmesh

context = bpy.context
ob = context.object
me = ob.data
bm = bmesh.new()
bm.from_mesh(me)
ret = bmesh.ops.convex_hull(bm, input=bm.verts)

verts = sorted([v for v in ret["geom"]
        if isinstance(v, bmesh.types.BMVert)],
        key = lambda v : v.co.length)

for v in verts[-2:]:
    loc = ob.matrix_world * v.co
    bpy.ops.object.empty_add(location=loc)

Notes: simple example above grabs two furthest from origin verts in convex hull. To find the 2nd furthest would find the furthest from the first furthest.  Will be arbitrary for something symmetrical like the sphere, where each point is radius from origin.

Simple test result on oblong


The number highlighted below indicates that your objects share one action which means that they all share the same keyframes.

You can create an copy of the action for the active object by clicking on the number. After that you should be able to modify the object's keyframes individually.

Update:
If you want to affect multiple objects by a single action, I think the default approach would be to add an armature with a bone for every object, add a Child-Of constraint to each object, choosing the specific bone, and then creating an action which animates the bones.


Rigify horse armature: hind leg bones seem wrong; tweak also on wrong layer?

I havent used the Rigify animal rigs but there are a few things I can share. Keep in mind that Rigify is tricky to customize. If there are too much edits it will not work right.

After adding bones in edit mode you have to let the rig know there are more bones in the chain. On the metarig go to Pose Mode and click on the Thigh bone. Now go to the Bone Properties panel on your right and find Rigify type> Limb Segments. Experiment with adding numbers here and generating the rig until you find it works.

In that panel you can also click on the layer where you want the tweak bones.


Why am I getting this weird anomaly with the loop cut?

you have a face inside your topology, press Z to see in Wireframe mode, select and delete the inner face


Why doesn't the fur follow the rigged mesh?

Place the Armature modifier above the Particle System modifier.


What's the best way to make a long, hollow cylinder composed of filigree?

Its not pretty but ...

Here I used the Bezier curves to make a basic design, you might be better off using a vector package like Inkscape and then importing your design.
Note that it is Cyclic, 2D, Extruded and Beveled.

I then converted the Curve into a Mesh (not sure that step is strictly necessary) and then added an Array modifier.

Created a Bezier Circle and rotated it by 90 degrees on the X and scaled it by 4.

Then added a Curve modifier after the array and set it to the new Circle.

This all took minutes and is bit rough, but I hope it gives you some ideas.


Adding a modifier to the top of the stack of multiple objects without overwriting previous modifiers

Heres one, this works on all selected mesh objects:
import bpy

class AddTri(bpy.types.Operator):
    """Add triangulate modifier on top of stack"""
    bl_idname = "object.add_tri"
    bl_label = "Add Triangulate Modifier"

    @classmethod
    def poll(cls, context):
        return context.active_object is not None

    def execute(self, context):
        act_obj = context.active_object #record active object

        for obj in context.selected_objects:
            if obj.type == 'MESH':
                obj.select_set(True)
                context.view_layer.objects.active = obj # make object active for bpy.ops to work on specific object

                mod = obj.modifiers
                md = mod.new("Triangulate", "TRIANGULATE")
                # quad_method: 'BEAUTY' 'FIXED' 'FIXED_ALTERNATE' 'SHORTEST_DIAGONAL'
                md.quad_method = 'SHORTEST_DIAGONAL'
                # ngon_method: 'BEAUTY' 'CLIP'
                md.ngon_method = 'BEAUTY'
                md.min_vertices = 4
                md.keep_custom_normals = False

                # modifier UI settings
                md.show_expanded = False
                md.show_in_editmode = True
                md.show_on_cage = True

                bpy.ops.object.modifier_move_to_index(modifier=md.name, index=0) # bring modifier on top of stack

        context.view_layer.objects.active = act_obj # make old active object active again
        return {'FINISHED'}

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

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

if __name__ == "__main__":
    register()

    # test call
    bpy.ops.object.add_tri()


What does clip=True mean in mathutils.geometry.intersect_line_sphere()

Short Answer: Yes, it does.

Long Answer:

The source code is located in this file. It calls line_point_factor_v3 which subtracts both, the end point line_b and the intersection point isect from the start point line_a, to get the relative vectors from line_a to line_b and the intersection point isect, respectively.

It then divides the dot product of these relative vectors by the squared length from line_a to line_b.

Since both relative vectors are on the same line, the result of the dot product is negative if they point in opposite directions, else the result of the dot product is the product of the lengths of these vectors.

So basically its

dist(line_a, line_b) * dist(line_a, isect) / dist(line_a, line_b)²

If clip is True it checks wether this is between 0.0 and 1.0 which means the intersection point is on the line segment from line_a to line_b


Bouncing ball stops bouncing after 250 seconds

This is because you need to set the Rigid Body Cache end frame to be 1000 instead of 250 as shown below:

Updated .blend file can be found here:


In v2.81 I am changing it like this:

import bpy

for area in bpy.context.screen.areas:
    if area.type == 'VIEW_3D':
        area.spaces.active.overlay.grid_scale = 0.25


Screw Modifier Destroying Normal in Blender

For anyone who might have the same problem. The screw modifier doesn't work well with faces. So have only edges or vertices when adding screw modifier

Here is a workaround for that problem if you really want to use the screw modifier with faces.

step1: select your object
step2: Add screw modifier
step3: add solidify modifier
step4: play around with offset and clamp in the solidify modifier
until you get normal in the right direction.


As already said by @Xtremity in the comments, it is rotating but you don't notice it. Your big gear has 30 teeths, so every 12 degrees (360 / 30) one teeth. Before the short stop, you rotate by +6 degrees every frame, so half a teeth of the big wheel. After the pause however, you rotate by 12 degrees, exactly one teeth, per frame, so you just don't see it rotating.

By the way, you're not rotating in the opposite direction after the stop, it just looks like it.

Rotation in frame 209:

Rotation in frames 210 to 230:

Rotation in frame 231:

You can clearly see, that before frame 210 it rotates by 6 degrees, after frame 230 by 12 degrees.


Smart UV Project: the sequence of the faces is wrong and has inconsistent width

I think you can work a bit on this: I tried with your file and got some decent result, imho.

The first thing is: I isolated just the exterior walls.

then I set the front view and unwrapped cylindrical

I got an (extremely high) quite nice square unwrap

but helping with 2d cursor and the pivot choice, it's easy to scale it dow to make it a bit more manageable

then I loaded a brick wall image similar to yours

and aligned and scaled the uv map to the image

what about the face sequence? it seems ok, look them while I select (in top view) all faces...

Hth..


Is it possible to have a preview while scripted rendering?

If you call the render() operator via PyConsole or Text Editor, a different default execution context is used. It is 'EXEC_DEFAULT'.

In contrast, buttons in panels and also menu entries use 'INVOKE_DEFAULT' by default for operators.

You can override the execution context in layouts:

col = layout.column()
col.operator_context = 'EXEC_DEFAULT'
col.operator("render.render")

As well as in the console / editor:

bpy.ops.render.render('INVOKE_DEFAULT')

If you use an override and keyword arguments for an operator call, the order is:

bpy.ops.render.render({'dict': "override"}, # dictionary for context overriding
                      'EXECUTION_CONTEXT',  # a valid execution context
                      undo,                 # undo support (True or False)
                      keyword="argument_1", # first operator argument
                      ...)                  # more operator arguments follow here

Links:

Keywords and Positional Arguments
Execution Context
UILayout.operator_context and the example of Calling a file selector
Invoke Function


Combining Translucent and Volume Shaders

Translucent shader gets power (brightness) from the light rays that enter the surface scatter inside and come through the material.

When the rays coming through the volume are absorbed by volume absorption, the translucent shader gets less energy and is darker.

The scattering is also an approximation and you will get much more accurate results with volume scatter or subsurface scattering shaders.


Mirror modifier. Instead of just moving the mirrored vertices it creates new vertex on each side

Turn on Bisect, it will cut the model in the middle and mirror it instead of copying/reversing it.


As much as necessary but as few as possible :)

The goal is to have a playable performance. And this depends on too much factors like shaders, draw calls, how much geometry at once, rest of ongoing code, target platform, target OS, and and and. The geometry is usually the smallest problem nowadays. The common graphical resource hogs are draw calls, particle systems, shadows. But code can slow down the game dramatically too.

That's why you normally start with a prototype to figure out what is possible within the given bounds. So make a prototype and simply try it out.


Python 2.8 creating Diffuse BSDF in a shader node, when I want it in a surface node

Small code that can bring the indication you need.

import bpy

# Clear all nodes in a mat
def clear_material( material ):
    if material.node_tree:
        material.node_tree.links.clear()
        material.node_tree.nodes.clear()

# Create a node corresponding to a defined group
def instanciate_group( nodes, group_name ):
    group = nodes.new( type = 'ShaderNodeGroup' )
    group.node_tree = bpy.data.node_groups[group_name]

materials = bpy.data.materials

mat_name = 'test'

material = materials.get( mat_name )

if not material:
    material = materials.new( mat_name )

# We clear it as we'll define it completely
clear_material( material )

material.use_nodes = True

nodes = material.node_tree.nodes
links = material.node_tree.links

output = nodes.new( type = 'ShaderNodeOutputMaterial' )

diffuse = nodes.new( type = 'ShaderNodeBsdfDiffuse' )

#With names
link = links.new( diffuse.outputs['BSDF'], output.inputs['Surface'] )
#Or with indices
#link = links.new( diffuse.outputs[0], output.inputs[0] )

Note: when you create a new material (materials.new(...)), it creates two nodes by default (principled linked to ouput).


clothing 2D pattern from Inkscape and simulate in Blender

In inkscape the paths need to be filled, and be a closed path.
For a filled shape in blender:
In the Curve->Shape tab make the curve 2D and set the  Fill Mode to Both (Front and Back)

If your idea is to use it as texture on a material, then you need to convert the image to a a raster format (tiff or whatever other format you are confortable with) Blender cannot use pahts as texture.
If what you want is to create a shape and fold it or wrap it around objects, then SVGs will need to be converted to meshes.


Need help with this one piece! (Floral ornment)

You could do it:

Manually. It will garantee that you're very close to the real object and you'll be able to make some close-up shots. Here is just a try with a small detail, you'll need to do if with whole shape of course:

With a Project From View texture: Draw the contours of the whole shape, extrude up, bevel, shade smooth, give it a Subdivision Surface modifier, unwrap from the top orthogonal view with the Project from View option, give it a material with the original photo as Image Texture, you can even add a bit of bump:

You can even cut with the knife or inset to extrude up or down some parts:

With curves: Draw some curves that roughly follow the ornments, bevel them, use the Profile tool, scale the vertices with AltS if you want more thickness, and when you're glad, convert to mesh:


Just push Z in wireframe, which is where you are. ShiftZ from while in the rendering view will put you back in solid viewpoert


BGE: Turn Physics off globally while keeping sensors

You need to keep the bullet physic engine to have many parts of the bge work, so don't disable that. Simply set all your objects to Static Physic Type. You will need to enable Actor and Ghost on them too.

The static physic type does not react to physics (no gravity, friction, etc). Actor lets the logic bricks "see" the object, and Ghost disables collisions.

With those three options on all your objects you should have a clean slate to build your own interactions off of.

To edit the physics properties on all your objects:

First set up one object like I describe above. Select all the objects, and keep the one you just edited the physics settings as the active object. Now press space and type "copy" choose "Copy Game Physics Properties to Selected". That's it, all the objects are set the same.


BGE: How to apply colour to a certain face with python?

If you don't need to apply coloir to that face in-game you can add different material to it without python- in materials tabe add ne material to mesh on the left of the list of materials. Than set that material to the color you want and go in edit mode. Than select the face you want to be colored in that color and select it(only). After that stay in edit mode and go to materials tab. Selec the material you want to apply on your face and than press assign under list of materials in materials tab!


Can't get Auto Smooth to work on extruded spiral

To create the spiral enable the Add Curve: Extra Objects plugin.

Then do Add->Curve->Spirals

For a smooth curve, don't convert your spiral into a mesh, keep it as curve and extrude it on the geometry section:

To add thickness use a solidify modifier:


Glass shader. How can I get rid of the reflection in the glass?

Glass is reflective, so if you want to completely get rid of the reflections it won't look like glass anymore.  This can be done by using a refraction shader which only passes light through and does not reflect any rays.  If you want to just tone down the reflections you can mix a refraction shader with a glossy shader sharing the same parameters.

Below is shown an example of 100% glass, 20% glass and 0% glass respectively.

This may make your render look undesirable in other manners however as it will no longer be very physically accurate.  If this is the case, I suggest playing with the angle of your camera and/or whatever is being reflected in order to have it not block your view (as you may sometimes do in real life to look through a glaring object).


Step-by-step to baking a model for export, so that it looks smooth but doesn't have all the faces of a subdivided mesh

Baking can be used to create the image texture for example a character. It can also be used to create normal maps. The below video teaches how to remove faces from a high poly mesh but still keep the detail in it by simply adding a normal.
https://www.youtube.com/watch?v=ApzVWuPa4A4


bpy.props types, update, set, and get fields format

Got it!

This page addresses how to get a function name, in a way that's friendly to class methods and not just script-scope functions.  Blender API requires a 'self' parameter in the specified function for update, set, and get, so it actually requires a class method anyway.

So, let Python do the formatting for you.

update: I had a partial answer here before.  I want to force use of the local dictionary, so that I know for sure that an instantiated object's method is used and that no global method is looked for.  The answers for this question provide the second part. Also, the incomplete answer I had before does not work because it uses a string where a function is expected.

Here's an example using the lower domain constraint in my script:

global set_domain_min

self["domain_left"] = bpy.props.FloatProperty(
    name="x >=",
    description="Domain left bound",
    default=-10,
    min=-sys.maxint - 1,
    max=sys.maxint,
    step=1,
    precision=6,
    subtype="DISTANCE",
    unit="LENGTH",
    set=locals()[self.set_domain_min.__name__]
)

I don't know if this is a duplicate topic, since it's specific to Blender's API requirements but is answered with a general Python question.  My last question was marked as a duplicate, and is, but I haven't deleted it because I think the original has poor wording for the topic.  Next time I happen by this site, if a mod has marked this as a duplicate then I'll just delete it.  The answering topic isn't obvious for somebody learning Python using the Blender API, but I'll leave this to others' judgment.

Update: Alternatively, the following can be used...

class foo:
    def __init__(self):
        self["bar_prop"] = bpy.props.FloatProperty(set=self.set_bar)
        self["bar"] = 1 / self["bar_prop"]

    def set_bar(self, bar_in):
        self.bar = 1 / bar_in

This makes it unnecessary to use locals ( ), but the 'self' identifier is needed.  Using locals ( ) is only necessary if there's an identifier with the same name declared global in-scope.  The first code snippet I posted above has been updated to demonstrate.  This can be useful for overloading an identifier such that the local is only used in specific cases.


How to create semicircle from sharp edge

Assuming you want to cut a hole in the shape of a semicircle, you can do it easily by erasing the two faces and adding a Subsurface modifier.

Then add two control edgeloops on the sides you want to be flat.

Alternatively, if want a drawn shape instead of a hole, just select one of the radial vertices and use the Spin modifier. The current position of the 3D Cursor will be used as the center.
Adjust settings like angle and number of segments as desired.


Select strips.
Right click to open menu.
Select Snap to Playhead.


Efficient way to delete all points below z = 0 on grid via Python script

This small script loops through the vertices in the active object and deletes all the vertices that are below 0 on the local Z axis. The local axis starts at the object origin.
Just paste this in to the text editor in blender and with your UV sphere selected press the Run button.
import bpy

vert = bpy.context.object.data.vertices

bpy.ops.object.mode_set(mode='OBJECT')

for v in vert:
    v.select = v.co.z < 0

bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.delete(type='VERT')
bpy.ops.object.mode_set(mode = 'OBJECT')


Remove Object and part of object its overlapping

There are a few ways to do this.

Using Boolean operations:

In Edit mode

Both pieces have to be part of the same object.

On the selected piece use Mesh>Faces>Intersect(Boolean)

In Object Mode

Both pieces have to be different objects.

Select the one that is to be cut. And add a boolean modifier and use the other object to intersect.

This method has the advantage of being non destructive and interactive. If you need to reposition or alter the cutting object you can do it and the affected object will be recalculated.

At this point you can choose to hide other object or Apply the Modifier to make the change permanent and delete the cutting object.


How can I select every Nth edge in only one direction on a plane?

You can do this in 3 easy steps:

Edge select one Edge with Alt + RMB.
Click on Select > Checker Deselect (F6 for Nth Selection, Skip and Offset)
Click on Select > Edge Rings

You just have to deselect the top and the bottom edge. In the .gif it is done with Shift + Alt + RMB.

Further Reading on this answer.

Further Information:

After using Checker Deselect you can adjust the desired Nth Selection at the bottom in the Toolshelf Panel or by pressing F6.

  Nth Selection
        Number of points to select.
  Skip
        Number of points to skip.
  Offset
        Offests at what point to start at.

quoted from the Manual


How do I initiate a render from Python but still show progress bar and UI updates?

You can do this by passing the 'execution context'. By default the execute() function is run when calling an operator from a script. If you press the render button from within the UI the invoke() function is run. To do the same from a script you would pass 'INVOKE_DEFAULT' as execution context. So for example bpy.ops.render.render('INVOKE_DEFAULT', animation=False, write_still=True).

See also the Python API docs: https://docs.blender.org/api/blender_python_api_current/bpy.ops.html#execution-context

Or for 2.80 (which is basically the same at the time of writing): https://docs.blender.org/api/blender2.8/bpy.ops.html#execution-context


How to take an animation off an object thats parent to another

If I understand correctly you are looking for a heath bar that follows the camera's location but not all the little rotations caused by animations. You may be looking for the child of constraint.

With these settings as the camera rotates on the x and y axis (like during a run animation) the cube does nothing. However, transform and rotation on the z axis by the camera affect the cube allowing it to always still be in view.


Replicating Cooktorr specular with Cycles vectors, almost there, but why vector is twisted?

Alright I found the issue, after reading the following observation about Cooktorr in blender dev:

https://developer.blender.org/T34564

I learned that Blender Internal Cooktorr was actually Blinn-Phong, so I reviewed the math of it and figured out which vector I had misplaced, I leave a picture with the solution, also the link to the math, for reference.

https://en.wikipedia.org/wiki/Blinn%E2%80%93Phong_shading_model


Problem with image texture name in image node that not match with the texture being used in the model

I think you are confusing the name of the file, and the name of the texture slot inside Blender :

The name of the texture slot can be whatever you want (you can change it ie. in the Image Editor).

When you open a picture file, Blender automatically create a new slot and name it as the file. But, if you then change the file, the slot will keep it's old name, which can indeed be confusing.


How can I have a property represent how far away an object is from another?

Measure to faces

The near sensor detects when any face of an object's (physics) hull is within a certain distance. This is especially good when you work with in-homogeneous formed shapes such as planes, poles, streets, fences. But this can be a pretty slow detection even in native code.

While a near sensor provides you with all the information you need a Python controller to evaluate that results. Be aware the distance will be the distance to the center - not to the nearest face.

detector.py:

PROPERTY_DISTANCE = "distance"

def distanceToProperty(controller):
    nearSensor = controller.sensors[0]
    if not nearSensor.positive:
        return

    center = controller.owner
    for hitObject in nearSensor.hitObjectList:
        hitObject[PROPERTY_DISTANCE] = center.getDistanceTo(hitObject)

You can control the filter via the GUI:

Near/Radar/Collision sensor [True Level Triggering] --> Python controller Module: detector.distanceToProperty

Measure to distance

In difference to the near sensor this method measures to the center of the object only. This is good on homogeneous formed shapes such as spheres, cubes, house.

The evaluating code is the same as before. The difference is that you need to perform the sensing via Python. That means your Python controller acts as a sensor (but is no sensor). To do that you have to constantly trigger the Python controller.

detector.py:

PROPERTY_DISTANCE = "distance"
PROPERTY_DETECTABLE = "detectable"

def distanceToProperty(controller):
    center = controller.owner
    for object in center.scene.objects:
        if PROPERTY_DETECTABLE in object:
            object[PROPERTY_DISTANCE] = center.getDistanceTo(object)

Always sensor [True Level Triggering] --> Python controller Module: detector.distanceToProperty


Selecting vertices algorythmically,i.e. a sphere?

import bpy,bmesh
from mathutils import Vector

mesh=bmesh.from_edit_mesh(bpy.context.object.data)
for v in mesh.verts:
    # select by sphere radius
    if v.co.length < 8:
        v.select = True
    # select by cylinder radius
    vcyl = Vector((v.co.x,v.co.y,0))
    if vcyl.length < 5:
        v.select = True
# trigger viewport update
bpy.context.scene.objects.active = bpy.context.scene.objects.active

See Blender: Scale a group of vertices using python on how to determine the center.

Demo:


Why is blender treating vertices differently when applying subdivision surface modifier?

To keep it simple:

If the faces normals are in the same orientation, they can be smoothly interpolated at the subdivision: their mean stays positive.

If they are not, their mean becomes null and so their is no interpolation possible and their mean (so the orientation) is null.

This is like to say the function is not derivable at the face junction.

So the junction stays a singularity and stays angular.


Constrain Transforms Empty to Sphere Vertex (Not Sphere Itself)

You can use "make vertex parent" to do that:

It is some kind of the invert of the hook:

Place the empty as wanted
Select it
Shift select the sphere
Enter edit mode for the sphere (maintaining the empty selected)
Select the wanted vertex of the sphere + 2 other vertices: because 3 vertices are needed to define an orientation plane
The make them parent of the empty using CtrlP

The result is visible here:


How do I cut a semicircle into a curved surface?

Cutting it without messing up the topology (ngons, tris, unwanted distortions, etc.) will be hard.
However, for your specific case I think you might have better luck building the shape by extruding/filling.
For example:

Duplicate a cylinder:

Select some of the edges along the top/bottom of the cylinder and press W>Bridge edge loops:

Repeat for the other side(s), then add a solidify and a subserf modifier:


You can simply add a Cone primitive and adjust the radius of the top (Radius 2) and then adjust the length and or bottom radius as needed.


what is the point of having the same object in multiple layers?

Camera:

If you have the camera in multiple layers, you can always see where it is positioned.

Lighting:

If you have lights in multiple layers, you can see all your objects under the same conditions.

Meshes:

If you have meshes in multiple layers, you might not have weird shadows caused by an object that isn't visible.

These are only a few; render layers are a very powerful tool and have many functionalities.


Rotation Driven by Position - Driver Issue When Rendering

This is a bug. The Drivers - at least in this case and at least in 2.82 - update only if the current frame is changed manually by user. If it is changed by script (which Render Animation also is) Drivers ignore it. You can check it by typing in Blender Console C.scene.frame_current = 5 - or any other frame number - and you'll see, that your object rotation stays unchanged though your frame has changed. More to say, for example if you are at the frame 5, manually change frame to 4 and than back to 5 - the result on the frame 5 will be different than if you would change frame to 6 and than back to 5.

Blender Drivers are buggy. I'd suggest to use Animation Nodes addon instead, it works more stable in general.


Baking to Filmic or Filmic Log in Blender 2.9?

When you save the baked image check Save as Render to apply the render view transformation.
Update
The PNG standard is an 8/16-bit integer format.  To preserve HDR information you must use a file format that supports floating point, which means Radiance HDR or OpenEXR in Blender's case.
https://docs.blender.org/manual/en/latest/files/media/image_formats.html


How to illuminate the darkness inside glass objects in Cycles?

This may be caused by Cycles's rendering of caustics.
From the wiki, Glass and Transparent Shadows:

Glass and Transparent Shadows
With caustics disabled, glass will miss shadows, and with filter glossy they might be too soft. We can make a glass shader that will use a Glass BSDF when viewed directly, and a Transparent BSDF when viewed indirectly. The Transparent BSDF can be used for transparent shadows to find light sources straight through surfaces, and will give properly-colored shadows, but without the caustics. The Light Path node is used to determine when to use which of the two shaders.

To clarify the node setup a bit:

The Light Path node determines the type of the current ray being traced. For each socket, it outputs a 0 if it is not that type or a 1 if it is. Thus, getting the maximum of those two values is equivalent to a boolean inclusive-or operation. The Maximum node will therefore output a 1 if the ray Is Shadow Ray or if it Is Reflection Ray; this will cause the transparent BSDF to be used (as it is the bottom input of the Mix Shader). Otherwise, it will output a 0, and the top shader (the glass shader) will be used.

The following diagram demonstrates some of the various ray types:

The node setup used is part of a node group called "TrickyGlass," which you can see at the top. A node group is a reusable chunk of nodes that can be parameterized just like any other nodes – in this case, with the three inputs on the left – and output, in this case, a shader. Thus, you can use this setup in a node tree like any other shader node.

Here's an image using just a regular glass shader:

And after switching to the TrickyGlass node group:


Adding details to low poly model for 3d printing

Hi,
if you need more details, you will have to add more vertices. You can reach it by several ways.

Globally via mesh modifiers(you can find it in context menu, which is defaultly on right side): Subdivision(Don't forget to use "Simple" option) or Multiresolution.

For specific parts: Edit mode -> Select vertices/lines/faces -> Right click -> Subdivide - You can also change some parameters(smoothness, number of cuts, ...)

There's also dyntopo - it's tool for sculpting, but it can cause unwanted results for 3d printing.

Don't forget some too detailed parts would be better to separate to more prints.

I hope this is that what you needed to know.


How to reduce the amount of noise in the rendered image?

Some tricks I use:

Avoid lights that have to bounce a lot to light your scene. Instead of a sunny exterior, consider making the window glass a light (ie make the emitter the last bounce in your system).

Use ambient occlusion option in world settings. It will brighten things up but start out less noisy.

How is your scene lit? It looks like there is not enough light. Try taking a photograph with no light it also looks grainy ;)


Objects in preview window do not show in the final render

(Reference this with the image below) You may be working with more than one Render Layer. Go to the "Render Layers" tab (2nd tab) and check if there is more than one entry inside the box (red box). If so, click the "-" (yellow box). After you've clicked on the tabs under "Layer" (blue box) for the desired layers you want to include in your final render, go ahead and click on "Save Current Layers for Render" (green box) - please note that this button is only for the "Amaranth Toolset" Add-On.


How to show (only) portions of Wireframe modifier? (Version 2.8)

How about, instead of using the wireframe modifier:

Deleting all but one of the radial edges of your cone, cut to the right length
Alt C convert it to a curve
In the curve's data panel set its full bevel to your liking
Make an empty at center of the cone (its original origin) rotated in Z by 360/32
Make an array of your curve, count 32, Object Offset, the empty as target.

Now you can keyframe the visibility of the original curve (if you want a complete disappearance). For the rest, you can keyframe the Count of the Array modifier.


To model the clouds faster, use the add-on CloudGen that comes packaged with blender. It does the material for you and there are good preset options. If it is taking too long to render, render two shots: Your standard shot with the platform and then another one that is the clouds on a transparent background. Then, you can use the compositor to layer the two shots and if your camera is the same, it should look seamless.


Separate selected UV map vertices from surrounding vertices

You can do this by selecting the face and using Select > Select Split from the Image Editor header or the Y key, then drag to separate. This method doesn't require you changing the Sticky Selection Mode, but it does require that you separate at least one tri. This method does not work for separating a single point or edge.


Advice on how to understand UV unwrap a rounded object

Stretching

First of all, you should make sure that your UV map is free from stretching as much as possible. It is impossible to make it complete stretch free unless you split every triangle. If you plan to draw on the texture only in the 3D editor, that might be a possibility.

To check stretching, assign a checkered texture, like the built in in blender.

Also, in the UV/image editor, in the left panel (hit N), under display, you can check the stretch checkbox. It will color code stretching. Pure blue means no stretching. Various nuances of light blue, cyan, green, and all the way to red means more or less stretching.
There are two kinds of stretching to select here, angle and scale. I mostly use the angle stretching.

Cylindrical mapping

To make it easy to paint latitude and longitude lines, you can use cylindrical mapping. In the 3D editor, in edit mode press U and select Cylindrical projection. The projection is relative your view. Press 5 and 1 on the numpad before doing the projection.

However, this technique will give you serious stretching at the poles. The top row and bottom row in the texture will be be concentrated to a single vertex.


Is this the entire script?  It looks like you forgot to import required modules.

import os
import math

Edit:

Er, well, I think Blender automatically does import math as *
so you'd remove the preceding math. from radians.

I believe you'd still need to import os, unless I'm mistaken about that point.

Edit  You have to define functions before you can run them in Python.  Don't know exactly what you're trying to accomplish with node tree in your run function, so I chopped that out for now, but this script at least runs.

import bpy, os
from math import *

# rendering constants
RENDER_RES_X = 640
RENDER_RES_Y = 480
FRAME_NO = 1

def configureBlender():
    bpy.context.scene.frame_current = FRAME_NO
    bpy.context.scene.render.resolution_x = RENDER_RES_X
    bpy.context.scene.render.resolution_y = RENDER_RES_Y
    bpy.context.scene.render.use_border = False

def run(output_dir):
    bpy.context.scene.render.filepath = output_dir
    bpy.ops.render.render(write_still=True)

def setCameraPosition(location, rotation):
    bpy.data.objects['Camera'].location = location
    bpy.data.objects['Camera'].rotation_euler = [radians(rotation[0]), radians(rotation[1]), radians(rotation[2]) ]

if __name__ == "__main__":
    configureBlender()
    setCameraPosition([0.49123,-2.22974,6.74501],[123.942,0.578,0.1])
    run(os.path.dirname(os.path.realpath(__file__))+'/test')


Here is a little panel I took from my project. As far as I understood, that's what you need.

class WowWMOGroupPanel(bpy.types.Panel):
    bl_space_type = "PROPERTIES" # This defines where our panel should appear
    bl_region_type = "WINDOW"
    bl_context = "object" # This defines the mode in which it appears. In our case, it is object. However, could be "edit" or any other mode.and
    bl_label = "Wow WMO group" # Label and property ID name
    bl_options = {'DEFAULT_CLOSED'}

    def draw_header(self, context):
        layout = self.layout
        self.layout.prop(context.object.WowWMOGroup, "Enabled") # This makes the panel toggleable.

    def draw(self, context):
        layout = self.layout
        row = layout.row()
        self.layout.prop(context.object.WowWMOGroup, "GroupName") # This is our text input property

        layout.enabled = context.object.WowWMOGroup.Enabled # Enables everything in layout if checkbox is enabled

    @classmethod
    def poll(cls, context):
        # check if it is object and mesh
        return (context.object is not None and context.object.data is not None and isinstance(context.object.data,bpy.types.Mesh))

class WowWMOGroupPropertyGroup(bpy.types.PropertyGroup):
    Enabled = bpy.props.BoolProperty(name="", description="Enable wow WMO group properties")
    GroupName = bpy.props.StringProperty() # our string input!

def RegisterWowWMOGroupProperties():
    bpy.types.Object.WowWMOGroup = bpy.props.PointerProperty(type=WowWMOGroupPropertyGroup)

def UnregisterWowWMOGroupProperties():
    bpy.types.Object.WowWMOGroup = None

# After doing this you can adress your property as bpy.context.scene.objects[some_id_or_name].WowWMOGroup.GroupName


Instead of Inserting Key Frames the Inset tool gets activated

You´re in edit mode at this time; pressing I while in edit mode indeed brings up the Inset tool.

You need to be in Object Mode and have your fan as a single object (no other mesh parts), then press N to bring up your side menue and move it all the way up to the "Transform" menue. Now you can see three values for Location and Rotation (x, y, z). Now hover over one of those values and press I to insert a keyframe.

To make the fan rotate, insert a keyframe for Rotation, go to a different frame (a few seconds at least), find the axis your fan rotates around, set its rotation to a high value and press I again. Now your fan rotates!

If you want to rotate your fan infinite, open up a new window inside of Blender by dragging one of the corner points of your current workspace and set it to "Graph Editor". Select your fan object, then select the axis you rotated in the Graph Editor, press Shift + E and select "Make Cyclic". You´re done!

Hope this helps, and happy blending!


cannot get wisps on ghost with point cloud node in blender

So I figured it out. All I had to do was turn my pony into the emitter and then select it and add quick effect smoke to the mesh and use the particle system as the smoke flow. Then bake all of the dynamics.


Reselect faces that was already selected?

For this you can use bmesh:

import bpy
import bmesh

OBJ = bpy.context.edit_object
DATA = OBJ.data
BM = bmesh.from_edit_mesh(DATA)

#Get selected faces
FACES = [f for f in BM.faces if f.select]

#Deselect to see if selection works.
bpy.ops.mesh.select_all(action='DESELECT')

#Select faces again
for S_FACES in FACES:
    S_FACES.select = True

#updates viewport
bmesh.update_edit_mesh(DATA, True)

Hope this helps :)


From the comment, I appeared to figure it out. Selected the mesh, went to edit mode, selected all vertices, press F to create a face, then solidified.


Theory

First thing normal map generators do is to converts the input image into a grayscale image, even if it is colored, that is because color information is practically useless in the generation process, the algorithm used to convert the RGB colors into single values varies from a generator to another, so it is recommended that you convert your input image into grayscale before using the normal map generator, the reason will become clear in the next section.

Imagine the image as a grid of vertices, each vertex represents a pixel, the z location (height) of each vertex is equal to its value (Which is just a scalar not an RGB vector; because it is a grayscale image, remember). So we realize that the image is just a 2D function that associates a value to each point in space, except it is not a continuous function, since it is only defined on some discrete points in space. This surface we just described has normals at each vertex (just like your mesh has normals), and those normals is what a normal map stores, so the generator's job is to simply compute the normals of the surface and encode it in an image. It can be proven that the normals' components relates to partial derivatives of the surface using the equation:

\begin{equation}
\vec{N_x} = \frac{-\frac{\partial F}{\partial x}}{\sqrt{{\frac{\partial F}{\partial x}}^2 + {\frac{\partial F}{\partial y}}^2 +1 }} \\
\vec{N_y} = \frac{-\frac{\partial F}{\partial y}}{\sqrt{{\frac{\partial F}{\partial x}}^2 + {\frac{\partial F}{\partial y}}^2 +1 }}\\
\vec{N_z} = \frac{1}{\sqrt{{\frac{\partial F}{\partial x}}^2 + {\frac{\partial F}{\partial y}}^2 +1 }
}
\end{equation}

Where $F$ is the function that represents the surface and $N$ is the unit normal vector. Partial derivatives describes the steepness and direction of the surface and they can be computed using what is know as Symmetric Derivatives which I explained in more details in my answer
here.

Assuming we have the partial derivatives, we can compute the normal vector components using the previous equation. A normal map stores the $x$, $y$ and $z$ components of the normal vector into the $R$, $G$ and $B$ channels of the image respectively. If we attempted to do that, we will encounter a problem, the image can only store positive values that are less than one (Assuming a standard image format is used), the normal vector components will always be smaller than one because it is a unit vector, however the vector components can be negative denoting directions opposite to the fundamental vectors of the space, so we have to find a way to encode these data which belongs to the interval $[-1, 1]$ to the interval $[0, 1]$ which is the possible values for a pixel. This is a simple remapping task that can be performed using the equation:

$$
\begin{equation} R = \frac{(\vec{N}_x+1)}{2}\\G = \frac{(\vec{N}_y+1)}{2}\\\label{1} \end{equation}
$$

Where $R$ and $G$ are the red and green channels respectively, notice that we didn't perform the same remapping to the $z$ component because it is always positive, think about the surface that represents the image again, its normals will always be facing the positive direction of the $z$ axis. By using the previous equation, we get the RGB values for the normal map, so we are ready to do the implementation.

Implementation

We can make a node group that computes both the $\frac{\partial F}{\partial x}$ and $\frac{\partial F}{\partial y}$ partial derivatives given an input image. The implementation is as simple as a translation and a subtraction:

Refer to the article for more information, the rest of the implementation is as easy as applying the two equations above and creating an image out of the individual channels.

An example result


Although you didn't specify what the "effect" is that's disappearing, I can tell from your node setup that the pseudo-refraction effect is only going to give you multi-colored noise:

This is because in real life, different wavelengths have different refraction indices.  When you change the IOR's on the different shaders and remove that extra Add Shader node, you can begin to see the colors:

EDIT: Also, if you're really interested in accurate light refraction, Cycles is not the engine you should be using.  For a free engine that can interface with Blender and accurately model caustics, look at Luxrender [ http://www.luxrender.net/en_GB/blender_2_5 ] which has unbiased rendering capability.  This is one I rendered with Luxrender:

EDIT 2: I think it depends more on your lighting than on the setting.  It will naturally be darker because of the shadows being cast, but you should still be able to get refraction shimmer.  I just added a simple, enclosed metal container and used the setup above:


Add two edge loops aroung selected edge loop (hard surface modeling)

Just use the Bevel operator for this Ctrl+B by default, no addons needed.

You can control how many additional loops are added from the operator options panel F6 by default.


Tips for creating an animated music video?

Import your song into a music program such as LMMS, and map out the beat with a drum instrument, using kick for the main beat, crashes for points where the track shifts into a high or low, and snares or a different-sounding drum for various points where you want characters to do certain things without the track shifting into a high or low.

Once you export the mapped audio track (just the drums; delete the main song), import it into Blender making sure that the first frames of the main song and the mapped audio track are aligned perfectly. Mute the song and work on your anim relying on the mapped drum pattern.

While mapping out your song, have a word document open. Write the time and what action takes place. Example:
2:43 (James draws sword) (the two characters are in standoff)
2:47 (James races forward to attack)

You can timestamp as much as you want, on many actions as you want. Just be sure to mark your track with the appropriate snare or crash if there are certain character actions that need to be signified.

If there are lyrics, go into Blender and animate them, replacing the current line of text every time there's a new sentence or stanza. Animating them syllable by syllable helps.

That's it so far! I'm working on my own music video in Blender too and I found all this stuff out the hard way. Perhaps once I finish and release the actual product, I'll release a BTS video sharing everything I learned and discovered.

Good luck on your music video!

EDIT: Obviously, you need to determine the frames per beat in order to sync to the music. Here's what you can do. Determine the BPM of you song here: https://getsongbpm.com/tools/audio

Then calculate the frames per beat of your song here: https://www.vjamm.com/support_av_bpm.php%3Flang=en.html

Adjust the value of your framerate until the frames per beat is at a whole number. Then, type in that framerate value into Blender (make sure to set it at custom), adjusting the base value underneath until the numbers on the framerate are correct.
For my project, I had a framerate of 24.4.


Why are game engine properties changing 1 tick late?

Problem
The problem was that, your integer property Timer was still equal to 45 when the weapon was switched, for exactly one logic tick, allowing a shot to escape. Then, one tick later, the message actuator could deliver the message to assign the property Timer to 0.
Reason
The message system actually takes one logic tick from the time the actuator receives the positive pulse from the controller, to the time when the message sensor on the receiving end receives the message and sends the positive pulse to it's controller(s).
How to fix it
I have un-checked the the check boxes on all of the logic we aren't using so it will be easier to see the necessary change. (re-check them before testing)

Your end result should look like this, only without the actuators on Active_Determiner
Essentially, all you need to do is Delete the logic bricks marked by a red box, and connect the bricks where the Blue lines are.
This will completely cut out the message system, (and the one-tick delay) and directly connect the bricks instead.

result:
It works! - yay!

If you didn't understand that, don't feel bad (logic can be confusing.) here is the blend file in case you did get confused.


It is because you are trying to set the depth of an object, not a cylindre. Once the cylinder is created, it is impossible to chage the "generation" parameters. A solution would be to create a new cylindre each time in your loop instead of making a copy of the previous one.

bpy.ops.mesh.primitive_cylinder_add(radius= 0.02, depth=value[3])
ob1 = bpy.context.scene.objects.active
ob1.rotation_euler = cylinder.rotation_euler
...


Small moments when I can't seem to do anything

You could try a right click. For example, using circle select needs a right click to accept the selection and escape back to normal.


The smaller object has Clamp Overlap enabled, so it's not actually being beveled by the shown Amount. You have to disable it.
Clamp ON

Clamp OFF


Without using a script, you can create a tick count property and use the property actuator to increment it each frame. With the always sensor you can set the frequency (now called skip) to trigger the update every frame, or two frames...

If you place that in a common object that is always in the game, such as the ground, when you want to know the tick count in a script you can get the ground object from the scene.

scn = bge.logic.getCurrentScene()
grnd = scn['ground']
tick_count = grnd['ticker']

For forking your own version of blender, you will find the main loop at the bottom of wm.c. You can add a property to the GameData struct in DNA_scene_types.h, then add it in rna_scene.c to access it via python. Note that changes to any structs need to maintain a multiple of eight bytes in length for alignment, builds will fail if you don't get it right, and moving any existing properties will break reading blend files. It has been a while since I looked at this so I may be missing a change needed, start here for info about changing the data structures.


Emission Shader + Alpha masking

Shadeless material in cycles can be obtained by using the Emission shader. For further instruction on how to handle all the interactions with other objects in the scene and dealing with shadow casting, I'll suggest to read:
Read Node for setting render colour, regardless of lighting

The alpha of the image can be used to control the shading property of the object by using as an input of a Mix Shader that mix the Emission shader and a trasparent shader.

Here's a possible node setup.


You don't have to do all this as Random option is available in the particle system settings in regard to the particles' scale and rotation. Use it.


How to stop a simulation that is lagging?

I have had this problem a countless number of times. The solution I always use that usually works is pressing the "escape" key on my keyboard while the animation is playing. This almost always works for me, and I hope it works for you. It also apparently stops pointCache bakes when the interface is frozen.


What is the best or fast way to add a star on top of a helmet?

I would suggest you use a shinkwrap modifier, as well as a solidify modifier to give it some thickness, and possibly a bevel:

This applies to any shape you'd like to project onto any surface.

Just keep in mind that you need to have enough geometry to allow it to deform smoothly, and preferably a quad loop around the border to avoid shading (or bevel) artefacts:


Fluid Simulation is still low quality even with resolution of 250

For one thing, a resolution of 250 isn't that much. Everything will look crappy at that resolution. And as gandalf3 said, make sure your domain isn't unnecessarily large.

Setting subdivisions to 2 won't really improve your simulation in this case. Change it back to 0 (or 1, because of blender logic it is the same) and save some baking time.

For extra smoothing, use the smooth modifier. However, it may reveal holes in the fluid mesh, so make sure you check what's going on before you render.


Animation nodes - How to make an object face camera yet let the object rotate around its normal?

Parent the camera to the object, in this case, the cube.

Simple as that.


Create a small section of road.

Add a curve to define the path the road will follow.

Back on the road section, add an array modifier, a curve modifier and a shrikwrap modifier. You set the array to fit the length of the curve. Then it follows the curve and the shrinkwrap sticks it to the terrain surface.

Giving a final result -

The curve can then be hidden. Or you can apply the modifiers and join the road mesh to the terrain mesh so they are one. Applying separate materials to each section of mesh.


The Blender BMesh Python API supports custom-data-layers per vert/edge/face/loop. Per face, it only supports the types (float, int, string, tex), so you'll have to make your own vectors and colors out of floats.

The code would be something like:

import bpy
import bmesh

ob = bpy.context.object

# create a bmesh editing context...
bm = bmesh.new()

# if we're in edit mode, there is already a BMesh available, else make one
if bpy.context.mode == 'EDIT_MESH':
    bm.from_edit_mesh(ob.data)
else:
    bm.from_mesh(ob.data)

# Make the layers..
tag_number = bm.faces.layers.integer.new('number_tag')
tag_vector_x = bm.faces.layers.float.new('vector_tag_x')
tag_vector_y = bm.faces.layers.float.new('vector_tag_y')
tag_vector_z = bm.faces.layers.float.new('vector_tag_z')
tag_color_r = bm.faces.layers.float.new('color_tag_r')
tag_color_g = bm.faces.layers.float.new('color_tag_g')
tag_color_b = bm.faces.layers.float.new('color_tag_b')

# fetch the layers
tag_number = bm.faces.layers.integer.get('number_tag')
tag_vector_x = bm.faces.layers.float.get('vector_tag_x')
tag_vector_y = bm.faces.layers.float.get('vector_tag_y')
tag_vector_z = bm.faces.layers.float.get('vector_tag_z')
tag_color_r = bm.faces.layers.float.get('color_tag_r')
tag_color_g = bm.faces.layers.float.get('color_tag_g')
tag_color_b = bm.faces.layers.float.get('color_tag_b')

# set the tag value for a particular face
bm.edges[face_no][tag_number] = new_number_tag_value

# retrieve the value for a particular face
my_number_tag_value = bm.faces[face_no][tag_number]

# save our edits
if bpy.context.mode == 'EDIT_MESH':
    bm.updated_edit_mesh(ob.data)
else:
    bm.to_mesh(ob.data)
bm.free()

At some point, you'll probably want to iterate selected faces, like this:

for f in bm.faces:
    if f.select:
        print(f.index)

I don't know if the collada exporter does anything with this custom BMesh data. If not, you'll either need to extend it, or write your own exporter.

See also:

bpy.context docs
bpy.types.Object docs
bpy.ops.object docs


How do I give the 2D cursor specific coordinates in 2.8?

2D cursor to coordinates : you will find in the display drop down menu

The Snap to options you will find in the UV Context menu (right click) :


I tried changing the scale variables, but they just revert back.

I am assuming by that you mean you are changing the scale of the parent object SketchUp through Blender---And not Animation Nodes. It simply reverts because Animation Nodes is overwriting the the scale of the object as defined by the Object Matrix Output Node. So, instead of changing the scale manually, define it in your node tree through the Compose Matrix Node.

Another method---Which I do not recommend due to its unpredictable consequences---is to set the scale of matrix to the scale of the object. By doing so, any manual change in the scale of the object is met with change in the scale of the matrix and is translated into a normal scaling behavior.


Why does the Minecraft-texture have black/dark borders in Cycles?

The problem is caused by Smooth Shading, to solve that you have to give your stairs model Edge-Split Modifier.

Before the ES Modifier

After the ES Modifier


How to extrude vertex normals along an angle with an even offset?

You can use simple extrude and scale, however along custom Transform Orientation, in this case View, in order to lock scaling on non-desired axes.

Select the face which is oriented at an angle (which looks like parallelogram). In the case of cuboid on your screenshot the one which is formed with the top loopcut on the side.

Align viewport with it so you see the face from the top. Shift+Numpad 7 will do that.

Once viewport is aligned, select the ring of faces to extrude (Alt + Left click on faces near an edge).
Make View as transform orientation along which transform will be done - press Alt+Space and choose View.

Press E to extrude, cancel default extrusion and press S to execute Scale tool.
Now lock movement on axis you don't want to interfere. In case of described viewport position View X axis should be locked, so after enabling Scale tool press Shift+X (locks global X) and then again Shift+X (locks View X). Move to the desired offset.


Mesh won't react to light and remains bright

I somehow managed to enable ambient occlusion in the world properties, disabling it fixed the issue for me


You have something like this (Blender Internal)

Sunlight lamp only lets you change the angle of the light-source and not the distance of the light to the scene objects. Test this by moving the sunlight closer or further away from the objects, compared to rotating the sunlight. If you want smaller shadows, don't use a sun lamp on its own. When you only have one light-source like a sunlight on default settings, you will get sharp shadows.

You can fake ambient light by adding Ambient Occlusion or Environmental Lighting, or add a few weak lights to give you more control.

adding Ambient Occlusion would give you this:

or adding Environmental Lighting for this:

You could also mess with the shadow settings of the sunlight lamp: (softsize & samples & shadow colour). But on its own that still doesn't produce a nicely illuminated image.

The trick really is to add more lights, but make them weak so as not to saturate the scene. If you are serious about lighting I recommend you read this classic post by Ben Simonds about lighting techniques.


Can a link in a node setup be temporarily disabled?


Blender Armature Weight Painting - Bone does not move how he should

Select your mesh and go into edit mode. Select single vertices and check Vertex Weights right in the properties shelf (see screenshot below). This way you can check for each vertex if it is influenced by an unwanted bone.

Another frequent error while rigging is if your mesh is mirrored. For modelling this is great, but when animating it's better to apply the modifier first.


I set Bone roll in python to 37 it sets roll value to 2636 degrees. Whats wrong?

Python always sets rotation in Radians, not degrees.

$2\pi$ radians is equal to $360^\circ$. This explains your issue, since

$$37 \text{ radians} = (37\cdot 180/\pi)^\circ \approx -2693^\circ$$

You'll need to convert degrees to radians by multiplying by $\pi\approx 3.14...$ and dividing by $180$.


Rather than using a symlink you can just point to a /scripts/ directory in User Preferences > File

After setting the path be sure to Save User Settings. Doing this will let you place your scripts in the folder designated, and leave the default folder alone.

Your folder structure should look like:

scripts/
  addons/
  addons_contrib/
  startup/
  presets/

Not all sub-directories are required, but you should have at least /scripts/addons/


Assign colour to vertices given face texture, and enable conversion to a point cloud

If you want to make each vertex store color from the appropriate place from the texture you want to bake texture to vertex colors. In case of baking in Blender this means you want your objects to be unwrapped and have a texture assigned to faces of the starting mesh.

First, unwrap the mesh if it hasn't been already. Then, if Cycles render engine is chosen, create a new scene / project and somehow transfer your mesh object there (Ctrl+C > Ctrl+V between different files can be handy, or append it from File > Append > Objects).

In the new project choose Blender Internal as render engine  (see how).

Then assign desired texture to faces of the mesh. To do so, open 2 editors in Blender window and choose one of them to be UV/Image editor (see more on this). In 3D viewport, enter Edit mode and select all. In the UV editor UV map should appear (see more info here if it doesn't). Choose your image texture you want to bake from in the UV editor via the dropdown list below the image.
Create a material for the object (default one works fine), then create new material texture for that material, its type by default should be Image or Movie. Choose image to bake to once more, this time in the dropdown list in the texture settings, Image rollout. Make sure Mapping is set to UV.

From this point you're left only to bake. In the Properties editor go to Render tab, scroll it to the Bake rollout and choose Textures. Below enable Bake To Vertex Colors option and press Bake button.

Note that quality of bake depends on density of geometry of the mesh.

Regarding the Bake UV textures to vertex colors addon. It makes it possible to bake in Cycles the same, but there's a small nuance - it expects texture to be assigned the same as in Blender Internal, i.e via UV editor to the face textures (however the addon doesn't require creating a material and assigning a texture to that).
Cycles doesn't do that since it doesn't use face textures to map images to mesh, so for baking with that addon in Cycles you'd need to switch to Internal, assign texture to faces with all selected in UV editor as explained above, then switch back to Cycles and bake.


Ok, so, radical solution, follow these steps:


How can I get this curtain to open and close realistically?

Here's a way to get you started,
Subdivide a grid or plane well and select some vertices that would be where the "rings" would go into the curtain. (a bit randomness is okay I suppose)

Add these selected vertices to a vertex group to be used by the cloth modifier for pinning.

Create a Shape Key and for the second key scale the pinning vertex group towards the cursor the direction the curtain will open.

Add cloth and subdivision surface modifiers.
For cloth settings, default is mostly okay aside from adding self collisions and pinning vertex group.

Next animate the shape key from 0 to 1 and you should end up with a result similar to below:

Here's a file to play with:


I have found a Solution. This is not really an answer as to why it is happening but it's too long to put into a comment and at least it fixes the problem.

Go into Edit Mode
Press P (for Seperate) and select By Loose Parts
Create a Cube somewhere in the scene
Select all the loose parts of your model and then the cube so the
cube is the active object and press Ctrl+J (for join)
Go back into Edit mode and delete the Cube, unwrap: done.

This is the same procedure by the way that I frequently use to set the rotation and scale of an object to 1.


The -t option is to specify how many threads are used for rendering, this should be followed by a number but the -a you have following it will give you an error.

The main issue you have with your command is that blender executes the arguments in the order they are given. Following it through means that blender starts in background mode, loads mainfile.blend, sets the engine to cycles, incorrectly sets the threads, renders an animation, opens the file //file then runs the script script.py.

What should work for you is -

blender -b mainfile.blend -E CYCLES -P script.py

If you are adding //file to specify the output file for the render, then you need to put -o in front of it (and add a file extension) and if it is a folder then also add a trailing slash -o //test_renders/.

You may also want to remove the render line from your script and use -f <frame number>. Note that using -f to render a specific frame from the command line will save the image to file so you don't need the render step in your script.

blender -b mainfile.blend -E CYCLES -P script.py -o //file.jpg -f 1


Why do is there a gaping hole in camera view but not in viewport shading?

Your clipping distance is too high. Select your camera, press the little camera icon in the bottom right of your screen. Then, reduce Clip start to the lowest value. Right now it is too high in the picture, make it lower than that


Add material and apply Diffuse color via Python

Actually, I figured it out shortly after posting the question.

Instead of using:

bpy.ops.material.new()

I needed to use:

bpy.data.materials.new(name="MaterialName")

So the final solution was:

activeObject = bpy.context.active_object #Set active object to variable
mat = bpy.data.materials.new(name="MaterialName") #set new material to variable
activeObject.data.materials.append(mat) #add the material to the object
bpy.context.object.active_material.diffuse_color = (1, 0, 0) #change color


You work with source code in the src folder of the cloned blender repo directly. If there is no project file for the IDE included (in your case the Visual Studio Solution) you need to create one and set it up to use this src folder.
Fortunately, Visual Studio offers support for git, so all you have to do is create a new Visual Studio Solution and set up git and the blender repo. Then you can track your changes and do the versioning in Visual Studio.
Of course you can still use the git command line but the source files stay in the src folder. Git handles the changes and keeps track of them. The repo itself with all versions and changes is usually stored in a folder named ".git" inside of the main folder.
Hope that helps.


Is there a way to render "material preview", as seen in the main layout (viewport)?

You can render directly from any viewport using the "Viewport Render" option:

Be sure to set the color management to Standard when rendering this way. Otherwise, the exported image will be run through filmic twice resulting in gray highlights.


You can do Shift+L > Object Data to select all visible objects that share the same data and then do U > Object and Data to make the selected objects single users.

Ctrl+L > Object Data can then be used to link the selected objects together again after making any changes.


For a linked collection instance

Pertaining to 2.8x

Example below. Collection instance "Cube.001" is linked from library "Cube.blend" where it belongs to collection "Cube"

>>> C.object
bpy.data.objects['Cube.001']

>>> C.object.type
'EMPTY'

>>> C.object.library
bpy.data.libraries['CUBE.blend']

Notice the collection is linked too

>>> C.object.instance_collection
bpy.data.collections['Cube']

>>> D.collections['Cube'].objects[:]
[bpy.data.objects['Cube']]

The dimensions of the individual objects in the group can be found via

>>> for o in C.object.instance_collection.objects:
...     o.name, o.type, o.dimensions
...
('Cube', 'MESH', Vector((2.0000009536743164, 2.0000009536743164, 2.0)))

which could be used to make a "virtual" bounding box for the collection.

How to have a boundary box around a whole group instance?

Similarly for linking the collection and instancing from local blend.


Frames Per Second

The output file format you've chosen, Xvid, does not support the frame rate you've chosen. Your error,

  Timebase 20999/500000 not supported by MPEG 4 standard, the maximum admitted value for the Timebase denominator is 65535

basically says: your frame rate (5 frames per second with a framerate base of 0.210, totaling 23.81 fps) isn't compatible with your output file format.

How to fix

As far as I'm aware you can't fix it, you have to either change the fps or the output file format.

Happy Blendering!


When selecting, it is this weird select tool and I dont know how to make it select with a click

You are on Lasoo select. Press W to toggle through select modes until the cursor in the top left of the viewport is an arrow with a dotted box around it again (box select is default). – Christopher Bennett


It seems like importing normals is impossible with 2.67 version of Blender. Blender recalculates them manually.

But for version 2.74 you can import custom normals using code sample:

normals2 = []
for l in mesh.loops:
    normals2.append(nlist[l.vertex_index])
mesh.normals_split_custom_set(normals2)
mesh.use_auto_smooth = True


Is it possible to have Smooth Shading on by default?

It is kind of possible to write an add-on for this with Python. There does not seem to be a nice way to trigger an operator(what smooth shading is in Blender apparently) every time an object is created, but it is possible to check the count of objects in the file every time scene is updated. Scene gets updated all the time so that is a whole lot of unnecessary checks, but it seems there is no nice or elegant way to do this. I am not entirely sure I can honestly recommend using it but this hack seems to work and it's the only way to do it I can think of. It shades anything new to the scene smooth. Pasting and duplicating will trigger it as well. You can save it to a .py file and install it as an add-on if you really need this functionality. You may also want to do something about ugly shading with sharp edges so you may want to uncomment the line enabling auto smooth.

bl_info = {
    "name": "Smooth shade new objects",
    "author": "-",
    "version": (1, 0),
    "blender": (2, 79, 0),
    "location": "Works every time new objects are added",
    "description": "Shades everything added to the scene smooth",
    "warning": "",
    "wiki_url": "",
    "category": "Mesh",
    }

import bpy
from bpy.app.handlers import persistent

bpy.last_count = 0

@persistent
def smooth_handler(dummy):

    if len(bpy.data.objects) < bpy.last_count:
        bpy.last_count = len(bpy.data.objects)
    elif len(bpy.data.objects) > bpy.last_count:
        bpy.last_count = len(bpy.data.objects)
        if bpy.context.object != None:
            #bpy.context.object.data.use_auto_smooth = True
            bpy.ops.object.shade_smooth()

def register():
    bpy.app.handlers.scene_update_post.clear()
    bpy.app.handlers.scene_update_post.append(smooth_handler)

def unregister():
    bpy.app.handlers.scene_update_post.clear()

if __name__ == "__main__":
    register()


Distance points between frames in motion tracking

This can only be done with a script.
(modified from this Source)
The script outputs a csv file with the coordinates for each tracker.
from __future__ import print_function
import bpy
D = bpy.data

outputFolder= "/set/your/output/directory/here"

printFrameNums = False # include frame numbers in the csv file
relativeCoords = False # marker coords will be relative to the dimensions of the clip

f2=open('export-markers.log', 'w')
print('First line test', file=f2)
for clip in D.movieclips:
    print('clip {0} found\n'.format(clip.name), file=f2)
    width=clip.size[0]
    height=clip.size[1]
    for ob in clip.tracking.objects:
        print('object {0} found\n'.format(ob.name), file=f2)
        for track in ob.tracks:
            print('track {0} found\n'.format(track.name), file=f2)
            fn = outputFolder+'{0}_{1}_tr_{2}.csv'.format(clip.name.split('.')[0], ob.name, track.name)
            with open(fn, 'w') as f:
                framenum = 0
                while framenum < clip.frame_duration:
                    markerAtFrame = track.markers.find_frame(framenum)
                    if markerAtFrame:
                        coords = markerAtFrame.co.xy
                        if relativeCoords:
                            if printFrameNums:
                                print('{0},{1},{2}'.format(framenum, coords[0], coords[1]), file=f)
                            else:
                                print('{0},{1}'.format(coords[0], coords[1]), file=f)
                        else:
                            if printFrameNums:
                                print('{0},{1},{2}'.format(framenum, coords[0]*width, coords[1]*height), file=f)
                            else:
                                print('{0},{1}'.format(coords[0]*width, coords[1]*height), file=f)

                    framenum += 1
f2.close()

Pay attention to the units used.
The script will output coordinates in pixels, where 0,0 is at the bottom left of the frame.
To use a float values, where the frame has coordinates 0 to 1, change relativeCoords = True
To include the frame number as part of the set, use printFrameNums = True


Mirror modifier creates duplicate vertices when modeling

Check the box of the 'bisect' Y axis in the mirror modifier.
The mirror modifier duplicates your whole mesh and mirrors it as a whole, so that's why there are duplicate vertices. To make it mirror only one side and get rid of the other, you must check the 'bisect' axis as well (bisecting literaly means cutting in half).
If the side it got rid of was not the one you wished to get rid, also check the 'flip' box in the same axis.


Export "Project from view" texture as uv texture

You can Bake the texture onto your UV map.

with your model selected in the 3d View, open the Uv/Image Editor and create a new image. Name it and dimension it however you like. Otherwise you can just leave the image blank for now.
With your model still selected in the 3d View, open the Node Editor. You don't need to mess with the material at all. Just add an Image Texture node using the blank image you just created. Make sure the Image Texture node is selected. It should have a brighter border than notes that aren't selected.
In the Render Panel of the Properties Editor, scroll down to the Bake section. The default Bake Type is Combined. If you just want the diffuse portion of the material, select Diffuse Color from the dropdown list.
Click Bake and the texture should appear in UV Editor aligned with your model's UV map.

Pink stripes mapped to original material with a separate 'Projected from View' UV map. Return to step one to bake as one texture map. Just be sure to have the original UV selected as active in the Properties Editor when doing so.


exported fbx with multiple textures has only one

You have to assign every material to its part and not only unwrap it with the textures.


Switch a light on/off with animation nodes

You can do it animating the light's strength.

(I did it in Cycles)

I couldnt add the screen shots that i took :/

First, select your lamp
Then go to the frame that you want the strength 0
Go to light settings and set the strength to 0
Press the 'i' key with your mouse cursor over the strength value and it will gets yellow
Go to the frame that you want the strength to be 100, set the strength to 100 and press the 'i' key again with the mouse over the number


Weird edges with solidify and subsurf modifier

You have inner faces, what we see is the shading between the outer and inner faces. If I select these faces and hide them:

I can see this face:

Delete these faces.


blender 2.8 how duplicate view3d area into new window from script

The operator still works in 2.80, but you need two parameters:

A custom context that tells the operator what area should be used for the new window
The correct execution context

The custom context can be created by modifying a copy of the current one. The area object for the 3D view can be found by iterating through bpy.context.screen.areas and checking for the type to be 'VIEW_3D'.

Executing bpy.ops.screen.area_dupli(context) will not work properly, because EXEC_DEFAULT is used as the default execution context. When this is the case event->customdata is NULL (see screen_ops.c) which results in the operator returning PASS_THROUGH and no window being created. The solution is to add INVOKE_DEFAULT as argument, which is exactly what the button in the user interface does.

import bpy

context = bpy.context.copy()

for area in bpy.context.screen.areas:
    if area.type == 'VIEW_3D':
        context['area'] = area
        bpy.ops.screen.area_dupli(context, 'INVOKE_DEFAULT')
        break


I can't find any low-level way to un-group the nodes. Consider that ops.node.group_ungroup() does a lot of things for free (keeps the references/data of the nodes, removes the input and output node, keeps the connections etc.) so I'd suggest to write your own operator and just call it within the Node Editor either by using spacebar or creating a button.

import bpy

def main(operator, context):
    space = context.space_data
    node_tree = space.node_tree
    node_active = context.active_node
    node_selected = context.selected_nodes

    if node_active.type == 'GROUP':
        bpy.ops.node.group_ungroup()

class NodeOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "node.simple_operator"
    bl_label = "Simple Node Operator"

    @classmethod
    def poll(cls, context):
        space = context.space_data
        return space.type == 'NODE_EDITOR'

    def execute(self, context):
        main(self, context)
        return {'FINISHED'}

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

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

if __name__ == "__main__":
    register()

In case there is no way around calling bpy.ops.node.group_ungroup() within the Node Editor, you can switch the current area.
Example based on: poll() failed, context incorrect? - Example: bpy.ops.view3d.background_image_add()

import bpy

def main(operator, context):

    area = context.area
    old_type = area.type

    # Set the area to NODE_EDITOR
    area.type = 'NODE_EDITOR'

    space = context.space_data
    node_tree = space.node_tree
    node_active = context.active_node
    node_selected = context.selected_nodes

    if node_active.type == 'GROUP':
        bpy.ops.node.group_ungroup()

    # Reset properties area
    area.type = old_type

class NodeOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "node.simple_operator"
    bl_label = "Simple Node Operator"
    '''
    @classmethod
    def poll(cls, context):
        space = context.space_data
        return space.type == 'NODE_EDITOR'
    '''
    def execute(self, context):
        main(self, context)
        return {'FINISHED'}

class LayoutDemoPanel(bpy.types.Panel):
    """Creates a Panel in the scene context of the properties editor"""
    bl_label = "Layout Demo"
    bl_idname = "SCENE_PT_layout"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "scene"

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

        scene = context.scene
        layout.operator(NodeOperator.bl_idname)

def register():
    bpy.utils.register_class(NodeOperator)
    bpy.utils.register_class(LayoutDemoPanel)

def unregister():
    bpy.utils.unregister_class(NodeOperator)
    bpy.utils.unregister_class(LayoutDemoPanel)

if __name__ == "__main__":
    register()


Yes, you can do this through the outliner editor window. Select all of the objects in your scene which have the desired texture image. Then, moving to the outliner window, expand the datablock for each object to the point where you can see the names of the image textures that you want to use to join the objects. In the outliner window, select image texture of one of the objects you wish to join, then each of the others, selecting these in the outliner window by holding down the SHFT key while you select the objects with the LMB. You can now join the selected objects by using CTRL - J


Camera Solving, the trackers in 3D space are inverted

I had this same problem. The points closer to the horizon were solved to be the closest point to the camera. That was when I was using auto detected points. I started over and manually selected a lot of high contrast point, only kept the good ones after looking at the graph clip editor, and then the scene solved perfectly


How to recover Lost work in Blender

Go to "File" -> "Recover autosave"
Use *.blend1 file - it is save before last save :-)
In splash screen use "Recover Last session" - open automatically saved project on Exit Blender.


So I feel very stupid but unchecking camera in the object info tab did it.


Subdivision Surface Artifact with Creases

Your geometry is not exactly flat. If you look at it from the top, you will see this.

I suggest moving your vertices like this:

But your main problem is that the creases end inside the mesh. If you extend them all the way to the end of your mesh, it will be without artifacts. Like this.

You can also clear the crease and insert two edge loops. I find it slightly easier to control the exact bevel this way. Use ctrl + R to create a edge loop. Click on the faces where you want it. Slide it up where you want it. Left click to finish placement.


Camera follows path, but is not looking the direction I want

If you use a Follow Path constraint, you can simply enable the Follow Curve option, and the camera orientation should follow the curve. In that case deactivate the Clamp To constraint. If you don't want to use a Follow Path, just keyframe the camera rotation.


How do i activate 'rendered view' in Cycles. Shift z is not working

Press z to open pie menu. Rendered view is at top.


How to select leaves on a sapling-addon tree when selecting their branch?

The leaves can be connected to the sapling mesh through the following steps.

1) In object mode, select the tree and the leaves.

2) Press ctrl+J to join the meshes.

3) Enter edit mode and select all using A.

4) Press ctrl+F and select 'Intersect (knife)' and make sure the Separate option is unselected and the Source is 'Self intersect'.

5) Now the mesh is fully connected, including leaves. Selecting a vertex and using ctrl+numpad + will select all of the connected elements.


It is easier to map the image on a circular mesh.

As an alternative you can create another image (or alpha channel) that defines the circle and use that as a mask to define transparency.


In blenders preferences under system you have a few options for the software used for sound, this may help playing sound from blender's VSE.

For the output video you need to check that you have selected an audio codec in the encoding options.


How to load correctly submodule into __init__.py Taking into account the use of bpy.ops.script.reload()?

It is not that bad to use the second method if you're not collaborate and distribute your project with other. In other words, personal usage is fine if you do take care of naming confliction.
The problem when you reload script is a common mistake that you assume that all object you imported from that module is reloaded by the reload method (imp.reload()). Instead reload all relative script, Python will only reload the required script, which is your module, not the * objects.
You can some how use Python built-in reload function to specify the updated script that you want to use and reimport * again:
from imp import reload
reload(function)  # bpy.ops.script.reload() seems like a sugar macro that handle the dependencies

from functions import *
# This is required since you don't reload e.g. `foo()` and `bar()` in your functions

And also if you want to use Method 1 for correctness:
from . import functions as fn
fn.foo('bar')

or
# You should take care about relative import path issue
from ./functions import (
    foo,
    bar,
    a_very_loooong_name_function,
)
foo("cool")
bar("hello")