text:
How to write the output of Blender console out to a file
Is it possible to launch Blender in a mode where everything that appears in the Blender Console is sent to a file?

That's OK, mods can add the tags that are necessary to your question later. Creating new tags is generally not a good idea, because it makes organization more difficult.

On Linux/Ubuntu its ./blender > myLog123.txt from the working directory.
./blender &> myLog123.txt to include Stderr.
In Python you can do
import sys
file = open(filepath, "w")
sys.stdout = file
#...
#...
sys.stdout = sys.__stdout__ #reset
file.close()

to catch the console output while your script is running.

Changing sys.stdout in Python apparently catches most of the console output, but not everything.

Oh that's a very cool / useful approach... will definitively try that!

On Windows,

Open a command prompt (Windows KeyR, type cmd and hit Enter)
Drag the Blender shortcut or exe onto the promptC:\Users\Yourname>C:\Path\to\Blender.exe
Add > %homepath%\Desktop\blender.log
Hit return to start Blender with all console output redirected to blender.log on your Desktop.

For Mac and Linux, have a look here:
http://www.blender.org/manual/getting_started/basics/interface/window_system/console_window.html

Thanks CoDEmanX... didn't think of that one, will try too!


text:
Save the bounding box position of an object in a text file
I have a .blend file found here and I'm asking if anyone could assist me to save the positions (x, y, width and height) of the bounding box of the moving object for every frame in the file attached, and save them in a text file. Each line will have the x y width height of the bounding box in each frame.
So if anyone could please advise me as its kind of urgent for me.

Object.bound_box in Blender is like a cube in object space, I assume you want AABB (axis-aligned bounding box) instead? But you say width and height, are they supposed to be relative to X and Y? One usually uses absolute positions. And why is it 2D? Do you want to simple ignore one dimension?

@CoDEmanX thanks for your comment. Yes, I want the bounding box in 2D, as the camera will be facing the object moving, so I only need to get the x y width and height and write them in a text file, then move to the next frame and so on..

So is it supposed to be relative to the camera? Because that makes a difference in code - simple, as long as the camera moves on a global axis. Are x y width height actually left top right bottom?

The camera will be fixed as shown in the example I shared the link, and the object will move in the scene of the camera. The x & y are the position of the top left corner of the rectangle of the bounding box facing the camera, while the width & hight are the distance from the top left corner to the top right corner and distance from the top left corner to the bottom left corner respectively.

This is an interactive tool, a modal operator that draws the x, y, width and height of the bounding box corners viewed from front (use ortho to check):
import bpy
import bgl
import blf
from mathutils import Vector
from bpy_extras.view3d_utils import location_3d_to_region_2d

class G:
    top_left = Vector()
    bottom_right = Vector()

def draw_poll(ob):
    if ob is not None and ob.type in ('MESH', 'CURVE', 'SURFACE', 'META', 'FONT'):
        return True
    return False

def draw_callback_view(self, context):

    ob = context.object
    if not draw_poll(ob):
        return

    mat = ob.matrix_world

    # 50% alpha, 2 pixel width line
    bgl.glEnable(bgl.GL_BLEND)
    bgl.glColor4f(1.0, 0.0, 0.0, 0.5)
    bgl.glLineWidth(2)

    bbox = [mat * Vector(b) for b in ob.bound_box]

    bgl.glBegin(bgl.GL_LINE_STRIP)
    bgl.glVertex3f(*bbox[0])
    bgl.glVertex3f(*bbox[1])
    bgl.glVertex3f(*bbox[2])
    bgl.glVertex3f(*bbox[3])
    bgl.glVertex3f(*bbox[0])
    bgl.glVertex3f(*bbox[4])
    bgl.glVertex3f(*bbox[5])
    bgl.glVertex3f(*bbox[6])
    bgl.glVertex3f(*bbox[7])
    bgl.glVertex3f(*bbox[4])
    bgl.glEnd()

    bgl.glBegin(bgl.GL_LINES)
    bgl.glVertex3f(*bbox[1])
    bgl.glVertex3f(*bbox[5])
    bgl.glVertex3f(*bbox[2])
    bgl.glVertex3f(*bbox[6])
    bgl.glVertex3f(*bbox[3])
    bgl.glVertex3f(*bbox[7])
    bgl.glEnd()

    min_x = min(b.x for b in bbox)
    max_x = max(b.x for b in bbox)
    min_y = min(b.y for b in bbox)
    max_y = max(b.y for b in bbox)
    min_z = min(b.z for b in bbox)
    max_z = max(b.z for b in bbox)

    bgl.glColor4f(0.0, 1.0, 0.0, 0.5)
    bgl.glBegin(bgl.GL_LINE_STRIP)
    bgl.glVertex3f(min_x, min_y, min_z)
    bgl.glVertex3f(min_x, max_y, min_z)
    bgl.glVertex3f(max_x, max_y, min_z)
    bgl.glVertex3f(max_x, min_y, min_z)
    bgl.glVertex3f(min_x, min_y, min_z)
    bgl.glVertex3f(min_x, min_y, max_z)
    bgl.glVertex3f(min_x, max_y, max_z)
    bgl.glVertex3f(max_x, max_y, max_z)
    bgl.glVertex3f(max_x, min_y, max_z)
    bgl.glVertex3f(min_x, min_y, max_z)
    bgl.glEnd()

    bgl.glBegin(bgl.GL_LINES)
    bgl.glVertex3f(max_x, min_y, min_z)
    bgl.glVertex3f(max_x, min_y, max_z)
    bgl.glVertex3f(min_x, max_y, min_z)
    bgl.glVertex3f(min_x, max_y, max_z)
    bgl.glVertex3f(max_x, max_y, min_z)
    bgl.glVertex3f(max_x, max_y, max_z)
    bgl.glEnd()

    G.top_left = Vector((min_x, min_y, max_z))
    G.bottom_right = Vector((max_x, min_y, min_z))

    bgl.glColor4f(1.0, 0.9, 0.0, 1.0)
    bgl.glPointSize(5)
    bgl.glBegin(bgl.GL_POINTS)
    bgl.glVertex3f(*G.top_left)
    bgl.glVertex3f(*G.bottom_right)
    bgl.glEnd()

    # restore opengl defaults
    bgl.glLineWidth(1)
    bgl.glDisable(bgl.GL_BLEND)
    bgl.glColor4f(0.0, 0.0, 0.0, 1.0)

def draw_callback_px(self, context):

    ob = context.object
    if not draw_poll(ob):
        return

    font_id = 0
    blf.size(font_id, 20, 72)

    region = context.region
    rv3d = context.space_data.region_3d

    text = "%.2f / %.2f" % G.top_left.xz[:]
    dim = blf.dimensions(font_id, text)
    loc = location_3d_to_region_2d(region, rv3d, G.top_left)
    loc.x -= dim[0]
    blf.position(font_id, *loc.to_3d())
    blf.draw(font_id, text)

    text = "%.2f / %.2f" % tuple(map(abs, (G.top_left - G.bottom_right).xz))
    dim = blf.dimensions(font_id, text)
    loc = location_3d_to_region_2d(region, rv3d, G.bottom_right)
    loc.y -= dim[1]
    blf.position(font_id, *loc.to_3d())
    blf.draw(font_id, text)

class ModalDrawOperator(bpy.types.Operator):
    """Draw a line with the mouse"""
    bl_idname = "view3d.modal_operator"
    bl_label = "Simple Modal View3D Operator"

    def modal(self, context, event):
        context.area.tag_redraw()

        if event.type in {'ESC'}:
            bpy.types.SpaceView3D.draw_handler_remove(self._handle_view, 'WINDOW')
            bpy.types.SpaceView3D.draw_handler_remove(self._handle_px, 'WINDOW')
            return {'CANCELLED'}

        return {'PASS_THROUGH'}

    def invoke(self, context, event):
        if context.area.type == 'VIEW_3D':
            # the arguments we pass the the callback
            args = (self, context)
            # Add the region OpenGL drawing callback
            # draw in view space with 'POST_VIEW' and 'PRE_VIEW'
            self._handle_view = bpy.types.SpaceView3D.draw_handler_add(draw_callback_view, args, 'WINDOW', 'POST_VIEW')
            self._handle_px = bpy.types.SpaceView3D.draw_handler_add(draw_callback_px, args, 'WINDOW', 'POST_PIXEL')

            context.window_manager.modal_handler_add(self)
            return {'RUNNING_MODAL'}
        else:
            self.report({'WARNING'}, "View3D not found, cannot run operator")
            return {'CANCELLED'}

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

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

if __name__ == "__main__":
    register()

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

The relevant part for you (front view only):
import bpy
from mathutils import Vector

ob = bpy.context.object
mat = ob.matrix_world
bbox = [mat * Vector(b) for b in ob.bound_box]

min_x = min(b.x for b in bbox)
max_x = max(b.x for b in bbox)
min_z = min(b.z for b in bbox)
max_z = max(b.z for b in bbox)

top_left = Vector((min_x, max_z))
bottom_right = Vector((max_x, min_z))

# x and y
#top_left

# width and height
#tuple(map(abs, (top_left - bottom_right))

And here's some code to write out what you asked for (front view):
import bpy
from mathutils import Vector

def main():

    # specify the object
    ob = bpy.context.object

    # change to your desired output location and file name
    filepath = r"D:\temp\bounds_2d.txt"

    scene = bpy.context.scene
    frame_current = scene.frame_current
    frame_start = scene.frame_start
    frame_end = scene.frame_end

    write_bounds_3d(filepath, ob, frame_start, frame_end)

    scene.frame_set(frame_current)

def write_bounds_3d(filepath, ob, frame_start, frame_end):

    with open(filepath, "w") as file:
        for frame in range(frame_start, frame_end + 1):
            bpy.context.scene.frame_set(frame)
            file.write("%f %f %f %f\n" % get_bounds(ob))

def get_bounds(ob):
    mat = ob.matrix_world
    bbox = [mat * Vector(b) for b in ob.bound_box]

    min_x = min(b.x for b in bbox)
    max_x = max(b.x for b in bbox)
    min_y = min(b.y for b in bbox)
    max_y = max(b.y for b in bbox)

    top_left = Vector((min_x, max_y))
    bottom_right = Vector((max_x, min_y))

    # make flat tuple, x y width height
    return top_left.to_tuple() + tuple(map(abs, (top_left - bottom_right)))

if __name__ == '__main__':
    main()

thanks @CoDEmanX for your answer, I really appreciate it!!

