text:
How can you align two vertices relative to a global coordinate when you want to preserve the orientation of the edges that contain them?
I want to move a vertex A along an edge A1 in such a way so that the vertex has the same Z global coordinate as another vertex B which is in another edge B1. B1 and A1 are not parallel.
I tried using the Normal coordinate system to move A along A1, but snapping to B only considers the current (Normal in this case) coordinate system so it didn't work as desired.
Then I tried snapping the 3D cursor to an endpoint of A1 and scaling A (with the 3D cursor as pivot), but snapping to B did not work as expected (I'm not sure why).
The only solution I was able to come up with was to duplicate the edge and snap A to B in the global coordinate system, then while moving on the XY plane snapping to the duplicated edge. Far from being practical.
Here is a picture of what I'm trying to achieve:

I want the selected vertex to move only along the green axis but I want to snap to the vertex in the red circle relative to the global Z.
Is there a better way to achieve this?

My thought is to add a second mesh object that is a plane on xy at your desired Z and big enough to intersect the relevant areas, setting its display to wire only, going back to your vertexes and sliding them with face/surface snap turned on. Can't test it right now though.

@StarWeaver yes, that's better than duplicating the edge, but I didn't want to create new geometry.

I would also like to know the answer :)
However, as a workaround for this specific case the knife tool K in combination with angle constrain C is very handy:

The knife angle constraint snaps to the viewport so ensure you are in front or side orthographic view to get the same z value as the other vertex.

This seems like the best solution so far, the only problem I see (apart from switching the 3D view) is when there are a lot of edges you don't want to cut in between the relevant edges. Dissolving a lot of vertices could become a quite slow task.

This is a task that blender doesn't offer any help (yet).
Vertex slide GG will allow you to slide the vertex along the existing edge that you want to follow. Unfortunately snapping doesn't work during vertex slide so you need to move the vertex until you get the z value of the matching vertex. You can see the vertex position in the properties sidebar while in edit mode.

You will find it hard to get an exact value, if you get it close and then use orthographic view to zoom right in you can get small movements to get very close to the value you are after.
It is the angle of the edge that causes issues, if the edge was vertical you can move constrained to one axis and use snapping to align it to another vertex.


text:
Unwanted sharp shadows when using a point lamp
I'm learning the basics and while modeling a simple volcano using a point lamp for the magma I keep getting unnatural sharp shadows, even when disabling ray shadow. I don't think the problem is in the mesh (you can find the .blend file in the comments). Here are some examples:

In this case I put the lamp outside the crater. If I disable Ray Shadow here it gets better.

Now placing the lamp inside the crater. Even when I disable Ray Shadow I keep getting those sharp transitions.

Related File

That is a problem with the mesh, see http://blender.stackexchange.com/q/1998/599 (yes, it can happen to BI too). Try adding more even geometry and smoothing that section out a bit

Thanks, the problem was the mesh indeed (had to switch to orthogonal view inside the crater to see it). I ended up solving it by adding another point lamp above the old one instead of modifying the mesh.

You can also try changing the shadow's Soft Size to affect how sharp or blurred the shadows will be.  If you are using Blender Render(Internal), the samples for the shadows are right next to the soft size.

For Cycles, the lamp size can be used to alter the softness of the shadows.

Thanks, the problem was the mesh (when the lamp was inside the crater) but your comment answered the other part of the question.

source: Stack Exchange

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

sort: votes


text:
Receiving a shadow without casting one?
I am trying to create a plane that will stop shadows that hit it, but will not cast a shadow itself. I am using Blender Internal and have tried a combination of "Receive", "Cast", "Shadows Only" and "Cast Only" to no avail.
Keeping "Receive" on but turning "Cast" off just allows shadows to pass through it.
In this image I'm trying to get 00 Caster to cast a shadow on 01 Blocker, and to have neither of them cast a shadow on 02 Receiver (which can receive shadows from other objects). Would Light Groups be a way of doing this?

Here's a link to the blend.

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


text:
Blender won't import .3ds file despite working in Photoshop
I am trying to import a .3ds file into Blender, but I am getting the following error:

The .3ds file in question was produced by an extraction/conversion script from a different convoluted file format, so I assume this is where the issue lies. However, the file imports fine into Photoshop, of all things.
I have tried exporting to OBJ from Photoshop, but the file is empty upon import (no vertices, objects, etc.)
I have tried opening the .3ds file in Maya and 3DS Max (specifically Maya 2014 and 3DSM 2015, which I read should have worked), no luck there either (it says improper file format).
I have also tried Autodesk's FBX Converter, which seems to be mildly better except all the vertices are collapsed together (there are 1K vertices in the file but they're all at 0,0,0.) I don't know if this is an issue on Blender's end or the converter's end.
I have also tried a really old version of Blender (can't remember which specifically at the moment), no luck there either (although I did read that this was supposed to work, but no.)
I recognize that in all likelihood this is not an issue with Blender, but the details in the error message made me think maybe someone here would know what I can do to further troubleshoot.
Oh one more detail, I don't know if this is relevant or not, but the file does not include a mesh but instead a bunch of unconnected vertices (a vertex cloud). If any programming savvy people here would know how to simply output the vertex coordinates so it can be read that way, that would work just as well.
Here is an example of a .3ds file (Google Drive)

I don't think .3ds format is good choice here as it has some limitations like vertices pre mesh count or triangle mesh limitations. If none of programs imports it as expected then most likely there isn't what you're searching for. If possible export to another format for point clouds

@MrZak I wish I could. The problem is, .3ds is the only feasible output format for the script that was used to extract/convert the original data. Normally I would chalk it up as simply a bad file format, except, like I said, it does actually work in Photoshop, and there is also a conversion application that works for some people. So I know it's possible to get the data out of the file, and since Blender does actually give a comprehensive error message, I would think that information could be used to troubleshoot the issue, though I could be wrong.

There was similar error while importing before but not .3ds rather than .fbx. I don't have idea about what's going on with this file which opens in one app and doesn't in others. Try filing bug report at https://developer.blender.org/maniphest/task/edit/form/1, maybe it's really bug (make sure to check latest Blender versions first)

Jace, can you please describe a full path from creation/download of the mesh and which software and formats were used. And, if possible, provide a mesh in another format.

@martinsifrar I didn't do this myself, someone else did and handed over the .3ds files, so my technical knowledge of this is limited. However, I do happen to know the process.
First we ripped .GO files (model file format) off of a video game disc (Jak and Daxter: The Precursor Legacy, if that's relevant), and used a BMS script (this one) to convert it into a readable format (.3ds). We used QuickBMS to do this. The guy behind the magic describes his process here.

Oh, I might need to add, I think .GO files are container files for multiple files IIRC.

I am not in any way qualified to talk about this script, but would it be possible to maybe convert  .GO into something more suitable for point clouds, for example, .PLY?

@martinsifrar Actually I was able to convert the 3DS files into PLY, as you suggested, using a program called 3D Object Converter, which for some odd reason was able to open the 3DS file, similar to Photoshop. The PLY files import to Blender perfectly. If you would like to post an answer recommending the PLY format I'd be happy to accept/award the bounty. Otherwise if this question needs to be closed as off-topic, I understand.

photoshop is known to me for notoriously exporting bad 3d formats. especially obj. try to avoid it

Super MegaBroBro posted this solution as an answer. You can give the bounty to him and mark it as a valid answer so this thread can be closed. Anyways, glad you did it and hope I helped at least a bit.

Do you have the source files? (whatever the format)

Very interesting read about the 3DS file format: https://en.wikipedia.org/wiki/.3ds
In human terms: it's hard to read the file manually because it's a binary. Still gonna try to read it though... Not sure I'm gonna get lucky however.

As user: martinsifrar suggests. You might be able to convert to the PLY format instead of the GO format. It appears you can use software called 3D Object Converter to accomplish this :)
Have fun :)

what i think is that its not the issue of blender or max or maya.... the extraction conversation step has resulted in a corrupted file... which however photoshop is able to read(given that photshop is not meant for 3d)...if you have windows 10... try opening it in window 3d viewer and if it is viewable there.. export it in obj format

Unfortunately it is not viewable in Windows 3D viewer. I do not think it's a corrupt file, as converting it to PLY format allows Blender to import it properly. I think Photoshop is able to import the original .3ds file format because it might support older formats due to a lack of updates, because, like you said, it is not a 3D-first program.


