Load Preset and execute Function or Operator

If its written in python can be found with a little digging.
The key here is in the menu, you are defining which operator to use to execute presets
    preset_operator = "script.execute_preset"

If we can find it in bpy.types then it has a python module
>>> bpy.ops.script.execute_preset.idname()
'SCRIPT_OT_execute_preset'

>>> bpy.types.SCRIPT_OT_execute_preset.__module__
'bl_operators.presets'

and there it is in 2.91/scripts/startup/bl_operators/presets.py
class ExecutePreset(Operator):
    """Execute a preset"""
    bl_idname = "script.execute_preset"
    bl_label = "Execute a Python Preset"

    filepath: StringProperty(
        subtype='FILE_PATH',
        options={'SKIP_SAVE'},
    )
    menu_idname: StringProperty(
        name="Menu ID Name",
        description="ID name of the menu this was called from",
        options={'SKIP_SAVE'},
    )

    def execute(self, context):
        from os.path import basename, splitext
        filepath = self.filepath

        # change the menu title to the most recently chosen option
        preset_class = getattr(bpy.types, self.menu_idname)
        preset_class.bl_label = bpy.path.display_name(basename(filepath))

        ext = splitext(filepath)[1].lower()

        if ext not in {".py", ".xml"}:
            self.report({'ERROR'}, "unknown filetype: %r" % ext)
            return {'CANCELLED'}

        if hasattr(preset_class, "reset_cb"):
            preset_class.reset_cb(context)

        if ext == ".py":
            try:
                bpy.utils.execfile(filepath)
            except Exception as ex:
                self.report({'ERROR'}, "Failed to execute the preset: " + repr(ex))

        elif ext == ".xml":
            import rna_xml
            rna_xml.xml_file_run(context,
                                 filepath,
                                 preset_class.preset_xml_map)

        if hasattr(preset_class, "post_cb"):
            preset_class.post_cb(context)

        return {'FINISHED'}

re-write another operator, using same properties,  to do whatever floats your boat when your preset is loaded, and tell the system to use it instead
preset_operator = "script.execute_preset_float_boat_version"

Ok, since we are no longer using the default operator, we can set the defaults for the operator in the draw preset method of menu class
>>> bpy.types.Menu.draw_preset(
draw_preset(self, _context)
Define these on the subclass:
- preset_operator (string)
- preset_subdir (string)
Optionally:
- preset_add_operator (string)
- preset_extensions (set of strings)
- preset_operator_defaults (dict of keyword args)

Define the callbacks
Looking at the operator code, notice two callback functions are run, one before the preset is loaded reset_cb and one after post_cb.  Have added these two classmethods to Menu to print to console when called.
so in full
import bpy
from bpy.types import Operator, Menu
from bl_operators.presets import AddPresetBase
from bpy.props import StringProperty

class ExecutePreset(Operator):
    """Execute a preset"""
    bl_idname = "script.execute_preset_float_boat"
    bl_label = "Execute a Python Preset"

    filepath: StringProperty(
        subtype='FILE_PATH',
        options={'SKIP_SAVE'},
    )
    menu_idname: StringProperty(
        name="Menu ID Name",
        description="ID name of the menu this was called from",
        options={'SKIP_SAVE'},
    )

    def execute(self, context):
        from os.path import basename, splitext
        filepath = self.filepath

        # change the menu title to the most recently chosen option
        preset_class = getattr(bpy.types, self.menu_idname)
        preset_class.bl_label = bpy.path.display_name(basename(filepath))

        ext = splitext(filepath)[1].lower()

        if ext not in {".py", ".xml"}:
            self.report({'ERROR'}, "unknown filetype: %r" % ext)
            return {'CANCELLED'}

        if hasattr(preset_class, "reset_cb"):
            preset_class.reset_cb(context)

        if ext == ".py":
            try:
                bpy.utils.execfile(filepath)
            except Exception as ex:
                self.report({'ERROR'}, "Failed to execute the preset: " + repr(ex))

        elif ext == ".xml":
            import rna_xml
            rna_xml.xml_file_run(context,
                                 filepath,
                                 preset_class.preset_xml_map)

        if hasattr(preset_class, "post_cb"):
            preset_class.post_cb(context)

        return {'FINISHED'}

class OBJECT_MT_display_presets(Menu):
    bl_label = "Object Display Presets"
    preset_subdir = "object/display"
    preset_operator = "script.execute_preset_float_boat"
    preset_operator_defaults = {
            "menu_idname" : 'OBJECT_MT_display_presets'
            }
    draw = Menu.draw_preset
    @classmethod
    def reset_cb(self, context):
        print("Reset")
    @classmethod
    def post_cb(self, context):
        print("Post Callback")

class AddPresetObjectDisplay(AddPresetBase, Operator):
    '''Add a Object Display Preset'''
    bl_idname = "camera.object_display_preset_add"
    bl_label = "Add Object Display Preset"
    preset_menu = "OBJECT_MT_display_presets"

    # variable used for all preset values
    preset_defines = [
        "obj = bpy.context.object"
    ]

    # properties to store in the preset
    preset_values = [
        "obj.display_type",
        "obj.show_bounds",
        "obj.display_bounds_type",
        "obj.show_name",
        "obj.show_axis",
        "obj.show_wire",
    ]

    # where to store the preset
    preset_subdir = "object/display"

# Display into an existing panel
def panel_func(self, context):
    layout = self.layout

    row = layout.row(align=True)
    row.menu(OBJECT_MT_display_presets.__name__, text=OBJECT_MT_display_presets.bl_label)
    row.operator(AddPresetObjectDisplay.bl_idname, text="", icon='ZOOM_IN')
    row.operator(AddPresetObjectDisplay.bl_idname, text="", icon='ZOOM_OUT').remove_active = True

classes = (
    ExecutePreset,
    OBJECT_MT_display_presets,
    AddPresetObjectDisplay,
)

def register():
    for cls in classes:
        bpy.utils.register_class(cls)
    bpy.types.OBJECT_PT_display.prepend(panel_func)

def unregister():
    for cls in classes:
        bpy.utils.unregister_class(cls)
    bpy.types.OBJECT_PT_display.remove(panel_func)

if __name__ == "__main__":
    register()


Is there a way to combine two png images at shader editor?


Substance / Blender GLTF workflow = wrong metal render

An ORM texture stores each map in a channel : Occlusion in Red channel, Roughness in Green channel, Metalness in Blue channel.

You need to use a SeparateRGB node to split the texture into separate channels. Then, simply connect each channel to the corresponding input.


Adding transparencies in blender grease pencil

so I think the reason this has occurred is your multiple pass shading has both overlapped and not quite joined when you've drawn it. Easiest fix is to draw the shading in 1 pass if you can.
If that's not possible you could enter Edit mode and, ensuring your viewport is set to "Select only points" (This is the first button to the right of the Mode drop down box) move the overlapping/miss matching points as desired.
Another solution would be to draw the boundary of the shading with a stroke on a layer and then fill on the multiply layer, hiding the original stroke layer once complete.
Or, my personal preference would be to remove the multiply effect all together and instead go for a black or grey dark layer with a low opacity. This would avoid the compounding colour (making areas darker) but obviously wouldn't fix the gaps.
Good Luck. Shout if you need any further guidance.


Fix for the given file

Made the adjustments @Delagone suggested:

Separated the tree object
Set the object origins for each tree object root.
Made sure the three tree objects are in one group
Choose the group instead of the object in the "Render" tab.

In the "Emission" tab

Emit from: "Verts"
Unchecked "Random"

Distributing particle system with weight painting

Particle system source mesh

The mesh resolution of the plane is very low.

The weight painting is saved in the vertices of the mesh. The more control you want over the weight painting and therefore the distribution of the particle system, the more resolution the mesh needs.

Emission of the particle system

The emission from setting tells the particle system where it should emit the particles. In the case of a plane with weight paint it should be set to "Verts" or "Faces".

Weight painting

You want a road with trees on both sides.

Then you need to weight paint to lines of both sides of the street where the trees should be.
The weight painting tells the particle system where it should put the trees.

The weight paint tells the particle system the probability

Example weight paints for road straight and with side street:


How to set dimensions of an object to default?

You can simply RMB click and Reset to Default Value
Note:
To make new cubes come in that default size, you'll need to type it in manually.
Simply resetting to default value won't work (not sure why).


Python: Ctrl+Click for buttons (capture invocation event)

Yes, it is possible if you use an invoke() method in your operator instead of execute(), because there's a 3rd parameter given to invoke - an event object.

That object has attributes about modifier key states among a few other pieces of input info.

Here's an example script, that adds a button to the 3D View. You can hold e.g. CtrlAlt down and click on it to let the operator report Ctrl+Alt+Click in the info area:

import bpy

class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"

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

    def invoke(self, context, event):
        ev = []
        if event.ctrl:
            ev.append("Ctrl")
        if event.shift:
            ev.append("Shift")
        if event.alt:
            ev.append("Alt")
        if event.oskey:
            ev.append("OS")
        ev.append("Click")

        self.report({'INFO'}, "+".join(ev))
        return {'FINISHED'}

def draw_func(self, context):
    self.layout.operator(SimpleOperator.bl_idname)

def register():
    bpy.utils.register_class(SimpleOperator)
    bpy.types.VIEW3D_HT_header.prepend(draw_func)

def unregister():
    bpy.utils.unregister_class(SimpleOperator)
    bpy.types.VIEW3D_HT_header.remove(draw_func)

if __name__ == "__main__":
    register()

Note that there can also be an execute() method in the operator, but it won't be called unless the execution context is not INVOKE_*, but EXEC_*. The default behavior of the Python Console is, for instance, to execute an operator, not to invoke it.

If there's no execute() and you run bpy.ops.object.simple_operator() in the console, an error will be reported in the System Console and the operator abort with {'PASS_THROUGH'}. You can explicitly invoke it however: bpy.ops.object.simple_operator('INVOKE_DEFAULT')


I don't think this is a materials issue.

I think what's happening is this: you have a low number of samples (it looks like it's definitely below 64). You mentioned you are using a denoiser, which works fine on other renders. However, this scene doesn't have a lot of light, so the signal-to-noise ratio is low, and the denoiser is having a hard time, producing artifacts. The solution would be to increase the number of samples. Using at least 256 might be a good idea:

Another factor that might have increased the amount of noise is that there is little direct lighting - some places need at least 2 bounces for light to reach them. The solution would be to add some more light sources. For example, you could put an emitting plane right behind the window. This would allow light to reach more places.

If this doesn't work for you, please add more information to the question. It's not easy to guess the problem from a single image :) !


How would i go about retopology for this object?

The quickest method I like to use is a remesh modifier and a decimate modifier. Works nice and fast. This tutorial might also help https://www.youtube.com/watch?v=rUzJefYNQlI


Hair Particle System to Create Forest: Some Trees are Floating

If the surface that the particles are emitted from is affected by another modifier then you will need to make sure that the particle system's modifier is below the other modifiers. This is so that the particle system can 'see' the previous modifier's result (because blender's modifiers execute in the order they are in the modifier 'stack', with each modifier passing on its data to the next).

Another option you may need is the Use Modifier Stack, found in the particle system's Emission panel. This makes sure the particle system is seeing the 'final result' of all the modifiers being applied to the object before trying to emit particles.


correct horizon in 360 rectilinear video

I think that you would have to wrap the rectilinear image onto a world texture using emission, then change orientation with the Mapping node. Use Cycles and reduce samples to 1 for speed. Cycles supports rectilinear rendering. I have tried this before but not rotation around x axis only z.


How do you add a custom label to a vertex?

After installation ( Header > Edit > Preferences > Add-Ons tab ) the shipped '3D View: MeasureIt' add-on can be used to label vertices, just using the 'Label' option:

They can be rendered, too, but I don't think you can suppress the line between the text and the vertex..


Apply subdivision surface modifier to one axis only (round edges)

I'd use the bevel modifier instead. You can target specific mesh parts using bevel weights on edges or vertex groups.
Subdivision modifier doesn't support any form of targeting per say, you can add support loops or use creased to control the deformation on the mesh, but you can't prevent the modifier to operate on mesh parts.


I made it work by wrapping bpy.console.execute(), then setting it afterward:

import bpy
class CONSOLE_OT_execute_wrapper(bpy.types.Operator):
    """Wraps command execution to maintain the current prompt."""
    bl_idname="console.execute_wrapper"
    bl_label="Execute Wrapper"
    interactive=bpy.props.BoolProperty(name="Interactive",description="Whatever the \"interactive\" property does for bpy.ops.console.execute.",default=False)
    prompt=bpy.props.StringProperty(name="Prompt",description="String that shows to the left of the current command.")
    @classmethod
    def poll(cls,C):
        return C.area.type=="CONSOLE"
    def execute(self,C):
        print("CONSOLE_OT_execute_wrapper.execute(%s,%s)"%(self,C))
        bpy.ops.console.execute(interactive=self.interactive)
        C.space_data.prompt=self.prompt
        return {'FINISHED'}
def register():
    bpy.utils.register_class(CONSOLE_OT_execute_wrapper)
    for kmi in [kmi for kc in bpy.context.window_manager.keyconfigs for km in kc.keymaps for kmi in km.keymap_items if kmi.idname=="console.execute"]:kmi.idname+="_wrapper"#Wrap
def unregister():
    bpy.utils.unregister_class(CONSOLE_OT_execute_wrapper)
    for kmi in [kmi for kc in bpy.context.window_manager.keyconfigs for km in kc.keymaps for kmi in km.keymap_items if kmi.idname=="console.execute_wrapper"]:kmi.idname=kmi.idname[:kmi.idname.rindex("_")]#Unwrap
if __name__=="__main__":register()

After running the above in the text editor, for now you can then set the prompt in User Preferences->Input, where you expand "Console", find each "Execute Wrapper" and set their "prompt" property. I'll put the option somewhere appropriate in the addon.


You could use object offset in the array modifier and then rotate the offsetting object (and then hide it if you don't want it visible in the scene)


Duplicate, Duplicate Linked, or modifier?

A good Idea is to use a Particle system that uses the red object as sourc eobject.
If you do you could follow this steps:

create a plane
add the plane a particle system
set the start and end frame to 1 and the lifetime to an high number, for example 20000 (if you plan on doing an animation, the lifetime should be higher than the last frame number, so that the particle won't disappear)
Set emit from Faces, then Grid and set the resolution as high as you need.
Then set the red object as the source
in field weight settings, set the gravity to 0 so the particles won't just fall

in this way you can also create those little "valley" between the proteins (blue object) using a magnetic force field.


Use one of the preset layouts.

On the top menu change from default to video editing:


animating transformation of one object into another

You can use shape keys.

Model your sword first. Create a base shape key. Then add a new shape key and start deforming it to to the shape of the bar, creating new shape keys along the way. Animate then the shape keys values so that you are left with the base shape key at the end.

Then just let the swordsmith do her job!

The example Blend file is HERE


How can I combine two colored textures so that the final image is blended to match a specific lighting setup

Basic node trees would be like this:

Sample file

Note:

The Composite node will only output based on Scene size set in Render tab. If you want to output full-size composite result, you have to use File Output node.
Mask node is sort of a trick to apply the transform result without being limited by the original image size.


In this test scene:

the empty has the original animation
the cube copies the empty animation and adds some random value
the amplitude of the random value is controlled by cube property :

this is the driver of the X_loc of the cube :

this is the animation while changing the cube property :


To create a good topology I'd stick to retopoflow as it's a huge timesaver for creating a decent topology.
Retopoflow Blendermarket
You can also give it a try for free even if I recommend buying it to support the developers.
Retopoflow Github
However it totally depends on your animation. I think you can even get away with a 50k poly model if you only create instances 'alt + d'.
As soon you want to use deformers on your geometry, it's worth to create a decent topo, otherwise it's getting way to slow. Both your images are rather bad for deformers. (First has to many polygons, second has not uniform quads / clear loops).


Point Density Textures are a way of rendering particles or mesh vertices as volumetric halos in Cycles.

A halo is basically a little volumetric ball.  You can accomplish essentially the same effect without point clouds by using dupliverts or a particle system with little spheres as particles.  However point density textures are much more efficient due to requiring a much simpler BVH, since the entire volume is within one object, instead of hundreds of thousands of little overlapping objects.

The above example uses a particle system with 250,000 particles and a turbulence force field.  To render it as a point cloud I created a "domain" object (a scaled cube) around the particle system and gave it a volumetric emission shader using the Density from the Point Density as the emission strength.  See this answer for how to set up a point density texture.


In order to bring up the influence menu to add drivers in OS X, press the command key + click. Make sure that your user preference is set to right click and tick on "emulate 3 button mouse".


Until the day arrives that we all have super computers... the meshes used for sculpting are not the ones used for animating. There are too many vertices which makes it cumbersome to rotate around, let alone animate. The automatic weights are not finding a solution - perhaps because of the high vertex count - and though you can manually add weight I don't think this is going to bring much joy.

My suggestion is to retopo a 'lighter' version which will be easier to work with.

Update: In response to Vlads comment below. The greatest concentration of verts are in the face. Selecting the face and AltP to separate it from the rest of the body. The headless body accepts the automatic bone weights and can be deformed by the armature. The obvious problem are the gaps that will form between the two objects.

It is always easier to talk after the fact but... finding a pose with a simpler mesh, earlier in the process, would have saved a lot of trouble.


What values do the --verbose and --debug-value options accept?

Both these arguments are mainly for developers.

--verbose is currently only used by libmv (camera tracking), however we will likely use in the future to control other output.
--debug-value is mainly for developers to test alternative behavior, from Python you can access it from bpy.app.debug_value from C/C++ you can access it from G.debug_value (with BKE_global.h include).

For example --debug-value 2 makes the manipulator rotation handles draw differently.

For verbose logging with camera tracking use --verbose 2.


How can I add a new vertex in blender 2.8?

It's ctrl+ RMB now. You could always create a face and delete the other three vertices.


Accidentally made backdrop viewer size zero. How to get it back?

Open the sidebar in the compositor N
Open the View tab
Increase the Zoom property in the Backdrop panel. Alternatively you can use Fit to fit the background image into the view or Reset Backdrop to reset the offset and zoom.


Is there a way to exclude an axis from the solidify effect?

You can do it in two steps:

Extrude, but don't move E then RMB
Then push/pull using shiftZ to avoid z displacements

"Push/pull" is available in the tool bar (alternate from shrink/flatten) or via menu "mesh/transform/push pull".
Though, you'll have to tune the distance with the mouse as the operator panel does not allow to choose the concerned axis.


Object wobbling and shaking while camera following a path

The problem is that the resolution of the path is too small. This results in the path being made up of a series of straight lines that are much longer than the steps of your animated 'follow path', resulting in the jitter.

You can re-create the curve with a higher resolution or you can edit your existing curve to add resolution by selecting the curve and enter Edit mode (Tab). Select all vertices (A), click 'Subdivide' in the tool shelf (T) - this will divide each section of the curve, although they will still form straight lines. Once you have enough additional points, click Smooth (again, in the toolshelf, just below Subdivide) a few times - this will round off the edges, effectively shaving the corners off the curve and making it smooth again.

The result should be a smoothed curve with higher resolution that should no longer cause the jittering.

Edit : Another way is to change the Spline Type of your curve - you currently have this set to 'Poly' (ie, lines). Changing it to Bezier or NURBS will produce a curved path without having to add additional control points. To achieve this, simply enter Edit mode and select all (as above) and then click Set Spline Type in the tool shelf (it's shown at the top of the above image). Select NURBS and your path should be smooth and track with no jitter.


How can a custom icon be loaded in an add-on?

You can only use already available icons, too see which are available enable the Icons add-on. A panel with all icons will be displayed in the text editor properties (or python console). The name of the icons is shown in a tooltip.

You can use the icon attribute like:

row = layout.column(align=True)
row.operator('id_name', icon='QUESTION')

Custom icons require compilation which is off-topic here but you could find a discussion on custom icons at this BA thread.

Possibly outdated information on how to integrate custom icons you find in the Wiki. There is descibed that all icons are stored in a single .png file which explains that you can't use SVG or any other format.


This is likely because the vertices are not aligned. The transform panel shows the median location of all selected vertices; setting it to 0 will move the whole selection as a unit:

To align the vertices, scale them (S) to 0 along the axis you which them to be aligned along. So for the X axis, S X 0:


Mantaflow: bake always crashes, cannot be resumed

After realizing that there's no problem if I use Uni Cache (what I usually avoid) instead of OpenVDB I've found an answer myself even for OpenVDB. I don't know why nobody else is experiencing these problems because I'm using the default settings but if so, here's the simple thing I did:
In Blender 2.90 and above the OpenVDB volume format comes with Advanced Settings. Here you can choose Compression Volumes "None", "Blosc" and "Zip". The default value is "Blosc".
After switching to "Zip", the baking works without any problems. "None" works, too. Only "Blosc" makes all my machines crash.
The difference to Blender 2.83 LTS (which doesn't crash) is, there are no Advanced Settings in that version, probably it uses "Zip" or no compression instead of "Blosc".


How can I turn this into a perfect cylinder

The easiest way is to use the LoopTools > Circle. Enable the LoopTools addon, select the bottom and top edges (or as you say, simply select the face loop), right click > LoopTools > Circle:


Rotating the camera:

press R to rotate at normal speed
press R and hold Shift to decrease the rotation speed
press R and hold Ctrl to rotate by 5 increments
press R and hold Shift+Ctrl to rotate by 1 increment

Panning and zooming the camera:

Enter the camera Fly Mode (Shift+F) and press:

E/Q to pan up/down
A/D to pan left/right
W/S to zoom in/out
hold Shift/Alt while panning or zooming to increase/decrease the camera speed (or do it using the Mouse Wheel)

These are the most common fly mode shortcuts. For more options take a look at the bottom strip after entering the fly mode.


User preferences rotate around selection needs to be ticked.


Blender provides property definitions that we can use to add custom properties to objects and bones. You will then want to define a panel that displays the property so that you can easily edit it.

As we can't animate strings I expect you will need to use a collection to define a string and frame number or range of frames that it will be applied to. Another option may be to assign a number to each sound and animate a custom integer. You can use an EnumProperty to create a menu that lists available sounds but stores a numeric value instead of a string.


Mirroring in Object Mode, taking rotation into account

If you are doing this so that they could be animated I would add a Copy Rotation Constraint and then invert the Y axis.

Or if you are modelling, Create a new collection with the left side (M) and then place a Collection Instance (Shift-A) of that and mirror the Instance. The collection instance has it's origin in the centre but it can be moved in the Context menu for the object -> Collections.

If you later on want to commit this to be real object you, just Make Instances Real (search for it with F3). They will still be linked copies.


Blue line in the Image Strip not showing

In the Video Sequence Editor:
View > Show offsets


Soft Body hooking stretches instead of moving

The order of the Softbody and Hook modifiers in the Modifier stack is important. For the soft body physics to take account of the hooked vertices it must be positioned below the hook modifiers in the stack. Performing the steps in the sequence in your question (create mesh, add Soft Body, set Vertex Group, add hooks) adds each modifier at the end of the stack so that the Soft Body will be first, followed by the hooks. ie,

Note the Soft Body above the hooks.

This will produce the following results (note that I've added Skin and Subdivision Surface modifiers to make it more visible) :

The modifiers are applied in 'top-down' sequence and so for the Soft Body to take account of the hooks it must occur after the hooks have been applied. Simply use the arrows (at the top-right of each modifier panel) to move the Soft Body to below the hooks and all should be well. ie,

This can then produce the following result :

Note that the only difference between these two results is the order of the modifiers in the stack.

Blend file included


Why is Blender 2.8 slower than older versions?

Eevee is used as a "quick preview" of sorts for your render. That way you don't have to wait for Cycles to sample before you can actually see your render in full detail; Eevee is real-time.

As for your main question, have you tried un-installing Blender altogether, and re-installing the latest version of 2.8?

If you have, it might be that you have 8GB of RAM and an i5 CPU. These are not the best performance-wise.


I'm only now learning Blender (2.83) but this was covered by the tutorial sequence I viewed yesterday.
This may not be the only answer, but it's one of them.
You cannot "remove" or get rid of the pivot. It appears that your pivot is at the bottom of the black dotted line to the left of the object. Every selected object has one. You can place it to a more convenient or useful location, however.
Place your 3D cursor where you would like the object pivot. (Shift Right Mouse Button)
In the layout viewport (I can't tell which viewport you are using), select Object, Origin, Set Origin to 3D Cursor. You'll see the small circle become coincident with the 3D cursor and rotations will now happen about that center.


How? (for blender 2.8) to set hotkeys for specific screen space (workflow editors)?

In 2.80 screen layouts have been replaced with workspaces. This refers to the entire layout of blenders window.

Using python we can change the active workspace with

nws = bpy.data.workspaces['Animation']
bpy.context.window.workspace = nws

I don't see an operator that allows us to change the workspace in 2.80, at least not without creating a new workspace. That would require writing an addon to add that functionality.

We can change the current editor (the one the cursor is over), to do that we use

bpy.ops.screen.space_type_set_or_cycle(space_type='VIEW_3D')

To use that in your custom pie menu

row.operator("screen.space_type_set_or_cycle").space_type = 'VIEW_3D'

When using that in the kemap editor, you enter screen.space_type_set_or_cycle and then choose the editor type in the menu.

You will find within the window group of hotkeys, where you want to add your hotkeys for this, combining ⇧ Shift with F1-F12 is already setup to switch editors. The NLA, Info and Preferences being the editors with no hotkey setup.


I see that you're trying to paint between vertices, you can't, if you want the painting to be more subtle you need to subdivide your object. And of course you also need to use the good brush strength (you can mainly use the Draw brush in Mix or Subtract mode, F to change the brush radius, ShiftF to change its strength, you can also use the Blur brush to smooth).
Weight painting is used to give a value between 0 (blue) and 1 (red) to your vertices, 0 meaning the selected vertex group (in the Vertex Groups list) has 0% influence on this vertex, 1 (red) meaning it has 100% influence on this vertex.
Which doesn't mean that this vertex can't be part of other vertex groups by the way, several groups can have a weight of 1, which means they will equally influence this vertex.
So you can't paint edges or faces, only vertices.
If you open the N panel > Item > Vertex Weight, you can select a vertex and see what group this vertex is part of and how much weight this group has on this vertex:

Also, good thing to know, if you want to paint through, disable the Front Faces Only and Front-face Falloff options and enable Projected:


How would you cut a shape out of an object using another object?

Knife Project Tool

The tool you are looking for is the Knife Project tool. Here's how to use it:

Create your cube that you want to put the circle on
Add a circle curve: SHIFTA -> Curve -> Circle
Position the circle in front of the face you want to put the circle on, as shown here (highlighted in green):

Now go to the viewport where the circle visually appears where you want your circle to be on your cube, like this:

Now select the circle, then hold down SHIFT and select the cube.
Switch into Edit mode
Tools panel (T) -> Mesh Tools section -> Add section -> click Knife Project
(Note: In 2.70, the Mesh Tools section is located in the Tools tab)

This will result in the cube now having a circular hole in the front face:

If you now want to fill the hole with a face, select all the vertices of the hole and press F.

NOTE: In this example, the circle is considered the Knife, which is kind of like a cookie cutter, or perhaps even a bullet, and so when you click on the Knife Project button, what Blender does is it projects/shoots the knife (here the circle) from the visual angle in your active viewport. So, make sure you have the knife visually lined up so that when it projects/shoots onto your destination object, it will make the circle right where you want it. Here are two examples of projecting from different angles:

An interesting note is that in the example above where the knife is visually at an angle, the resulting face on the destination object is NOT automatically deleted (see the highlighted face on the lower example.)

Also, you can indeed use any shape as a knife:


You first need to find the pattern, use a plane, rotate it 45°, squeeze it to make a lozenge, duplicate and mirror it on the X axis.

Then subdivide, extrude and begin to move the edges so that the array copies will fit. Give it a first Array modifier on the X axis, then a second Array on the Z axis. To make it turn around give it a Simple Deform modifier / Bend mode. Also give it a Subdivision Surface modifier. You can still modify the original mesh to give any correction. If the pattern is not supposed to rotate around a cylinder but around another shape, just give your object a Curve modifier with the good curve shape instead of a Simple Deform.


Ive had this issue before too and solved it like this:

Have the plane 2m x 2m in size
Apply the particle system
Join the particles to the plane
making it tile

(option 1)
 Duplicate the original plane and move it 2m to the left/right/top/bottom and corners

(option2) use 2 array modifier, uncheck relative, check constant distance and set it to 2m on X and the other 2m on Y, now the middle one has all the overlapping parts.

that way the middle plane has all the overlapping parts

if you have multiple particle system, apply them all at the same time, join them together with the plane

Now you can proceed with the baking


I know this is old but had to work on a similar situation tonight.

All you need to do is add the vector to your 3D point A(which should also be a vector pointing from your object to the origin point of the scene). This should give you a target point in 3D space.

target_point = point_A.worldPosition + vector

If you want to change the distance away from your point_A origin, you need only alter the magnitude of your vector:

vector.magnitude *= 5 # 5 times the vector length

or

vector.magnitude += 30 # 30 Blender units greater than your original vector


Anyone know why in this video, this bone detaches the arm to my mesh?

It probably is just that the upper-arm's mesh is assigned to that bone or a child bone.
Select this mesh, switch to weight paint mode, and check the different bone's weights.


Using the interactive bevel tool
You can select the specific edges you want to bevel (switch to edge selection mode to make this easier, press Ctrl + Tab in Edit mode and select Edge) and use Ctrl + B and drag to interactively adjust the bevel, additionally roll the scroll wheel to add in edge loops to round out the bevel. To bevel a single vertex, use Ctrl + Shift + B.

Using the bevel modifier
Another way is to select the edges, add them to a vertex group from the Object Data panel and then use that group as input for the bevel modifier by choosing Vertex Group under Limit Method. This method is non-destructive meaning you can easily revert/make any changes by deleting the group or updating it.

NB: While you might select edges, the bevel modifier actually works on vertices so depending on your selections, results can vary. When using it, try to keep the edges connected and not spaced or leave gaps.


Using array modifier to array an object between 2 curves

You can use Array Modifier's Fit Length or Fit Curve options

Fit Length - specify a maximum length of arrayed objects (use the length slider)
Fit Curve - use a curve to determine the length (adjust the curve to control length)


How can i select an Edge loop when using a graphic tablet?

Do I have to create a new shortcut to Select Edge Loop? If so, what do you recommend? What should I do?

Changing the shortcut is one possibility.

Another way is to map a middle-click to your stylus button (I use 2 button stylus with lower one set to middle and the other one to right click). This way the viewport navigation works with default shorcuts so there is no need to change other ones. Also left click (stylus tip) select works the best with a tablet (imho) - I did not encounter this non-default option colliding with any other shortcut or UI functionality.


i'm not sure without seeing your code ( a github link would be great ). I can make a guess about how you might be able to avoid the KeyError

# ImagePreviewCollection(dict) is a subclass of Python's built-in dict type
main_collection = icon_collection["main"]
icon = main_collection.get(some_key)
if not icon:
    main_collection.load(icon_name, icon_path, 'IMAGE')

I use custom icons in mesh_tiny_cad

If i'm reading bpy/utils/previews.py correctly it isn't possible to overwrite or clear a key/value pair.

If you are keeping track of the IDs somehow then..

if icon_id in [v.icon_id for k, v in pcoll.items()]:
    ...


Change Color Associated with Transparency?

Let's say you have an image with an alpha channel:

Which in turn, is nothing but a mask: an image with a black and white channel that determines the opacity of the RGB information. Black (0) is considered transparent, white (1) opaque.

If one were to use the image as color for the texture we get an opaque texture, because the alpha channel is not being used, just the RGB information.

Adding a transparent shader and using the alpha information to control the mix will make the black (0) pixels of the alpha channel be transparent and the white ones opaque (1).

If you don't want to use the color information of the image, but want to keep the mask to control the transparency, then just set the color of the shader to whatever color you want and use the alpha channel to determine the mix with a transparent shader.

If your image has no alpha channel you could still use the color information as mask:

In this case, since the mask information is in the blue channel, you can use any of the other two channels (red or green) to determine the mix between diffuse and transparent.

But your confusion is coming from thinking of transparency.

If what you want to do is mix colors (with no shader being transparent) then use the image as mask to mix colors.


Blender Video Editing, Newbie, channel 0

Thanks

I'm not sure of some of the "blender language" yet, but my problem was because I dropped a video in and then pressed space (as play).

At the top right pane of the screen is a panel that is described as "Scene" and has a drop down panel that is titled (?) Dimensions. I think this is what Leander described, but there appears to be nothing described as a "Properties Area". (What should I read to understand this?)

My problem was fixed by changing the "frame start" and "frame end" in said Dimensions drop-down panel to be something appropriate for the video I had dragged in.

I had referred to this as a channel 0 being the sort-of-blank channel underneath channel 1. I'm not yet sure of its proper name. But I see now that the "frame start", "frame end" combo selects a display area in the background of the channels, and that the area I refer to is in the foreground, and contains the text for markers and perhaps other things...

Thanks very much for the pointers, I'm hopefully on my way now.


One option would be to make a mesh that from the front has the profile you want, but is a prism/cylinder with flat ends; then do a boolean intersect with a sphere of slightly larger radius.  Then you can union that with the rest of the robot head.

Once you are confident you will not longer have to adjust the geometry of any of the elements of the boolean you can apply the modifiers to create a final mesh.  or not.

Also, you probably want to use a UVsphere with the poles on the sides where the ears are.

If the fact that the sides of the "face" are coplanar to the YZ plane is a problem, an alternate technique would be to discard all but the outer face polygon and then extrude/scale relative to the origin to give it conical sides.  (this way the rim polygons would be perpendicular to the sphere's surface instead of perpendicular to the X axis).


How do I change the file path for all the textures used?

File -> External Data -> Find missing files -> Choose your texture folder -> Find missing files.

Blender will then replace all missing textures with the fitting ones from the new selected folder.


Bone heat weighting: failed to find solution for one or more bones (tried all "solutions")


When using spotlight as a projector, the projected image is consistently slightly offset in rendered image

I suspect that this is due to rounding - the Image coordinate would naturally vary from 0.0 to 1.0. Your image width (2001) is a tricky number to represent in binary (all values are held in binary in a computer) so there will naturally be a rounding error - however small. In a perfect situation you'd expect anything below 0.5 to round down and 0.5 and above to round up but, due to the error in precision, values aren't held exactly - so values very close to, but below, 0.5 might actually be represented as slightly higher and actually round up when they should be rounded down. This would mormally be balanced by opposite rounding at the other end of the range (ie, values slightly less than 0.0 being rounded up) but since image coordinates are limited to the range 0.00000000 - 1.00000000 this doesn't occur (since they are never less than 0) so the rounding is slightly biassed to one side - ie, 0.0 to, say, 0.49999 are rounded down but 0.49999 to 1.0 are rounded up. The extra 0.00001 causes the discrepancy.

Note that I haven't any evidence for this - just my thought regarding how values are held internally and how rounding occurs. Written as an answer rather than a comment as too long-winded for comments.

A good test would be to use an image width of 2048 (a power of 2) and see that each side is shaded the same (ie, pixel 1024 should match 1025 precisely.


How to apply two different materials in Blender Internal on front faces and back faces, *while involving transparency*

I'm not having this issue.
Use the Backfacing output of a Geometry node to drive the Fac input of a mix shader. The top Shader input is what will show up on the front face and the bottom Shader input is what will be on the back face.
Also, I enabled Alpha Clipping on the front face material in the material Settings panel. Backface culling is also turned off for the front face material.


How to attach an animated object to a rig?

Yes it's possible

Select the lamp
Shift+Select the armature
Enter into Pose mode (Ctrl+Tab)
Select the bone you want to attach the lamp to
Ctrl+P and select 'Bone relative'


There was some manual work to do. I don't know how useful this answer is, but my steps were:

S.001 Bring the object to a sensible scale, and apply the scale.
In the 3D View 'View' tab, set Near and Far Clipping to be able to see the object consistently
Note, by enabling Face Normals in Overlays, that the object is already 2-sided
Also note, by seeing the face-dots around the perimeter, that there are degenerate faces connecting the inside and outside.

So.

ShiftG select the degenerate faces by similar area (0). Delete them.
Using CtrlL select (linked) all the inside faces and delete them.
Delete the bottom half of the object and replace with a Mirror modifier in Z, 'Merge' and 'Clip' checked.
Assign a Solidify modifier above the Mirror with 'Rim' unchecked to allow merging, towards the inside. This leaves  gaps which can be filled, but no intersecting faces, which you're trying to avoid.
When it looks good, apply the modifiers.
Enable the 'F2' shipped Add-On.  and use it to run round the gaps between edges, connecting by hand, (holding down F), because 'Bridge Edge Loops' fails somewhere, and I want to see where.
OK, got them, fix the topology at the points by hand. About half a dozen faces.

Bevel and subdivide, if wanted.


Graph in blender a function of two variables,

There is an addon shipped by default with Blender called Add Mesh: Extra Objects capable of doing this. It is disabled by default and can be activated from the User Preferences dialog.

Start by opening File > User Preferences > Addons then search for Extra and activate the Add Mesh: Extra Objects addon.

Then in the 3D View press Shift+A > Add > Mesh > Math Function > Z Math Function or XYZ Math Function depending on what you want.

Introduce the function equation in the corresponding fields and adjust precision as necessary.

See related question for more details.


Make sure you have Receive Transparent checked for your map's material, if that is not checked the receiving material will only render shadows at full strength.

In the properties panel under the Material tab beneath the Shadow heading check the Receive Transparent check box.

Receive Transparent (quoting from the manual)

  Allows this material to receive shadows whose intensity is modified by the transparency and color of the shadow-casting object

In the case of a smoke simulation, it will definitely will have intensity, or alpha less then one.

The image below is an example:
Without Receive Transparent on the left and with Receive Transparent checked on the right.

 I changed the Receive Transparent on only the ground plane, the object casting the shadow does not need it checked unless it too will receive a transparent shadow.


Helpful tricks to use when moving/scaling/rotating an object: to move on two axes while scaling/moving/rotating press S/G/R then SHFT+(axis you don't want to transform on). This will allow you to move on, say both X+Y axes, but not the Z axis if you press G-SHFT+Z, or only scale on X and Z- S-SHFT+Y.


Leg Control Bone Disappearing in Pose Mode

It looks like you have hidden the bone by pressing H. In pose mode press ⎇ AltH to unhide all bones.

Another way is to find it in the outliner and unhide the one bone.


Model a single tooth.

Add an Array modifier, and a Curve modifier to that tooth object.
Add a new circle curve ShiftA > Curve > Circle
Set the Fit Type of the array modifier to Fit Curve, and target the Bezier Circle (added in step 3). Also set the Object of the curve modifier to the Bezier Circle.

If the teeth overlap, you can scale the circle to get the teeth to line up perfectly.


If you're using mesh (and not other methods like Displacement modifier or Bump or Normal Maps), I'm not sure there's any easy way to fix bevels, maybe somebody will tell. Anyway, let say you have this shape:

To simplify it, use the Checker Deselect tool, play with the parameters to delete as many vertices as you want.

Once you're glad extrude the mesh, then bevel.

Now you need to bring some manual corrections where the edges are overlapping.

If you need to fatten the bottom, select it and use altS.

As I suppose your mesh is supposed to bend at the end, add some additional edge loops on the surface.


Tips for removing a handle point from a complex mesh

Sculpt mode has a few tools to do this. One of them is
Trim tool (Box or Laso).

or
Flatten tool (with Dyntopo enabled)


"Start" and "exit" buttons are not working properly in blender game

Mouse over text does not work, instead use a plane invible and parent it to the text (child), to make parent use Alt+P.

The plane needs to be an actor to be detected.

Use the logic on the planes:

And to change the color use cont.owner.children[0].color = [1,1,1,true].

When you use module execution mode it pass the controller to the function.

#Note that there is no imports

def start(cont):
    l_click = cont.sensors['MouseStart']
    m_over = cont.sensors['MouseStart1']
    game_actuator = cont.actuators['startGame']
    if l_click.positive and m_over.hitObject:
        cont.activate(game_actuator)

def exit(cont):
    l_click = cont.sensors['MouseExit']
    m_over = cont.sensors['MouseExit1']
    game_actuator = cont.actuators['Game']
    if l_click.positive and m_over.hitObject:
        cont.activate(game_actuator)


Is it possible to create a fluid simulation of rain?

You can try the Fluid physics type in a particle emitter :

Add a particle system to a plane and configure it the way you want (number, start, max age...)
In the Physics panel, select Fluid.
Select the object you want the particles to run down on
Add a Collision physics modifier to this object (make sure it has enough faces), with particle damping Factor set to 1
hit play and:

Next, you just have to create a nice shader (this one is a blueish transparent shader, just for demonstration, very bad)

However, this type of simulation is not very realistic and some tweaks may be needed to suit your needs. It's just a track...


To get rid of the noise in the volumetric you would need to increase the number of samples considerably and this is probably not practical as it already takes a considerable amount of time to render.

There are things you could do to improve the render times.

The volumetric domain is quite a bit larger than it needs to be. You could scale it down in the X dimension to that it is sufficiently around the lightening but not too far towards the camera or too far behind. This will reduce the volume that rays need to pass through it, considerably improving render times
The trees are very high detail with many polygons and transparency - you could simplify the trees to reduce the number of faces. Possibly even rendering a small set of trees and adding them to the scene as an image plane, layering multiple trees to get the complexity.
The lightening seems to be very high poly - with 6 levels of subdivision. You could re-model the lightening with better geometry to considerably reduce the polygon count.

However, you would still require a large number of samples to resolve the noise - you're already rendering at 800 samples and may need to increase that by a factor of 10 or more to start to resolve the noise to satisfactory levels.

An alternative is to remove the volumetrics entirely and, instead, use the compositor to add the effect of the scatter using Blur and Fog Glow effects.

To demonstrate, I rendered out your image as two separate layers - the lightening :

And the trees (but note that the trees have not rendered with the same detail as your sample image - I believe this is due to your images for the pine needle leaves not being packed into the Blend file). It should be sufficient for the demonstration though :

The 'brightness' of the lightening is actually due to two distinct effects - the 'scattering' in the atmosphere (which makes the sky appear brighter around the flash) and the 'glare' in the lens (whether camera lens or the eye). The main distinction being that the 'scattering' light will be behind the trees while the 'glare' is in the lens and so can appear in front of the trees.

This can be achieved with the following compositor nodes :

This is a fairly simple setup and some additional tweaks could produce better results (such as feathering the edges of the mask with a blur and shrink/grow for better transition between trees and sky).

Essentially, this setup uses the Depth pass of the trees to generate a mask that can be used to separate sky from trees. A Blur node spreads the light from the lightening to mimic the scattering (the Darken node cuts down the amount of light since the emission is too strong and would 'white out' the entire sky). The mask is then used to mix in the lightening behind the trees and glare added and the brightening of the sky (when unmasked) is added in.

You can adjust the Factor of the Darken node, the Threshold of the Glare and the dimensions of the Blur to tweak the effects.

This produces the following result :


I can't transform the "Body" Mesh anymore in Edit Mode

Yes I also tried the answer of selecting the body in object mode, switch to edit mode, 'a' to select the whole mesh and then alt + h to 'unhide' and now the mesh is editable again.


You need to set the maximum draw type for the character to be 'Textured', currently it is being limited to 'Solid'


The correct way to add reflective coating is to mix in a Glossy shader through Fresnel:

This is what it does - it coats the surface with more reflection, becoming fully reflective at grazing angle (it is influenced by the Fresnel IOR):

The result is less-transparent more-reflective, denser looking glass. Which can be done with glass IOR itself as glass already has reflection:)

But we can apply this generally to any shader, to add a reflective coating (clear-coat) on top. Such coating is usually so thin it is fully transparent and only it's reflective properties matter (the reflection is of dielectric nature - so white).

This has also the benefit of ability to change the base reflectance of the coating if really needed. Here, let's have base reflectance just 20% of the normal Fresnel node (also note that base reflectance of dielectrics don't change much):


Is there any way to preview freestyle lines using cycles?

No
As of 2.79, unfortunately there is no way to preview Freestyle lines using Cycles.


Is there a list for all available python functions?

These functions (or rather methods, properties and attributes) you are asking for are blender-specific, thus part of the Blender Python API (a.k.a. bpy) - just to clear it up. For standard python module features, please refer to the official python docs.

.polygons, .length etc. are properties of certain Blender type instances (objects). To find out what they do and which features are available, you need to check out the bpy API docs for a particular type (class).

There is a page in the docs about how to use the docs:
Blender/Python API Reference Usage: examples of how to use the API reference docs

  Example

  .polygons is a property of the type bpy.types.Mesh.

  It is a type on its own, MeshPolygons, > which has an .active property and an add() method.

  If you use the slice notation on .polygons, you will get elements returned of a bpy_prop_collection. The element type is MeshPolygon. A MeshPolygon has i.e. a .normal property in turn.

As you can see, the methods and properties are not found in a single place. The most valuable information is hidden in the bpy.types section of the docs. You can use the online search, or use Blender's built-in Python Console with auto-complete to figure out what is where. You can also find out the type and search for it in the API docs by adding bl_rna.identifier to an object:

>>> bpy.context.object.data.bl_rna.identifier
'Mesh'

>>> bpy.context.object.data.polygons.bl_rna.identifier
'MeshPolygons'

>>> bpy.context.object.data.polygons[0].bl_rna.identifier
'MeshPolygon'

Prepend bpy.types. and you have your type to lookup in the docs!


Blender 2.83 object selection not working correctly

when you are in the edit mode press 1 for vertex selection, 2 for edge selection or 3 for the face selection. Try to press alt+H in edit mode it will unhide everything. If it does not help please provide me with the sreenshot


Mesh is deforming in Pose mode without moving the bones

The bone called DEF-spine.003 is supposed to stretch towards the bone called tweak_spine.004, but as you can see it doesn't completely:

It's because the Stretch Original Length value has been changed... To come back to the default one, click on the X button:


How to create an arrow geometry using python?

a very flexible way to do that is to use the Rigify addon. You enable it in the User Preferences -> Addons tab, look for Rigify and check it.

Now, if you go to Edit Mode of ANY mesh, there's a button in the Transform Panel:

Rigify now creates the code needed to make this Object via Python. Go to a Text Editor, and select widget.py:

This is all the code you need, wrapped in a nice Python function. So to recap: Model your Mesh as you wish it to be, Apply all modifiers, and encode it using Rigify Dev Tools.


Why does the Multiresolution leave bumps in my mesh?

Figured it out. I just needed to recalculate normals. Had faces facing the wrong way.


How to get the menu with Add Gear options back?

This menu is called the operator panel and it only pops up when you first create the object. If you make any changes to the object it will disappear forever.

To get it back you'll have to create a new gear!


Unable to find the input tab to provide the path for luxrender in blender 2.74

You can find it in the "Blender User Preferences" in the Addons tab, under the plugin Render:LuxRender.


how important is it to keep faces to 4 vertices for rendering?

It makes a number of things easier and some modifiers only work on quads. One such modifier is subsurf. Also when you need to make a loop cut, it only works on quads. When you hit a triangle or ngon the cut you are making will break there.


There is another solution. I encountered a similar problem where it showed a red dialogue box saying image cannot be written. So I just made another folder in the same directory and saved it in that folder. It worked perfectly!
(solution for Windows 10)


Cloth Sim

Add Circle 16 sides, Extrude, Scale, Grid Fill
Extrude, Scale outer loop, select vertices for each side and Scale on (X/Y) to zero to get square shape, add extra loops Ctrl+R+3

Add cloth simulation (physics)
Add ShrinkWrap modifier, select one vertex loop next to perfect circles and assign vertex group to these, and use this group for modifier
The illusion that brings cloth more to paper feeling is under Data Properties > Normal > Auto Smooth

To add detail to the lowpoly simulated mesh just add a Normal Map texture of smashed paper

Notes:

Select outer loop and with Proportional editing (O) rotate (R) a bit, twisted topology results in nicer sim

With a few extra loops close to existing folding is a bit closer to your reference.

To let border of paper stick closer to glass you can create another vertex group and use second Shrink-wrap modifier with a subtle Ofset value.


When you have accumulated vertices in the corner of a low poly mesh?

You can solve this easily and with a clean topology by keeping it all quads.
Just create a "quad corner" around the radial part, where quads meet at a three-edge vertex.

Start by extruding one of the "center edges" from the radial part so it meets the adjacent one. Then extrude one of the remaining ones, and place it so the quads meet at the center and match perfectly (Use Ctrl snapping to aid in precise placement if necessary).

Repeat the process for the opposite edge , you can quickly create a new face between the two existing edges by pressing F.

You you then end up with a two edge gap you can easily bridge to the remaining edges with the Bridge Faces operator, B key.

Don't forget to W > Remove Doubles at the end, to merge together all newly created geometry.

For more info consult this comprehensive Topology Guide


Get position of the first solid crossing limits line of a camera

Ignoring other object's which might be located between the mesh and the ray origin you can use the object's ray_cast method:

If there are multiple mesh objects, you might simply iterate over the objects, picking the one yielding the closest intersection point.

import bpy
from mathutils import Vector

cam = bpy.data.objects['Camera']
group = bpy.data.groups['Group']

min = (cam.data.clip_end, None, None)
for obj in group.objects:
    v0 = obj.matrix_world.inverted() * \
         cam.matrix_world.translation

    v1 = obj.matrix_world.inverted() * \
         cam.matrix_world * \
         Vector((0.0, 0.0, -cam.data.clip_end))

    success, location, normal, index = obj.ray_cast(v0, v1)
    if index != -1:
        mag = (obj.matrix_world * (location - v0)).magnitude
        if mag < min[0]:
            min = (mag, obj, location)

#set the cursor to the intersection point
if min[1]:
    bpy.context.scene.cursor_location = min[1].matrix_world * min[2]


How can i set a specific length for an edge?

Just to illustrate Ray's comment.

Enable ✓ the Mesh Tools addon.
Preferences > Addons > Edit Mesh Tools

Switch to Edit mode, to see the Mesh Tools addon.
It's under Sidebar > Edit > Mesh Tools


Piotr commented that you could override the Delete operator, as described for a different purpose in this answer: https://blender.stackexchange.com/a/28933/66651

I am using it to remove derivative objects. It works very well!

class delete_override(bpy.types.Operator):
    """delete objects and their derivatives"""
    bl_idname = "object.delete"
    bl_label = "Object Delete Operator"

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

    def execute(self, context):
        for obj in context.selected_objects:

            # replace with your function:
            my_function(obj)

            bpy.data.objects.remove(obj)
        return {'FINISHED'}

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

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


It seems I have found a solution now.
In the Particles-tab there's a Cache option. If the particles are Baked they render properly even though there is a curve-guide affecting them.


Color management affetcs video sequencer

Press N in the Sequencer and in the Side Panel Just head over to Modifiers and add any modifier you want to add to manage your look of the clip
Hope this may Solve your Problem


The situation you describe is a result of a failure to apply the rotation to the object. It may be possible to edit the model, but I find it is quicker to apply (keyboard shortcut combination:  CTRL  -  A  as soon as I've made the desired rotation.


Is there a way to know (programmatically) how many objects are visibile in a rendering?

You can give each object a unique object ID ("pass index" in the object properties).These can be output as render pass; each pixel will have the ID of the object that's visible there. This will not only give you a count of the number of objects (just count the number of unique values) but also a ground truth for segmentation & shape recognition.

This Python script will give each selected object another ID:

import bpy

for nr, obj in enumerate(bpy.context.selected_objects):
    obj.pass_index = nr + 1  # reserve pass index 0 for "no object".

For more info, see the ID Mask Node section of the Blender manual.


how to extrude along face normals evenly?

In This case the problem was that the mesh object had non-uniform scale transformations. The solution was to Apply the transforms Ctrl - A , then choose Scale.


Try lowering the Threshold value.
The Glare node works based on the luminance (or brighness) of the pixels in the image, the Threshold value means that pixels that are brighter than that number will be affected by the glow, while values lower than the set number will not.

By lowering it, you are changing the node's level of tolerance. If it's set to a low value, it means that even a small amount of light will make the glare show up.
You also may be rendering in EEVEE. Switch to Cycles.


See this answer regarding mirroring bones.
The armature has to be a "parent" of the mesh in order to move it. In order to do this, in Object Mode select the mesh then Shift + click the armature. Ctrl + P to parent and select With Automatic Weights for best results. You can move the bones by selecting the armature and switching to pose mode.
I suggest watching/reading a comprehensive guide for rigging a character and adjusting it, as it's challenging, even for intermediate users.


Code or workaround to create snap to pixels from unwrap

I'm not a massive user of this feature, but as far as I can tell, Snap to Pixels refers to snapping while you are moving UVs around in the editor using the standard translation tools, like G, R and S. See the comparison in this GIF (first I move around without Snap to Pixels enabled, then with):

The trick is, you simply enable the G tool, and the vertices will already snap. Just LMB click to confirm.


Blender Select Random Face But Not Sides

You can do this in two steps:

Select one of the triangular faces, press ShiftG (Select Similar) and choose Polygon Sides. Now all triangular faces should be selected.
Press space, type in Select Random and hit Enter. Now here comes the trick: You can switch from Select to Deselect mode in the Tool Shelf on the left hand side of the 3D viewport:

If the Tool Shelf is not shown press T while your cursor is in the 3D Viewport.


Why is a vertex from another island is moving if I move an UV island?

Two possible settings:

As @moonboots has suggested, you may have 'Keep UV And Edit Mode Mesh Selection In Sync' checked, in which case the whole UV is made available in the UV window, and you're selecting mesh vertices, so all UV face-corners associated with the vertices are selected:

Or you may not have Sync Selection checked, in which case you are selecting UV face-corners directly, but you have the option via the 'Sticky Selection Mode'  to select them separately, or together if they share a UV location, or together if they share a vertex in the mesh:


Sort a list of objects by their distance from a point

There are a number of ways to sort lists in python. Here is one using lambda.

import bpy
from mathutils import Vector
# some list of objects (taken from q)
objects = [bpy.data.objects["Text.002"],
           bpy.data.objects["Text.003"],
           bpy.data.objects["Text.005"],
           bpy.data.objects["Text.007"]]
# sort by location from (0, 0, 0)
objects.sort(key=lambda o: o.location.length)
# sort by visual location from (0, 0, 0)
# eg objects moved by constraint / parenting etc.
objects.sort(key=lambda o:
             o.matrix_world.to_translation().length)

v = Vector((1, 2, 3))
# sort by distance from v
objects.sort(key=lambda o:
             (o.matrix_world.to_translation() - v).length)


Smoke not showing up in render but shows up in materials (I'm using my cpu)

The problem was that the mesh that I used was colored and not transparent and that caused problems beacuse I set temp. diff in domain to 0


Python node that replaces itself in the editor with a group?

You can probably write a script that generates such node setup after being given a file path. Use the single selected node to read its inputs and outputs, then delete it by the script and attach generated nodes' IO to what you read.


some good reference: adding geometry

note that you must be in editmode (EDIT: to go to edit mode, create a mesh, select it with right-click, and then hit "tab"), and remove doubles after run the script:

import bpy, bmesh

obj = bpy.context.object
me = obj.data
bm = bmesh.from_edit_mesh(me)

v1 = bm.verts.new((2.0, 2.0, 2.0))
v2 = bm.verts.new((-2.0, 2.0, 2.0))
v3 = bm.verts.new((-2.0, -2.0, 2.0))

bm.edges.new((v1, v2))
bm.edges.new((v2, v3))

bmesh.update_edit_mesh(obj.data)

if you have the point list, may be you can apply some loops


How do I fix this problem with vertices?

Nevermind, I figured this out thanks to Duarte. Wow im a noob. Ngons were my problem for anyone referencing this problem.


It is difficult to tell without the actual Blender file, but in the image provided, some of your UV islands are in fact overlapping and others are quite close together.

To fix this, select all of the faces in edit mode and then, with your cursor over the UV window, hit Ctrl + P. This will automatically arrange the UV islands. In the 3D viewport window, in the tools panel (far left of the image), you can then set a margin, which you'll want to avoid this bleeding.

Additionally, you can set the bleed amount option in Texture Paint Mode to 0px, but this may cause problems later on. Especially if you want to use a subdivision surface modifier on the model.


Cycles Render does not reflect camera view

The visibility setting is different for viewport an render, check if the visibility is setup correctly for all objects

This also applies for modifiers, so if that din't help check that also.


Blender Texture Paint a Voxel Model - 64px x 64px texture - Need Pencil/Voxel Brush

Below your color picker there is a Box named Blend and its set to add which is exactly what you said: It will make your color brighter every time. Set it to Normal or Mix (Im not home right now so I can't lookup)


I solved my issue by deleting the right side of my mesh and bones and re-mirroring them. I did not find the root cause.


How to generate final texture image for complete designed scene

I'll start from the very beginning even though you said that you have texture painted some of the models since most of these steps will apply to everything you do when making assets for games or accelerated rendering.

1.) Select seams that will help to represent your model as a 2D image.  Try to imagine this step as if you are making a real model and wrapping paper around that model.  Paper does not stretch well so you'd have to cut the paper in such a way that it naturally fits to the contour of your model. Try to apply this idea to building your UV coordinates since this will help to eliminate texture stretching for 3D models.  It will also help to keep the texture resolution consistent across the model.  There are situations where you can ignore this but for now this should work well for you.

Step 1)  Select the edges that will form the seams for the UV island coordinates.

Step 2) With the edges select, press Ctrl-E then find Mark Seams, now those edges will be highlighted in red.

Step 3 and 4)  Select all the faces of your model,

then press the u and select UV Unwrap.  If I had added an extra vertical seam across from the one that I did add, then the UV islands would be able to take up more of the texture space.  That would be more efficient since less of the texture would be wasted on empty space.  You could also add another model's UV Islands to that empty space so that they both share the same texture.

Now in the UV Image Editor, add a new texture.  This will be the texture that you will bake your materials to.

Next, for models that have been texture painted, you will also want to do the following since this will help to eliminate the seams that are left from painting a model since Texture Paint does not have overdraw.  Baking does, so baking a texture after you have painted it will fix this issue.

So add a material and set it to be shadeless as shown in the following image.

Next, add the texture that you painted in as a material texture and be sure to set the mapping coordinates to UV as shown in the image.

Now go to the baking panel and set the render type to Full Render, this will work since the Material is already set to Shadeless.  (Full Render also allows you to bake multiple materials that are connected together in the Node Editor so when you are more comfortable with all this then you may want to use that as well.)

For comparison, here is the Texture Painted model that will show seams when it's displayed on a model.

Now press Bake and save your texture.  Be sure to set the Margin to whatever you feel is best.  I use 64. Now the color along the seams will be extended out past the edges of the UV coords.  For this to work, the UV islands should be at least a few pixels apart from one another.

This is basically the procedure for baking any materials using Blender Internal and this pretty much all applies to baking other types of passes such as Ambient Occlusion, Vertex Colors, etc...


The problem is that you have activated the Smooth Shading option of the T menu, but your object is a low-poly mesh. If you try to smooth a low-poly mesh these strange artifacts can happen. It's true that you have given your object a Subdivision Surface modifier that is used to simulate a high-poly mesh, but you have disabled its Display modifier in Viewport, so the artifacts still appear.

You say that you did that because you wanted to have both smooth and sharp edges.

If you want to have a smooth appearance but at the same time keep some sharp edges, add some additional edge loops close to the angles you want to keep sharp. Here is how:


Can two objects linked to the same mesh data have independent shape key blends?

Two objects that share the same mesh data will also use the same shapekey values. Shapekeys are part of the mesh data and as such, every instance uses the same key value for each shapekey.


How to clean up mesh after using Knife Project on a curved surface

try to make a strait line as on the pictur it shuld atleast look better.

if you whant to kep the shape add a new edge close to it and work whith it insted.

the last thing I whant to say is if you combinde the subsurfes and mirror modefiers. Put the mirror modefier firs if you don't whant a sharp edge on the mirror point.


Add a Cylinder and put to where you want to have your hole and how deep it shall be.
Add a "Boolean" modifier on the cube. In the settings set "Operation:" to Difference and the Cylinder as "object:"
Apply the modifier.


EEVEE supports reflection by having a map that saves a screenshot of reflection.

You can add a reflection plane in front of your mirror. Also, the reflection setting in both the material settings and in the main render panel should be checked.


Ah, I found the issue.

I have two entrances to the house, a front door and a back door. To prepare for the extrude for the foundation, I added a edge below the doors, so it would make a face when extruded.

It seems that extruding non-faces is causing issues in Blender, and that's what was causing my issues.

Removing these edges before extruding works. So I can simply fill the faces after extruding.


How can i Unfold UV in one axis (horizontal) like Maya Unfold

Just in case this makes a difference, forgive me if I've missed the point..

'Follow Active Quads' refers to active quads in UV space.

Here's an object that produces non-orthogonal UVs when unwrapped cylindrically:
(The cylindrical projection is view-dependent, you want the poles aligned to screen Y and the equator along screen X)

The quad at the bottom left of the UV has been straightened, by scaling or snapping, and left active.

Now going back into the 3D View and U unwrapping again, with 'Follow Active Quads' and the 'Even' option, aligns the UV.

This could have been a selection of faces, rather than all of them, if that's what's needed.


It looks like you have a face inside the glass wall, the subsurf modifier does not handle this kind of non-manifold geometry very well.

Look closely, see the face within the wall.

To get rid of it just go into wireframe view and select the spare face and delete it with Del > faces.

Edit:

I looked at your .blend file and since in your particular case you are using a solidify modifier to get the glass thickness you can't directly select the offending faces and delete them.  Just go into edit mode and select all with A, then hit W > remove doubles.  This will merge the duplicate vertices along the crack.

Here is a comparison:

See how before I removed doubles, when I selected the edge loop at the location of the crack only have “tails” in one direction?  This means there are double verts at that location.


Why is only part of my render taking so long? Did I do something wrong? (Cycles)

Rendering takes time.

Rendering complex scene takes more time than simple scenes.

The higher the number of particles the longer it will take to render.

Using a large number of subdivisions in the subsurf modifier will increase the number of polygon on the scene, further increasing the computation needed to render the scene.

Simulations will also use more resources and stress your computer.

Not all segments of an animation will take the same time to render,  it all depends on the elements used for each frame in the scene.

It seems to me that your scene exceeds the resources of your hardware. You don't state how much ram your system has, but chances are your system is running on virtual memory and going slower.

There are many things you can do to optimize your scene: Bake all simulations, reduce the complexity of your geometry, render in different layers and composite later, reduce the size of the image textures used. Maybe bake some of the materials...

As a side note: Never render complex animations as mpeg directly. Render as an image sequence and encode as video later, you'll be very disappointed if after such long renders your computer crashes and you realize all of the previously rendered frames are gone, and you have to start over.Rendering as image sequences will also allow you to stop the rendering process to use your computer and resume later.

I doubt there is anything wrong with the file itself.... You didn't pack your textures with the file, so it's hard to asses the scene properly. (Frame 166 rendered in 39 seconds using GPU on my system...)


Why is the Steam version of Blender taking so long update?

This is most likely due to the fact that Blender 2.76 is not officially released yet. What is currently available for download is the second release candidate. If it doesn't work as expected when the official release comes out feel free to update this question.


Is there a list or something available which shows the code of the Symbols of Blender

The Icon Viewer does exactly what you need. It displays all internal icons in the tool shelf of the text editor. Click on an icon to copy the name.


How to animate a set of 2-D data points described in a csv file?

I'm going to recommend that each point be represented by a circular mesh (You can create a prototype pretty easily using the Add/Mesh/Circle menu entry).  You will then add keyframes for the location data.

There are other answers about importing CSV data:

python script to read in .csv file containing quaternion coordinates and turn it into a path/curve for an object to follow

Here's the excerpt about keyframing position:

def keyframe_location(obj, fname):
    with open(fname, 'r') as loc_fh:
        r_loc = csv.reader(loc_fh, delimiter=',')
        i = 0
        for row_loc in r_loc:
            row_loc = [ float(x.strip()) for x in row_loc[:3]]
            fr = 10+2*i
            obj.location = row_loc
            obj.keyframe_insert(data_path="location", frame=fr)

            i = i+1

You will likely want to instantiate the graphical objects representing the data points using techniques similar to http://www.purplefrog.com/~thoth/blender/python-cookbook/link-mesh-array.html

import bpy

def army(mesh):
    scn = bpy.context.scene
    for r in range(10):
        for c in range(4):
            obj = bpy.data.objects.new("army", mesh)
            obj.location = ( r*3, c*3, 2)
            scn.objects.link(obj)

army(bpy.data.meshes["Cube"])

Any complete solution is going to integrate answers to about 10 distinct questions.


How to add drivers in node inputs in python?

Drive the default_value property of a particular input channel.

>>> n = C.scene.world.node_tree.nodes.new("ShaderNodeMath")
>>> d = n.inputs[0].driver_add("default_value")

>>> d.driver.expression
'0.5'

>>>


VSE How to blur a rotating tire after rendering?

A way to fake motion blur would be to mix the same animation with a slight offset:


How to rotate half of a plane around the split edge after cutting it in half using loop cut

Select the edge, set the 3d cursor to it (Shift+S, 4); Set the cursor as the pivot point for rotation (Dot); then select your face, and create a new custom transform orientation, it will give you the correct gizmo axes for rotation (if your edge matches any of the world axes you can skip this step); rotate as you wish. :-)
You can also use the "Active element" as your pivot point. In this case you have to select all the edges of your plane to rotate, and the "hinge" edge should be selected last (to become that active element).
And for the simple plane you can also use "Normal" as your transform orientation (it works great in this case, and you have not to deal with creating custom transform orientations).


How to Blur a Video Background in blender?

Yes, you can do it. There are two methods I can think of right off the bat:

Use a Difference Key! This will NOT work if your camera is moving, but can give you decent results that don't require masking by hand. If your footage is from a stationary camera that was mounted to a stable tripod, you could take the difference of the background with no actors, and then the background with actors. Just take the time to shoot the background alone, and then bring your actors in for another shot without moving the camera at all (you might want to just let the camera record continually for both shots so you don't have to touch it).

A word of warning though: if your actors appear in color that is
    similar to the background footage, the mask will have lots of nasty
    holes in it. So don't wear blue shirts if your background is blue,
    etc.

Also, the backgrounds in both shots have to stay EXACTLY the same; I would avoid anything that moves like trees in the wind etc because they will ruin the Difference Key. Cheap cameras also tend to auto adjust exposure / brightness, and this will also ruin your Difference Key if this happens. A good rule is to shoot in a bright area and do not get too close to the camera or block the light from entering it in any way. Also, watch out for shadows because they WILL show up with your actors, and cannot easily be separated (unless you mask them out by hand or try some layer filter curves to block darker color values).

Using a Difference Key on the two pieces of footage, you can apply a blur effect to your background while preserving the focus of your actors. In the image below, I have simulated a background shot, and a background shot with an actor, and used the Compositor to achieve fake DOF. You can use the same node set up for your video footage! You could further tweak the layers in Compositor to get more specific results, but I wanted to keep the example as simple as possible so you can build on it however you like. Notice on the "Difference Key" node I turned "Tolerance" to "0.009". You will need to play with "Tolerance" and "Falloff" to see how it affects your video footage for best results!

Use Tracking and Masking, and patience. If your footage has spots that work well for tracking (high contrast areas that are stable) you could use masks in Blender like the guy in this Youtube tutorial explains, showing how he did it on a still photo, but this same technique can be used with video, even video from a moving camera if you can track and animate the mask for the subject. The difficulty level to get good results varies a lot depending on what you want to do, and how complex your subject / scene is. Tracking and masking is awesomely powerful, and the scope of it is beyond what I can answer right now. I will say though, you will have to plan your shots well if you want the best tracking results, even placing markers or using props to make things easier when working with the footage in Blender. For Masking, it helps if you know how to use the Pen Tool / Bezier curve handles. Knowing those tools is essential for making good masks. Best wishes!


Is it possible to have a separate animation timeline in another layer?

I've achieved my goal by simply increasing the needed amount of timeline frames and duplicating and extending everything I need to be short into a loopable manner.
This way I can animate different objects to go faster or slower in the same scene.


How do you calculate Array Modifier with Relative Offset?

As, i said, use constant offset instead relative, it's much easier:

"Relative" doesn't mean "length of object plus something", this means "length of object multiply by given number". Relative offset is a factor, that multiply with length of the object. In your case is 1.25 for top block and 1 for others.

If want to calculate it, lets try:

Offset in m is 1.45 (1.25+0.2) relative unit is 1.25. So to get offset you need to divide 1.45 by 1.25

1.45/1.25=1.16

So, 1.16 is offset in relative units.

For bottom blocks with 1m length  relative units will be different (block has 1m length), so offset will be 1.45 / 1 = 1.45


How to output multiple images from Blender's compositor with Python?

You can add File Output nodes to the compositor to get multiple files saved from any point of your compositing without the need for any Python:

You can also use Python to add more nodes:

import bpy

bpy.context.scene.use_nodes = True
tree = bpy.context.scene.node_tree

for every_node in tree.nodes:
    tree.nodes.remove(every_node)

RenderLayers_node = tree.nodes.new('CompositorNodeRLayers')
RenderLayers_node.location = 0,0

comp_node = tree.nodes.new('CompositorNodeComposite')
comp_node.location = 400,0

links = tree.links
link = links.new(RenderLayers_node.outputs[0], comp_node.inputs[0])

for i in range(0,100):
    output_node = tree.nodes.new(type='CompositorNodeOutputFile')
    output_node.name = "Output node number "+str(i+1)
    output_node.location = (400,(-140-i*110))
    link = links.new(RenderLayers_node.outputs[0], output_node.inputs[0])

See the documentation for more info.


In blender this is called Skinning:

Add a NURBS surface circle Shift+a, s, c.
Tab into edit mode.
Shift+d to duplicate your the segment a few times.
Select you segments, aa for all of them.
Press f to skin selection.

You'll probably also want to unable Endpoint U in the Active Spline panel under "Object data" in the Properties window.

The image included in the question shows a shape with a differing number of segment points. This is currently not possible.

Note. There's work being done to give Blenders limited NURBS a overhaul (but progress has been slow).


You can CtrlAltQ to toggle Quad View, then click to the nearest grid crossing to place 3D Cursor there, then ShiftS > Cursor to Grid to snap the 3D Cursor in two of the side views (to snap it precisely to the grid dimension as you want). Then, ShiftS > Selection to Cursor (Offset) to offset the selection to the 3D Curor, without collapsing:

NOTE: Snapping cursor to grid currently depends much on the view zooming, in other words, the visual grid scale, so, if it cannot be easily snapped to the crossing, just give it another try after zooming in or out.

UPDATE: For your concern in the comment, you can temporarily add an empty to assist snapping:


Add modifier to all objects and change modifier-property

You have two problems.
First you are looping through all the objects, not just the mesh objects. So for example when the loop gets to a camera  it can not add the decimate modifier, and the script brakes.

Second issue with the data not being available (modDec.face_count). This is yet another scene update issue.

Here is the changed code.

import bpy

for obj in bpy.data.objects:
    if obj.type == "MESH":
        modDec = obj.modifiers.new("Decimate", type = "DECIMATE")
        bpy.context.scene.update()

        while modDec.face_count >= 1000:
            modDec.ratio *= 0.5
            bpy.context.scene.update()

Notice the if obj.type == "MESH": simple if statement that is only working on the mesh objects.

The real change is the two bpy.context.scene.update() lines. You need two because of the while statement.
Last thing I changed is your if(modDec.face_count > 1000): line. You need to keep changing the ratio while the face_count is bigger then 1000.

The way you were setting the ratio it did not actually get the face count down below 1000.


how can I make an emission shader shine through a transparent material?

Make sure you have caustics enabled by unchecking No Caustics in Render settings > Light Paths:

With caustics:

Without caustics:


Where can I find RGBA, color depth or compression settings?

The output options depend on the output format.
For FFmpeg video, just open the Encoding options to change the settings.


Compare to the default setting of curves, twist method was changed. I'm not very sure what's this setting doing. But set it back to Minimum will solve the problem.

Reply to the comment
Select all the points than set the Mean Tilt to 180 degree.
(Actually you can control the rotation of any point one by one. Just choose the points you want to twist than use the Tilt button from the left sidebar. Than click and drag the yellow circle.)


Mirror modifier creates new vertices in weird ways

The Mirror Modifier, unless it's configured differently, mirrors a mesh around the Object Origin. It duplicates any geometry on the other side.

Usually you shouldn't cross the mirror glass. But when you add the default cube, 4 verts are left of the O.O. and the other 4 are right of the O.O. So it's not the best place to start.

Here are the 4 stages, shown with cubes:

Every vertex is on the left side of the middle, everythings fine.
4 verts are left and 4 verts are in the middle. That's where clipping comes in. It will glue any verts to the middle that try to cross it. It doesn't repair any tresspassing. Be careful when you do that with a cube. It will trap a face in the middle which can lead to unclean topology.
That one's not too healthy: most cubes are on the left side but one is on the right side. You can do that but it requires more attention.
That one causes sort of bad geometry. the original and the mirrored mesh intersect, edges are crossing the line. z-fighting can occur when the faces are parallel to the mirror axis.

Now, technically you can do any of that, you just have to be careful not to cause unwanted effects.


The Touch sensor has been removed, but in its place there is a updated Collision sensor.

The M/P button will toggle the Collision sensor only targeting a property or material.
To target anything, just leave the property field blank.


You can go to domain settings under cache -> reduce the end frame


Why does one face appears so warped when UV unwraping?

Ngons tend to cause problems for the UV Unwrap algorithm.  Not always but often enough, it seems random which ones will work and which ones won't.

You can deal with that particular case by pressing Shift+7 on the number pad so the view aligns with that selected faces normal then press u to bring up the Unwrap menu and then select Project from View

Now the shape should now perfectly match the face.  You'll still likely have to resize it though.


Use Cycles baking for Blenders internal renderer

to be organized , save the models in one blend file with no material , in a separate blend file you link the models in and set up their materials. this will guarantee no material mixup happens and your blend file project will be cleaner.

you could also make a separate scene for each renderer (e.g a cycles scene and internal scene , a bake scene)


Painted Texture does not appear when rendered

are the materials set correctly?
did you save the image? last version that I used only renders the saved file.


Render semi-transparent self-intersecting surface in cycles

two useful functions

import bmesh
import bpy

def set_smooth(ob):
    mesh = ob.data
    smooth_states = [True] * len(mesh.polygons)
    mesh.polygons.foreach_set('use_smooth', smooth_states)
    mesh.update()

def remove_doubles(ob, d=0.00001):
    bm = bmesh.new()
    bm.from_mesh(ob.data)
    bmesh.ops.remove_doubles(bm, verts=bm.verts[:], dist=d)
    bm.to_mesh(ob.data)
    bm.free()

Those two functions aren't really meant for real-time stuff, but neither is bpy.ops stuff. They can however be integrated in a key-framed and rendered animation, no problem.

import bmesh
import bpy
import numpy as np

# set_smooth() and remove_doubles() are declared elsewhere

nth, nph = 101, 200
th  = np.linspace(-0.5*np.pi, 0.5*np.pi, nth)
phi = np.linspace(-np.pi, np.pi, nph)
y3 = np.sin(th) - 1.8*np.sin(th)**3
X = np.cos(phi)[None,:] * np.cos(th)[:,None]
Y = np.sin(phi)[None,:] * np.cos(th)[:,None]
Z = np.zeros_like(X)            + y3[:,None]

verts = [tuple(thing) for thing in zip(X.flatten(), Y.flatten(), Z.flatten())]
faces = []
for ith in range(nth-1):
    for iph in range(nph-1):
        v1 = nph*ith + iph
        v2 = v1 + 1
        v3 = v2 + nph
        v4 = v3 - 1
        faces.append((v1, v2, v3, v4))

me = bpy.data.meshes.new('wow')
me.from_pydata(verts,[],faces)
ob = bpy.data.objects.new('wow', me)
ob.location = (0.0, 0.0, 2.0)
bpy.context.scene.objects.link(ob)
set_smooth(ob)
remove_doubles(ob)

setting up a cycles material via script is a little bit involved, and you might ask yourself, how much of this should I be doing via script or manually setting up the material and only adjust certain parameters via script at render time..

import bpy

scene = bpy.context.scene
scene.render.engine = 'CYCLES'

my_mat = bpy.data.materials.new('cool_mat')
my_mat.use_nodes = True
nodes = my_mat.node_tree.nodes

# material output and diffuse nodes are present already, get them by name
mat_output = nodes.get("Material Output")
diffuse = nodes.get("Diffuse BSDF") # new(type='ShaderNodeBsdfDiffuse')
# mix and transparent are added by the script
mix = nodes.new(type='ShaderNodeMixShader')
transp = nodes.new(type='ShaderNodeBsdfTransparent')

mat_output.location = 300, 0
mix.location = 0, 0
diffuse.location = -200, 50
transp.location = -200, -100

''' hook up shaders '''

# link mix_shader to material output
a = mix.outputs['Shader']
b = mat_output.inputs['Surface']
my_mat.node_tree.links.new(a, b)

# link diffuse to mix
a = diffuse.outputs['BSDF']
b = mix.inputs[1]  # 'Shader' is used twice, so you access via index.
my_mat.node_tree.links.new(a, b)

# link transparent to mix
a = transp.outputs['BSDF']
b = mix.inputs[2]
my_mat.node_tree.links.new(a, b)

''' small shader adjustments and mixing '''

mix.inputs[0].default_value = 0.8  # factor
diffuse.inputs['Color'].default_value = [0.8, 0.0, 0.191713, 1.0]
transp.inputs['Color'].default_value = [1.0, 0.152801, 0.582658, 1.0]

which combined, gives something like this:

I suspect a node setup like this might be a little more interesting: (note: I have ambient occlusion on!)

The idea is to make the color or factor a function of the cross product between surface normal and the up vector (0,0,z). Using the nodes allows you to embrace vector mathematics for the adjustment of the shader at local points.

or taking the viewing angle into account too:

And notice there is a backfacing output on the Geometry node, worth exploring


Is there a good way to join these two objects up?

There are a few approaches I might use.

Boolean modifier is the most straight forward route - make the blue and purple parts larger so they overlap, and then use the intersection operation. A route like this usually works well in CAD software, but it's often not the best in Blender.

A better approach in Blender is using its mesh editing tools like proportional editing (the o key in edit mode).

Start with a plane, rotate it to face the front and press TAB to enter edit mode.
Use S + X to sale in one axis and S + Y to scale in the other, and G to position it into the right space.
Subdivide it using loop cut, to get a bunch of edges along where it needs to curved (use the scroll where to increase the number of cuts):

Select the one or two vertices in the top middle (using RMB and SHIFT+RMB if selecting two). Press o to use proportional editing mode. Press g to start moving the vertices. Press z to only move on the Z axis. Use the scroll wheel to increase the size of the white circle so you start moving all the vertices at once. You can try SHIFT+o to cycle different fall offs ("Inverse Square" worked best for me):

The bottom is also curved. We'll fix that later.
Now do the same for the other axis from the top view (press 7 on the numpad), but this time select both the top vertices and bottom vertices. Again, use g to grab, and now y to constrain to the Y axis.
Let's fix the bottom edge. Turn proportional editing off using o. Switch back to front view using 1 on numpad. Select the whole bottom row by holding ALT and clicking and edge (or B and drawing a box around it). Press S to start scaling, z to constrain to the Z axis, and 0 to scale to zero.
The whole thing may need its position fixed now. a to select all and use the on screen widget to move it around one axis at a time

To finish it, and add the ridge at the top, you can use extrusions:

Select the top row using ALT+LMB
Press e followed by y and drag the mouse to extrude outward along the Y axis
Press e followed by z and drag to extrude upward along the Z axis
Press e + y again to extrude it inward


Installing CUDA for Blender Cycles on Ubuntu 12.04

If you want to use CUDA for rendering with a downloaded Blender release, you do not need to install the CUDA toolkit. What you do need is (proprietary) NVidia drivers for your graphics card, any reasonably recent version will do.

Ubuntu and other linux distributions provide a way to do that, and you may already have them installed. If you don't you should for best Blender performance even when you don't use Cycles GPU rendering. If CUDA does not show up in User Preferences > System > Compute Device, you may need to install a newer NVidia graphics driver.

If you want to make your own Blender builds with CUDA support, you need to install the CUDA toolkit. To do that, download the CUDA toolkit 5.0 from:

https://developer.nvidia.com/cuda-toolkit-50-archive

And install with a command like this:

sudo sh cuda_5.0.35_linux_64_ubuntu11.10-1.run

It may ask you about installing drivers, but it's usually best to skip that part and only install the toolkit in the default location. The drivers will interfere with drivers that you installed through the package manager. You do not need to set any environment variables or make links like that tutorial, it's really this one command.