Thanks again @CoDEmanX for your answer. I have one more question if you could please help me do it, I was going to edit and add it to this question but I thought it would be better if I posted a new question. The question is found here http://blender.stackexchange.com/questions/7198/save-the-bounding-box-position-of-an-object-in-the-rendered-image-in-a-text-file so if you could please have a look and I have provided pics showing explaining what I want. And please let me know if you have any questions or need any more clarification. I'm very thankful.

Taken the simple scene and comments into account and assuming that the origin of the object is centered, this should do the trick. But be warned: if you have a more complex scene or different setup it will probably fail miserably.
import os
import bpy

def get_anim_info(obj):
    width, height = obj.dimensions[0:2]
    # Assume origin in centered.
    x = obj.location.x - width / 2
    y = obj.location.y + height / 2
    return "{} {} {} {}".format(x, y, width, height)

# Save the file in the same directory as the blend file
dir = os.path.split(bpy.data.filepath)[0]
f_path = os.path.join(dir, "anim.txt")

scene = bpy.context.scene
anim_info = []
obj = bpy.context.object  # Use the active object.

for frame in range(scene.frame_start, scene.frame_end + 1):
    scene.frame_set(frame)
    anim_info.append(get_anim_info(obj))
    with open(f_path, "w") as f:
        f.write("\n".join(anim_info))

source: Stack Exchange

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

sort: votes


text:
How to call invoke_popup?
I just can't figure out how to create a custom popup which can receive data etc. What I want to do is let the user select one of the currently selected UV-layers and just hand that back to me. So I created a class like this:
class UVLayerPrompt(Operator):
    """
    Prompts the user for the uv-layer he wishes to select for each object
    """
    bl_idname = "mhmu.uvprompt"
    bl_label = "Choose the uv-layer"

    uv_layerPos = 0
    def execute(self, context):
        print('HI')
    def invoke(self, context, event):
        self.layout.template_list("UI_UL_list", #is this correct? I guess not...
            list_id="UVLayer_LIST", # I guess yes
            dataptr=context.object.data, # my guess: yes
            propname="uv_textures", # yes?
            active_dataptr=context.scene, # I could use some other location, okay
            active_propname="uv_layerPos") # I have to assign a IntegerProperty to this, right?
        return {'RUNNING_MODAL'}

after I registered my class etc.

when I call window_manager.invoke_popup(UVLayerPrompt) then it says:
TypeError: WindowManager.invoke_popup(): error with argument 1, "operator" -  >Function.operator expected a Operator type, not OrderedMeta

I realized that this is not correct. Still I don't know how to react with the context (how do I popup a new instance? with python code ofc?, how do I read the chosen value from that?)
EDIT: I will try to clarify my question: I have an export script that may export several objects. For each of these objects I want to ask the user in a responsive way which uv-texture he wants to be exported. Only one layer per object should be possible and of course I have to call the popup within my script (NOT by the user) and after it run I have to know the result of it.
How far have I gotten with this by now? Using the answer below me I realized that I should use a script that is 'INTERNAL'. Secondly I think I now finally understand how Operators are supposed to work.
I figured out how to do it: if you want to call a script from inside a script you have to call bpy.ops.operator.name('INVOKE_DEFAULT')

invoke_props_dialog(...) seems more appropriate here. It opens a popup with an OK button, and the operator's execute() method will only be called if the user clicks this button. (The other popup types execute on every property change.)
A dynamic EnumProperty is populated automatically with all UV textures of the current object (see uvtex_items callback). It is added to the dialog as expanded prop(...), remove expand=True if you want a dropdown list instead.
invoke_* require an operator instance (object), not an operator class (type). You usually pass self, which is a reference to the operator instance:
import bpy

def uvtex_items(self, context):
    return [(t.name, t.name, t.name) for t in context.object.data.uv_textures]

class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"
    bl_options = {'REGISTER', 'UNDO'}

    uvtex = bpy.props.EnumProperty(items=uvtex_items)

    @classmethod
    def poll(cls, context):
        return (context.object is not None and
                context.object.type == 'MESH' and
                len(context.object.data.uv_textures) > 0)

    def invoke(self, context, event):
        return context.window_manager.invoke_props_dialog(self)

    def draw(self, context):
        layout = self.layout
        col = layout.column()
        col.prop(self, "uvtex", expand=True)

    def execute(self, context):
        self.report({'INFO'}, self.uvtex)
        return {'FINISHED'}

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

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

if __name__ == "__main__":
    register()

Paste the code into Text Editor and Run Script. Then move your mouse over 3D View, hit Spacebar, search for Simple and run the Simple Object Operator.

So how would I call a new popup from outside? For each object U want to have the users choice. How would I let Blender open an instance of UVLayerPrompt?

So you want to open a sequence of popups, to let the user pick a UV map, with no option to abort this process? Or let the user click some button for each object? Not sure what you mean with uvtex_items, functions are first-class citizens in python. My code requires the active object to be a mesh object with at least one UV map, or Simple Object Operator won't appear in the spacebar menu list.

I clearified the question a bit (in EDIT:)

Ah ok, yeah. Well, you need to use a different execution context for a dialog, since its modal handler is added in the invoke method, not execute (but execute is called by default if you call a bpy operator in script, thus the action is taken but without user interaction).

One could also use col.prop_search(self, 'uvtex', context.object.data, 'uv_textures') instead of col.prop(self, 'uvtex', expand=True). This way the user can search for specific names if he has many items.

How do you make it modal so that when you click outside the popup, it will not disappear so you are forced to click OK?

Since the bug still seems to be unfixed, I'll offer my solution.
The point is, English speakers may not understand this, but if you are in an environment with a multi-byte language,
character bug will occur.
If you have already executed the function, it won't happen,
If you put a function object in an item, the multibyte information will surely be garbled and the enumerated property will collapse.

To work around this, I came up with a way to run uvtex_items in invoke in advance and share the itme list in a global function.
items = []

def uvtex_items(self,context):
    global items # Global definition for use with other variables
    items.clear() # Clear previously read information
    for idx, t in enumerate(bpy.context.object.data.uv_layers):
        # When adding an icon, it is necessary to add the item number name as well.
        items.append((t.name, t.name, "description","UV",idx))
    return items

The following is for function generation and the actual function to be loaded in the item is shown above.
def get_uvtex_items(self, context):
    return items

This is the execution function,
The list is generated within invoke.
def invoke(self, context, event):
    uvtex_items(self,context)
    return context.window_manager.invoke_props_dialog(self)

The overall code is as follows
import bpy

items = []

def uvtex_items(self,context):
    global items # Global definition for use with other variables
    items.clear() # Clear previously read information
    for idx, t in enumerate(bpy.context.object.data.uv_layers):
        # When adding an icon, it is necessary to add the item number name as well.
        items.append((t.name, t.name, "description","UV",idx))
    return items

def get_uvtex_items(self, context):
    return items

class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"
    bl_options = {'REGISTER', 'UNDO'}
    uvtex_items=uvtex_items("self","context")
    uvtex:bpy.props.EnumProperty(name="test",
    items=get_uvtex_items)

    @classmethod
    def poll(cls, context):
        return (context.object is not None and
                context.object.type == 'MESH' and
                len(context.object.data.uv_layers) > 0)

    def invoke(self, context, event):
        uvtex_items(self,context)
        return context.window_manager.invoke_props_dialog(self)

    def draw(self, context):
        layout = self.layout
        col = layout.column()
        col.prop(self,"uvtex", expand=True)

    def execute(self, context):
        self.report({'INFO'}, self.uvtex)
        return {'FINISHED'}

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

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

if __name__ == "__main__":
    register()

Incidentally, here is the code for a case in which the global is not used but is completed within the class.
items=lambda self,context : SimpleOperator.items

This code is a function that only returns items in its own class composed of lambdas.
    @classmethod
    def uvtex_items(cls,context):
        cls.items.clear() # Clear previously read information
        for idx, t in enumerate(bpy.context.object.data.uv_layers):
            # When adding an icon, it is necessary to add the item number name as well.
            cls.items.append((t.name, t.name, "description","UV",idx))

It looks to me like you don't need a class method for the update function,
However, it is necessary if you want to read external files, etc.
import bpy
from bpy.props import EnumProperty

class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"
    bl_options = {'REGISTER', 'UNDO'}
    items = []

    uvtex:EnumProperty(name="UV Map List",
                        items=lambda self,context : SimpleOperator.items)
    @classmethod
    def uvtex_items(cls,context):
        cls.items.clear() # Clear previously read information
        for idx, t in enumerate(bpy.context.object.data.uv_layers):
            # When adding an icon, it is necessary to add the item number name as well.
            cls.items.append((t.name, t.name, "description","UV",idx))

    @classmethod
    def poll(cls, context):
        return (context.object is not None and
                context.object.type == 'MESH' and
                len(context.object.data.uv_layers) > 0)

    def invoke(self, context, event):
        self.uvtex_items(context)
        return context.window_manager.invoke_props_dialog(self)

    def draw(self, context):
        layout = self.layout
        col = layout.column()
        col.prop(self,"uvtex", expand=True)

    def execute(self, context):
        self.report({'INFO'}, self.uvtex)
        return {'FINISHED'}

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

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

if __name__ == "__main__":
    register()

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

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


text:
How to animate a character walking around?
I've rigged a character and started animating it, but I've had problems trying to re-use poses after the character has walked around and is facing a different direction (or even the same direction, but after rotating 360°)
Should I parent the rig to an empty and do the rotating/whole character translations with the empty? How will I prevent the feet from sliding around then?
What is the best way to do this?

Rigify and MHX use a bone called master. In order to apply poses independently of position and orientation the master bone which must not be added to the poses.
Parenting the rig to an empty might also work.

When the feet start to slide around the walkcycle is too slow for use with the movement. In this case you can select the walkcycles keyframes and scale them until it looks right.

Good answer +1,however, I should DV it because you use purple in the UI

@X-27 What is the official Blender.SE theme?

um.... I use the default theme so I'd guess that that is the official theme

@Stacker, we're just too lazy to change it.. :P. your theme does seem a little... dark.

@VinceScalia I think this should be the default theme https://i.sstatic.net/Ck5t3.png  (Came form this question)  http://blender.stackexchange.com/q/14682/5426  DO NOT flag this as "The linked image is so horrendously ugly."

well my wacky brother thinks it looks better...


text:
Render Border's related check boxes - How do they work?
Render Border,

is a great little function for reducing render time while experimenting, but what does the 'Render Border' check box in the Properties >View panel do - apart from turning off the red border when un-checked? (there is no Manual reference to this)