text:
Join objects that have the same texture
I'm wondering if there's a way to join all objects that share the same texture image. I don't want to join them if they have the same material, but rather, if they use the same source image texture.
I assume it's possible with Python scripting? For clarity, I'm using Blender v2.76 on Windows 10. I've tried "Select Linked" with Shift+L > Texture in Object mode but it doesn't work.
Edit
To clarify, I'm asking if this can be done automatically/not-manually. Here's why: I imported an .obj file, and for some reason it imported each face as its own, separate object (let's call these "face/objects"). This yields around 3,000 separate objects or so. I figured that, since each of the face/objects share only 3 source image textures, it'd be possible to select each face/object that uses the same source texture image to merge them into one object. In the end this should yield only 3 objects. I hope that made sense.

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

My apologies, please refer to my edit.

Jase, I don't have the skillset to write the code to combine into objects automatically, but the fact that it can be done manually means a Python script can be written to do it, too.

That's definitely good to know. I'm guessing blender.SE shouldn't be used to request Python snippets, but at least now I know it can be done, so thanks for the info.

I'd expect that a request for a code snippet would be considered out of scope for the site, but would fit right into the python support forum at Blender artists.

Ah, I think you're right about the scope thing. In that case, I will accept your answer. Thanks for the help!


text:
Collision “Thickness Outer” and “Inner”
When you look at the Collision settings in Physics Properties, you’ll find Thickness Outer and Inner. I understand that Outer is an option to detect external objects like Cloth and SoftBody.
However, I'm puzzled about the purpose of Inner. Since it’s already preventing collisions from the external objects, why does Inner exist? And what happens when it scales up, and down?

Here's the Blender manual description which should explain it.

Thickness outer and inner do not refer to external objects.  They refer to the space external or internal to the mesh, as determined by its normals.
Here we are, a few frames into a soft body simulation, with "face orientation" display enabled:

The small soft body plane has settled into a position about 1 unit above the larger plane (as indicated by the default scale cube next door, 2 units cubed.)  The outer collision margin indicates the margin, as measured in the directions of the collider's normals.  Let's flip the normals and check again:

The plane falls normally, until it enters a space within 0.5 units of the collider, 0.5 units being what I specified as the inner margin....

Then is rapidly sucked through the collider-- in the direction of the collider's normals-- until it reaches 1.0 units outside of the collider, after which, it is thereafter accelerated only by gravity.
Let's put the plane above the scaling cube, give that cube collision with those same settings, reverse its normals, and see what happens:

The plane falls under gravity until it reaches 0.5 units of the top of the cube, after which it is rapidly propelled into the middle of the cube and falls under gravity until it reaches 1.0 units of the bottom the cube, after which it settles as if the bottom, reversed normal side of the cube is a floor-- settles at 1.0 units above that floor.
Inside and outside, in the context of physics, are measured by the directions of normals.  The inside margin is how far it checks collision in the direction of the negative normal; the outside margin is how far it checks collision in the direction of the positive normal.
There is no need to check external objects.  Collision doesn't react to anything.  Any collision object is the external object, external to the sim, and all you have to do to get a mesh to interact with cloth or soft body physics is to give it a collision modifier.

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


text:
How to apply transforms without changing the origin?
My object is far away from 0,0,0 point, it has to. The origin point also has to be in the center of my geometry. Every time I click on apply my origin goes to back to 0,0,0.
How to apply my location without changing the origin?
3D Cursor and Transform pivot point both don't work.

Are you pressing ALT+G? If so, that's clearing your location transform, not applying it. To apply it, hit CTRL+A and choose the Location option. If this isn't what you're doing, can you take a screenshot or something?

@Tumbleweed: That is what it does. You are pressing Ctr+A - Apply Location that brings an origin to Zero and keep object in location. Same if you rotate object and Apply Rotation - rotation stay but value in Rotation is set to zero. So my Q is what do you expect from "apply location"? From what you wrote object is far that is OK and has its origin in his centre, so what do you expect to act?

I expect every transform to be zero, But when I apply it to zero with "apply location", the origin will change (screenschot added)... is there no way around? Have to export for unity but the pivot will be totally messed up

It can't be :) Values represents origin position in world. Why do you need something like that?

Would this help? - https://blender.stackexchange.com/questions/99821/how-can-i-shift-or-move-an-entire-animation-to-a-different-location/99911#99911

Ctrl+A -> location to deltas.

Using Ctrl+A Apply > Location to Deltas.
will alter the delta locations such that the origin remains unchanged whilst the objects location is zeroed.
Note Unable to test if this works as expected when exported to Unity

You can move the object after going into Edit Mode, select all the vertexes and press G, or add the coordinates well after you used Apply All Transforms.
You don't need what you ask for, if I correctly understood.

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


text:
Error while trying to use Curve Modifier - Cannot apply modifier for this object type
I was trying to use a curve modifier on some text. Everything works fine until I try to apply the modifier. I'm not sure whether I'm doing something wrong. Can someone be kind enough and give it a quick look please.

You need to convert the text to a Mesh object.
Object -> Convert to -> Mesh from Curve/Meta/Surf/Text

It worked.Thanks

The problem is there are vertical edges missing. Two options:
1) Make straight letters moved by equal distance from center
2) If curved letters is what you need - you need to create a surface, divide it couple of times, than create letters, convert text from curves to mesh. Project mesh letters on a surface. Cut out the rest (faces), than apply curve modifier.


text:
I need to export a list of particle coordinates
This code was built for Blender 2.78, but I trying build the code in 2.8.
Blender doesn't show any errors, just opens a new empty text file.
I'm using the code from here:
import bpy

object = bpy.context.scene.objects["Plane"]
particles = object.particle_systems[0].particles

bpy.ops.text.new()

for p in particles:
     bpy.data.texts[-1].write("<particle x='"+str(p.location[0])+"' y='"+str(p.location[1])+"'z='"+str(p.location[2])+"'/>\n")

Is there something I am doing wrong?

Of Blender 2.78 to Blender 2.82 there were several changes.
Now the code that yes work:
import bpy

depg = bpy.context.evaluated_depsgraph_get()
object= bpy.context.scene.objects['Plane']

particles = object.evaluated_get(depg).particle_systems[0].particles

bpy.ops.text.new()

for p in particles:
    bpy.data.texts[-1].write("<particle x='"+str(p.location[0])+"' y='"+str(p.location[1])+"'z='"+str(p.location[2])+"'/>\n")

I get to this code after find these links:
Particles python access is broken in 2.8
Manipulating particles in python


text:
How do I control the origin to my scale?
I was following a tutorial to creating an anvil and had a question in mind. When creating this Anvil, I came to a step where I had to create the tip of the anvil- keep in mind that I made the point too long.
Without thinking too much, I committed to the length and I created 5 edge loops that were evenly distributed along the length.
I guess you can see my problem now. Having committed to a longer length of the point, I now had to make the length shorter while keeping the edge loop evenly separated and intact to the body of the anvil.
Being a Photoshop user, I thought "oh no problem I can just scale it", but when I scaled it, I realized that I'm limited to scaling in the center of my selection- it was not from the side I needed to scale it from.
I will attach images to best explain what I have, versus what I was thinking of.
I do know that I can just backtrack or be more careful next time, but if there is a tool for something like this, I believe it would be very useful in the future!

Just use 3D cursor as pivot point :).

Select the edge loop and put 3D cursor there. Mesh > Snap > Cursor To selected.
Set Pivot point to 3D Cursor.
Use Scale tool gizmo to scale only on X axis.


text:
Material based in mesh and not on verices
I want to create a T-Shirt, that has this pattern on it, like shown in the picture, my problem is that I want to have the image texture based on the mesh, and not on the density of the vertex.
So that the pattern is evenly distributed. I have made a UV Map node connected to Vector from a Mapping node with a scale's factor on X and Y, which is connected to a Image Texture, connected to the material output.
I'm sorry, but i cant take a picture of it.
When I take a vertex and grab it on the Y axes, the image is also scaled in the Y-axis, so that my pattern is scaled on the Y-axis.
I don't want my pattern scaled, but increased in numbers, so that it fits.

Take a screenshot: https://www.take-a-screenshot.org/

I would, but my Computer has a problem with the Internet connection, and I only can post from my Smartphone. And I dont can send a screenshot to my smartphone from my computer, because my computer has a porblem with the internet connection..

And if i take a photo from my Computer, I cant upload it from my Phone

Finaly I have done it. I reposted my question with my computer under "material distributed based on mesh and not on vertex"


text:
When I apply a material objects loses self shadow
When I apply a material in Blender the objects lose self shadow.
Not the shadow it casts but on its back faces, if that makes sense.

Would you mind posting a screenshot of your situation ?

Yes... We need to at least see the result and your shader. Or even get our hands on your .blend file.


text:
Animation Nodes can Not be enabled and also can not be deleted
Animation Nodes addon (Jacques Lucke Version 2.1.4 ) can Not be enabled in Blender 2,82a and also can not be deleted There is an exclamation mark icon inside triangle and it says line 351 in eneble mod.

Make sure you have the latest version installed : https://animation-nodes.com/#download and check the common issues : https://github.com/JacquesLucke/animation_nodes/issues/1240

So, I've added DLL as suggested and WOW it works, I can not believe it, Thanx a million!

No problem ! Have fun


text:
What should I connect with the Emission notch in the Principle PSDF (Blender 2.8)
I'm trying to use an Emission map in the Shader Editor.
I added a texture and connected it to the Emission node and then with the principle BSDF, but the red line appeared showing that there's something wrong with it.
My object also appear purple. What am I missing here?

Emission is a shader itself (consider it as nearly a terminal node). Its output cannot go in the principled. You should connect the texture directly to the emission slot.

@lemon "You should connect the texture directly to the emission slot" Yes it worked. I thought it was sort of like Normal maps... thank you very much for the quick reply.

All the connections are color coded, the "Emission" slot on the "Principled BSDF" shader for example is yellow and stands for "Color", while grey connections are usually for sources that deliver values between 0 and 1. (usually because they do not complain, more about that later)
The blueish connections are for vectors, means a triplet of values from 0.0 to 1.0, here you can also connect color values as they are delivered as triplets RGB as well.
And then you have the green connections, which are either the output of a shader node or the input for the "Material Output" node.
You can connect colors to grey nodes, but it is usually better to convert the values to the correct range, be it by "Color Ramp" node or "RGB to BW" node. "Image Texture" nodes with their Color Space set to "Non-Color" or "Raw" also deliver values from 0 to 1, and should therefor change their output to grey if you ask me, but that's something you for now just have to keep in mind. Because "Image Texture" nodes set to for example "sRGB" default would represent a grey-scale image different then if you set the node to "Raw", since it would convert the data into another Color Space, which is not wanted. You can test it by using a height map image and changing the Color Space from "Raw" as it should be, to "sRGB".
As mentioned already, you can use colors as input for a vector connection, but here it's up to you to know what you are doing. One example would be that you can use the "Mix Color" node with the "Factor" set to 1.0 in the same way the "Vector Math" node would work. Both give the same result but i'd suggest to try and stick with the color coded connections to be on the safe side.
Since the Emission connection is yellow, a color, you can connect "Image Texture" nodes as well as "RGB" nodes, but here a little tip:
If you want to have a really shiny "Eevee" "Bloom" effect, connect a "Combine XYZ" node (vector) BUT here comes the thing.. you can enter a value like 500 for X,Y or Z and it will literally bloom your mind ;)
As you can use the XYZ as RGB you can compared to a "RGB" node go over the 1.0 value and thus create cool neon effects.

Got it... I didn't know about all the color code stuff. I'll try the Bloom effect later. Thanks.


text:
I run blender 2.82a I get a blank screen
I am using Windows 8 on a 64 bit I just finnished downlaoding blender 2.82 the latest version and installed it.
I run blender I get the c:prompt screen for a millisecond and then the software opens and just a blank grey screen.
AMD Radeon HD 7601M Driver Version 13.151.0.0 Driver Model WDDM 1.3
Any fixes?

I am not sure if this is the information you're looking for.
AMD Radeon HD 7601M
Driver Version 13.151.0.0
Driver Model WDDM 1.3
I sincerely apreciate your help

Check if you system fulfills the minimum requirements for Blender 2.8x and update your graphics driver.

Yes it does fulfill the requirements, and the drivers are uptodate, still, nothing!

What is your GPU and graphics driver version?

The AMD Radeon HD 7610M has the TeraScale 2 architecture and doesn't fulfill the minimum requirements. Blender 2.8x needs GCN first generation or later.

Are there solutions out there?

Either using an older version of Blender that supports your hardware or upgrading your graphics card. Although given that it's a mobile card, you're likely using a laptop which makes this difficult.

thanks a million. I will use the older version.


text:
How would I go about making an object suddenly 'kick' up into the air, repeatedly?
I’m hoping to create a nice music driven animation, that shows an object ‘kicking’ into the air, a bit like a popcorn kernel popping, but in time with the music.
What kind of approach would this involve? Physics? Gravity?
I have already experimented with baked F-curves to audio, but it's not quite right.
I wondered if it was some kind of turning on/off of a force, to propel the object into the air, and letting it fall down/bounce, before propelling it again. All synced to the beat.
Any ideas much appreciated.
Thanks!

Had some good success with the 'popping plane' approach, using three objects:

The pushed cube
The pushing cube
The floor

Just a single frame of pushing cube Z movement, after experimenting I just need a tiny amount.
I can hide the pushing cube. Boom.

every force or even gravity can be turned on and off with keyframes so you can animate it. However I am not sure if physics is what you want if it is supposed to be controlled

Why do you need physics, do you need some kind of collisions between many objects? Otherwise, what you're asking is achieved by Z location defined by a simple curve that starts with a bezier point with a handle going vertically (so the curve is steep at the beginning), and ends with a point having a horizontal handle (so the velocity is lower and lower and gets to zero, then the reverse, with the object falling faster and faster. The curve points also have "Bounce" interpolation type, though I guess then you might indeed need physics for more elaborate movement at the end, based on shape.

Thanks everyone.

I don't want to control the object when it's propelled into the air, I just want to propel it, and let gravity/rigid body physics take over. That's why I thought physics would be involved. So ideally, at each 'beat' in the music, I'd do something to propel the object vertically and let it fall and collide each time

Possibly related: How can a force be applied not to the center of a rigid body object, but to one specific vertex of the object?

Thanks. I'm still not sure which force I would use. So I'd place an empty underneath the object, and turn on a force with which to propel the object into the air? Which force?

Apologies, I'm a newbie. But I've realised a possible solution, use 'force' under the object. Make sure it's strong enough so that when it's turned on, it pushes the object into the air, then I can turn it off immediately. So it acts a bit like an air cannon. What do you think?

@jameslondon74 was the answer you previously posted intended as a solution you found to your own problem, or was it intended as an update to your question?

Here's a semi-controllable manual but simple solution. Use a combination of Rigid Body Physics combined with an animated passive floor plane. The benefit is you have easy control of the speed and height of the object 'kick' by simply changing the floor plane keyframes. The downside is it requires some manual timing to the music.

Add Rigid Body physics to the object.
Add a floor plane with Rigid Body physics set to passive and check 'Animated'. (Disable render to hide.)
Animate the floor plane location up and down to 'kick' the object up in time with the music.

This is a nice idea worth trying, thank you. I could hide the popping floor plane, and add a visible floor plane for the floor. This also means I can keep the popping floor plane bumping to the music, constantly effecting all the other rigid body objects that are on top. In my mind, I'm wanting the same effect as flicking something in the air with your fingers, so this is kind of the same thing isn't it.

Just trying it, it is a little fiddly. Is there a solution there I can use a force to literally push an object in a particular direction, and then turn that force off immediately afterwards? Sort of like a physics force cannon?

You can use a force and I’ve done that before for animations, (eg animate the gravity direction)… but it’s actually harder to control than this way in my opinion.


text:
How can I make this script not get exponentially slower?
I'm trying to linked-duplicate an object with nested sub-objects.
I've rewritten bpy.ops.duplicate_move_linked() as a function without bpy.ops so it should be faster since it doesn't refresh the GUI, but unfortunately it still gets exponentially slower as more objects are added, and when its done the scene memory is only 613MiB.
For the test script below (to run on default scene) it first makes a bunch of 100 nested cubes, and renames to my nested object, which is the one it then tries to linked-duplicate many times.
import bpy

### Function to duplicate an object and all its children, maintaining the parenting structure
def duplicate_recursive(obj, collection):
    ### Create a new object with the same mesh data as the original object
    new_obj = bpy.data.objects.new(name=obj.name + "_duplicate", object_data=obj.data)

    ### Link the new object to the same collection as the original object
    collection.objects.link(new_obj)

    ### Set the new object's location and scale to the original object's location and scale
    new_obj.location = obj.location
    new_obj.scale = obj.scale
    new_obj.rotation_euler = obj.rotation_euler

    ### Duplicate all children and maintain the parent-child relationship
    for child in obj.children:
        new_child = duplicate_recursive(child, collection)
        new_child.parent = new_obj  # Maintain the parenting structure
        new_child.matrix_parent_inverse = child.matrix_parent_inverse.copy()

    return new_obj

### Test ###
if __name__ == '__main__':
    bpy.context.preferences.edit.use_global_undo = False

    # for first execution / scene setup: create nested object with 100 sub-objects
    cube = bpy.data.objects.get("Cube")

    if cube:
        cube.name = "My Nested Object"
        previous_cube = cube
        collection = cube.users_collection[0]

        for i in range(0,100):
            print('duplicating cube', i, '/', 100)
            duplicated_cube = duplicate_recursive(previous_cube, collection)
            duplicated_cube.parent = previous_cube
            previous_cube = duplicated_cube

    print("Done setting up scene / nested cubes\n\n\n\n")

    # at this point scene contains 8 verts and 103 objects

    # function under test - create linked duplicates of nested object, without bpy.ops.duplicate_move_linked()
    # WATCH OUTPUT IN CONSOLE

    my_object = bpy.data.objects.get("My Nested Object")
    if my_object:
        collection = cube.users_collection[0]

        for i in range(0, 300):
            print('duplicating object', i, '/', 300)
            duplicated_cube = duplicate_recursive(my_object, collection)

    # gets exponentially slower as more objects are added, even though no bpy.ops are
    # used and the memory is still low... WHY?

    bpy.context.preferences.edit.use_global_undo = True

As done here, I have tried disabling global undo, and also view layer exclude or hide render until it is finished with no luck. I assume it is to do with the depsgraph updating, since the slowdown seems proportional to the number of objects as more get added.
Any way to fix?

You will not get performance improvements from rewriting the non-python bpy.ops operators. You are creating 30k cubes and every other cube created takes more time depending on how much already are in the bpy.data.objects. The main performance hit is the bpy.types.Object.children which takes ~49% of the time, it is written in python as tuple(child for child in bpy.data.objects if child.parent == obj), bpy.data.objects.new: ~19% and collection.objects.link: ~19%.

Side question: how did you measure that?

cProfile and snakeviz. But the results within a function are not detailed so you need to wrap Blender API calls into their own functions.

Ok, my question was more 'why', it shouldn't get slower and slower to create more objects, what is it doing that's not just allocating more memory and filling it? Surely like appending to an array but in C fashion.. a pointer/address lookup should not depend on the length of the existing data.
I know it seems trivial but whatever the underlying cause is is affecting my scripts performance on many fronts, whether I've added too many textures, objects, or keyframes to the overall blend file, everything gets slower and slower

Also, I was not aware of what ops are C based and python based, I'll bare this in mind in future. Does this mean C based ops only trigger a GUI update when complete?

If a bpy.ops supports vectorization then utilize it. bpy.data.objects.new and collection.objects.link are optimized. Look into reducing .children usage and figuring how objects might be created in one set.

All operators trigger updates. When calling as bpy.ops.object.something operators can be patched not to trigger view layer updates by making a dummy out of _BPyOpsSubModOp._view_layer_update. C-based operators may trigger updates internally.


text:
Cannot Perform a full Root Motion Loop
I'm having an issue at the moment where I need the root animation to follow a specific circular pattern, however, when I try to do this, at the last second the animation flips itself back around.
https://i.sstatic.net/gl4Jj.jpg I've included a video of the issue within this imgur link.
So essentially I need it to come to rest back at the center without suddenly looping back around when it returns to its initial pose. Both keyframes at the beginning and end are exactly the same.
Blender file I made with the issue

Hello, could you please share your file (only the armature or even only the root bone)?

Sure I can! I had to make a new file since I didn't save the old one, but this one is doing the exact same thing anyhow. I'll add a link to my post!

if you switch from Quaternion to Euler it will be easy to fix, you can choose rotations on bone's Y axis of 90°, 0°, -90°, -180°, -270°. There's a problem with the Quaternion last interpolation, Quaternion seems painful when you go over a certain angle but someone will be more accurate than me. Also, why don't you use a Follow Curve constraint all along your curve?

Thanks Moon! And to be honest, I tried that but had no idea how to keyframe it into the animation so that when I exported the FBX, it was still following that same path! I tried to figure it out but got lost somewhere along the way. Figured this way would be easier.

If you switch from Quaternion to Euler it will be easy to fix, you can choose rotations on bone's Y axis of 90°, 0°, -90°, -180°, -270°. There's a problem with the Quaternion last interpolation, Quaternion seems painful when you go over a certain angle but some Blender experts will be more accurate than me. Also, as you're trying to make something rotate around a circle, you could use a Follow Curve constraint.


text:
I want to attach a downloaded shirt to a model but not distort the mesh
I want to adjust the shirt to fit on the model, both are downloaded and I just want to fix the arm situation without distorting the mesh

I want to put the shirt on the model (not an armature) without moving the vertices. Want the result to sort of be like 'snap to face' but snap to face doesn't work

Have you tried that: Parent the t-shirt to the armature, create a pin group that will be the part of the t-shirt that won't be affected by any physics, give a Collisions physic to the body