Also, after setting a Render Border, in the Tool Shelf >Set Render Border panel, there is a 'Camera Only' check box:

I have tried many different combinations of these with renders, and the result is… confusion! Can someone please clarify this for me?

wait, how did you get those X min, X max  properties ?

Expanding on sambler and Aldrik's answers,
Enabling the Border setting in Render settings > Dimensions enables border for the rendered image and sets the camera bounds as the Camera Border.

As you can see, in the Viewport render with Border enabled, only the part of the scene visible to the camera is rendered:

With Border disabled, everything is rendered:

Viewport border:
Ctrl+B (or View > Render border) sets region in the 3D view that will be rendered when the Viewport shading is set to Rendered (this can be toggled in 3D view > Properties Panel (N) > Render Border

(Useful for making the part of the scene you want to see converge faster by not rendering other parts)
As mentioned by sambler, the Camera Only setting does not seem to make any difference (bug?)
Rendered Border:
Using Ctrl+B or Shift+B in the Camera view will define a region in the camera that will be rendered while the rest of the camera will not (if Render settings > Border is not already enabled, doing this will enable it)

As you can see, the rendered image only rendered the border selection and left the rest as black (or transparent, if you have your render settings set to RGBA in a format that supports transparency)
The Crop option  crops the black part off automatically:

(Note that disabling the Border setting in Render Settings > Dimensions or in 3D view > Properties > View will not erase the border selections)
Pressing Ctrl+Alt+B will clear all the borders and disable the border setting in Render settings and the Properties panel.

This answer is the most complete one, but I think my answer (Set Viewport Shading to Rendered, if you don't, then Render Border, and the Render Border check box don't function properly) should be added, to prevent others from having the same problem.

@SteveW I'm not sure what you mean by they won't function properly, (As far as i can tell, they do what they ought to do when nothing is rendering)
If you mean that they will have no effect, I added a mention about that in my answer.

What I mean is this: If, for example, your Viewport setting is 'Solid' and you are not in camera view, you can draw a Render Border - but it does absolutely nothing! There is nothing to tell you 'you must be in Rendered Viewport Rendering' for it to work. On the other hand, if you change to Camera View it does work when you Render (F12). This was the whole reason for my question in the first place! : /

The border render defines a rectangular area that confines the rendered result.
You have two border settings available.
1) The first border is applied to the camera view and final render. The border option in the render settings enables/disables the effect of this setting.
2) The other border setting only applies to the viewport render whether you are viewing from left, right, top, user defined etc. This border does not affect the render result and is not visible when you switch to camera view in the viewport.
There is an operator to 'Clear Render Border' with a CtrlAltB shortcut that doesn't appear to have a menu entry. This operator will clear (not just disable) either defined border depending on the current viewport.
I believe the Camera only option you see in the operator panel is intended to define the clipping border is to be applied as 1 above. I don't see that option making a difference currently.

Properties shelf Render Border setting
With the introduction of the Rendered Viewport Shading, render border can be used to limit the rendered region of the 3D View. The setting in the Properties shelf toggles this feature.

Camera Only check box
This creates a render border only if in camera view. Enabling it in the Tool Self does not undo the initial boarder creation. It seems to exist only so the Shift+B shortcut can function differently depending on the view.

A good explanation but I fail to see how this answers OP's question(s).

Please read the question before answering. ;)

I tested the shift+B shortcut, and it does draw a border in camera view (not in normal view though) but so does ctrl+B.. what is the point of having two shortcuts that do the same thing?

@gandalf3 Shift+B is the original legacy shortcut for render border.

From my point of view, this is the answer:
Set Viewport Shading to Rendered, if you don't, then Render Border, and the Render Border check box don't function properly, and also, the Camera Only check box doesn't work at all.
This has been an unintentional trick question (due to my ignorance). I had no idea that the Viewport Shading > Rendered worked so well (or even existed for that matter)! I have used the Solid setting for so long now, ignoring the other settings.


text:
open .stl file with blender
I need to open .stl files with blender, without importing them!
In the properties of my .stl file, blender is set as "open with", but when I double click on the file it just opens blender as my preset user preference (without any objects). The same happens when I drag the file over the blender icon to open it that way.
Whats funny is that if I drag and drop the file over an older version of blender (2.49) then it opens the .stl file fine.
Any ideas?
Thanks

Assosiating STL with Blender no longer works, you have to use File -> Import -> STL now.
This is because STL used to be written in C and loaded the same way *.blend files were, but now its an addon.
Note, its possible to make a shell script or batch file which you can assosiate STL with, that calls blender with the addon, though this isnt completely straightforward and will require some small Python snippet to run the importer.

Okay, the problem is that I'm trying to open the STL file automatically from php via:
exec("start /B cmd /k $blender -b C:\xampp\htdocs\test.new\upload\$file -P C:\xampp\htdocs\test.new\newBlender\getData.py");
But now I should call a separate python file from php and in that python file import the STL into blender, then run the python file that was originally called straight from php?

Regarding command line args, see: http://blender.stackexchange.com/a/8405/55

Hi! cannot find "import -> STL" in the file menu under 2.76 of blender, has it been removed or is this an external addon? thanks

You must have the add-on disabled, try reset factory settings.


text:
2.8 object not showing in preview and render
Hello everyone just testing out 2.8 V. I have stumbled with the tipical nooby thingy "object not showing in render and preview", any advice and help will be appreciated.
image attached if anything else is needed please let me know.
original file was a 2.79 version file. i this helps.
thnx a lot!

can you add the blend file to your question? Grab the URL of the question
Go to https://blend-exchange.giantcowfilms.com/
Select the blend file
Add the url of the question
Grab the url that results
Go back to the question and edit it
Add the new url to the bottom of the post

OK,   I found a solution (don't know if its the right one as I mention in my previous answer) I have uploaded the .blend file.

I had changed instancing from Verts to None and it showed up again in preview and render.

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


text:
Bendy Bones alternative
Bendy Bones is an impressive tool but i can't export it to UE4.
Do you have any alternative way ? If you have it, can you explain me ?

Thanks !

Here's my file.
Link - File address
I tried something like this but the Beziercurve doesn't follow in pose mode.
PS: i would like to create an animation and then export it to UE4.
Thanks !

You could just use a normal curve, change it into a mesh, and then export it?

Anything you can do with bendy bones, you can do with spline IK.  It's just more painful to set up and use.  By a lot, IMO.  Take a look for info on spline IK and how to use hooks on curves.  (And drivers, if you need Y axis rotation.)

Use Spline IK instead.
Here's some documentations for you to explore:

Spline IK - Blender Manual
Creating an IK and Spline IK switch in blender for beginers ans advance by the luwizart Animations
Spline IK - Unreal Engine Documentation

More tricky to setup, but does the job quite right.
Have fun with that.


text:
Displaying information in 3D window text object if ray .positive own.text = (object_one)
I have two object in a scene and a text object. I want the reading object to gather information from objects object_one and object_two on scene and have text object to display info from those objects.
Something like own.text = (reading_object).
I am using a ray sensor to detect object_one and object_two information.I need this information to be displayed as a text object.
Something like
object_one = scene.object["object_one"]
object_two = scene.object["object_two"]

Scene = bge.logic.getCurrentScene()

ray = cont.sensors["ray"]

if ray.positive:
    own.text = own.target
    target = str(["text"])

What information you want to show? How should the text object know what object has this information?

Do you want information from the object detected by the RaySensor?

@Monster From the user's edit, yes.

exactly! I am using a ray sensor to detect object_one and object_two information.I need this information to be displayed as a text object. Something like

I still do not know what information you want to show. What should the text object show when object_one gets detected?

I need the property name given to object to show up.In this case that would be object_one or object_two.


text:
Blender 2.8 equivalent of UV Squares / make islands straight?
I'm starting to use Blender 2.8 beta and have a question :
Is there something like UV Squares that I could use to make my UV islands straight ? I already tried with pins, didn't worked.
Thank you ! :)

Possible duplicate of How to get perfect UV sphere Mercator projection?

https://blender.stackexchange.com/questions/78358/how-to-straighten-curved-uvs-into-straight-belt/78376#78376

Possible duplicate of How to perfectly align UV coordinates automatically?


text:
How to limit GPU/CPU use?
I tried to render two little movie clips I dropped into the timeline to learn how to do video editing in Blender 2.8 and after a minute my computer box started beeping (which it's done once before when I tried mining Monero and it overheated and shutdown).
How can I limit how much damage Blender is doing to my box?

Hm, VSE rendering was always a single-threaded task, I doubt they change it for 2.8. Any way, you can limit CPU threads in Render tab by switching from Auto to desired number.

Please would you explain where that setting is, I don't see it in my properties.

It is in Performance rollout, see "Threads" section here: https://docs.blender.org/manual/en/latest/render/cycles/settings/scene/render/performance.html#threads

That's for an older Blender, and a completely different default rendering engine.

But even if I switch from Cycles to EVEE and fix 1 thread my fan still goes wild and the computer beeps. Which doesn't happen when I render video & music with multiple intense VSTs in Reaper, so I don't think it's a computer problem.

Finally, I've now noticed it only happens when the render window is showing, if I minimize it, no beeping so far and CPU usage stays around 90% only


text:
Blender 2.8 Beta wouldn't load old 2.79 Key Configuration
Blender 2.8 Beta wouldn't import 2.79 Key Configuration
Is this a bug or a feature?
Thank you.

Keymaps and input settings changed significantly between 2.7# and 2.8 to the point where it is not trivial to make them compatible.
For this reason, importing old keymaps has been intentionally disabled.

But before, Blender offered an emulation of 3DS Max keyboard shortcuts for easier transition. Is this going to be available again?

Chances are, more keymap  templates are going to be added later. I think the developers are busy with bugs at the moment.


text:
Armature doesn't work with my model
I created a model for my game. It's called "Player" in blender view port. I also created an armature for it with the name "metarig". When I combine "metarig" and "Player", selecting them through "Shift" and pressing "Ctrl+P", I choose option "With automatic weight". However when I try to move the bones in the "Pose Mode", they move, but the "Player" itself doesnt move and remains static. How can I solve this problem? My blender file to look at

Your mesh is too dense, that's the main problem, you could scale up the armature and object, apply the scale and rotation and parent again, but you'll still have some problems, the best is to create a low-poly version of your character.

Thank you, it worked!


text:
Linking duplicate objects that were duplicated , rotated, scaled before import
So this is an odd one. This started as a way to try and optimize a game map I'll be porting into unreal. These maps are ripped with individual meshes for each object. Many of which are identical except they are rotated and scaled prior to hitting blender. The result is every object in the scene has the same scale and rotation values. I have no problem getting the objects back to their world location after linking but I cannot figure out how to apply the original rotation and scale back. It seems to just use the parent for reference. This script started out as the instanceHarvestor found on github that i've been modifying. My 2 images show my original scene showing 3 objects. They are the same geometry but are scaled and rotated different. You can see that after I run the tool the 2 perpendicular objects rotate and scale to match the new linked parent.This example is just a very small portion of the level I picked because it has 3 objects set close together scaled and rotated differnt for quick testing.

And the code I'm using right now to try and accomplish this.
    "name": "InstanceHarvestor",
    "author": "BlockyBard",
    "version": (0, 19),
    "blender": (2, 90, 0),
    "location": "View3D > Object > Relink Duplicates",
    "description": "Relinks duplicated objects based on mesh signature",
    "category": "Object",
}