@moonboots what if it isn't an armature, I've been "blending" for like a month lol so i don't know whether it qualifies as one because its just an import from Sketchfab with no bones I think. I'm planning to rig it in Mixamo after I get the clothing right. Also in light of being relatively new I'm not sure how to create a pin group and I didnt' see the collisions physics and some things aren't really there on youtube. help, sosssss lol

so it's not clear what you mean by "attach the shirt without distorting mesh", attach what to what and what distortion?

I want to put the shirt on the model without the shirt looking warped (i.e moving the vertices) so make it look like I used snap to face but snap to face doesn't work

maybe try the Pose brush in Sculpt mode?

used grab and it kinda worked out well but pose might come in handy as well, thanks :)

I think the Pose brush is the best in your case, if you understand how it works


text:
Making a hole on a not flat surface
I am a beginner but I am having some difficulties trying to recreate the holes and elevations pointed out in the picture. First I thought I could achieve that with a cylinder and a boolean modifier, but I am not so sure now.
I am wondering if I could create a circle and "project" it on the surface in any way, as if it was a sticker or a shadow, from which I could extrude. That would be very useful for other projects, so I would like to know if that option exists in Blender. The shrinkwrap modifier isn't making that work, as I first expected.
How would you guys approach this problem?
[

Attempt with cube + cylinder

This is my model so far. Any insight on how to get rid of Ngons?

You could make sure that you have a 2x2 square topology, create a 8 vertex cylinder, keep it selected and press CtrlF > Intersect (Boolean):

Choose Difference and Fast in the Operator box:

Join the vertices to have this topology:

Thank you for your answer, moonboots! I have looptools and have used it before. The problem I see here is that my surface is composed of two planes, one of them being inclined. That method woul be a bit tricky for this situation, I think. O maybe there is an easy way to adapt that to my problem that I cannot see.

I've edited, does it answer?

Hi! Yes, it did, but I have some questions: I used that option (I though I could use booleans only through modifiers, thank you!), and I automatically got the hole, instead of the circle shape. No need for extrusion. Is that normal? Also, should I have asubdivided square under the circle shape, as you? I guess it's convenient so I don't get Ngons, but still, it's a bit tricky for me to create those subdivisions shared by two planes. I'll add a screenshot of the result.

I see the result you show: Use a 8 vertex cylinder instead, and create some orthogonal edge loops in order to have a 2x2 square like in my pictures

Ok. I have been trying for a while, but I am having problems with making the correct subdivisions on these planes. First I combined the cylinder with a subdivided 2x2x2 cube in order to use the boolean with both and get the exact shape, but I guess the point is not having Ngons around the 2x2 shape either. I will think about it a give it a try later, but if you have some advice, I would appreciate it. I'm still a beginner and get confused with apparently easy things. :S Thank you! I will edit my post with a screenshot of the full model and the result with the 2x2x2 cube.


text:
Why is my design image deformed and moved? It seems to fit on the uv map layout, but not on the model itself, how should I fix it?
I am only beginning with Blender and tried to create a coffee pouch while following some tutorials.
I thought I did everything the same, marked seams, unwrapped model, exported UV layout, made layout fitting design in adobe illustrator (only the front side yet to try how it fits) and then used shader editor, but the imported design seems to be deformed and moved on the side.
It will be probably some silly mistake I made along the way, but I can't figure out what I did wrong. How can I fix it?

I can't see from your image, but I think it has to do with the values in your mapping node - either manually place the islands (as you have) or "find and position" your texture through a mapping node - don't do both, its easy to confuse yourself and get lost.

Hi Lucie, welcome to Blender SE. It is normal, that you make mistakes when following tutorials. So either you restart again and follow each step exactly as in the tutorial, or you give us enough informations so that we can help you because you didn't show us enough information so that we can help you. Because you are a beginner i would suggest you provide your blend file so we can check it out what you have done. Just open https://blend-exchange.com/ and follow instructions.


text:
Which normal input socket should I use when I have a mix between shaders?
Since we have the option to use normal maps in Cycles via the normal input socket, this question frequently pops in my head:
In the simplest mix, diffuse and glossy, should I connect the normal map to the diffuse or the glossy shader?
What about other shader mixes?

I don't think I understand your question. you can plug it in to either one, it depends on what you want.

The easiest solution is to try it yourself and see which one (or all) produces the result you want. It's part of the process of creating the material.

Well.. Julian answered to my question already. But you are right, I should have done some testing before. Now I did it and will add to Julian answer. Thank you both.

If you want to give the whole material a structured surface, put it into both. In over 90% of all cases, this is probably what you want.
But there are others:
If you want to material to look like the paint or glossy part is smooth and even and below that, there is a bumpy surface (application example: Wood finish in a car interiour), then add the normal map only to the diffuse shader of the shader.
If you want the material to look like it has a smooth general surface but a slightly scratched paint or top layer, it might make sense to only connect it to the glossy shader (probably the less frequently used case).

Hi Julian. I have made a image to test your solution and you are absolutely right. Thank you for your answer!


text:
Scale about true center with Mirror modifier
When I scale vertices of an object that has a Mirror modifier, the points scale about the median of the non-mirrored points only. How can I configure Blender to include the mirrored points in the calculation of the origin?

I am hoping for that to be included in the Mirror-Modifier everytime Blender gets an update.

Snap Cursor to Selected.
In the Properties shelf, for the mirrored axis, subtract the Median location from the 3D cursor location.
Set 3D Cursor as Pivot.
Scale.

I think this is an excellent workaround

If you don't have a  Mirror Object, the symmetry lies on the object center. So one fast way might be:

Out of editmode with TAB
SHIFTS+3, cursor to selection
TAB again
. for cursor as pivot point and scale (change back to Bounding Box Center with , or Median Point with CTRL,).

@WChargin  Since when and why is bounding box not the default anymore? Bounding box in most cases scales much more usefully than median point. There's a reason it has the easier shortcut

Median point has been the default since at least 2.64. I've never seen bounding box as the default.

Still I have a hard time understanding why. In the majority of cases I'd be scaling around the outer verts of something, not to the relative distribution of verts. Why should little vertex intensive details shift my scaling center? The ways of the developer are many and mystic.


text:
Texture scaling to real world measurements?
Is there a method to scale a texture in relation to the measurements of the model?
For example, consider an architectural model with a concrete paving. Its image texture is a "real world" photo measuring 3×3 times which makes it 180cm × 180cm. Is it possible to make Blender scale the texture in model-units? Or the other way around: is it possible to automatically scale the UV coordinates so they fit the "real world size"?

This is a bit difficult to try and tell exactly what you are asking.

example: i do a balkony with size 3x8m. i want to map a picture of concrete paving to it. the picute is tileable and has a size of 200x200 pixel. i want to tell blender that the length of the picture is 1m. If i can do this i only have move my uv coordinates to an corner of the picture and the size is like "in real world" - in this easy example it is no problem to fix it by hand - in larger buildings with non perpendicular and not quadratic rooms, or a texture that is not that clear in size as concrete pavings, its not that simple to fix.

If you only work with planes or meshes in which all faces have 90° angles between them, following the local object's coordinates, yes (typically planes and cubes which were only rotated in object mode and on which you didn't apply the rotation). You have to apply scale first with Ctrl + A -> scale.
1) Unwrap in edit mode with U, select the cube projection mode. By default it will make the smallest image's side to be 2 Blender Units long.
2) In Node Editor: Connect a Texture Coordinate Node with UV output to a Mapping node. Connect this Mapping node output to the vector input of your Image Texture Node.
3) Choose the appropriate Scale values in the Mapping node. "Scale factor" = 2 / "image's smallest side in Real World distance". The 2 is because of the cube projection scaling the smallest side to 2 BU. If you know your image is 1m on x and on 4m on y (in the real world), then give 2/1= 2 for x an y scale in the Mapping node

Other UV projection modes aren't predictable. If you want an always working solution, I think you will have to write it in OSL, but your render time will be 4-5 times slower.

hm dont work for me. if i unwrap with a cube projection. different object get differnt sized uw layout. the same texture is scaled different on each object.maybe its possible to use the uv coodrdinates of another object? (cycles) so its possible to place a plane with 1x1m sized- i place the texture there and use this coordinates with another object.

did you apply the scale on your objects ? I can't reproduce your problem if my scale are 1, 1 and 1 on x, y and z

As I said, It only works for 90° faces (faces follow world coordinates). If you want more complicated object, use smart UV project, but it doesn't always work as you want.

I corrected the solution, I made a mistake yesterday, sorry, I was tired :D Please try again and with scale applied.

There are a number of places that affect texture scale:

Object scale.
UV scale, see UV editing and the UV Warp modifier.
Texture space: Object | Transform | Scale Texture Space (Shift+Alt+T). For numeric input see the Texture Space panel under Object data tab of the Properties editor.
Image mapping:

For BI this is found in the Mapping panel of the Texture tab of the  Properties editor.
For Cycles this is done using the Mapping node.

The Magic UV addon (available here) can be used to accomplish this.
To install the Magic UV addon:

Place uv_magic_uv folder in the Blender/(version number)/scripts/addons folder.
In Blender, go to File > User Preferences > Add-ons.
Scroll down the list and enable "UV: Magic UV".

Use:

For a given texture intended to be X units by X units in size, make a reference square (e.g., the side of cube) of those dimensions.
Switch to the UV Editing screen layout.
UV map the square such that it occupies the entire UV area (no margin).
With the square selected, press U and select World Scale UV > Measure.
To apply the same scaling to other faces, select them, press U, and select World Scale UV > Apply.

A video demonstrating Magic UV's World Scale UV functionality is available here (recorded by Nutti, the creator of the addon).

please do not post link only answers. By all means link to the addon and where to read the full docs, but links can not be your entire answer. Please edit your answer, adding the necessary steps so your answer could be read and useful right here.

@David fair point; I've included the full text of the answer.


text:
How can I make a circular object appear perfectly round?
How do you make a spherical/ovular object in Blender?
I can make square objects, and I can make a UV sphere. But how would I make an object that appears spherical in render?

Down-voted because you don't explain well (as you can see both answers your got are quite different), You need to explain why adding a circle/sphere does not satisfy your needs.

@ideasman42 sorry about that. About the answers though, they both answered my question well. They're both good answers I'd say, as Haunt_House said below, they're both important.

Are you looking for "Smooth Shading"?

This isn't really as smooth as adding more vertices.

In the main menu:
Add > Mesh > UVSphere
Add > Mesh > IcoSphere
In the tool properties panel you can adjust
the resolution. Later you can even add a
subdivision surface modifier
to it. Note that this way a sphere is
represented with polygons.
Theoretically a ray-tracer can render real spheres,
but cycles does not support it. Even meta-balls are
rendered polygonally, not as real smooth surfaces.

Sorry I meant sphere. Oops, :(

I wish I could say you both were right, but I think the answer below is better. I'd one up you both if I could though.

Both answers are important. Smooth shading only affects the surface of the object, but not it's outline. If you use smooth shading on a 32 vert circle, the outline will look edgy. Btw, you can give upvotes to both answers.

@Haunt_House not enough rep

I'm not seeing the "tool properties panel".  Is there a keyboard shortcut to view that?

To make a UV sphere rounder, increase the number of segments and rings in the "Add UV Sphere" panel. These are good values to use:

Use subdivide with a smoothness of 1:
Mesh before subdividing:

Subdivided with no smoothing:

Subdivided with smoothing of 1:

This way the polygon doesn't approach a sphere — more like a smooth but bumpy rock.


text:
How do I select an object in the 3D viewport?
I am trying to select the cube that in the middle of the scene. How can I select it? All I see is a crosshair appearing everywhere I click. Is this a bug?

That circle/crosshair is the 3D cursor.
To select you need to Right click instead of Left click.
You can change this behavior in File > User Preferences (CtrlAltU) > Input:

Open the User Preferences:

Go to the Input tab. The select left/right options are under Mouse:

If you want to save these settings as the default for the next time you open blender, click  Save User Settings in the Header (at the bottom of the window):

This is one of the most controversial parts of blenders UI.
For some further information you might want to check out:

"Fixing Blender – Part 1: Why It’s Broken" by Andrew Price

This video by Sebastian König explaining some advantages to using RMB to select

"Fixing Blender – Part 2" by Andrew Price

This 3 hour discussion about Blender's interface

"New Blender UI Proposal" by Andrew Price

The manual on object selection

Well that is annoying. Why blender why! every other program is left click. :)

@BlenderBoy This is been a topic of a lot of controversy lately..

Agreed.  but you get used to it... UNTIL you move to another app (such as image editing) and get infuriated because you're right clicking things and it's not working.

Strange. I have no problems with that whatsoever. And one big word of advice: Blender is not meant to by tried out. It's a highly complex very powerful tool that needs at least some tutorials to learn.

Lets not turn a troll question into yet another UI discussion.

You can change this in the User Preferences pane found at the top left of the main window in the File menu.
Next click the Input tab, then locate Select With, you will see two options which are Left and Right.
You may also want to look a little further down for Invert Zoom Direction if the current mouse wheel zoom seems backwards to you.
At the very bottom, you should see a button that says Save User Settings, click this to save the change.  Just be sure to remember this when you are following any tutorials or you will end up really confused.  It's really not a big deal once you know what's going on here.


text:
How exactly does the Sigma parameter affect the Velvet shader?
How does the Sigma value of the Cycles Velvet BSDF shader work? Intuitively, it seems to serve as some sort of ceiling value for the shading. How does it affect the light bouncing? I've looked at the ray diagram on the shaders page, which seems to show an away-from-center spread:

Is the sigma value related to the variance (in statistics, σ means variance) of the spread? Comparing the diagram to that of the normal distribution seems to indicate that this may be the case:

This would seem to mean that a σ-value of 0 makes the shader behave like a glossy shader, while a σ-value of 1 would make it behave like a diffuse shader; however, this does not appear to be the case.
I've prepared a video demonstrating a changing σ-value, from 0 to 1, on an actual velvety object for added realism.
Could one of the developers who understands what is going on identify the meaning here, mathematically or otherwise?

It rather seems to define the response curve towards the view angle.
The velvet shader makes a material look brighter the smaller the angle between the view vector and the surface tangent vector is, it's bright if you look on a surface in the tangent direction and dark if you look at it from it's surface normal direction.
With sigma=0, you seem to have to look at a surface perfectly in tangential direction to receive light, while higher values spread it across a wider range of angles so that with sigma=1, the distribution goes all the way to a normal view angle and is relatively even.


text:
Best practices for masking image layers for compositing?
I'm looking for a efficient way to do image masking within Blender (using the masking tool) à la After Effects.  Basically, I want to cut out my images from within Blender instead of doing it destructively in an image editor.
Typically, in AE, I would precomp an image then do the masking in that precomp.  I'd like to mimic this workflow in Blender; however, it always seems overly complicated.
I have considered creating a separate scene with the same dimensions as the image and masking there, then bringing it into a master scene to assemble in 3D space, but I'm not sure I can map this to a plane.
Sorry that I may not be explaining this very well. If anyone is familiar with AE, then you'll be familiar with what I'm trying to achieve.

there is many different types of maskings ,if you have any link to AE example it will be fine

go to node editor and enable use nodes
add mask node and mix node
in uv editor change from paint to mask (if you want a mask image, upload that image to uv editor, the mask will be placed over your image)

LMB+Ctrl  to add point on the curve, close curve by enabling toggle cyclic
use this mask as input for mask node and plug mask node to factor of the mix node

for rotoscoping you could use this add on, see this for more info.

To be honest, there is no single universal "best" masking or keying way exists for all images. However, there would certainly be the "most suitable" way for specific images regarding specific needs.
Currently, there are two main way for masking within Blender, one is regular masking. which can be created in UV/Image editor or Movie Clip editor; Or you can use matte compositing in Node editor, which is mainly keying methods. Both ways got their own advantages and limits. So, sometimes you need both to work together. Regular Masking is easy, but Color Keying is a bit complicated and needs experience a bit. But I believe you can master them well if reading wiki and watching some neat tuts on various sites, such as Youtube and CG Cookie, etc.
For regular masking, HERE may help you some:

(Image from Mango project)
For node keying, HERE may help you some:

This was flagged as offensive, could you perhaps use a different image in the node keying example.

Hmm, maybe, I'll try now. Thanks for reminding.

The closest thing to a precomp in blender's compositor is a node group. selected nodes that you wish to precompose then pres Ctrl G. Hit Tab to enter/exit the group.
NOTE: Not all input and output nodes can be grouped.
See here for more on masking.

For this you can practice with different types of keys in add>matte.
for masking mostly difference key,color key and distance keys are used.
Try something like this:
add an image to blender compositor

add any one of the key and pick the colour you want to remove.Experiment with different types of keys and do fancy things like combining two images

Please try to answer the question. Your not telling how to mask out and create a "precomp". Your telling how to use keying matte.


text:
Blender GUI error after install
I have a strange start screen of Blender 2.8 on a MacOS 10.11.6 as you can see below....
I am not quite sure what is going on.
It is a clean install after a MacOS reinstall. I had an older version of blender that worked fine.
Ideas?

Blender 2.80 requires macOS 10.12 or later, your operating system is not supported. You can still use Blender 2.79 and earlier versions, all new versions will require an operating system upgrade.

Thank you very much! Indeed I installed 2.79 and the issue is gone.


text:
How can I animate the camera in a perfect circular rotation around a fixed position?
I have an object at a fixed position in 3D space. I would like the camera to circle around it while facing it. I want to path of the camera to be circular in 2D, meaning that it does not move up or down.
I need this to be pretty accurate. I don't want to manually set a keyframe every frame for position and rotation. I would like to do this maybe with an expression, not with manual keyframing. I am not sure how to go about this but I think it is going to involve Python as well as some trigonometry.

No keyframes on the camera or no keyframes at all?

The requirement of not using a keyframe, is strange (and unnecessary I think). Rather then add odd limitations to your questions - can you give more details about what your looking for? - or just state why you can't use keyframes is fine too.

I meant no manual keyframes. A start and end key is fine but not for every frame.

Yeah, you could...
You could do this with trigonometry. You'd need three drivers: X Location, Y Location, and Z Rotation.
If you want to drive it based on, e.g., the frame, you could pick some constant T for the period (the number of frames for a full circle) and r for the radius, to get:

X Location: r * cos(frame / T * (2 * pi))
Y Location: r * sin(frame / T * (2 * pi))
Z Rotation: atan2(y, x) + pi/2

Create a variable y with settings Transform Channel, Camera, Y Location.
Create a variable x with settings Transform Channel, Camera, X Location.

...however, this is downright silly.
There is no reason you would really want to do this. Here are a couple problems:

There's no need to be dipping into Python and drivers when all you want to do is a simple orbit.
It makes things more complicated and more difficult to maintain. If you want to change the radius, for example, you have to change it in two locations. Same for the period.
You have to have a trusted blendfile. Since Blender 2.68 you have to load a blendfile as "trusted" to use any Python (as you should!).

Better way to do this:
Use an empty, rotation, and a constraint. Create an empty and parent it to the object you want the camera to follow. Then, parent the camera to the empty. All you need to do now is insert keyframes on the Z rotation of the empty to rotate the camera around. To ensure that the camera faces it, add a Track To constraint.

How and why does this work?
When you rotate the empty, it also rotates all its children about the empty. This is exactly what you want — an orbit. The camera will turn, as well, but the Track To constraint makes sure it's in sync with the object. Otherwise, it could be turning at the right speed but always facing out, or always to the right, etc.
Benefits of this solution

If you animate the object that the empty is parented to, the camera will continue moving correctly.
This is really easy to do and takes about 30 seconds.
If you work on a team, people will know exactly what you're trying to do.
You can also animate the camera if you want (move it up or down, in or out, etc.) and the tracking will still work.

Here's what it looks like:

well if its so silly, what is the proper way of doing it?

@Jebediah see my edit.

will the path be circular though?

@Jebediah yes, it will.

@Jebediah I've added an animation of rotation so you can see how it turns out