import bpy
from collections import defaultdict
from mathutils import Vector, Matrix

def get_mesh_signature(mesh):
    """Calculates a signature for a mesh based on its vertex, edge, and polygon count."""
    return (len(mesh.vertices), len(mesh.edges), len(mesh.polygons))

def get_material_signature(obj):
    """Returns a tuple representing the materials of the object."""
    return tuple(obj.data.materials)

def calculate_edge_data(obj):
    """Calculates and returns edge lengths and edge vectors for an object."""
    edge_lengths = []
    edge_vectors = []
    for edge in obj.data.edges:
        v1 = obj.matrix_world @ obj.data.vertices[edge.vertices[0]].co
        v2 = obj.matrix_world @ obj.data.vertices[edge.vertices[1]].co
        edge_lengths.append((v2 - v1).length)
        edge_vectors.append(v2 - v1)
    return edge_lengths, edge_vectors

def relink_duplicates(context, operator, operate_on_selected=False, match_material=True):
    """Relinks duplicated objects based on mesh and optionally material signature."""

    signature_groups = defaultdict(list)
    relinked_count = 0
    objects = list(context.selected_objects if operate_on_selected else context.scene.objects)

    # Identify objects to duplicate
    objects_to_duplicate = []
    for obj in objects:
        if obj.type == 'MESH':
            mesh_signature = get_mesh_signature(obj.data)
            if match_material:
                material_signature = get_material_signature(obj)
                signature_groups[(mesh_signature, material_signature)].append(obj)
            else:
                signature_groups[mesh_signature].append(obj)

    # Isolate objects that need to be duplicated
    for group_key, group_objects in signature_groups.items():
        if len(group_objects) == 1:
            objects_to_duplicate.append(group_objects[0])

    # Keep track of the names of objects to be deleted
    objects_to_delete_names = [obj.name for obj in objects_to_duplicate]

    # Duplicate objects that need to be isolated
    for obj in objects_to_duplicate:
        if obj.type == 'MESH':
            new_obj = obj.copy()
            new_obj.data = obj.data.copy()
            context.collection.objects.link(new_obj)
            objects.append(new_obj)

    # Clear the signature groups for re-processing
    signature_groups.clear()

    # Re-group objects based on mesh signature and materials
    for obj in objects:
        if obj.type == 'MESH':
            mesh_signature = get_mesh_signature(obj.data)
            if match_material:
                material_signature = get_material_signature(obj)
                signature_groups[(mesh_signature, material_signature)].append(obj)
            else:
                signature_groups[mesh_signature].append(obj)

    # Store original data for all objects
    original_data = {}
    for obj in objects:
        if obj.type == 'MESH':
            edge_lengths, edge_vectors = calculate_edge_data(obj)

            original_data[obj] = {
                "origin": obj.location.copy(),
                "edge_lengths": edge_lengths,
                "edge_vectors": edge_vectors
            }

    # Redirect print statements to a file
    logfile = open('Instance_Relink_Log.txt', 'w')
    global print  # Declare 'print' as global
    old_print = print
    print = lambda *args, **kwargs: logfile.write(' '.join(str(arg) for arg in args) + '\n')

    # --- Log edge data for all objects before linking ---
    print("---- Edge Data Before Linking ----")
    for obj in objects:
        if obj.type == 'MESH':
            print(f"Object: {obj.name}")
            print(f"  Edge Lengths: {original_data[obj]['edge_lengths']}")
            print(f"  Edge Vectors: {original_data[obj]['edge_vectors']}")

    # Relink objects within each group
    for group_key, group_objects in signature_groups.items():
        if len(group_objects) > 1:
            sorted_objects = sorted(group_objects, key=lambda obj: obj.name)
            reference_obj = sorted_objects[0]
            for obj in sorted_objects[1:]:
                if obj.data != reference_obj.data:
                    # Link to new mesh data
                    obj.data = reference_obj.data

                    # --- Log before and after applying transformations ---
                    print(f"\n--- Object: {obj.name} ---")
                    print(f"  Location (Before): {obj.location}")
                    print(f"  Rotation (Quaternion) (Before): {obj.rotation_quaternion}")
                    print(f"  Scale (Before): {obj.scale}")

                    # Apply original origin
                    obj.location = original_data[obj]["origin"]
                    print(f"  Location (After applying origin): {obj.location}")

                    # --- Calculate and apply rotation based on edge orientation ---
                    # TODO: Implement rotation calculation using edge orientation

                    # --- Calculate and apply scale based on edge lengths ---
                    # TODO: Implement scale calculation using edge lengths

                    print(f"  Rotation (Quaternion) (After applying rotation): {obj.rotation_quaternion}")
                    print(f"  Scale (After applying scale): {obj.scale}")

                    relinked_count += 1
                    print(f"Relinked {obj.name} to use {reference_obj.name}'s data")

    # Restore the original print function
    print = old_print

    # Close the log file
    logfile.close()

    # Delete the original objects that were duplicated
    for obj_name in objects_to_delete_names:
        obj = bpy.data.objects.get(obj_name)
        if obj:
            bpy.data.objects.remove(obj, do_unlink=True)

    return relinked_count

class OBJECT_OT_relink_duplicates(bpy.types.Operator):
    bl_idname = "object.relink_duplicates"
    bl_label = "Relink Duplicates"
    bl_options = {'REGISTER', 'UNDO'}

    operate_on_selected: bpy.props.BoolProperty(
        name="Operate on Selected",
        description="Only relink duplicates among selected objects",
        default=False
    )
    match_material: bpy.props.BoolProperty(
        name="Match Materials",
        description="Check if materials match before relinking",
        default=True
    )

    def execute(self, context):
        relinked_count = relink_duplicates(context, self, self.operate_on_selected, self.match_material)
        self.report({'INFO'}, f"Relinked {relinked_count} duplicate objects.")
        return {'FINISHED'}

def menu_func(self, context):
    self.layout.operator(OBJECT_OT_relink_duplicates.bl_idname)

def register():
    bpy.utils.register_class(OBJECT_OT_relink_duplicates)
    bpy.types.VIEW3D_MT_object.append(menu_func)

def unregister():
    bpy.utils.unregister_class(OBJECT_OT_relink_duplicates)
    bpy.types.VIEW3D_MT_object.remove(menu_func)