the velocity does not look constant?

@Jebediah it's not; that's just me manually rotating with my mouse (as you can see by the rotation cursor). If you inserted keyframes on the Z-rotation of the empty instead you would get constant (or linear, or Bézier, or whatever you want; it's a normal keyframe now) velocity.

I really like this solution!  How can I bake the second solution to keyframes so I can use it in my game?

I can't get it to work. what objects are suppost to be parent to what objects. "parenting" two objects, does not say which is child and which is parent. Also how do you add keyframes, set camera target and how do you render your animation to a video file?

@nivs1978: These are pretty general questions; I recommend consulting a tutorial or the documentation. For instance, a web search for “blender parent objects” takes me to these official docs as the first result.

Another option would be to use a Curve Circle. Set the center point of the circle to the center of the object you want to orbit around.  Parent the camera to the Curve Circle using the Folow Path option.  This gives you a perfect, scalable circle but also allows you alter the shape of the orbit if you want by manipulating the points on the circle.

A good addition to this answer would be some screen grabs to show setup of constraint as setting the Up axis can be confusing

You can check how to use it there : https://www.youtube.com/watch?v=SqOso5jgYa4


text:
Setting objects into edit mode often seems to fail in python script
I am only just starting to learn/use python in blender.  I have the following script
import bpy

for obj in bpy.data.objects:

    if obj.name[0:4] == "Text" and obj.type == "MESH":

        bpy.context.scene.objects.active = obj
        bpy.ops.object.mode_set(mode = 'EDIT')
        print(bpy.context.mode)

        #bpy.ops.mesh.select_all(action = 'SELECT')
        #print(bpy.ops.mesh.remove_doubles(0.0001))
        bpy.ops.object.mode_set(mode = 'OBJECT')

I am trying to work out why I keep getting a context error for bpy.ops.mesh.select_all so I added the print(bpy.context.mode) line and commented out the line that was failing (plus the next line which takes action)
what I get in the console (this script is being run from the console rather than run in place) is a mixture of 'OBJECT' and 'EDIT_MESH' outputs.. suggesting that mode_set is failing a lot of the time.
What am I doing wrong?
I am using blender 2.68a on Windows 7.
Edit I discovered the actual cause of my issue (hinted at by Adhi's edit) and wanted to add it to my post so that others can take something away from this - the objects that were not being switched into edit mode were on another layer.  Once I made all layers active my script was able to switch all objects into edit mode.  So basically an object in an unselected layer cannot be set into edit mode.
I am also grateful for the other help and suggestions, they have been useful to help me learn python scripting within blender which is something I would love to use more extensively.

can you give more info about your environmnt (os, Blender v. #)? How many objects you have?

Just with a quick glance at your code, it appears like you're trying to set multiple objects in Edit mode at the same time. This is not currently possible.

OS- Windows 7. Blender 2.68a.  I'm not sure exactly how many objects.  There are approximately 400

for what its worth -- I ran your script on 1536 cubes with duplicated vertices (24576 verts total) and it went through fine (reducing verts to 12288). The only change was print(bpy.ops.mesh.remove_doubles(threshold=0.00001)). Blender 1.68a, mac os x mountain lion

As a side note: You can use obj.name.starswith("Text"), and note that bpy.context.mode and bpy.context.object.mode differ, see bug tracker.

Another side note:  Using bmesh, can often remove the need to swap mode and context object altogether.

As mentioned by dimus, your problem is solved by adding keyword to the mesh.remove_doubles operator's first argument, meant as threshold property value. With that little bug fixed, your script works properly.
What causes the error is that, keyword arguments are used to set operator properties, and positional arguments to set how the operator is called (further explained in the API docs). By not using a keyword for the first argument, you're turning it into a positional argument, thus interpreted as operator execution context which is an error.
EDIT: Another possible error is iterating over bpy.data.objects, which comprises of all objects in every scene in a file. The script is bound to fail if there's more than one scene in a file containing a MESH object, because it'll try to make object from a different scene the active object of current scene which is contextually incorrect. You should iterate over bpy.context.scene.objects instead.
Here's the amended code, can't see any other bug:
import bpy

scene = bpy.context.scene
scene.layers = [True] * 20 # Show all layers

for obj in scene.objects:
    if obj.type == 'MESH':
        scene.objects.active = obj

        bpy.ops.object.mode_set(mode='EDIT')
        bpy.ops.mesh.remove_doubles(threshold=0.0001)
        bpy.ops.object.mode_set(mode='OBJECT')

Actually I hadn't got as far as correcting the remove_doubles function because the function that was failing was select_all.  it was failing whenever the object had not managed to enter edit mode.

@MrVimes: I missed another bug :) It's still not related to mode_set, though. Can't see cases where that one could fail. Showing the Outliner space of your test file would help.

I have marked yours as accepted because your edit pointed me in the right direction for finding out what was actually going on - the objects that were not going into edit mode were on another layer.  I shift-clicked all the layers with objects in them and ran the script again - it was then able to switch all objects into edit mode.

So there's another one. Blind troubleshooting sure is fun :D Edited again for completeness.

Since Blender 2.80 scene.objects.active = obj no longer works. Use bpy.context.view_layer.objects.active = obj instead.

I, too, have had issues in the past using the mesh select_all operator from within Edit mode. As an alternative, try looping through all of the vertices and setting their select property to True. Then, switch into Edit mode before doing the Remove Doubles operator. Your code should look something like this:
for obj in bpy.data.objects:

    if obj.name[0:4] == "Text" and obj.type == 'MESH':

        bpy.context.scene.objects.active = obj
        for vert in obj.vertices:
            vert.select = True
        bpy.ops.object.mode_set(mode='EDIT')
        bpy.ops.mesh.remove_doubles(threshold=0.0001)
        bpy.ops.object.mode_set(mode='OBJECT')

I came across this subject and want to post my solution, removing doubles of object with given objectname :
def myremovedoubles(objectname, mergedist):
    obj = None
    try:
        obj = bpy.data.objects[objectname]
    except ( RuntimeError ):
        pass
    if (obj != None):
        try:
            bpy.ops.object.mode_set(mode='OBJECT')
            bpy.ops.object.select_all(action='DESELECT')
            bpy.data.objects[objectname].select = True
            scene.objects.active = obj
            bpy.ops.object.mode_set(mode='EDIT')
            bpy.ops.mesh.remove_doubles(mergedist=mergedist)
            bpy.ops.object.mode_set(mode='OBJECT')
            return True
        except ( RuntimeError ):
            pass
    return False

this function will return True if executed without RuntimeError, meaning the remove_doubles function was executed
it doesn't crash when the object doesn't exist
it sets the object as the only active (and selected)
it switches between modes, assuming mode='OBJECT' is the default

Not a fan of the try catch, especially when IMO not required.  For instance obj = bpy.data.objects.get(objectname) removes the need for your first try.

and scene is not available when this function is called from another filen   and mergedist doesn't always work : more often the name of that argument is threshold.   and when using something like def do(func, *args) I get an unexpected list of unavailable context properties : bpy.context. seems unavailable. If I pass bpy.context.scene as argument other errors come up.    The try/catch thing is just a point of view, I assume the .get function loops the available, so probably takes more action

Rubbish.  Because code fails silently, it hasn't worked.   All the cases you mention will just cause your code to fail silently.  Also, trying to set an object from data (bpy.data.objects) as context object,  if it is not linked to the context scene will cause an error,  which is an easily avoided basic logic error IMO.  Get the object from context.scene.objects Finally, here is the Blender API Best Practice "point of view" on try / except

On a lighter note, using bmesh, removes the need for edit mode and bpy.ops... altogether.  Example here

@user42646 it's great that you've tried to post an answer. This is not a good way to solve the problem, and as batFINGER points out bmesh is the far more modern way to solve this. That's a danger and posting new answers to old questions and that's why new answers to old question pop up fresh in the review queue. Anyway I gave you an up vote just for "effort". Hint: In the beginning it's easier to get reputation (points) asking questions unless you have a pretty good answer. Welcome to stackexchange! If you haven't already, why don't you take the tour


text:
Model a simple 3D spiral shape?
I need to model a simple spiral shape. I imagine the best way to do this is with curves, but I am unsure how to create a perfect spiral shape with curves. What's the best/easiest way to make a spiral tube?

Another procedual way is to simply enable the Add Curve: Extra Objects addon. It is used to generate many kinds of curves with various parameters, including spirals.
To enable it, CtrlAltU to open User Preferences window, then find and enable it under the Addons tab.

Then you can tweak feature like Bevel or Extrude in the curve's Object Data tab to bring depth for it.

You can use the Screw modifier to do this.
From the manual:

The Screw modifier is similar to the Screw tool in the Tool Shelf in that it takes a profile object, a Mesh or a Curve, to create a helix-like shape.

(source: blender.org)

If you want to make a spiral from discrete objects, i.e. a discontinuous spiral, the array modifier is a nice way to do this. You would add an array modifier to the original object which is aligned (Object Offset) on an Empty. Move that Empty up (Z-axis) and away (e.g. X-axis) from the original object. Then rotate the Empty around the Z-axis. The rotation angle and distance determines the radius and object density of the spiral. Don't forget to set a length in the array modifier, either a fixed count or a fixed length (or relative to the length of a curve).
In fact you can use this technique for continuous spirals as the array modifier allows merging. But this needs exact (but not hard) planning in the design of the object, the angles and distances. It is worth it when you want a finely decorated but repeating spiral.

Note that the cube is in the origin.

Position and rotation of the Empty; in this example the absolute position is the same as the relative position to the cube. In reality you would probably parent it.

The settings for the array modifier.
You can simply manipulate (or animate) the spiral by moving or rotating the Empty. Changing the scale of the Empty gives another nice effect.

As the question asked specifically for a simple tube I will give an explanation how to do this with this technique. But be aware that this only pays under certain circumstances (modelled segments, end caps) as it drives your vertex count way up.
I will model a spiral with 8 segments and a radius of 6 Blender Units (BU) and a distance between two turns of 2 BU.
1) Add a plane.
2) In Edit Mode rotate it so it is perpendicular to the X axis.
3) In Edit Mode move it up 6 BU on the Y axis.

4) Extrude e, cancel ESC. The newly created vertices are selected.
5) Select the 3D cursor as pivot in the lower via .. (The cursor is still in the origin?)
6) Rotate by -45° around the Z axis. 45° because we want 8 segments. 360°/8 = 45°.
7) Go into face selection mode and delete the front faces so an empty tube stays.
8) Select the extruded vertices.

9) Now I will do a little simplification. In theory it is best to rotate the segment so that the segments will fit. The easier way for a simple tube is to slant the segment. Move up the vertices by 0.5 BU along the Z axis. 0.5 * 8 = 2, the distance between two turns.
These basic shape determine the borders for you tube segment. Within these borders you can model, as long as the end vertices match. If you need something different than a square you should create that shape before extruding.
10) Leave Edit mode.
11) Add an Empty in the origin.
12) Rotate the Empty by 45°, move it up by 0.5 BU.
13) Select the tube object, add an array modifier. Uncheck "Relative offset", check "Object offset", select the Empty as Offset object; check "Merge".
14) By changing the "Count" you can easily determine the size of the spiral.

When you add an subdivision modifier and set the shading to smooth you get a smooth spiral.
The number of segments determines when the pattern repeats. In fact you can easily build a 360° segment for a full rotation and just use a regular array modifier with relative offset to create a spiral.
If you use twisted elements where the front ends still align you can easily model things like ropes. But again, high vertex count, so it must be worth it.

Make sure to apply transforms when using this method, before applying the array modifier! (Blender 2.8)

On 2.8 go to Edit > Preferences > Addons and search for "Extra Ccurves".
Then add a new object with Add > Curves > Spiral Curve > Archemedian and play with the settings.

Any tips for playing with the settings in 2.83? I added a curve but it just shows up flat. I can't find the settings menu like in other versions of blender

Nevermind, got it. For those on 2.83, the object settings appear in the lower left corner


text:
Align viewport view to object/Move object to viewport view
How do I align the viewport view so it is looking out of a selected object? How do I move an object to the viewport's view? This would be useful for placing some objects like lights where the viewport "camera" is, or aligning one object to another.

How to lock the view to prevent rotation of the view camera?, Can I lock the viewport to always jump to what is currently selected?.

https://blender.stackexchange.com/questions/323804/how-can-i-align-an-existing-object-to-the-3d-viewports-xy-plane

Viewport to object
To align the viewport to the object, select your desired object and hit CtrlNumpad0. This sets the selected object as the active viewport camera. Hit Numpad0 to return to your normal view, and return back to the object view again with the same key. Repeat this procedure on the camera when you are done in order to use the camera as normal.
Object to viewport
To align the object to the viewport, first set the desired object as your active camera and return to your view (steps above), then hit CtrlAltNumpad0 to snap the object set as your active camera to your current viewport view. You can also fly the view with ShiftF to move the object around with the view. You may need to enter wireframe mode by hitting Z (while not in fly mode) in order to see.
This is the same process you may already be familiar with when aligning the camera, but it also works on other objects.


text:
Cut mesh at intersection
I have an extruded rectangle that intersects the side of the cylinder. I need this extruded rectangle to cut a hole out of the side of the cylinder. Below is a picture:

(Ignore the middle segment)
I tried the Boolean modifier but it didn't work (yes, I tried all 3 options).

Boolean
The Boolean modifier needs a closed mesh to work properly, see the wiki:

This means that this modifier will only work properly for the
intersection of faces of the two meshes that will result in another
closed loop of edges (filled with faces), creating a new resulting
face topology.

(You can have an open mesh as long as the open parts do not intersect or interact with the boolean operation)
Removing the middle section of the cube should fix it:

You may also need to recalculate the normals (CtrlN)
Also ensure that:

The Modifier is applied to the cylinder.

The Operation is set to Difference:

Knife
In addition to the Knife project tool mentioned by Haunt_House, You may want to use the Knife tool for this:
In edit mode, press K to start the knife tool and C to enable Angle Constrain. (you may need to hold shift at some points to place a cut, due to the view not being aligned perfectly to the topology)

Modeling
Another simple way to do this is to use Loopcuts:
Press CtrlR and use the scrollwheel or the keyboard to set the number of cuts:

You can then use Edge slide (GG or CtrlE> Edge slide) to slide them into the correct position:

An advantage to this is that this does not produce N-gons (see this)

Can you explain the knife method further? The selection doesn't snap to the intersection of both edges, even when the mesh is joined.

@Keavon It's not snapping to the intersection of the cube and the cylinder, if that's what you mean. It's just snapping the angle to 45 degree increments. If you want to Exactly copy the shape of your cube, you are better off with Haunt_House's answer

Ok. His answer didn't work perfectly, but your boolean operation tip did work, so you got the accepted answer. Thanks.

You should be able to use Knife Project. This tool takes one mesh and cuts the second mesh according to the outline of the first.
Since the cutting mesh needs to be outside the cutted one, you need to select the cutting part and separate it with P. Then leave editmode, select your cutting mesh, then shift-select the main mesh and enter Edit Mode. Adjust the view, so you are looking in the direction of the cuts. Finally use the button in the Mesh Tools or find it in the Space menu
Then all you have to to is to go into Object Mode and join both meshes with CtrlJ and stitch them.
The workflow I'd recommend would be to make three loop cuts and extrude that. You can scale the front of the second mesh to zero to flatten it.

If your mesh is not for the game engine, I recommend giving the object some thickness.

I once had a very similar problem.
Maybe this cool script by Witold Jaworski may become helpful.
http://airplanes3d.net/scripts-253_e.xml
Basically it takes two meshes and creates an edge loop in the intersection. From that you can easily rework your meshes to get the desired effect. I find it very useful and in many cases much better then the original boolean operations (which create a lot of bad topology on the meshes).
The description about how to use it is available at the link above.
Hope it will help you and other Blender Users :)


text:
Preview rendering the current view from the viewport?
How can the current viewport view be rendered as a preview?

Blender 2.8+
This is now accomplished with the fully interactive Rendered viewport shading mode.
Click the rightmost sphere icon in the top right of the 3D viewport to enter Rendered mode, which displays the scene (more or less) exactly as it will be rendered:

Alternatively, hit Z and select the Rendered mode from the Shading pie menu:

To remove any overlays, outlines, or gizmos covering up parts of the rendered view, turn off Gizmos and Overlays by clicking the icons beside the dropdown arrows left of the shading mode:

Blender 2.69 – 2.79
Use the key combination ShiftZ to switch to Rendered mode. Hit the key combination again to return to Solid mode. Alternatively, switch the Viewport Shading mode between the white sphere (Solid) and pink sphere (Rendered) in the 3D Viewport header/footer bar.

This lacks viewport overlays, however, so it will be difficult to work in fully rendered mode. Nonetheless, it is possible to pivot the view and look around.

Blender 2.68 and Earlier
Switch the Viewport Shading mode between Solid and Rendered as described in the section above. However, the ShiftZ shortcut is not bound by default in earlier versions of the software. But you can bind it yourself:
Open the User Preferences (File > User Preferences...) and switch to the Input tab. From the expandable list, locate 3D View and expand it, then also expand 3D View (Global) immediately below.

Scroll to the bottom of the expanded list and you will find an Add New button.

Click Add New, then expand the new entry entitled "none".

With the new, unbound keymap entry expanded:

Replace none with wm.context_toggle_enum which should lead to three new text fields appearing beneath.
Bind the Z key by clicking the key field (contains the default A) and press Z.
Check the Shift keyboard modifier checkbox.
Fill the new three values, starting with space_data.viewport_shade for Context Attribute.
Next, enter SOLID for Value 1 (beneath Context Attribute).
Finally, enter RENDERED for Value 2 (right of Context Attribute).

To save these changes for future use, click Save User Settings at the footer of the User Preferences window which will update the startup file with the currently open one that now includes the added keymap. Make sure this is a clean startup file.

Note: this will not use any compositing you may have.

Note: this shortcut was added in 2.69. For older versions you can setup this shortcut manually.

Rendering the Current View
The easiest way to do this is this:

Set the camera's view to your current viewport's view:
CTRLALTNumpad 0
Then render the image with one of these methods:

Info header -> Render -> Render Image
Object Properties window -> Render tab -> Render section -> click the Render button

You can read more about rendering in Blender here on the Blender Wiki.

Useful for doing an actual render, but the purpose of this question was to make people aware of Shift + Z to preview render the current view.

Oh, I didn't realize you only wanted to talk about the Rendered View mode for the 3D Viewport.

It's a useful answer if people are looking to do a real render so you may want to label the answer as such and keep it.

If you don't want the camera to permanently move to your current view, make sure to keyframe it first.

Or make another temporary camera. Or just use Ctrl + Z after rendering to undo it. Not to be confused with Shift + Z, the other solution.

I don't have a NUMPAD, my keyboard is small, how do I do step 1 without a NUMPAD!