if __name__ == "__main__":
    register() ```

Do you export to the Unreal Engine?If the layout is to be reproduced on the Unreal Engine side as well, it may be necessary to output object information such as JSON files on the Blender side and process to read them on the Unreal Engine side.

Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.

Yes I export out to unreal. I export gltf with instance data selected. And then import into level in unreal. I have no issue with that side of things. I just need to get the geometry linked up correctly in blender prior


text:
Why does it show 2 vertices under each other when in edit mode?

So I was making a donut and went In to edit mode and I saw that there was 2 vertices under each other it was really annoying this problem has showed up twice and and it happened with 4 vertices once

This is the effect of your subdivision surface modifier: in orange you have the vertex coordinates location in edit mode, in black the result after the effect of the modifier.
You can change this UI behaviour clicking on the two buttons on the modifier (nothing will change on render, only edit mode UI appearance).


text:
One common edge
How do you make these models share one common edge and then round everything off

Hello and welcome. Please use a title that matches the content of the post. It should read like a question, be descriptive but succinct, unique and identifying, summarizing the problem so that anyone searching for similar issues is likely to find this. Remove anything superfluous, avoid using words like "this", "help with", "issue" or "question about", instead describe what "it" is. Remember, your title is the first thing visitors see, answers you get depend heavily on it. See What is the problem of asking “How do I do this?"

It is very simple but can be tricky to understand by description.
What you need to do is to go in edit mode, then by vertices, join the two vertices of the corner by selecting them and pressing F on you Keyboard. Then you can close the remaining space in the geometry on both sides by selecting the 4 vertices of the face and pressing F again.
Now the only thing you need to do is to bevel the edge of the corner. You can do it by pressing CTRL + B and it should have that shape you want.
Please before bevelling, don’t forget you apply scale of your model.
Good luck!


text:
Problems with shadows
What's the right way to make it smoother? Adding new edges doesn't help much.

The triangle must be turned into quad. And removing edges actually is the way to go with smoothness

hello could you please share your object? https://blend-exchange.com/

Very likely you have somewhere where the artefact appears, a triangle or N-Gon. You need to turn geometry into quads to avoid any awkward edging shadows.
I can see at least one triangle in your sample.
It might also be that you have duplicated geometry (vertices, edges or faces overlapping). You can merge by distance to make sure you sort this problem out. One last step would be delete loose geometry.
Good luck with your issue!


text:
Loop cuts not making it all the way round

Hi,
I am trying to make loop cuts that connect to the verteces around the top of the stairs (to fix n-gons), but the loop cut seems to stop at an arbitrary place. Do you know why this might be?
Also, does my stairs topology look ok? This is my first time modelling and all I know is that I should try to avoid n-gons.

It stops whenever it finds a face that does not have exactly 4 sides or is not connected to the next face. You should review your topology

https://blender.stackexchange.com/questions/7990/why-does-loop-cut-and-slide-ignore-some-faces-but-not-others https://blender.stackexchange.com/questions/17870/loop-cut-wont-go-all-the-way-around


text:
Deselect Multiple Edges
I want to deselect multiple edges on my model. I currently know how to deselect one edge at a time by CtrlClick, but I am looking for a faster way for that. Deselecting one by one takes forever.
I am using the 3dsmax preset, so the CtrlClick is deselecting edges one by one.
For example, you could use the selection tools in 3dsmax (lasso, circle, box, spray etc.) to quickly deselect verts / edges / faces by Alt(Click+Draw a region).

Do you mean  shift+click? Ctrl+Click is for lasso select.

I am using the 3dsmax preset from the splash screen. Shift+Click doesn't do anything.

Cant get to enable the circle/lasso select tools as I am using the 3dsmax preset.

It seems that Lasso select is not assigned in the max preset, but circle select (C) and box select (B) should both work. You can also assign the lasso select tool to a shortcut if you want.

I bit the bullet and am using the Default Blender shortcuts from the splash screen. I did get to access the circle (C), and could deselect the elements using Shift+LMB. Thanks...!


text:
Text alignment changed in 2.70
I am a fairly confident blender user, who has been using the software for about 1.5 years. I have recently updated from version 2.63 to version 2.70, but I have noticed that in version 2.70 the text alignment has changed.
Is there any way to change it back?

I have looked all over the internet and cannot find any way to change it in the User Preferences.

I don't know of anyway to change this, short of editing the source code and compiling blender yourself.. I'm curious though, why do you prefer the old alignment over the new alignment?

That's just my personal preference - as I have used the old one for the past 1 and a half years, It looks weird to me.

Looked weird to me too at first, but I've gotten used to it. Now 2.6 looks weird!

Meh, still prefer 2.6!

This is a new feature in v2.70. It looks like someone missed to add it to the release notes despite this being a pretty noticeable change.
Proposal / discussion:
https://developer.blender.org/T37761
Commit:
https://developer.blender.org/rBdde5e5ce2581ffd544b442c58d6eefbc1ff61772
AFAIK there is no option to change it other than compiling without this pragma def: USE_NUMBUTS_LR_ALIGN (see above commit).


text:
Bone not moving in standalone player
I have coded a Blender animation's bones to move while the BGE is running. I made an Always sensor run code in a module that changes the bones using rotation_euler.
It works fine in the embedded player (the bones change xyz positions as instructed), but not in the standalone player.

The solution to this is actually quite simple:
You cannot have any errors in your python scripts/modules, else the Standalone players animation will not run, it just sits there, making you feel sad inside.


text:
Adding driver through python doesn't work properly?
I am writing a script and this script required adding a driver to an object,so I added it but I have 2 problems with it.

I have added a single property variable and set its ID and path. After I run the script, the variable added correctly and everything is fine, but I see that the path is colored in red and Blender said that my driver failed. I figure how to fix this, by selecting the ID object (spin object) one more time (which is already selected) as shown in the figure.
So how can I fix this? Because I don't want to do this every time I run the script.
and here is the script and the image.
newVar.name = "Array"
newVar.type = 'SINGLE_PROP'
newVar.targets[0].id = bpy.data.objects['Spin object']
newVar.targets[0].data_path = 'modifiers["Array"].count'

When I change the value of the variable (array count), I didn't see the effect until I press update dependencies. I want it to be updated without pressing update dependencies
every time I change the value of the variable. How can I do this?

That is a script fragment.  I can not reproduce your problem without making a LOT of assumptions about the rest of the script.  Did you create the modifier before or after the driver?  You should probably include a copy of the script that can reproduce the problem when it's run from a brand new .blend file containing the default cube.  Failing that, give us some more detailed instructions on how to reproduce the problem.

well,thanks you are right,I have added the modifier after adding the driver not before it,so this is the 1st problem solved,do you know the 2nd problem?

I think this is a limitation of the current dependency graph.
The way I would handle it is to add a custom property to the object, than add a driver to the array count that uses the custom value, set this other driver to also use the custom property.
As answered in the comments, you also need to overcome the chicken and the egg theory when creating drivers.
Edit

Add a new custom property to the object. in the UI you click the add button, in python there is nothing special, you just give the property a value and it gets created.
bpy.data.objects['Cube']['myControl'] = 1
Add a driver to the count value of the array modifier

Add the same driver settings for the other item that previous read modifiers['Array'].count

Now when you change the myControl value, both items will use the same value. You can create a panel wherever you like to display the custom property or add it to an existing panel.

the array count value updated properly but I still have to press update dependencies or refresh the Scene so the rotation of the empty that I put the 1st driver updated.

Are you pointing the empty.rotation to 'myControl' or to array.count?

actually,it works,I forget to change the path,thanks


text:
What is a keying set and how does it fit into the animation workflow?
I'm having trouble finding a good, newbie friendly description of what a keying set is exactly and how it fits into the animation workflow. I first discovered keying sets when trying to add a keyframe to an armature and getting the error "No active Keying Set".
This prompted me to search the wiki which only has a link pointing to the article Animating in 2.5, Getting to grips with Keying Sets, which I found overly complex for a non power user.
When and why do I have to use a keying set, and what is the purpose behind them?

A keying set is a collection of properties which should be keyed together. E.g. if you want to animate an object's position you need to set a start-keyframe of the initial location and an end-keyframe of the final position.  The position is described as x,y,z coordinate Location is a keying-set that inserts x,y and z at once.
In this image you see (Dope Sheet in the upper part) a location keyed for frame 1 and rotation for frame 2 both were inserted by pressing I and selecting Location respectively Rotation.

If the object should also rotate you can user LocRot to insert location and rotation at once. The other features described by Leon cover arbitrary properties (almost everything can be animated in blender). Later you might want to animate color, transparency of a material then you would need to learn more about it. For the time being this should provide you a basic idea.
Related: What do the preferences keyframing options actually mean?

Great answer, thanks. Do you know if other 3D programs use keying sets, or are they unique to Blender?

Keying Set is used for inserting/deleting keyframes for specific property channels on specific datablocks, without having to select them in advance.
By default, there are some commonly-used keying sets listed at the right hand side of the header in Timeline editor, such as Location, LotRot, Available, etc. Once you add new keying sets from the Keying Sets panel in Scene tab, it can be displayed or used in the Timeline list, as well as in I menu. In animation workflow, it is more effective when using with AutoKey feature.
After creating a keying set, a new Active Keying Set panel will pop up below it for defining specific data path for certain targets:

If a datablock is keyable, you can see related items in context menu when right clicking on it, so that you can add/remove keying set easily:


text:
Grime follow Edge of Faces
I want to make a procedural material to create a panel that has grime following the edges of the face, sort of like an old retro texture, or a minecraft block.  It needs to work on stretched faces as well.
The main difficulty is that I don't know how to make it follow the edges of all said faces in the model.

If you are using Cycles, there is a Pointiness attribute to a Geometry (shader) Node that can detect and highlight harsh angles representing "edges". This only works in Cycles and does not work in EEVEE, unfortunately, and will not always give you the result you want (it can often depend greatly, and sometimes unintuitively, on the angles of your desired edges).
I suggest first testing it by connecting the value through a ColorRamp directly to the Material output and adjusting the sliders until you can see what it's doing (as you can see from my image the sliders generally need to be very close together to isolate only "thin" areas).

If you think it catches the edges the way you like, you can then go ahead and use it as a Mix Factor between your Panel Material and your "Grime" Material:

In Eevee, if you have a rigid body like that, you could try to use something like a difference of vector length, and abs(max(max(x, y), z)) - of course will only work if all flat faces are aligned to 4 cardinal directions or up or down...

I am currently using EVEE, but I am glad you showed this to me!  That's looks like a great method!  Any idea if this will eventually be a usable method in EVEE?  If not that's ok, cause I'm willing to use Cycles.  (Cycles is the ideal method anyhow :D)

@RBlong2us: https://blender.stackexchange.com/help/someone-answers


text:
Sequence of Bones rotate One by One - Controlled by One Bone
I want to create an armature that has several bones that are all controlled by one bone.  When that one bone is rotated, it will rotate all of the bones, but one at a time.  So when one bone has rotated, say, 90 degrees (or however you decide), the next one will start rotating.  When the second bone has finished, the third will start rotating, and so on.
How can I create such an armature?  The bones do not change position, only rotation.

https://blender.stackexchange.com/help/someone-answers

Use self in drivers.

Similarly to @joshsanfelici have set the bones to XYZ Euler and driven the rotation z property of each bone via the target bone.
The ability to use self in drivers let's us get away with having one common driver and feed into it object properties.
In this case if one of our pose bones is self and the target bone is named "Bone" and is in the same armature then
self.id_data.pose.bones["Bone"]

is the target bone, and
self.id_data.pose.bones["Bone"].rotation_euler.z

is its $Z$ axis Euler rotation.
If we add a custom property to each bone, eg "prop" it can be used as the start rotation, eg
self["prop"] = 0.0

Rotations are in Eulers, as explained in other answer. So for example sake, if "prop2" is $\pi / 2$ can drive the bone using the target bone using a pretty long an inelegant expression that is the maximum of the minimum between 0 and the target rotation subtract the start range, and the range between our props...
Instead I have written a little script to add some props, make a simple UI, and a driver expression.  The UI is appended to the Pose Mode options panel in the 3D view N Tools Panel.
import bpy
from bpy.props import FloatVectorProperty, StringProperty
from math import radians

## properties

bpy.types.PoseBone.copy_range = FloatVectorProperty(
        size=2,
        unit='ROTATION',
        default=(0.0,radians(90)),
        )

bpy.types.PoseBone.target = StringProperty(
        )

# UI

def draw(self, context):
    ob = context.object
    pb = context.active_pose_bone
    self.layout.label(text="Bone Switch Test")
    self.layout.prop(pb, "rotation_euler", index=2)
    self.layout.prop(pb, "copy_range")
    self.layout.prop_search(pb, "target", ob.pose, "bones")

bpy.types.VIEW3D_PT_tools_posemode_options.append(draw)

## driver expression

def rotate_switch(self):
    target = self.id_data.pose.bones.get(self.target)
    if target:
        rz = self.copy_range
        range = rz[1] - rz[0]
        # map to 0 : range
        trz = target.rotation_euler.z
        return min(max(0, trz - rz[0]), range)

    return 0.0

bpy.app.driver_namespace["rotate_switch"] = rotate_switch

See the driver expression is
min(max(0, trz - rz[0]), range)

where trz is the target $Z$ rotation, rz[0] is at which rotation of target our bone starts, and range is the end minus the start of our bones rotation.
Easily extendable.
The idea here is to make it as easy to extend as possible. Can copy any of the driven bones and change their rotation range and the name of the driving bone on the fly.
Can edit the driver function and re-run the script, for example this simple change, (dividing the target rot by 4)
    trz = target.rotation_euler.z / 4

to make the "hammers" fall 90 degrees for each revolution of target bone.

Also here is a little helper script to convert all selected pose bones to XYZ euler rotation, and add a driver to all selected bar the active. (assumed the active is the driving bone)
import bpy

context = bpy.context

for pb in context.selected_pose_bones:
    pb.rotation_mode = 'XYZ'
    if pb is context.active_pose_bone:
        continue
    fcurve = pb.driver_add("rotation_euler", 2)
    driver = fcurve.driver
    driver.use_self = True
    driver.expression = "rotate_switch(self)"

In this setup I use drivers on z rot local space of all bones.
First left bone has this expression:
var if var <pi/2 else pi/2
As "var" is the Z rot controller value, this can be read as:
"give me var, if var is minor than 90 degrees, else give me 90 degrees".
So the driven bone copies the controller rotation only if its value is less than 90 degrees, then it stops at 90.
Center bone has a driver with this scripted expression:
(var - pi/2 if var>pi/2 else 0) if var<pi else pi/2
As "var" is the Z rot controller value, this can be read as:
"give me (var minus 90 degrees, if var is above 90 degrees, else give me 0), if var is minor than 180 dgrees, else give me 90 degrees.
For the third right bone it becomes:
(var - pi if var>pi else 0) if var<3*pi/2 else pi/2
And so on, remembering that
0 degrees equal to 0 radians
1 deg = pi/180 rad
90 deg = pi/2 rad
180 deg = pi rad
270 deg = 3*pi/2 rad


text:
Does Blender Have a Cycle Select Option?
Sometimes you have two edges that are directly on top of each other, which makes it almost impossible to select the one you want.  Does Blender have an option to cycle through the possible edges/faces/etc you are trying to select?
So far the only option I know of is hiding the one so you can select the other, but a cycling method would be way more efficient.

Yes.  It helps to be in X-Ray mode, but this is not necessary.  Simply do not move the mouse and click again.  One way to enter X-Ray mode is to use the toggle in the header. It's the icon that looks like overlapped rectangles:

This does not work on edges that are not apparently close enough together.  There you simply have to zoom in.

thanks man!  X-Ray mode is helpful alright.


text:
Export to .STL Format In Correct Scale - Inches
I've tried and tried to 3D print models that I have created, and I need them in .stl format.  When modeling in Blender, I change the units in Blender to Imperial - Inches.  However, whenever I try exporting it, it becomes super small.  I don't even know that checking "Scene Unit" helps.  I figured out that if I scaled it by 100, it would appear as corrects scale in Fusion 360, but then I try printing it and it's way bigger than it should be.
How can I know for sure that it's gonna print at the right size?  Is there a way I can double-check?

Does this answer your question? Scaling a mesh for 3D printing

By default Blender uses 1 unit = 1 meter even if you change the units in Blender to Imperial - Inches. That change only affects the GUI display, not the internal representation. According to Wikipedia, STL is unitless so use a scale of 39.37 to convert from meters to inches when you export, or tell the program you import into the file is in meters.
Basically, in Blender's Scene tab, set the Unit System to whatever you're comfortable with, choose whatever length you like, but leave "Unit Scale" set to 1.0. This leaves Blender internally using Meters, this is a good thing, because the unit system is a little strange sometimes.
When exporting your STL, set the Transform Scale to 39.37 (to convert meters to inches) and don't bother with "Scene Units" check box, it multiplies by the value in "Unit Scale" which we purposefully left at 1.0.

I tried this method out, and it looks like it will work.  I will find out soon.  Thanks!

It works!  Thanks!

I think it depends on what software you are using to print, and how it interprets .stl files. (I don't really have an answer but i hope my example helps and/or gives some insight)
First, if you open a new Blender file and measure the starting cube with the MeasureIt add-on it is 2 x 2 x 2 meters. If you set MeasureIt to Imperial Units, MeasureIt will no longer indicate 2 meters but (for instance) 6.56 ft.
If you set Blenders Unit System (under Properties > Scene Properties > Units) to Imperial, only the grid in the 3d Viewport will change. So the geometry of you model does not change or scale. Using either metric or Imperial in Blender, or switching between them, does not matter.
Secondly: I regularly covert .step files or part files from NX or Solidworks to .stl and import them into Blender. In order to get the right scale in Blender I set the Scale (when selecting the file in Blender) to 0.001.
So if I export the 2x2x2m cube from the Blender start file to one of these programs, I set the scale (when selecting the file in Blender) to 1000. If I do this the measurement tool in the engineering program (i.e. Solidworks) gives the same value for the size of the cube, which is 2x2x2m.
I would have advised you to do the same, but since you stated that a scale of 100 already yielded a result that was to big, I'm afraid you have to figure out (or try to look up) the conversion ratio between Blender and the specific program you use to print.

If you're using 0.001 and 1000 to go to and from Solidworks, I would assume Solidworks defaults to millimeters?

I would say that an arbitrary distance between two points (two sets of coordinates in virtual 3D space) is (always) given a 1000 times higher value (in terms of units of distance) by Solidworks than it is by Blender. In other words: the coordinates (in the .stl file)  are the same but Blender says (for instance) the distance between them is 2m and Solidworks says it's 2000m.

Nearly all slicers default to millimeters. The STL file format does not contain provisions for storing units so you have to set the size in the modeling program


text:
How to set render filepath using blend filename in python
Let say I have blend file called test01.blend, then I want to automatically assign render filepath via python to /media/data/render/[current blend filename]/[current blend filename]_.
So, it should look like this /media/data/render/test01/test01_
I'm trying to access it via bpy.data.filepath, but I got only full file path for current blend file not blend file name.
Thanks for your help

See this post

From iKlsR's answer:

You can get the filename with
  bpy.path.basename(bpy.context.blend_data.filepath). This will return
  it as a string without the path attached.

You can then assign the render output path with it:
import bpy

filename = bpy.path.basename(bpy.data.filepath)
if filename:
    bpy.context.scene.render.filepath = filename

Note that basename will include the file extension (.blend). You can strip it using os.path.splittext():
import os
import bpy

filename = bpy.path.basename(bpy.data.filepath)
filename = os.path.splitext(filename)[0]

if filename:
    bpy.context.scene.render.filepath = os.path.join("/media/data/render", filename, filename + "_")

is there any difference between bpy.context.blend_data.filepath and bpy.data.filepath?

it'll print .blend also in render filepath, any workaround to solve this?

@aditia Added a workaround

@CoDEmanX Good question. I don't know, but I don't see any.. (perhaps you should ask it? ;) )

@gandalf3 your workaround solve my issue, thanks a lot

maybe make it more generic and use os.path.splitext[0] instead of replace('.blend', '')?

Yes, IMHO os.path.splitext(filename)[0] is cleaner. There's always a possibility that .blend is embedded within the file's basename, though of course it's bad naming.


text:
How can I get back to Blender's default theme?
Even though I am relatively new to Blender I am recording a tutorial for a Blender exporter. I have been advised that I should use the Default colour scheme (for the UI). I have no idea which one that is. Can anyone tell me?

If you go to File -> User Preferences... and then to Themes, there's a Reset to Default Theme button.

or bpy.ops.ui.reset_default_theme() from the console.

You can also save a preset called "Default", so that You can switch back to it from the Theme Presets Menu. Since you lost the Default theme, You can follow the answer as posted by @jasperge and then the steps below

Add a new preset based on factory default theme

Name the new preset as Default

Later, if you changed your theme to some other theme, You can switch back to Default very easily

I can't believe they don't have a "Default" preset already. I would have never noticed that button.

Arguably just as important (more important?) as the default color scheme is the default layout (keybindings, screen layout, etc.). You might be better off resetting the whole thing to defaults by going to File > Load Factory Defaults.
Alternatively, include a start-up .blend file (and theme) as a downloadable addition to your tutorial. At the very least, this gives your audience the chance to have their whole set-up match yours right from the start.


text:
Blender equivalent of components in Sketchup
I have used sketchup before. I want to know can we make components or similar feature or addon available. In sketchup if we make a object components and make several copies of that object and if edit a single object of that component it will affects to all the components we have made with that main object. for the reference how the component works https://www.youtube.com/watch?v=rKhRDvpn_DU

This sounds like a linked duplicate. Use Alt+D instead of Shift+D when duplicating and I believe that you will have what you are looking for. Editing any individual object will change them all.
For more info on duplicating see the docs:
https://docs.blender.org/manual/en/latest/scene_layout/object/editing/duplicate.html
https://docs.blender.org/manual/en/latest/scene_layout/object/editing/duplicate_linked.html

Thanks thats what im looking for. One more question can we divide as u can see the reference video https://www.youtube.com/watch?v=XmJUPXC9gAA

You can't by default, but that is an add-on that wouldn't be too difficult to write. I don't see how it is that useful though when we have the array modifier.

If there is any addon available plz share the name or the link & can i post a new question with this topic

Yes, you could ask a new question for that (probably a better thing for BlenderArtists), but there isn't already an add-on for it so someone would have to develop it. I could do it pretty easily, but I'm super busy right now :-|

As the answer from JakeD stated, you can Link Objects in blender. But the functionality in sketchup allows you to encapsulate those objects (you can have components inside components and go on. In blender you can´t have objects inside the mesh (As far as I know).
But in Blender 2.8, you have collections, which is some kind of layers, and allows you to have Collections inside collections and them you can have an Colletion Instance, Which will get closer to the nested Component system of Sketchup!
When using a Collection Instance, when you change the main collection all others instance collections get changed!

You could already do this before 2.8 in Blender, it was called groups and Group Dupligroups https://blender.stackexchange.com/questions/47295/sketchup-like-components-case-study-is-it-in-or-even-feasible/


text:
I have a 3d solid drawing I need to import from autoCAD
I am trying to use Blender as a way of improving the look of our 3D drawings.
I have tried to research this and have managed to save original as a DXF then import to blender, however it is only showing as wireframes not as solid 3D objects!
Thank you

Yes sure,
I scale the drawing down in AutoCAD first and then save as DXF
and this is the result when imported into blender
Whats interesting is when I import the DXF back into CAD I get the same wire frame result!
I've attached what the origonal AutoCAD file looks like and shows what I'm trying to achieve.

related: https://blender.stackexchange.com/questions/62606/can-i-import-autodesk-inventor-2016-models

Can you post pictures to show us what you mean?

When importing from autocad to blender, usualy it is  pieces of furniture for me, i'm using stl format and downscale it to fit units and view. Never using dxf because having problems with it.


text:
I merge 2 vertex and become weird ,How can i fix?

First pic :Before merge
Second pic: After merge

Your question is unclear to me.  Please try to rephrase.  Please show a different image.  Please clean up the title of your question.

Sorry yo make you unclear. I'm newbie to use blender.

Please rephrase the entire question.

Whatever you did ... undo it .. Control Z.  Try it 3 different times to see if you get better results.

@atomicbezierslinger Sorry for make question unclear. I'm newbie to use blender. I merge 2 vertex and them become like in picture .i don't know how to fix them.

I already undo them.But not work.Them become same.

turn off clipping, move the vert, then turn clipping back on https://imgur.com/GTOGu88

To me, it looks like you have not cleared one side of your mesh before setting up the mirror modifier.
So if you still have both sides of the mesh and you're trying to merge things from both sides, the result is quite straightforward.
The mirror modifier is meant to literally duplicate symmetrically your mesh. Its purpose is for you to handle only a fraction of the mesh. But you have to cut out the part you want to let to the mirror modifier first.
So, if that's the issue:
In edit mode, Numpad 1 for front view, use Z to set the wireframe mode (it will allow you to select hidden geometry).
Select one side of your mesh up to the center with B and delete it.

I guess the problem is that you're misled by the Adjust Edit Cage To Modifier Result option of the Mirror modifier (fourth button) that makes the mirrored vertices workable, and you've created the hand on the mirrored side instead of original side. So, disable this option, now you'll see what I mean. Grab the hand and switch it to the right side, do a S X -1 to mirror it so that it is flipped in the right direction when it is in the right side. Now you can make the joint between the hand and arm.

Select the upper and lower portions of the wrist area. Do this first. Then try merge.  Two loops are selected.

Later.

Do not select the left and right sides at the same time.
Only do the left hand side first.
Then do the right hand second.

You mean i have to unable mirror and merge left hand first?

You are trying to merge too far and unlinked verticies. And If you are doing something identical use mirror modifier.


text:
Is there a way to have the unwrapping function not rearrange islands?
I have a character I want to unwrap. I marked my seams and when I hit "unwrap" all islands are  auto-rearranged.
This is a great function but I need to overlap mirrored unwraps and the different scale and rotation of each island makes this difficult. Overlapping results not perfect as I would like. Is there a way to avoid this auto arrangement?

Yes - to some extent, you can pin UV's to control the placement of each island.
To control the scale and placement you only have to pin 2 uvs on the island, to control the overall shape better you may want to pin 4 or more.
See docs on live-unwrap and pinning, older wiki docs but still valid


text:
Delete all unused textures from Blender using Python
With large projects that have hundreds of textures, it can be very difficult to deal with them in the UV image editor using the following little drop-down menu.

The best solution that I've come with so far is to modify the UV Image Editor code using some code from the Sculpt and Texture Paint section which is very helpful but it's still difficult to tell if something is in use and it has to be reopened every time something is selected and deleted.
(It now looks like the following in case anyone is interested.  You can do this by menu-clicking the image icon next to New and Open then selecting edit source and changing the following line in space_image.py
layout.template_ID(sima, "image", new="image.new", open="image.open")

to be
*layout.template_ID_preview(sima, "image", new="image.new", open="image.open", rows=8, cols=16*)

This question deals with deleting textures and it's what I already do.  But it's time consuming and very difficult to find the unused textures when there are a couple hundred of them, especially if the drop down menu has to be reopened and searched for everyone one of them.
So my question is the this:
Is there a way to delete all the unused textures using a Python script?
I have found one script that does not work very well.  Sometimes it does and sometimes it does not.
This gives the impression that there is something going on behind the scenes when it comes to how textures are considered to be in use.
By the way,  I don't use Fake User or pack images so this may simplify things a bit.

If the datablocks are unused, they should be cleared out when you reload the .blend..

The problem is having to reopen and search the menu over and over again since it closes when something is selected.  Also, it's not always clear what needs to go just from looking.

I'm not sure I understand.. Couldn't you just save the .blend and re-open it? (Ctrl+S, then Ctrl+Shift+O 1) That should clear out all datablocks with no users.

I do that but it does not work all the time.  I've even tried deleting every last object from the scene, saving, then reloading it, but most of the textures were still there even though there were not any models.  This works fine for removing materials but textures are really hard to get rid of.

I just tried what I said about deleting all the objects, then saving and reloading.  Most, or all the textures were still there, but when I fully shutdown Blender and reloaded the empty scene then only 17 of the textures are still there.  I guess this should be a bug report.  (This is without using the posted script).  When I ran the script, another 12 disappeared right away.  3 were loaded from Texture Paint and 2 were from a model that was not there.

Hm.. It sounds like something strange is going on, but I have no idea what. AFAIK reloading the .blend should be the same as restarting blender, and reloading the .blend should remove every datablock with 0 users (images with a little 0 next to them in the menu).

I just decided to check back in so I can load the .blend for you to have a look at.  When I reopen Blender and load this file, there are 41 textures listed in the UV Image Editor.  I've attached it to my question as an Edit.

When opening the .blend here, there are ~28 textures, and no textures with 0 users. Which is what I would expect.

Yeah, I wish I had looked at it more carefully.  There were models that I missed.  I even filed a bug report because I did not see your comment.  I'm super embarrassed about this one.  I was sure I deleted all the models.

No worries, I've reported my own silly mistakes as bugs often enough..

I was recently listening to a podcast interview with Kent Trammel and he said that he never reports bugs because he is worried about making a fool of himself.  Now I really get it.  Anyways, thanks for your help with this.

The reason for my confusion 2 years ago is a lot more clear now.  The .blend file must be saved and reloaded twice before image data is finally gone for good.  Now I know to press Ctrl+S then Ctrl+O twice in a row when images are stuck.

Happily that's one of the things that's being refactored for 2.8 (some of it might even be in 2.78)

Remove all images with zero users from the blendfile:
import bpy

for img in bpy.data.images:
    if not img.users:
        bpy.data.images.remove(img)

Do you know if anyone written an addon to have this option accessible right from the UV Image Editor?

How can I remove all texture without users OR with fake users?

ID.use_fake_user

if not img.users or (img.users == 1 and img.use_fake_user):

fix as 0 use ...press ctrl and delete  " texture , material and others" and after, save your work

"Using Python".

Please expand your answer so it is clear what steps need to be taken. Also consider that the question asks for an answer using Python.


text:
Is OpenCL possible within Blender either via cycles or internal?
I have the  Radeon R9 280X video card and was wondering if there was anyway at all to enable GPU rendering with this card? I know Nvidia has CUDA cores and that works. That's good and all, BUT I don't feel like dropping $900 on one of those cards.
I did some research on OpenCL with Blender (which seems to be compatible with AMD cards), but it seems the functionality has been disabled within Blender??
I would like to use cycles with the card, but if that is not a viable option then I'll stick with Blender internal. I just hate CPU based rendering. It takes ages to do the renders.

You cannot replace Nvidia cuda cores with whatever ati has. You will have to stick to cpu based rendering for now. OpenCL Cycles was planned, but I don't think it will be equivalent to what blender has for nvidia.

I understand equivalency is not there. I am just wanting to decrease rendering times.

I don't think that's possible atm

Nope, this is not possible in cycles due to driver limitations. Also check the wiki and this thread on BA which as some working tests. Development on BI has stopped and AFAIK there is no support for GPGPU rendering of any kind in BI.

I have the beta drivers if that makes any difference?

You could try a development/testing version, but there is no easy way to do this atm.

Blender Internal
BI never had any kind of GPU rendering support, and as development on BI has stopped, probably never will.
Cycles
Cycles only supports cuda at the moment, due to issues with amd/ati drivers. (also see the wiki)
However, there are some experimental tests using the "leaked beta version of what might be AMD's next official drivers" which you may want to try.

Install the sdk for your card (AMD should have some sdk for OpenCL)
Create a batch file to replace your blender shortcut:
cd C:\Program Files\Blender Foundation\Blender
set CYCLES_OPENCL_TEST=all
Blender

Save as startBlender.bat and run it as administrator
Open the user preferences (CtrlAltU) and go to System tab, set compute device to CPU only (GPU and CPGPU might not work for AMD, you would have to test it yourself)
In the Scene settings set Render > Device to GPU Compute
Set your viewport Shading to Rendered to test it and compare it with CPU compute
Wait first time (Blender needs to compile the OpenCL kernel)
Enjoy faster renders (40 percent at least on my side)

This worked for my Intel card and for Nvidia the OpenCL functionality is included inside the driver, so no SDK download was required, perhaps some other things are required for AMD. I don't know about that, sorry.

I use 2x r9 280x's cross fired. Just drop down to cmd and use set cycles_opencl_test=all and runn blender.exe from the directory. The 1st scene will take a while to compile so just render the cube. Than open your scene.
I was able to pick up the cards for just under 250 each. I still want to add 1 more to decrease render times.
Hope this helps
Raul

I'm not sure cross fire is speeding up rendering.. SLI (the nvidia equivalent) does not speed up rendering as cycles can use each GPU independently (SLI makes multiple GPUs act like one gpu, actually decreasing performance for cycles). I realize crossfire is probably very different from SLI, but I thought I'd mention this.


text:
Alternate between user input and automation in one-step script
I would like my script to do the following :

Save selected object's name and add an object (automation)
Let user move the added object where he wants (user input, stopped with leftclick)
Move the 3D cursor to where the object was moved, delete that object and reselect the original object (automation)
Let user move the original object where he wants (user input, stopped with leftclick) and terminate the script.

I tried to modify the template "simple modal operator", but without success. I looked the doc, googled, watched other scripts which are modal... nothing. The best I did get was to reach step 3, but then the script seems to ignore the line where I change the active object. The same line works in the python console...
I don't specifically want the solution for my case, but at least if someone could explain how to properly alternate many times between user input and automated steps, it would be nice.

Great script, lukas_t! I didn't even know about Macros :D
That fancy object ptr thing works for me, no error message in 2.67.
I solved the "remember last object"-problem in another way, maybe that is not going to give errors for you, matali. I simply used static class attributes to store snap settings and the object.
import bpy
from bpy.types import Operator, Macro
from bpy.props import *

class TranslateCursorMacro(Macro):
    """Overall macro for combining move and cursor operators"""
    bl_idname = "object.translate_cursor_macro"
    bl_label = "Translate Cursor"
    bl_options = {'REGISTER', 'UNDO'}

    @classmethod
    def poll(cls, context):
        if not context.active_object:
            return False
        return True

"""
def _find_prev_object(ptr):
    for ob in bpy.data.objects:
        if ob.as_pointer() == ptr:
            return ob
"""

class Storage:
    ob = None
    use_snap = False
    snap_element = 'CLOSEST'
    snap_target = 'INCREMENT'

class RememberObject(Operator):
    """Store active object"""
    bl_idname = "object.remember_object"
    bl_label = "Remember Object"

    def execute(self, context):
        # XXX This is not super nice, but we don't have real
        # properties shared between macro component operators.
        # In an addon this might be stored as a module-level
        # python variable.
        context.scene["_prev_object"] = context.active_object.as_pointer()

        Storage.ob = context.active_object
        Storage.use_snap = context.tool_settings.use_snap
        Storage.snap_element = context.tool_settings.snap_element
        Storage.snap_target = context.tool_settings.snap_target
        context.tool_settings.use_snap = True
        context.tool_settings.snap_element = 'VERTEX'
        context.tool_settings.snap_target = 'ACTIVE'

        return {'FINISHED'}

class DeleteNoQuestionsObject(Operator):
    """Delete object without asking"""
    bl_idname = "object.delete_no_questions"
    bl_label = "Delete Object"

    def execute(self, context):
        # XXX The usual bpy.ops operator opens a popup
        # when invoke. Use this wrapper to avoid that.
        bpy.ops.object.delete('EXEC_DEFAULT')
        return {'FINISHED'}

class SelectPreviousObject(Operator):
    """Select previous object"""
    bl_idname = "object.select_previous_object"
    bl_label = "Select Previous Object"

    def execute(self, context):
        context.tool_settings.use_snap = Storage.use_snap
        context.tool_settings.snap_element = Storage.snap_element
        context.tool_settings.snap_target = Storage.snap_target

        ob = Storage.ob
        if ob is None:
            self.report({"WARNING"}, "Previous object not found")
            return {'CANCELLED'}

        """
        ptr = context.scene.get("_prev_object", None)
        if ptr is None:
            return {'CANCELLED'}
        del context.scene["_prev_object"] # cleanup
        ob = _find_prev_object(ptr)
        if not ob:
            self.report({"WARNING"}, "Previous object not found")
            return {'CANCELLED'}
        """

        for tob in bpy.data.objects:
            # Avoid checking every ob, just deselect all an re-reselt previous
            #tob.select = (tob == ob)
            tob.select = False
        ob.select = True
        context.scene.objects.active = ob
        return {'FINISHED'}

bpy.utils.register_class(TranslateCursorMacro)
bpy.utils.register_class(RememberObject)
bpy.utils.register_class(DeleteNoQuestionsObject)
bpy.utils.register_class(SelectPreviousObject)

TranslateCursorMacro.define("OBJECT_OT_remember_object")
TranslateCursorMacro.define("MESH_OT_primitive_uv_sphere_add")
TranslateCursorMacro.define("TRANSFORM_OT_translate")
TranslateCursorMacro.define("VIEW3D_OT_snap_cursor_to_active")
TranslateCursorMacro.define("OBJECT_OT_delete_no_questions")
TranslateCursorMacro.define("OBJECT_OT_select_previous_object")

Just in case anyone wonders how to pass parameters to the operators in the macro:
import bpy

class m(bpy.types.Macro):
    bl_idname = "object.macro_test"
    bl_label = "Macro Test"

bpy.utils.register_class(m)
op = m.define("TRANSFORM_OT_translate")
op.properties.constraint_axis = (True, False, False)

It works, thanks a lot CoDEmanX, problem now is who gets the bounty ? I think Lulas can get it as he did the biggest part. You learned something from his script, and I give you a point for your fix all right ?

Is Luka's version working for you ? You don't get the error I have ? Maybe it's due to Linux or the SVN versions I used... If so it may be reported as a bug for 2.69.

Alright. Honour to lukas for sure!
Need to test what Macros can do else :D
//edit: Lukas' version works for me indeed, not sure if I use it right / in the same way as you do?!

Well, I run the script and then spacebar -> "Translate cursor". I get the error after left clicking. What do you do ? Just tested in 2.67b, same error "object not found" after first left click (placing the sphere)

I select an object, turn on snapping, run operator from spacebar menu. Sphere can be snapped, left click, 3d cursor moves and sphere vanishes. Originally selected object is still active and selected, other selected objects are lost from selection however (can easily be fixed). So I guess we use it the same way, I just don't experience any errors. Tested with 2.69 testbuild 1.

Lukas's version works under Windows, so it's only Linux specific... and on Linux your script works... strange.

That's indeed an interesting find, on windows it's fine. Must have to do with the pointer, maybe linux does this differently? I still wonder why the assignment fails silently...

@CoDEmanX Yep it's the pointer 2.75.4  linux 64 line 40 OverflowError: Python int too large to convert to C int


text:
How do I divide the driver value?
I have an Empty x-position driving the rotation of a Cube.
And I want to divide the value of the position of the Empty, so that the Cube rotates half the value.

Add a single driver to the cube (e.g. Z-rotation)
Go to Graph Editor and switch to Drivers mode
Set Ob/Bone of the variable var to reference the Empty
Enter the Expression var/2 (or var*0.5)

var is equal to the X Location of the Empty, dividing it by 2 halves the "influence" of the location to the rotation of the Cube.


text:
Best/ preferred way of storing Image references?
I'm currently working on a project-specific addon where I'm dynamically loading and removing images on the fly.
So far I've gotten away with a simple Image.isProjectProperty, but I now need an (ordered) list of these dynamically loaded images. However, a CollectionProperty with a type of BlendDataImages seems to be out of the question, and there doesn't appear to be a StringVectorProperty to store the names in either.
I could probably sort a temporary list, then find their bpy.data.images[] indices and store those in an IntVectorProperty, but that doesn't seem very safe either; what if 0-user images get removed between sessions? Is there a better way of going about this? What am I missing?

If you need multiple strings, why not use CollectionProperty? bpy.types.PropertyGroup comes with a StringProperty already (name), then just add new items to the collection and assign an image's name.
*VectorPropertys shouldn't be used if the amount of integers, bools or floats aren't limited conceptually. They are meant to store things like transformation matrices, which are never larger than 4x4.
Since image datablocks are ID types, why don't you add an IntProperty and assign a number, then sort images by that? Set the default to -1, and ignore these to distinguish unrelated images from your project images:
import bpy

# Register property - should be in register()
bpy.types.Image.project_id = bpy.props.IntProperty(
    default=-1,
    min=-1
)

# Assign number
img.project_id = ...

# Filter and sort
sorted(filter(lambda x: x.project_id > -1, bpy.data.images), key=lambda x: x.project_id)

The problem with using a CollectionProperty is that I need a different amount of names each time (one for each image loaded at the time). Assigning an id could work, but then I would still need to iterate through all images and sort them every single time I need them.
An alternative I though of would be to load all images using a naming convention, like __ProjectImage1, which would work, but doesn't seem like the best solution either.

Nevermind, I'm just being an idiot. ;) I'm using another framework at the moment and had the wrong idea of a CollectionProperty in mind. Thanks!


text:
How do I add colour to this set of nodes?
I'm attempting to create a sort of starry effect using nodes. However, I can't seem to be able to add colour to it. This is the following node setup:

And this is the result:

This is essentially three layers of noise textures. One on its own, and two modified with wave textures, to create different densities, and to add a cloudy effect. Unfortunately, this is all black and white, and I'd like to control the colour of each 'layer' of noise textures.
Changing the colours in any of the ColorRamp nodes has not helped. Setting random colours to any of these nodes simply controls brightness. Adding a MixRGB node before the Math nodes at any point seems to achieve the same result, or no change at all.
How can I add some colour to this?

If you replace your Math nodes with Vector Math you can use a color ramp to color the result.
I'm not exactly sure what the end result should look like or why you chose the particular mathematical operations, so the end result is just to show that it contains color set by the color ramp.

Not sure why I chose the mathematical nodes that way. It was a combination of looking at other online guides, and doing some experimentation on my part. Just playing around with different effects, I suppose. In any case, I'll give your suggestion a try in a little while.


text:
Point cloud animation
I have around 5500 .ply files, which amount to about 7 GB of point cloud data; each file is one frame of animation.
Is there any feasible way of importing this into blender for processing? I am aware of tools like Stop-motion-OBJ and Sverchok nodes; however, due to the large number of files, blender simply can't handle it.
The only solution I've found is setting up a scene with camera and lights, and then importing and rendering each frame separately with a script, similar to the procedure detailed here. However, since I only have the point cloud data, I'd have to add spheres around each point to be able to render them. This amounts to creating a new .ply file with vertices corresponding to a sphere centered around each point. I've already managed to automate this process; however, according to my calculations, the last frame alone would have a size of 10 GB after appending the spheres.

Welcome to Blender Stack Exchange. My gut feeling is you would need to have an object that uses Particles or Dupliverts to generate the "spheres" you mentioned, and swap out the mesh data on each frame using a Python script. Sorry I can't offer more more specific details on how to do this.

Maybe create a single triangle instead a sphere and use script to make it Billboard effect? Or you may want to go in OpenGL for directly render those point cloud

Expanding on Mentalists suggestion: When you import a ply the data looks like a lot of vertices (points) but no lines or faces. When using dupliverts the object gets duplicated on each of these vertices (this takes care of creating spheres). This process takes very little memory because the same mesh data is just linked each time. Thus the script basically needs to (1. import next ply 2. parent object to imported ply 3. enable dupliverts 4. render 5. delete ply ). Animating a vertex through all plys will need some serious processing.

This isn't ideal, but could you split the sequence of .ply files into multiple chunks, and create multiple blend files, each with their own subset of the sequence?


text:
Rigid body animation with constraints and relationships
I want to drop a Padlock object that not only bounces the main body of the lock but has an open lock that also swivels when it hits.
I can't do this with a parent child relationship since it isn't calculated in the simulation...  any ideas?

It sounds like Rigid body constraints are what you want.
For a padlock you most likely want a Hinge constraint, to allow rotation on only one axis.
Creating a Rigid Body constraint
3D view > Tool Shelf > Rigid body tools:

This is the easiest way (currently) to create RB constraints. (Select objects and press Connect. all selected objects have to be Rigid Body objects to do this.) This will create an empty that represents the constraint. (Constraint settings are in the physics panel)

A quick setup,
frame 1 and frame 50:

Note that the orientation of the empty refers to the orientation of the "hinge" (what direction it's allowed to rotate in.) by default the hinge will be allowed to rotate around the local Z axis of the empty.
Result:

Long ago I created demo video that illustrates the behavior of several of the physics constraints: https://www.youtube.com/watch?v=r6JNh-i-uVI