For people using a custom input setup (I'm using the packed-in 3ds max settings with a few modifications) the keyboard shortcut alone isn't very useful. For anyone wanting to find, change, or add these settings in File -> User Preferences -> Input, their names and values are:
For "Quickly previewing the current view" (Shift Z): Toggle Rendered Shading
(in 3D View -> 3D View (Global) with the value view3d.toggle_render)
For "Rendering the current view" (Ctrl Alt Numpad0): Align Camera To View
(in 3D View -> 3D View (Global) with the value view3d.camera_to_view)


text:
Rotate object on axis between two points
I have an object and two points I need to rotate the entire object around. I created two empties for the rotation points and I need to rotate it around an axis formed by the line between the two empties. I tried adding object constraints to no avail. In the image below I need to rotate the triangle around the axis of the red line.

Similar to another question. You can try this way.

Since I asked this question, Blender 2.8 introduced this as a proper, easily-accessible feature. Scroll down past the old answers for the easy solution. (Don't downvote old answers, by the way— they are useful for anyone using an older version of Blender.)

Blender 2.8+
This is vastly simpler in recent Blender releases.

In edit mode, select your two points (in Vertex Select mode) or your edge (in Edge Select mode).
Open the Transform Orientation popover:

Then click the Create Orientation "+" button:

This creates a custom transform orientation, likely named "Edge" by default for you. Make sure it is selected when you want to use it, or switch back to the default of Global when you are done. You can also delete the custom transform orientation with the "X" next to its name:

When your custom transform orientation is active, you can rotate along its Y axis with RY or use the Rotate gizmo:

We have several transform orientations available within the 3D view that determine which way an object moves along a given axis.

When these options don't fit the task you can define a custom orientation. This option is available in the properties sidebar N

To put it simply, if you add an object and rotate it 23.6 degrees on the z axis and then use it to define a custom orientation, you can then use that orientation to move, rotate or scale another object along the same x and y axis which will be at 23.6 degrees from the world x and y axis.
To use this when you have two empties in place -

Select one empty and press ShiftS and select Cursor to Selected.
Add a plane and scale to zero on the x axis (SX0Enter).
Enable snapping to vertex  in the 3D Header.
Ensure the view is aligned to a preset (left, top, front...) that is looking straight at the two empties so that the only angle between the two is the angle you want to define. If you wish to define an orientation that alters more than one axis you can repeat the next step several times from three views to get the alignment right.
Begin rotating the plane R and move the cursor over the second empty. When a circle is shown around the centre of the empty showing that it is snapping to it, accept the rotation. The rotation of the plane will now match the angle between the two empties.
Show the properties sidebar and find the Transform Orientations panel, create a new orientation by clicking the .

The plane can now be deleted and the new transform orientation can be used to move or rotate other objects along an axis running parallel to a line between the two empties.
When a custom orientation is selected the XX, YY and ZZ shortcuts normally used to move on the local axis will use the custom axis instead of the local axis.

Actually, there is no need to create the two empties if you are just going to form an imaginary axis. I think the relatively simple and fast operation here would be:
If you want to do in Edit mode:

Select all elements you want to rotate, then hold Shift and click that edge twice to make it active;
Alt. (period), ShiftNumpad 1;
R to rotate as you want, then Enter. Done.

If you want to do in Object mode:

Select one or more objects, make sure the target object is selected last. Select the target edge in Edit mode;
ShiftS > Cursor to Selected, . (period), ShiftNumpad 1;
Back to Object mode, R to rotate, Enter. Done.

-
P.S.: Of course, you can press AltSpacebar to display as the Normal coordiate system for easy judgement, or CtrlAltSpacebar to create / store a new transformation orientation based on that for further use, just as others mentiond. I just want to suggest the quickest and accurate way.

For those who don't know, Alt+. changes the pivot point to the active element. You can see the other pivot options on the menu right next to the shading options.

Manual Way
First, select one of the empties and hit SHIFT+S>Cursor to Selected.

then MMB to rotate the view until the two empties line up.

Now, hit . (period) to set pivot point to the 3D cursor.  Finally, select the object and hit R to rotate.
Pythonic Way
This scripts uses the vector between the two empties and rotation around the 3D Cursor.
import bpy
from mathutils import Vector

def main():
    C = bpy.context
    D = bpy.data

    #rotation set to 90 degrees (rotation in radians)
    rotation = (6.283185/4)
    #Save objects by their presumed names
    empty0 = D.objects["Empty"]
    empty1 = D.objects["Empty.001"]
    object_to_rot = D.objects["Suzanne"]

    ####################################################

    #set pivot point to be one of the empties by temporarily placing cursor there
    #use of Vector() here is to avoid copying reference to cursor location
    old_cursor_loc = Vector(CursorAccess.getCursor())
    CursorAccess.setCursor( empty0.location )
    CursorAccess.findSpace().pivot_point = 'CURSOR'

    #make object the active object
    C.scene.objects.active = object_to_rot

    #get axis we rotate around
    rotation_axis = empty1.location - empty0.location

    #override the rotate operator
    override = get_override('VIEW_3D', 'WINDOW')
    bpy.ops.transform.rotate( override, value=rotation, axis=rotation_axis )

    #restore old cursor position
    CursorAccess.setCursor( old_cursor_loc )

def get_override(area_type, region_type):
    '''Returns a dictionary which can be used to override certain bpy operators'''

    for area in bpy.context.screen.areas:
        if area.type == area_type:
            for region in area.regions:
                if region.type == region_type:
                    override = {'area': area, 'region': region}
                    return override
    #error message if the area or region wasn't found
    raise RuntimeError("Wasn't able to find", region_type," in area ", area_type,
                        "\n Make sure it's open while executing script.")

class CursorAccess:
    '''This code allows you to set and get the cursor location.  It came from the addon Cursor Control
    http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/3D_interaction/Cursor_Control'''

    @classmethod
    def findSpace(cls):
        area = None
        for area in bpy.data.window_managers[0].windows[0].screen.areas:
            if area.type == 'VIEW_3D':
                break
        if area.type != 'VIEW_3D':
            return None
        for space in area.spaces:
            if space.type == 'VIEW_3D':
                break
        if space.type != 'VIEW_3D':
            return None
        return space

    @classmethod
    def setCursor(cls,coordinates):
        spc = cls.findSpace()
        spc.cursor_location = coordinates

    @classmethod
    def getCursor(cls):
        spc = cls.findSpace()
        return spc.cursor_location

if __name__=='__main__':
    main()

You can do this with Mesh Align Plus (my addon). Either watch the steps in the GIF or read the text version below (I recorded the setup you described above, and then a couple of more generalized examples in case you want to do something similar):

The feature you're looking for is the Quick Axis Rotate operator in the 3D View > Tools Panel (T) > Mesh Align Plus Tab, in its own panel.

Pick a target axis in edit mode (Tab), by using shift + right click to select the two edge verts (leave them selected, and make sure Auto Grab Source is checked, it is by default)
Type in the angle to rotate by for Amount, and with the object you want to apply the rotation to selected, hit Apply to: Object

Pick a target axis (edge) in Edit mode.
Snap the 3D cursor to the selected edge (Shift + S and click Cursor to Selected).
Set the 3D cursor as pivot point (keyboard period button).
Open the Properties shelf N and go to the Tranfsorm Orientation rollout at the bottom of the panel.
Click the 'plus' button to create new transform orientation (or press Ctrl+Alt+Space).
Make sure created orientation is active one.
Now you can rotate around that edge by pressing R and Y + Y (along local Y axis of that given edge).

I don't like the existing answers.  First, I'll tell you why.  Then, I'll offer my own solution.
First, this is not something for which any addons are required, and installing addons when it can be done simply isn't necessary.
Second, rotation around pivot points gives strange interpolation when used in an animation.  The reason for that is because it's not straight rotation, but a combination of rotation and translation.  There are times that it will work fine, depending on local axes, but times that it will work confusingly wrong.
Third, rotation about arbitrary axes can also give strange interpolation, when using Euler angles (and the absence of any bones in your pictures suggests that you're using Euler angles for your transforms.)  Rotating about arbitrary axes when using Euler angles can easily give you confusing weirdness as well-- best demonstrated by "rubik's cube" animations.
So, what is the solution I'd advocate?  Basically what you started with, but couldn't quite finish: a pair of empties and constraints.  Start with the pair of empties you have, one at either point that defines your axis.  Nothing is parented yet.  Next, give one empty a damped track targeting the other empty.  Finally, parent the object you wish to rotate to the constrained empty.  To rotate the object, rotate the parent empty in its local Y axis.  (You may wish to give this empties transform locks to prevent rotation in other axes and possibly translation/scale; you may wish to set deltas for it as well.)
This requires no addons, using only standard Blender tools, and gives you good interpolation regardless of transformation mode and axes, because all of your rotation will be in one local axis of your empty.


text:
Straighten UV map edges?
Is there a way to straighten all the edges of the selected area of a UV map automatically? This means aligning every edge (set of consecutive vertices selectable by AltRMB). Currently I have to do this manually, as illustrated below, by selecting an edge (AltRMB over the edge), hitting S to scale, and X or Y to constrain it to the X or Y axis and then 0 to set the scale to zero, averaging the distance between all points on that axis.

This is the final result that I'm trying to achieve:

As illustrated above, this is extremely slow to do manually. I have tried Follow Active Quads, but in most cases that doesn't result in a straight grid where all the vertices are lined up along the X and Y axes. Is there an automatic way to straighten the edges of a UV map by lining them up along the X and Y axes?

there is W key for straightening one edge at a time , or use follow quad when unwrapping to give you a straight grid

You can faster this process using SHIFT+R shortcut. Align a single edge scaling it along x, y or z axis and pressing 0. Then select the next edge, press SHIFT+R and your previous action will be repeated. You may also check out this add-on: http://cgcookiemarkets.com/blender/all-products/uv-squares/ It's a great tool for doing things like this.

Your best bet might be to just unwrap the mesh again using a method that preserves the proportions of the mesh (Project from View, Follow Active Quads, etc)

@Gonzou Shift + R sounds quite helpful. I'll be sure to remember that. That add-on you linked to looks perfect, but could somebody here write a similar one for free use by the Blender Stack Overflow community?

Set all your reputation as a bounty and maybe someone may do an add-on like this for you ;). But seriously, you may also check out the NoviceInDisguise's answer here: http://blender.stackexchange.com/questions/23293/uv-coordinates-on-a-deformed-plane May be helpful for U.

@Gonzou I may put a bounty on it, but just to make sure it doesn't go to waste if nobody answers, I should ask if anyone may be interested in writing such an add-on if I were to put a bounty on it.

Note that follow quads won't necessarily unwrap in a rectangle shape.


text:
What is vertex and edge shading?
I know how shading works with faces:

That's set by choosing Smooth/Flat under Faces in the Shading menu:

But what do the other two options—Edges and Vertices—do?

This feature makes it possible to sharpen or soften individual components of a mesh instead of soften or sharpen the entire mesh. Especially for Low Poly Modeling it can be useful to have more control about the object's appearance and thus to define a more complex shape with less geometry.

Result of sharpen the selected edges only:

Note: In Order to make it work, enable Auto Smooth Option in the Properties Panel > Data.
When sharpening vertices, the connected edges are also affected:

Render result of sharpen edges only:

This is very useful if you want to create a Terminator effect... :)