No texture in cycles render No texture showing in cycles render. Good in cycles. Here the picture of problem:

well, because cycles is a bit different to add a texture you should do this - first  click on use nodes in the materials tab. Then click on the dot next to color and then select "image texture". Now click on the drop down menu below the "image texture" on the left, it should have your img file.Cycles by default uses uv's so it should look fine


Rotating a water wheel I have this problem:

I'm trying to make a water wheel rotation but i can't render it smoothly,

I've tried rotating it by 45/90/180° and it always have thise freeze from last frame to the first frame. Ending at the last-1 frame doesn't help much. And rotating by 360° doesn't help either cause it just doesn't turn, stays at the same position. I've tried different end frames like 30 or 60 frames for 30-60fps but it doesn't change much either.

Here's a gif of what it looks like when it turn 45° in 30frames

The end of the gif is just a buggy gid it doesn't do that in blender.

Thank you

When only you animate frame 1 to 60, it means that it will not start at frame 1 with full speed and it will not end at frame 60 with full speed, butthe motion will get faster in the beginning and slower in the end. Go to Graph Editor and look how the rotation-curve is getting steeper.

To counter that you can start the animation earlier and end later. Or you manipulate the development of the roation in den Graph Editor, making it a constant movement.


2.90.1 Vertices Keep Hiding, Unable to Weight Paint Mask I have an issue with only a part of my mesh hiding the vertices, even though it will still show the faces and the complete mesh.
It will look like this until I press Alt + H to unhide the hidden verts of the coat. The sleeves are always visible, and the coat isn't for some odd reason.

After unhiding them, I proceed to go into weight painting mode and that works fine. Until I try to mask a part of the mesh and then the issue with the vertices occurs. They go back to being hidden, like I never unhid them.

Only the sleeves can be weight painted while in the masking mode.

I have zero clue as to why this keeps happening.
The coat was originally a cloth simulation and converted to mesh after the simulation got to a point I liked.

After going into sculpting mode and pressing Alt + H, it seems to have fixed the issue.
I did this because sculpt and weight paint had the same issue. Wouldn't let me touch the coat. I could sculpt and paint the sleeves, but only the sleeves.
It works now after that. I don't know why that fixed it, but it did.
For now.


Is there a way to assign materials based on a color map in blender? I am trying to add Snow stuck to the bottom of a pillar and have created a procedural snow effect using substance designer, but I'd like to have the ability to set the pillar material using blender as opposed to adding one using substance designer as well ass add subsurface scattering to the snow which is easier using Blender, Is there a way to assign either different materials based on the colour map or use it as a mask to combine different materials. I know I could use Substance Painter to assign materials based on colour but as I mentioned I prefer using blender for subsurface scattering and would also like to avoid having to use multiple programs for everything if I could, by doing this in Blender I'd only need to use Blender and maybe load up Substance Designer to generate a few other once using different seeds so as to avoid too much repetition but when using only one I don't even need to load that up.

You may be able to use mix shader nodes

I achieved this result;

Using this node setup;

And these black and white textures (painted in blender, directly on the object);

.blend file here;

Effectively, what this does is uses the black (0) and white (1) or gray (some decimal value in between) as a factor for a mix shader. This mixing can be added to as many times as you like with this setup.


sculpting - How to get rid of the bumpy surface? When I normally sculpt in blender using subd (without dyntopo) the surface looks clean after applying some strokes, but when I enable dyntopo the surface gets bumpy quickly, I guess because of the many triangles added by dyntopo during sculpting.

The smoothing brush doesn't do much when I try to smooth the surface, and it leaves me with more bumps and uneven surface.

A picture showing what I mean on the model butt, (sorry can't use imgur):

https://pasteboard.co/Ixo5DOM.png

My topology is fine, I didn't use triangles or N-gons in my base mesh, and I don't have any doubles or flipped normals.

This bothers me because I want to bake the sculpt details later, and this will affect the results.

As far as I know the smooth or flatten brush is the only way to do this. You can change your brush size or strength, or you can set your dyntopo value to a number larger than the level of detail you currently have, use the simplify brush everywhere you need to, and see if smooth and flatten work any better for you with a simpler mesh.


How to animate a mesh that changes through editing? So I want to change how the mesh looks (through edit mode) so the geometry of the shape changes throughout the animation. So I have a laser but I want my selected faces to be scaling up and down. How can I do this?

Thanks in advance

You can use shape keys:

Go into the mesh properties

Add a new shape key

add another shape key
Edit your mesh
Animate the influence of the new shape key by hovering over the property and hitting I


you have 12 vertices, but are only using 4...
'f 1 2 3 4' is your first plane, so edit second one to read 'f 5 6 7 8' and third one to 'f 9 10 11 12'


How to place cubes evenly around a hexagon? On a hexagon shape, I am trying to place all these cubes nice and evenly but I am having a very hard time in doing so. Can somebody please tell me how to place all the cubes evenly?

An quick way to do so would be DupliVerts.

Parent the cube to your hexagon

In object settings of the hexagon set duplication to verts

Enable rotation
Now you have your corner stones:

Copy your cube and hexagon and rotate them to get the stones in between

The original cube in the middle will not show up in a render.
But you can get rid of it by making the Duply Verts real Ctrl | Cmd+Shift+A.


Is there any way to make edges corners become rounded? i'm a new blender i'm trying to making edges corners become rounded but i couldn't find any way to makes it.I tried to use Insert faces (shortcut I)
and Bevel but it didn't work as i expected,i don't know if i have missed something please give me an advice.

1.As you can see at first picture the red circles where i want it to be rounded
2.I want my corners to be rounded as second picture at red circles

Rounding the corners of the inset face cannot be done directly.

But you can extrude it and so have a "volume" that can be beveled.

Select the inset face
Extrude E
Go to edge select mode CtrTab
Select the edges
Bevel CtrlB (use mouse wheel or +/- from the numpad to choose the amount of bevel)
Once ok, remove the extrude face (select it then X then vertices)
Remake the original face: back to edge select mode CtrTab, then Alt select the border then F to make the face


How would I create a ribbon around a hat? Im trying to make a ribbon to wrap around a top hat that im making that it looks natural and has like creases and stuff and with a little bit hanging off the back.

Thank you! :)

Alright!

I experimented quite a while for this. Cloth sim seemed to be a good alternative, especially this tutorial.

But eventually I found that modelling by hand the results are better, at least for the ribbon:

Start by selecting a portion of the hat:

Duplicate it Shift+D. Scale it along the normals Alt+S. Separate it P. Assign new material to it if you wish:

Add some edgeloops Ctrl+R. Deselect all A. In the vertex mode, go to 'Select' > 'Random'. Enter 15%. Deselect the top and bottom edgeloop, or the edges of the ribbon:

Slide the vertices all the way down GG. Select all A and in W select 'Remove doubles':

Add some horizontal edgeloops Ctrl+R:

Select all A and deselect the boundaries or edges of the ribbon:

Go to 'Mesh' > 'Transform' > 'Randomize'. I used these values:

Select all A, W > 'Smooth'

Then, select horizontal edgeloops in edge mode one by one and slide them GG in order to form tighter creases. Also scale them by their normal Alt+S in order to make nooks and crevices, or hills and valleys, or something like that:

Maybe add some more horizontal edgeloops Ctrl+R, maybe select all and smooth again A, W > 'Smooth'. Maybe select an edgeloop and add bevel Ctrl+B. This is the creative part, go nuts. Finally, add a Solidify modifier (and move it to be the topmost in the modifier stack) to give it some thickness:

That's it.

I hope this was helpful :)

.blend

In the .blend file there is also my simulation test, which doesn't look bad either (maybe it's even better for some situations), especially after you apply some of the methods mentioned here to the simulated mesh. Just play the timeline Alt+A to see the simulation in action. After that, it's handy to Apply the Cloth modifier and continue modelling from there:


Solid mode in video editor I'm trying to render a sequence in the video editor but the textures disappear when I go into the video editor and add the strips I need. I'm in blender render with the strips on the bottom track

Has anyone encountered this? If so, how did they fix it?

Go to View- Properties - then under the OpenGPL Preview- change solid to texture


Combining Black and White with Color Rendering I'm looking to create the effect of sliding a window across my scene and to have everything in that window rendered black & white. (Everything outside the window will still render via color channels).

I've considered multiple layers, multiple cameras and using a glassy material, and have tried the last of these directly. (It didn't have the desired effect).

I imagine the solution could be one of a few things: maybe rendering a black and white camera at the same time as rendering a color channel camera and later splicing the scenes together in editor?; or maybe slowly switching from one scene to another (as if a panel effect)?

My thanks in advance for any tips!

My solution was as follows:

Riffing off one of many excellent tutorials by OneMinuteVideoTutorials on YouTube, I used a plane with a transparent material that I linked to a Material ID in node editor.

The first step is assigning the transparent material a Material ID (Material > Settings > Pass Index), and then enabling Material Index passes (Render Layer > Passes > Material Index).

The effect can then be achieved using the following combination of nodes:

Notice that the effect is contingent on the saturation in the Hue Saturation Value node being set to 0.


Blender 2.49b crashes when right-clicking to select an object After updating my Windows 10 tonight, I'm now having a problem in Blender version 2.49b where every time I try to right-click an object to select it, Blender instantly crashes and closes.

1 - Yes, I have to use this version of Blender. It's the only version that can import/export nif files for Skyrim modding.

2 - No, my object does not use subsurfing. No, I am not trying to animate or make a movie. It's just a very simple, low-poly object.

3 - The issue does not occur for a new file with 1 starter cube, but as soon as I add another object and try to select either of the 2 objects, the crash occurs.

4 - If I press A to select all, the crash does not occur. The problem only happens when trying to select an individual object via right-click.

5 - I have an Intel graphics driver, but I just updated it, and updating did not fix the problem.

Any help you guys could give would be appreciated. I went through all of the google pages on this topic, and none of them have advice for my version of Blender.

(NOTE: This is NOT a duplicate! I have to use an old version of Blender that no one seems to have given existing advice for. I have already gone through all the similar questions on this site, and none of them have helped. )

Runnig such an old version of Blender on a modern version of windows can lead to incompatibilities such as you are experiencing - the old versions were obviously developed way before Windows 10 was even imagined and there are all kinds of reasons why newer Windows could expose a bug that’s been dormant and undiscovered in the old Blender code.

Probably the best way forward is to run against an older version of the operating system that doesn’t experience the problem. If you don’t have the physical hardware to run such a system you can run it as a ‘virtual’ computer using VM tools such as VirtualBox. I’ve had great success running older versions of Blender on VirtualBox running Linux (which is free to install if you can’t get Windows XP) - so I currently have a Windows 10 laptop running Blender 2.79.6 and Blender 2.8 and use a Linux VM (in VirtualBox) to run earlier versions.


UV is stretching without a reason This fret board has the seam in the right position, but the uv is stretching.
The upper part should be the same as the part that is not stretching, and this is happening with other parts of my mesh as well. I even move the vertices in the same position (uv vertices) as the lower part and was not stretching.
Any idea how to solve the problem?

Overall the uv is really deformed, the right and left have a bit of stretch as well

I don't know exactly but I have some ideas. I tried to recreate the problem and couldn't, but I created other problems and here's how I fixed them.

If I have a non-manifold mesh (meaning the bottom of the fretboard doesn't have a face, just the top and sides) and I unwrapped, it would unwrap the mesh into 2 pieces... even though I just added edge seams in the same places you did, along the 4 curved "short" edges. And, I got stretching for no reason. https://i.imgur.com/GJlvNxP.jpg
Just as a guess I tried recalculate normals, and it shows the stretching is worse?? https://i.imgur.com/ElknAqI.jpg
So I decided maybe the missing face is the problem. I added a face to the bottom, and added edge seams to 3 out of 4 edges so that everything would stay attached in the UV editor as 1 piece. The stretching is gone, but it's still two pieces, wtf? https://i.imgur.com/PpWyCpE.jpg
Next I figured the problem must be the seams, so I cleared them and carefully added them again in the same places. Almost correct, but 1 small piece is still detached, and it does NOT have seams on all 4 sides. ... hrm. https://i.imgur.com/kU9N4sU.jpg
Finally, I figure out there's an extra vertex somewhere that I didn't want. I did mesh - clean up - remove doubles. This removed the 1 vertex. When I unwrapped again, it's perfect. https://i.imgur.com/92dwf8e.jpg

I think a hidden extra vertex can create this stretch problem... the mesh is attached to it, but you don't see it, because it overlaps some other vertex that it separated from without problems, due to the edge seams you created.

So my advice is... make sure the mesh doesn't have missing faces. Clean up any extra points or edges or doubles. Recalculate normals. Confirm cuts are in the correct place, then unwrap again. Hopefully one of those ideas fixes it.


Should an Operator remember its last-used settings when invoked? I have an operator that draw its own panel (via invoke_props_dialog) when invoked to let user set properties which are then applied to the selected object, but the settings are not remember from one call to another when I use the operator's own panel. It works though when using the Tool Shelf Redo feature (bottom of the left panel in the 3D view).

Here's a sample code example to illustrate this issue. It adds a Test Panel with a Test button to the Data properties.

# add a Test Panel with a Test button to the Data properties.
import bpy

class DATA_PT_test(bpy.types.Panel):
    bl_label = "Test Panel"
    bl_space_type = "PROPERTIES"
    bl_region_type = "WINDOW"
    bl_context = "data"

    def draw(self, context):
        self.layout.operator("object.test_invoke")

class OBJECT_OT_test_invoke(bpy.types.Operator):
    bl_idname = "object.test_invoke"
    bl_label = "Test"
    bl_options = {'REGISTER', 'UNDO'}

    width = bpy.props.IntProperty(name="Width",
            default=10, min=0, max=100)
    height = bpy.props.IntProperty(name="Height",
            default=20, min=0, max=100)

    def execute(self, context):
        self.report({'INFO'}, "w:{}, h:{}".format(self.width, self.height))
        return {'FINISHED'}

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

def register():
    bpy.utils.register_module(__name__)

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

if __name__ == "__main__":
    register()

Detailed steps:

Use the operator button: it uses its default settings.
Change the settings, apply them, then re-use the button: the last-used settings are not remembered, it still uses the default one.
Use the operator button, modify the settings in the Tool Shelf, use the button again: the setting from the Tool Shelf are remembered. (It does the same when using the Redo Last F6 panel to modify the settings).

For info, I already know some hacky ways to make it work but that's not really the point.
I'd like to know if something is wrong or missing in this code, if it sounds like a Blender API bug, or if it's simply not an expected feature.

I'm using last official Blender 2.69.0 (r60995). I have the feeling it worked with previous releases (only from 2.62 though) but didn't feel like reinstalling just to try...

1) The dialog is supposed to start with the default settings. A new operator instance is created as you open it, and the default values are taken from the property definitions. The redo panel works differently, it revokes what the last operator did, but keeps the values in the UI and re-executes with new settings.

One could say, the redo panel relates to the last operator, whereas your dialog is part of a new operator.

2) Operators remember their settings to allow for redo / repeat functionality, see Operator Design.

The operator log is available to python:

bpy.context.window_manager.operators

You could read the value used for a translation like Operator.properties.value. But I wouldn't recommend to iterate the log in reverse direction until you find an instance of your operator, just to read the last used settings.

How about this generic solution instead, which stores the settings at python class level:

Use a static variable (dictionary) to store the operator settings on execute(), and load them on invoke() into self.properties. These two methods can be defined together with the static dict as separate class, and be mixed-in into the operator class:

import bpy

class OperatorSettings:

    # Static member
    _settings = {}

    def save_settings(self):
        for d in dir(self.properties):
            if d in {'bl_rna', 'rna_type'}:
                continue
            try:
                self.__class__._settings[d] = self.properties[d]
            except KeyError:
                # catches __doc__ etc.
                continue

    def load_settings(self):
        # what exception could occur here??
        for d in self.__class__._settings:
            self.properties[d] = self.__class__._settings[d]

class DATA_PT_test(bpy.types.Panel):
    bl_label = "Test Panel"
    bl_space_type = "PROPERTIES"
    bl_region_type = "WINDOW"
    bl_context = "data"

    def draw(self, context):
        self.layout.operator("object.test_invoke")

class OBJECT_OT_test_invoke(bpy.types.Operator, OperatorSettings):
    bl_idname = "object.test_invoke"
    bl_label = "Test"
    bl_options = {'REGISTER'}

    width = bpy.props.IntProperty(name="Width",
            default=10, min=0, max=100)
    height = bpy.props.IntProperty(name="Height",
            default=20, min=0, max=100)

    def execute(self, context):
        self.report({'INFO'}, "w:{}, h:{}".format(self.width, self.height))
        self.save_settings()
        return {'FINISHED'}

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

def register():
    bpy.utils.register_module(__name__)

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

if __name__ == "__main__":
    register()

Should work for base types (int, float, str), but will probably fail for CollectionProperty as it is. But should be possible if you implement (de-)serialization functions for such propert types.

If you add non-property class variables to the operator, make sure to exclude them in save_settings(), or add a type check for all members - see the bl_rna property for that:

self.properties.bl_rna.properties['...'].type # e.g. 'INT'

BTW: I removed 'UNDO' from bl_options 'cause every change in the redo panel causes a re-execution of the operator. This is not the case for the dialog, the operator is run once on confirmation. Such dialogs should be used if an operator takes a long time to finish, to avoid irresponsive UI. So it's probably not supposed to have the redo functionality enabled.

3) There's another approach:

Register global properties (e.g. on bpy.types.Object or bpy.types.WindowManager) and add them to a panel. Let the user set them before (s)he clicks an Execute button. Pass the global properties to the operator. Global properties are remembered, so it works similar to the redo panel.

Example:

import bpy

class PrintSomeString(bpy.types.Operator):
    bl_label = "Print Some String"
    bl_idname = "object.print_some_string"
    bl_options = {'REGISTER', 'UNDO'}

    print_this = bpy.props.StringProperty(name="Print this")

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

class HelloWorldPanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Hello World Panel"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"

    def draw(self, context):
        layout = self.layout
        layout.prop(context.window_manager, "some_string")

        props = layout.operator(PrintSomeString.bl_idname)
        props.print_this = context.window_manager.some_string

        props = layout.operator(PrintSomeString.bl_idname, text="Print welcome message")
        props.print_this = "Welcome to Blender!"

def register():
    bpy.utils.register_module(__name__)
    bpy.types.WindowManager.some_string = bpy.props.StringProperty(name="Some String")

def unregister():
    bpy.utils.unregister_module(__name__)
    del bpy.types.WindowManager.some_string

if __name__ == "__main__":
    register()

Paste into Text Editor and Run Script. See Object tab in Properties Editor.


Flipping an array of planes in random order using Animation Nodes I'm trying to make an array of planes to flip one at a time in random order. So far I managed to flip them one at a time in order. Below is an image of my 3D viewport and Animation Nodes setup. How could I proceed?

Instead of a Falloff you could use Compose Matrix. Math Nodes are there just to make a single plane rotate and you can feed it 100 random numbers to make them all rotate. Clamp node is there to restrict rotation.

One at a time
To make the planes rotate one at a time you need to replace the random numbers with a list of integers (One step is the time it takes for one rotation) and suffle them.


Isnt any solution to move the 3d cursor and origin to pivot? I want to place the 3d cursor at the particular place but i just able to place the pivot at that point, i have no idea how to move the 3d cursor and origin to the point. Seek for help

You can position the 3D cursor by hitting or holding Shift and right mouse button in the 3D view, the 3d cursor coordinates are located on the view side panel of the 3D veiw and hitting shift + S will bring up a menu with other 3D cursor options. If you want to make an objects origin point the 3D cursors position just right mouse click in 3D view and go to "Set Origin" also Shift + C will reposition the 3D cursor back to the worlds center.


3x4 camera matrix from blender camera In computer vision, the transformation from 3D world coordinates to pixel coordinates is often represented by a 3x4 (3 rows by 4 cols) matrix P as detailed below. Given a camera in Blender, I need code that returns P.
Context where this shows up
It is common for people to want the reverse: to set Blender or OpenGL camera transforms from a given 3x4 P. This is so due to Augmented reality where 3x4 cameras are computed from real imagery using computer vision / structure from motion algorithms which are then used in CG to render registered synthetic models.
In my case, I am using Blender to generate synthetic data to validate a 3D structure from motion (3D reconstruction) algorithm. I need to use the synthetic Blender cameras inside a computer vision pipeline based on 3x4 P.
Some Details
An image pixel $(u,v)$ is generated from world $(x,y,z)$ coordinates through a 3x4 matrix using projective coordinates:
$$kx = PX,$$
where $k$ is a constant, $x = (u,v,1)^t$, $X = (X,Y,Z,W)^t$, and $P$ can be decomposed as
$$P=K[I|0] \begin{bmatrix}
R & T\\
0^\text{t} & 1
\end{bmatrix} = K[R|T],$$
where $K$ can be written as
$$K=\begin{bmatrix}
\alpha_u & s & u_o\\
0 & \alpha_v & v_o\\
0 & 0 & 1
\end{bmatrix},$$
where
$$f=\text{focal length}$$
$$\alpha_u=\frac{f\times u\text{ pixels}}{\text{unit length}}=\frac{f}{\text{width of a pixel in world units}}$$
$$\alpha_v=\frac{f\times v\text{ pixels}}{\text{unit length}}=\frac{f}{\text{height of a pixel in world units}}$$
$$u_o=u\text{ coordinate of principal point}$$
$$v_o=v\text{ coordinate of principal point}$$
$$s=\text{skew factor}$$
I need to generate this from a Blender camera (e.g., from the Cycles engine).
Preliminary Research
I could certainly detail this up further in terms of all the coordinate systems and work out the solution myself if need be, but I'm looking to reuse well-tested shared code. Perhaps there could be something in libmv.
Directly related to:
What is blender's camera projection matrix model?, blender camera from 3x4 matrix
Other related questions:
How can I get the camera's projection matrix?,
How to find image coordinates of the rendered vertex?

I wrote the function get_3x4_RT_matrix_from_blender to do this, listed below.
import bpy
import bpy_extras
from mathutils import Matrix
from mathutils import Vector

#---------------------------------------------------------------
# 3x4 P matrix from Blender camera
#---------------------------------------------------------------

# Build intrinsic camera parameters from Blender camera data
#
# See notes on this in
# blender.stackexchange.com/questions/15102/what-is-blenders-camera-projection-matrix-model
def get_calibration_matrix_K_from_blender(camd):
    f_in_mm = camd.lens
    scene = bpy.context.scene
    resolution_x_in_px = scene.render.resolution_x
    resolution_y_in_px = scene.render.resolution_y
    scale = scene.render.resolution_percentage / 100
    sensor_width_in_mm = camd.sensor_width
    sensor_height_in_mm = camd.sensor_height
    pixel_aspect_ratio = scene.render.pixel_aspect_x / scene.render.pixel_aspect_y
    if (camd.sensor_fit == 'VERTICAL'):
        # the sensor height is fixed (sensor fit is horizontal),
        # the sensor width is effectively changed with the pixel aspect ratio
        s_u = resolution_x_in_px * scale / sensor_width_in_mm / pixel_aspect_ratio
        s_v = resolution_y_in_px * scale / sensor_height_in_mm
    else: # 'HORIZONTAL' and 'AUTO'
        # the sensor width is fixed (sensor fit is horizontal),
        # the sensor height is effectively changed with the pixel aspect ratio
        pixel_aspect_ratio = scene.render.pixel_aspect_x / scene.render.pixel_aspect_y
        s_u = resolution_x_in_px * scale / sensor_width_in_mm
        s_v = resolution_y_in_px * scale * pixel_aspect_ratio / sensor_height_in_mm

    # Parameters of intrinsic calibration matrix K
    alpha_u = f_in_mm * s_u
    alpha_v = f_in_mm * s_v
    u_0 = resolution_x_in_px * scale / 2
    v_0 = resolution_y_in_px * scale / 2
    skew = 0 # only use rectangular pixels

    K = Matrix(
        ((alpha_u, skew,    u_0),
        (    0  , alpha_v, v_0),
        (    0  , 0,        1 )))
    return K

# Returns camera rotation and translation matrices from Blender.
#
# There are 3 coordinate systems involved:
#    1. The World coordinates: "world"
#       - right-handed
#    2. The Blender camera coordinates: "bcam"
#       - x is horizontal
#       - y is up
#       - right-handed: negative z look-at direction
#    3. The desired computer vision camera coordinates: "cv"
#       - x is horizontal
#       - y is down (to align to the actual pixel coordinates
#         used in digital images)
#       - right-handed: positive z look-at direction
def get_3x4_RT_matrix_from_blender(cam):
    # bcam stands for blender camera
    R_bcam2cv = Matrix(
        ((1, 0,  0),
         (0, -1, 0),
         (0, 0, -1)))

    # Transpose since the rotation is object rotation,
    # and we want coordinate rotation
    # R_world2bcam = cam.rotation_euler.to_matrix().transposed()
    # T_world2bcam = -1*R_world2bcam * location
    #
    # Use matrix_world instead to account for all constraints
    location, rotation = cam.matrix_world.decompose()[0:2]
    R_world2bcam = rotation.to_matrix().transposed()

    # Convert camera location to translation vector used in coordinate changes
    # T_world2bcam = -1*R_world2bcam*cam.location
    # Use location from matrix_world to account for constraints:
    T_world2bcam = -1*R_world2bcam @ location

    # Build the coordinate transform matrix from world to computer vision camera
    # NOTE: Use * instead of @ here for older versions of Blender
    # TODO: detect Blender version
    R_world2cv = R_bcam2cv@R_world2bcam
    T_world2cv = R_bcam2cv@T_world2bcam

    # put into 3x4 matrix
    RT = Matrix((
        R_world2cv[0][:] + (T_world2cv[0],),
        R_world2cv[1][:] + (T_world2cv[1],),
        R_world2cv[2][:] + (T_world2cv[2],)
         ))
    return RT

def get_3x4_P_matrix_from_blender(cam):
    K = get_calibration_matrix_K_from_blender(cam.data)
    RT = get_3x4_RT_matrix_from_blender(cam)
    return K@RT, K, RT

# ----------------------------------------------------------
# Alternate 3D coordinates to 2D pixel coordinate projection code
# adapted from https://blender.stackexchange.com/questions/882/how-to-find-image-coordinates-of-the-rendered-vertex?lq=1
# to have the y axes pointing up and origin at the top-left corner
def project_by_object_utils(cam, point):
    scene = bpy.context.scene
    co_2d = bpy_extras.object_utils.world_to_camera_view(scene, cam, point)
    render_scale = scene.render.resolution_percentage / 100
    render_size = (
            int(scene.render.resolution_x * render_scale),
            int(scene.render.resolution_y * render_scale),
            )
    return Vector((co_2d.x * render_size[0], render_size[1] - co_2d.y * render_size[1]))

# ----------------------------------------------------------
if __name__ == "__main__":
    # Insert your camera name here
    cam = bpy.data.objects['Camera.001']
    P, K, RT = get_3x4_P_matrix_from_blender(cam)
    print("K")
    print(K)
    print("RT")
    print(RT)
    print("P")
    print(P)

    print("==== Tests ====")
    e1 = Vector((1, 0,    0, 1))
    e2 = Vector((0, 1,    0, 1))
    e3 = Vector((0, 0,    1, 1))
    O  = Vector((0, 0,    0, 1))

    p1 = P @ e1
    p1 /= p1[2]
    print("Projected e1")
    print(p1)
    print("proj by object_utils")
    print(project_by_object_utils(cam, Vector(e1[0:3])))

    p2 = P @ e2
    p2 /= p2[2]
    print("Projected e2")
    print(p2)
    print("proj by object_utils")
    print(project_by_object_utils(cam, Vector(e2[0:3])))

    p3 = P @ e3
    p3 /= p3[2]
    print("Projected e3")
    print(p3)
    print("proj by object_utils")
    print(project_by_object_utils(cam, Vector(e3[0:3])))

    pO = P @ O
    pO /= pO[2]
    print("Projected world origin")
    print(pO)
    print("proj by object_utils")
    print(project_by_object_utils(cam, Vector(O[0:3])))

    # Bonus code: save the 3x4 P matrix into a plain text file
    # Don't forget to import numpy for this
    nP = numpy.matrix(P)
    numpy.savetxt("/tmp/P3x4.txt", nP)  # to select precision, use e.g. fmt='%.2f'

Detailed Tests

I included some helper functions and tests to cross-check the 3D-2D projection process with another approach using world_to_camera_view from @ideasman42's answer to How to find image coordinates of the rendered vertex? The floating point coordinates match up perfectly up to many decimal places. To get the integer pixel coordinates after projection, just round them.

I tested this visually and analytically with a few scenes, to make sure both routines were exactly correct on actual rendered images.

I represented e1, e2, e3 and O with small cone objects whose tips were at the desired positions
and coded with different colors: Red for X, Green for Y, Blue for Z
I placed the camera at a convenient location at first,
R = identity, T = (0,0,5)
I used default Blender parameters for the camera intrinsics
I computed the P matrix by hand and computed it using my rountines and they match perfectly
Visually comparing both the Cycles render and the OpenGL render in GIMP show that the produced coordinates match well visually (up to perhaps +- 1 pixel error, which is the sort of thing this careful testing was carried out anyways - to be investigated).
I then arbitrarily rotated and translated the camera such that the world e1, e2, e3 remain visible and at general locations. The projections match visually in the rendered images, and also match to the ones given by the object utils routine given above.

Here is an example of a test output:
  K
<Matrix 3x3 (2100.0000,    0.0000, 960.0000)
            (   0.0000, 2100.0000, 540.0000)
            (   0.0000,    0.0000,   1.0000)>
RT
<Matrix 3x4 (-0.0594, -0.9483, -0.3118, -0.6837)
            ( 0.6234,  0.2087, -0.7536, -0.1887)
            ( 0.7797, -0.2391,  0.5787,  4.2599)>
P
<Matrix 3x4 ( 623.8236, -2220.9482,   -99.1637, 2653.7441)
            (1730.0916,   309.2392, -1269.9426, 1904.1343)
            (   0.7797,    -0.2391,     0.5787,    4.2599)>
==== Tests ====
Projected e1
<Vector (650.3716, 721.1436, 1.0000)>
proj by object_utils
<Vector (650.3716, 721.1436)>
Projected e2
<Vector (107.6402, 550.4857, 1.0000)>
proj by object_utils
<Vector (107.6403, 550.4857)>
Projected e3
<Vector (527.9586, 131.0692, 1.0000)>
proj by object_utils
<Vector (527.9586, 131.0693)>
Projected world origin
<Vector (622.9655, 446.9949, 1.0000)>
proj by object_utils
<Vector (622.9656, 446.9949)>

Here is the test set with the blender rotation and location for the camera.

Here is the OpenGL render. The coordinates output above match the tip of the cones visually (up to +- 1 px error, perhaps due to aliasing).

Limitations: this code currently does not support certain intrinsic camera parameter configurations, see my answer to What is blender's camera projection matrix model? for a list of the limitations to get_calibration_matrix_K_from_blender.
Object coordinates: to deal with object coordinates, first transform to world coordinates, see my answer to How to find image coordinates of the rendered vertex?
Matrix multiplication used to be * before Blender 2.8, newer versions use @ instead


Make an Object not reflected by a Surface? I want to make an Object which cant be seen on Reflective Surfaces, for example: Metal. I want to make it so that if I Place the Object over a Reflective Material, it should not be seen on there.
How can i make it so the Surface doesn't Reflect my Object?

Thanks in Advance!

You can do this with the Light Path Shader Node.

EDIT: Do note that I what I posted works with the default settings in cycles, but EVEE reflections behave differently so it might not be the exact same.

FOR CYCLES:

Here is a basic shader setup that prevents reflective surfaces from seeing your object. In fact it prevents it from casting any reflected light at all.

You can turn this

Into this

By using this Shader setup Involving the afformentioned Light Path Node.

You can read more about the Light Path Node here but the value you are interested in is the "Is Reflection" value.

Long story short, things that have light reaching you only as a result of reflection from other objects (in this case the underside of the ball) are flagged as "reflection" rays by this light path.

For reference:

This shader setup works by using the mix and transparent shader nodes, driven by the light path. If a ray is a reflected light path, it has a value of 1 being put into the FAC value of the mix shader. This makes the mix shader choose 100% of the SECOND input shader.

Non reflected light gets classified with a 0 in FAC therefore it only chooses 100% of the FIRST input of the mix shader

You can use this effect to for example, make reflections semi transparent if you replaced the second node with a translucent shader instead of a transparent one or you can put a complicated node graph to use in place of the reflection while leaving the original directly viewed object as its normal shader.

This is especially interesting if you plan to do NPR (Non photo real) renders etc.


Rotating empty deforms my mesh (Peter France's tutorial) Blender version: 2.92
I'm watching Peter France's tutorial about creating a Spider-Man animation. He creates an empty, parents it to SM keeping transform and in "constraints" adds "follow path" and chooses a path. I do the same and everything works fine until i'm trying to rotate an empty to rotate an actual model. Idk why but it deforms my mesh. Before creating an empty Peter France says that "without it your mesh will be deformed if you try to rotate it" but it deforms anyway. I've tried adding a "follow path" constrait directly to my model but it still deforms. I was experimenting with "influence" but it just moves my model away and it stops following the path.

This is how it look like before i'm trying to rotate the empty

And this is the result of rotating it
I've rewatched the tutorial a few times but I haven't noticed any differences. I repeat same actions he does.
This is the tutorial https://www.youtube.com/watch?v=b0hWrpAG6Sg
My problem begins at 9:13. He rotates an empty an it works fine.
And sry for my english

I was also facing the same issue.
You can use the "Locked Track" constraint in the Spiderman body + Rig. And add a target as Spiderman body. It worked for me. Do let me know if this works in your case.


Variable representing object's rotation minus another object's rotation not working? Here's my code:

import bge
from bge import logic
from math import degrees

def mimic_process():

    cont = logic.getCurrentController()
    own = cont.owner
    own_rotation = own.worldOrientation.to_euler()
    mimic = own.parent
    mimic_rotation = mimic.worldOrientation.to_euler()

    own_rotation_x = "%.0f" % degrees(own_rotation.x)
    own_rotation_y = "%.0f" % degrees(own_rotation.y)
    own_rotation_z = "%.0f" % degrees(own_rotation.z)

    mimic_rotation_x = "%.0f" % degrees(mimic_rotation.x)
    mimic_rotation_y = "%.0f" % degrees(mimic_rotation.y)
    mimic_rotation_z = "%.0f" % degrees(mimic_rotation.z)

    rotation_fix_x = own_rotation_x - own_rotation_y

    if (own_rotation_x > mimic_rotation_x):
        own.applyRotation((rotation_fix_x, 0, 0), True)
        print('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')

    keyboard = bge.logic.keyboard

    if bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.OKEY]:
        own.applyRotation((0.01, 0, 0), True)

mimic_process()

The line rotation_fix_x = own_rotation_x - own_rotation_y is the cause of the problem. I got my object's rotation, put it in a variable, did the same with another object [the mimic object], and attempted to subtract them out. I don't know why it wont subtract them. How can I fix this? Thanks.

Only use the formatting strings "%.0f" % degrees(mimic_rotation.x)to format output to print statements, file etc, not to set values.  The formatting converts the value to a string.  Feel somewhat responsible as this was taken from my answer to your question  https://blender.stackexchange.com/a/41328/15543.

Use round or floor if you want just the integer part here, although I'm not really sure what you are trying to achieve.  Are you trying to restrict values to whole degree amounts?  As pointed out previously blender uses radians as its default unit.  http://bgepython.tutorialsforblender3d.com/GameObject/applyRotation

rotation_fix_x = own.rotation.x - mimic.rotation.x
if own.rotation.x > own.rotation.y:
   own.applyRotation((rotation_fix_x, 0, 0), True)

The above would work ok because it is dealing in float types, but wouldn't set to a whole degree amount.
Here is some console code from bpy looking at the rotation_euler.x of an object

# rotation.x in radians
>> C.object.rotation_euler.x
1.1093189716339111
# rotation as degrees.
>>> x = degrees(C.object.rotation_euler.x)
>>> x
63.5592952084158
# rounded to a whole number
>>> y = round(x,0)
>>> y
64.0
# how much to add to C.rotation_euler.x to make it whole number in degs.
>>> fix = radians(x - y)
>>> fix
-0.007691749642459737

To step in degrees use radians(1) when applying your rotation from the kb.


My texture isn't working with my baked normal I created my own normal but when I add a texture from Poliigon, it looks really blotchy and weird. How do I get my texture to look more natural with the normal I baked?

Here's a copy of the file https://drive.google.com/file/d/1CaOtMp7PLY_wtZe7TV00ynI1tMJTXoDK/view?usp=sharing

You are looking at the wrong model. The image shows your high poly, which is not (and does not need to be, because that's why you bake to a low poly) unwrapped. Your low poly model is on another layer.
The texture should go on your low poly. Then it looks fine.


Proportional Editing - Limit to selected? This seems an obviously desirable option for proportional editing: to be able to transform only selected elements, using, say, the active element as the center of falloff. Is there a Blender way to achieve this reasonably quickly?

I know it can be done by hiding the elements you wish to remain untransformed, but often you want to see them during the transformation.

One workaround is to select the vertices that you want to leave unaffected and press H to hide them. Proportional editing will only have effect on the visible geometry.


follow path constraint lost I have created an object following a curve. That works fine. To messure the length
of the curve using the add-on measurelt I converted the curve to a mesh. Then I converted
the mesh back into a curve. Now the object does not follow the curve any more.
Removing the follow path constraint and add it again did not help.
Can you help me understanding what's happening here?

The question, what is the result of first converting  a Bezier curve to a mesh and then back to a curve is still interesting. But I found a way to solve my original problem. I think it is not a work-around but the proper way of doing it. I needed to extend a Bezier curve by a new curve of fixed precomputed length. This is what I do: I generate an auxiliary  polygon of the desired length exactly in the place where I need the extended curve with the help of "measurelt".  Then I extend the Bezier curve following the polygon. Then I delete the auxiliary polygon.


Export rest pose to unity as default action I'm trying to export my model to unity.
I've made low poly character and animated it with idle, walkF, walkR, walkL and walkB animations.
After exporting to unity as .fbx file or .blend file the character won't stay i T-pose. It sees its walkL(walk left) animation as its default action.
In a fact I don't want no action to be default. By default I want my character to stay in T-pose.
Please, I'm helpless...

Select your character > click the pose data property tab >
Skeleton > Rest Position > reset the rest position
Pose Mode: How to reset transformed armature to its rest position?


Is there a reference for how to add custom keymaps to operators in an addon? The Blender API is horribly convoluted, when it comes to actually being able to find any valuable examples or reference code for how to implement features when developing an addon.
Is there a reference that can help with how to implement custom keymaps in an addon?

In the end, I poached some examples from other people's addons and made an addon myself, writing this up as a keymap reference documentation to help myself during the process. Hopefully it can help some others...
Notes and Reference for implementing keymaps in Blender Addons
Valuable Resources:

Space Type Reference bpy.types.KeyMap.name
Keymap Constructor incl. Space Type and Region Type Reference bpy.types.KeyMaps.new
Key Type, Map Type and Value Reference bpy.types.KeyMapItem.name
How to extract keymap names

Example

See the Keymap Code section of the __init__.py script for a working example
Note, not all use cases are covered. This is a primer to begin to make sense of things

Keymap Names
For Keymaps to show in their corresponding location in the [Edit >> Preferences >> Keymap] ui in Blender, keymap name must be identical to one of the following 224 strings (without the number), surrounded by quotes. E.g. "Window":
0    Window
1    Screen
2    Screen Editing
3    User Interface
4    View2D
5    Region Context Menu
6    View2D Buttons List
7    Frames
8    Property Editor
9    Outliner
10    Markers
11    Time Scrub
12    Animation
13    Dopesheet
14    Dopesheet Generic
15    3D View Generic
16    Grease Pencil
17    Grease Pencil Stroke Edit Mode
18    Grease Pencil Stroke Paint Mode
19    Grease Pencil Stroke Paint (Draw brush)
20    Grease Pencil Stroke Paint (Erase)
21    Grease Pencil Stroke Paint (Fill)
22    Grease Pencil Stroke Paint (Tint)
23    Grease Pencil Stroke Sculpt Mode
24    Grease Pencil Stroke Vertex Mode
25    Grease Pencil Stroke Vertex (Draw)
26    Grease Pencil Stroke Vertex (Blur)
27    Grease Pencil Stroke Vertex (Average)
28    Grease Pencil Stroke Vertex (Smear)
29    Grease Pencil Stroke Vertex (Replace)
30    Grease Pencil Stroke Sculpt (Smooth)
31    Grease Pencil Stroke Sculpt (Thickness)
32    Grease Pencil Stroke Sculpt (Strength)
33    Grease Pencil Stroke Sculpt (Grab)
34    Grease Pencil Stroke Sculpt (Push)
35    Grease Pencil Stroke Sculpt (Twist)
36    Grease Pencil Stroke Sculpt (Pinch)
37    Grease Pencil Stroke Sculpt (Randomize)
38    Grease Pencil Stroke Sculpt (Clone)
39    Grease Pencil Stroke Weight Mode
40    Grease Pencil Stroke Weight (Draw)
41    Paint Face Mask (Weight, Vertex, Texture)
42    Paint Vertex Selection (Weight, Vertex)
43    Weight Paint
44    Vertex Paint
45    Pose
46    Object Mode
47    Paint Curve
48    Curve
49    Image Paint
50    Sculpt
51    Mesh
52    Armature
53    Metaball
54    Lattice
55    Particle
56    Font
57    Object Non-modal
58    3D View
59    Image Editor Tool: Uv, Tweak
60    Image Editor Tool: Uv, Select Box
61    Image Editor Tool: Uv, Select Circle
62    Image Editor Tool: Uv, Select Lasso
63    Image Editor Tool: Uv, Cursor
64    Image Editor Tool: Uv, Rip Region
65    3D View Tool: Pose, Breakdowner
66    3D View Tool: Pose, Push
67    3D View Tool: Pose, Relax
68    3D View Tool: Edit Armature, Roll
69    3D View Tool: Edit Armature, Bone Size
70    3D View Tool: Edit Armature, Bone Envelope
71    3D View Tool: Edit Armature, Extrude
72    3D View Tool: Edit Armature, Extrude to Cursor
73    3D View Tool: Edit Mesh, Extrude Region
74    3D View Tool: Edit Mesh, Extrude Manifold
75    3D View Tool: Edit Mesh, Extrude Along Normals
76    3D View Tool: Edit Mesh, Extrude Individual
77    3D View Tool: Edit Mesh, Extrude to Cursor
78    3D View Tool: Edit Mesh, Inset Faces
79    3D View Tool: Edit Mesh, Bevel
80    3D View Tool: Edit Mesh, Loop Cut
81    3D View Tool: Edit Mesh, Offset Edge Loop Cut
82    3D View Tool: Edit Mesh, Knife
83    3D View Tool: Edit Mesh, Bisect
84    3D View Tool: Edit Mesh, Poly Build
85    3D View Tool: Edit Mesh, Spin
86    3D View Tool: Edit Mesh, Spin Duplicates
87    3D View Tool: Edit Mesh, Smooth
88    3D View Tool: Edit Mesh, Randomize
89    3D View Tool: Edit Mesh, Edge Slide
90    3D View Tool: Edit Mesh, Vertex Slide
91    3D View Tool: Edit Mesh, Shrink/Fatten
92    3D View Tool: Edit Mesh, Push/Pull
93    3D View Tool: Edit Mesh, To Sphere
94    3D View Tool: Edit Mesh, Rip Region
95    3D View Tool: Edit Mesh, Rip Edge
96    3D View Tool: Edit Curve, Draw
97    3D View Tool: Edit Curve, Extrude
98    3D View Tool: Edit Curve, Extrude to Cursor
99    3D View Tool: Edit Curve, Radius
100    3D View Tool: Edit Curve, Tilt
101    3D View Tool: Edit Curve, Randomize
102    3D View Tool: Sculpt, Box Mask
103    3D View Tool: Sculpt, Lasso Mask
104    3D View Tool: Sculpt, Box Hide
105    3D View Tool: Sculpt, Mesh Filter
106    3D View Tool: Sculpt, Cloth Filter
107    3D View Tool: Sculpt, Color Filter
108    3D View Tool: Sculpt, Mask By Color
109    3D View Tool: Paint Weight, Gradient
110    3D View Tool: Paint Weight, Sample Weight
111    3D View Tool: Paint Weight, Sample Vertex Group
112    3D View Tool: Paint Gpencil, Cutter
113    3D View Tool: Paint Gpencil, Eyedropper
114    3D View Tool: Paint Gpencil, Line
115    3D View Tool: Paint Gpencil, Polyline
116    3D View Tool: Paint Gpencil, Arc
117    3D View Tool: Paint Gpencil, Curve
118    3D View Tool: Paint Gpencil, Box
119    3D View Tool: Paint Gpencil, Circle
120    3D View Tool: Edit Gpencil, Tweak
121    3D View Tool: Edit Gpencil, Select Box
122    3D View Tool: Edit Gpencil, Select Circle
123    3D View Tool: Edit Gpencil, Select Lasso
124    3D View Tool: Edit Gpencil, Extrude
125    3D View Tool: Edit Gpencil, Radius
126    3D View Tool: Edit Gpencil, Bend
127    3D View Tool: Edit Gpencil, Shear
128    3D View Tool: Edit Gpencil, To Sphere
129    3D View Tool: Edit Gpencil, Transform Fill
130    3D View Tool: Edit Mesh, Make Line
131    3D View Tool: Hops
132    3D View Tool: Hardflow
133    3D View Tool: BoxCutter
134    3D View Tool: Cad Transform
135    Gizmos
136    Generic Gizmo
137    Generic Gizmo Maybe Drag
138    Generic Gizmo Tweak Modal Map
139    View3D Gesture Circle
140    Gesture Box
141    Gesture Zoom Border
142    Gesture Straight Line
143    Header
144    Standard Modal Map
145    Animation Channels
146    Knife Tool Modal Map
147    Custom Normals Modal Map
148    Bevel Modal Map
149    UV Editor
150    Paint Stroke Modal
151    Mask Editing
152    Eyedropper Modal Map
153    Eyedropper ColorRamp PointSampling Map
154    Transform Modal Map
155    View3D Fly Modal
156    View3D Walk Modal
157    View3D Rotate Modal
158    View3D Move Modal
159    View3D Zoom Modal
160    View3D Dolly Modal
161    View3D Placement Modal Map
162    Graph Editor Generic
163    Graph Editor
164    Image Generic
165    Image
166    Node Generic
167    Node Editor
168    Info
169    File Browser
170    File Browser Main
171    File Browser Buttons
172    NLA Generic
173    NLA Channels
174    NLA Editor
175    Text Generic
176    Text
177    SequencerCommon
178    Sequencer
179    SequencerPreview
180    Console
181    Clip
182    Clip Editor
183    Clip Graph Editor
184    Clip Dopesheet Editor
185    Clip Time Scrub
186    Generic Gizmo Drag
187    Generic Gizmo Click Drag
188    Generic Gizmo Select
189    Toolbar Popup
190    Generic Tool: Annotate
191    Generic Tool: Annotate Line
192    Generic Tool: Annotate Polygon
193    Generic Tool: Annotate Eraser
194    Image Editor Tool: Sample
195    Image Editor Tool: Uv, Sculpt Stroke
196    Image Editor Tool: Uv, Move
197    Image Editor Tool: Uv, Rotate
198    Image Editor Tool: Uv, Scale
199    Node Tool: Tweak
200    Node Tool: Select Box
201    Node Tool: Select Lasso
202    Node Tool: Select Circle
203    Node Tool: Links Cut
204    3D View Tool: Cursor
205    3D View Tool: Tweak
206    3D View Tool: Select Box
207    3D View Tool: Select Circle
208    3D View Tool: Select Lasso
209    3D View Tool: Transform
210    3D View Tool: Move
211    3D View Tool: Rotate
212    3D View Tool: Scale
213    3D View Tool: Shear
214    3D View Tool: Measure
215    3D View Tool: Object, Add Primitive
216    3D View Tool: Sculpt Gpencil, Tweak
217    3D View Tool: Sculpt Gpencil, Select Box
218    3D View Tool: Sculpt Gpencil, Select Circle
219    3D View Tool: Sculpt Gpencil, Select Lasso
220    Sequencer Tool: Select
221    Sequencer Tool: Select Box
222    Sequencer Tool: Blade
223    Sequencer Tool: Sample

The above References are spat out by blender scripting console when running:

    import bpy
    for i, km in enumerate(bpy.context.window_manager.keyconfigs.default.keymaps):
        print(f"{i}\t{km.name}")

Note, these refer to what context one's cursor must be in during a Blender session, for key presses to actually activate. If, for example "User Interface" is used, the hotkey will only activate anything when the cursor is hovering over a user interface panel (not e.g. the 3D viewport). If, for example "Window", the hotkey will activate anywhere within the Blender application window

Region Types
region_type must be one of the following references:
[‘WINDOW’, ‘HEADER’, ‘CHANNELS’, ‘TEMPORARY’, ‘UI’, ‘TOOLS’, ‘TOOL_PROPS’, ‘PREVIEW’, ‘HUD’, ‘NAVIGATION_BAR’, ‘EXECUTE’, ‘FOOTER’, ‘TOOL_HEADER’], default ‘WINDOW’, (readonly)
Map Types
map_type must be one of the following references:
{'KEYBOARD_MODIFIER', 'KEYBOARD', 'MOUSE_WHEEL', 'MOUSE_GESTURE', 'MOUSE_BUTTON', 'MOUSE', 'NDOF', 'TWEAK', 'ACTIONZONE'}, (optional)
Space Types
space_type must be one of the following, where the left-side CAPS is the reference. Use the reference in your code:
EMPTY Empty.

VIEW_3D 3D Viewport, Manipulate objects in a 3D environment.

IMAGE_EDITOR UV/Image Editor, View and edit images and UV Maps.

NODE_EDITOR Node Editor, Editor for node-based shading and compositing tools.

SEQUENCE_EDITOR Video Sequencer, Video editing tools.

CLIP_EDITOR Movie Clip Editor, Motion tracking tools.

DOPESHEET_EDITOR Dope Sheet, Adjust timing of keyframes.

GRAPH_EDITOR Graph Editor, Edit drivers and keyframe interpolation.

NLA_EDITOR Nonlinear Animation, Combine and layer Actions.

TEXT_EDITOR Text Editor, Edit scripts and in-file documentation.

CONSOLE Python Console, Interactive programmatic console for advanced editing and script development.

INFO Info, Log of operations, warnings and error messages.

TOPBAR Top Bar, Global bar at the top of the screen for global per-window settings.

STATUSBAR Status Bar, Global bar at the bottom of the screen for general status information.

OUTLINER Outliner, Overview of scene graph and all available data-blocks.

PROPERTIES Properties, Edit properties of active object and related data-blocks.

FILE_BROWSER File Browser, Browse for files and assets.

PREFERENCES Preferences, Edit persistent configuration settings.

Key Types
Available keys and their references can be seen here, where the left-side CAPS is the reference, for the colloquial key name on the right-side. Use the reference in your code:
NONE Undocumented

LEFTMOUSE Left Mouse, LMB

MIDDLEMOUSE Middle Mouse, MMB

RIGHTMOUSE Right Mouse, RMB

BUTTON4MOUSE Button4 Mouse, MB4

BUTTON5MOUSE Button5 Mouse, MB5

BUTTON6MOUSE Button6 Mouse, MB6

BUTTON7MOUSE Button7 Mouse, MB7

PEN Pen

ERASER Eraser

MOUSEMOVE Mouse Move, MsMov

INBETWEEN_MOUSEMOVE In-between Move, MsSubMov

TRACKPADPAN Mouse/Trackpad Pan, MsPan

TRACKPADZOOM Mouse/Trackpad Zoom, MsZoom

MOUSEROTATE Mouse/Trackpad Rotate, MsRot

MOUSESMARTZOOM Mouse/Trackpad Smart Zoom, MsSmartZoom

WHEELUPMOUSE Wheel Up, WhUp

WHEELDOWNMOUSE Wheel Down, WhDown

WHEELINMOUSE Wheel In, WhIn

WHEELOUTMOUSE Wheel Out, WhOut

EVT_TWEAK_L Tweak Left, TwkL

EVT_TWEAK_M Tweak Middle, TwkM

EVT_TWEAK_R Tweak Right, TwkR

A A

B B

C C

D D

E E

F F

G G

H H

I I

J J

K K

L L

M M

N N

O O

P P

Q Q

R R

S S

T T

U U

V V

W W

X X

Y Y

Z Z

ZERO 0

ONE 1

TWO 2

THREE 3

FOUR 4

FIVE 5

SIX 6

SEVEN 7

EIGHT 8

NINE 9

LEFT_CTRL Left Ctrl, CtrlL

LEFT_ALT Left Alt, AltL

LEFT_SHIFT Left Shift, ShiftL

RIGHT_ALT Right Alt, AltR

RIGHT_CTRL Right Ctrl, CtrlR

RIGHT_SHIFT Right Shift, ShiftR

OSKEY OS Key, Cmd

APP Application, App

GRLESS Grless

ESC Esc

TAB Tab

RET Return, Enter

SPACE Spacebar, Space

LINE_FEED Line Feed

BACK_SPACE Backspace, BkSpace

DEL Delete, Del

SEMI_COLON ;

PERIOD .

COMMA ,

QUOTE “

ACCENT_GRAVE `

MINUS -

PLUS +

SLASH /

BACK_SLASH \

EQUAL =

LEFT_BRACKET [

RIGHT_BRACKET ]

LEFT_ARROW Left Arrow, ←

DOWN_ARROW Down Arrow, ↓

RIGHT_ARROW Right Arrow, →

UP_ARROW Up Arrow, ↑

NUMPAD_2 Numpad 2, Pad2

NUMPAD_4 Numpad 4, Pad4

NUMPAD_6 Numpad 6, Pad6

NUMPAD_8 Numpad 8, Pad8

NUMPAD_1 Numpad 1, Pad1

NUMPAD_3 Numpad 3, Pad3

NUMPAD_5 Numpad 5, Pad5

NUMPAD_7 Numpad 7, Pad7

NUMPAD_9 Numpad 9, Pad9

NUMPAD_PERIOD Numpad ., Pad.

NUMPAD_SLASH Numpad /, Pad/

NUMPAD_ASTERIX Numpad *, Pad*

NUMPAD_0 Numpad 0, Pad0

NUMPAD_MINUS Numpad -, Pad-

NUMPAD_ENTER Numpad Enter, PadEnter

NUMPAD_PLUS Numpad +, Pad+

F1 F1

F2 F2

F3 F3

F4 F4

F5 F5

F6 F6

F7 F7

F8 F8

F9 F9

F10 F10

F11 F11

F12 F12

F13 F13

F14 F14

F15 F15

F16 F16

F17 F17

F18 F18

F19 F19

F20 F20

F21 F21

F22 F22

F23 F23

F24 F24

PAUSE Pause

INSERT Insert, Ins

HOME Home

PAGE_UP Page Up, PgUp

PAGE_DOWN Page Down, PgDown

END End

MEDIA_PLAY Media Play/Pause, >/||

MEDIA_STOP Media Stop, Stop

MEDIA_FIRST Media First, |<<

MEDIA_LAST Media Last, >>|

TEXTINPUT Text Input, TxtIn

WINDOW_DEACTIVATE Window Deactivate

TIMER Timer, Tmr

TIMER0 Timer 0, Tmr0

TIMER1 Timer 1, Tmr1

TIMER2 Timer 2, Tmr2

TIMER_JOBS Timer Jobs, TmrJob

TIMER_AUTOSAVE Timer Autosave, TmrSave

TIMER_REPORT Timer Report, TmrReport

TIMERREGION Timer Region, TmrReg

NDOF_MOTION NDOF Motion, NdofMov

NDOF_BUTTON_MENU NDOF Menu, NdofMenu

NDOF_BUTTON_FIT NDOF Fit, NdofFit

NDOF_BUTTON_TOP NDOF Top, Ndof↑

NDOF_BUTTON_BOTTOM NDOF Bottom, Ndof↓

NDOF_BUTTON_LEFT NDOF Left, Ndof←

NDOF_BUTTON_RIGHT NDOF Right, Ndof→

NDOF_BUTTON_FRONT NDOF Front, NdofFront

NDOF_BUTTON_BACK NDOF Back, NdofBack

NDOF_BUTTON_ISO1 NDOF Isometric 1, NdofIso1

NDOF_BUTTON_ISO2 NDOF Isometric 2, NdofIso2

NDOF_BUTTON_ROLL_CW NDOF Roll CW, NdofRCW

NDOF_BUTTON_ROLL_CCW NDOF Roll CCW, NdofRCCW

NDOF_BUTTON_SPIN_CW NDOF Spin CW, NdofSCW

NDOF_BUTTON_SPIN_CCW NDOF Spin CCW, NdofSCCW

NDOF_BUTTON_TILT_CW NDOF Tilt CW, NdofTCW

NDOF_BUTTON_TILT_CCW NDOF Tilt CCW, NdofTCCW

NDOF_BUTTON_ROTATE NDOF Rotate, NdofRot

NDOF_BUTTON_PANZOOM NDOF Pan/Zoom, NdofPanZoom

NDOF_BUTTON_DOMINANT NDOF Dominant, NdofDom

NDOF_BUTTON_PLUS NDOF Plus, Ndof+

NDOF_BUTTON_MINUS NDOF Minus, Ndof-

NDOF_BUTTON_ESC NDOF Esc, NdofEsc

NDOF_BUTTON_ALT NDOF Alt, NdofAlt

NDOF_BUTTON_SHIFT NDOF Shift, NdofShift

NDOF_BUTTON_CTRL NDOF Ctrl, NdofCtrl

NDOF_BUTTON_1 NDOF Button 1, NdofB1

NDOF_BUTTON_2 NDOF Button 2, NdofB2

NDOF_BUTTON_3 NDOF Button 3, NdofB3

NDOF_BUTTON_4 NDOF Button 4, NdofB4

NDOF_BUTTON_5 NDOF Button 5, NdofB5

NDOF_BUTTON_6 NDOF Button 6, NdofB6

NDOF_BUTTON_7 NDOF Button 7, NdofB7

NDOF_BUTTON_8 NDOF Button 8, NdofB8

NDOF_BUTTON_9 NDOF Button 9, NdofB9

NDOF_BUTTON_10 NDOF Button 10, NdofB10

NDOF_BUTTON_A NDOF Button A, NdofBA

NDOF_BUTTON_B NDOF Button B, NdofBB

NDOF_BUTTON_C NDOF Button C, NdofBC

ACTIONZONE_AREA ActionZone Area, AZone Area

ACTIONZONE_REGION ActionZone Region, AZone Region

ACTIONZONE_FULLSCREEN ActionZone Fullscreen, AZone FullScr

Note the suggestions here and here on generally available keys
Also, see this visual reference for a map of all default hotkeys

Value
"value" must be one of the following references, corresponding to the nature of the button press or tweak:
enum in [‘ANY’, ‘PRESS’, ‘RELEASE’, ‘CLICK’, ‘DOUBLE_CLICK’, ‘CLICK_DRAG’, ‘NORTH’, ‘NORTH_EAST’, ‘EAST’, ‘SOUTH_EAST’, ‘SOUTH’, ‘SOUTH_WEST’, ‘WEST’, ‘NORTH_WEST’, ‘NOTHING’], default ‘NOTHING’

Hopefully this makes a little more sense of things, and helps you with creating your own basic addons


Is there a way to make gradient shadows? Fairly new Blender user here. I'm using Blender Render for this next project of mine and I'm wondering if there is a way to make smoother shadows for these arches.

As you can see, within the arches, each block seems to get less dark, as opposed to a smooth shadow. It might have something to do with how it's built. It is three different pieces, the arches themselves, the block roof and some cubes that fill in the empty space.

Being new, I couldn't really figure out how else to do it, but any input you guys might have would be great! Thanks!

EDIT:

As L0Lock said, to smooth an object, you can simply click on Smooth Shading (in the Tools panel, on the right of your 3D View > Tools > Shading > Smooth) and enable the Auto Smooth option (Properties panel > Data > Normals > Auto Smooth and play with the Angle value).

My first answer was to use both Smooth Shading and Subdivision Surface. Why that? Because it won't only create a gradient shadow, it will also smooth your shape, which is generally what you want. In that case, no need for the Auto Smooth, but you will have to add some edge loops close to your angles to keep your angles sharp. That said you'll probably need to change your topology to make it work:


Is the physics engine capable of reproducing this effect of a ball oscilating due to a water jet? [video] So I have this video: https://www.youtube.com/watch?v=yq_qSWZDHHk

I'm wondering, is it possible in a scene to add a water source on top and a rigid-body ball on the floor, and with the correct viscosity and friction between the floor and the ball, would the Blender physics engine by itself be capable of reproducing this effect?

That last part is important. I don't mean if it is possible to reproduce doing the animation by hand, I mean if the physics engine itself is capable of doing the animation just by having the initial parameters.

For this it's necessary for there to be friction due to viscosity between the liquid and the ball, and friction due to surface irregularities between the ball and the floor.

Any comment is appreciated, thanks.

Edit: this question (Physics cross-simulation interactions) was posted on 2013, as well as its answer, and I wanted to see if something had changed.

No, the fluid simulation system is independant of other simulation systems and can't interact with rigid bodies.

Rigid bodies can't be simulated with the fluid system either.

  Note that the simulator is not suitable for non-fluids, such as materials that do not “flow”. Simply setting the viscosity to very large values will not result in rigid body behavior, but might cause instabilities.

A workaround would be to simulate the rigid body before hand and "simulate" the fluid with placeholder objects, like force fields or other constrained rigid bodies or hand animation. That way it would appear as if the fluid system had an effect on the rigid body.
During the fluid simulation, the rigid body has to be set as a fluid obstacle. For the fluid simulation, it is irrelevant how the motion of the obstacle was created.
The fluid can't influence the rigid body.

Related questions:
Rigid body and fluid interaction
Fluid and hair interaction


Blender array modifier wont rotate around empty object I want to place object radiallty around a center pivot. I know it can be done with array modifier.
So I tried and got a weird result and I cant figure out what is wrong.
At cursor is the Pivot object. And the one above it is the original. I want to rotate it around Y axis so it would create a circle of these shapes, but instead I get this. And if I rotate the empty object in any way it just rotates the object around some random axis. I'm using blender 2.83. What am I doing wrong here?

When you give an Array modifier an object-offset target, there is a transform that would take the original of the arrayed object to the target.
For example:

The original cube is the one at 3 o'clock. Although the cube's mesh is at X=2, the cube's pivot, the object, is at 0, and aligned to the world. It's the larger yellow axes in the picture. (The mesh was moved in Edit mode, leaving the object behind.)
In the picture, there is also an Empty at 0, the smaller orange axes. The transform that would take the cube object to the Empty is a rotation of 30 degrees. The Empty is the target of the object-offset array.
The transform that would take the original object to the target in an object-offset array is the one that's given to each iteration of the array, with respect to the previous iteration. So, above, each element of the array is rotated 30 degrees from the previous one, about its own object axes.
In short, to get a clean rotation, without a translation being added, too, the object's axes must be coincident with the target, just rotated, that's all.


Could I use BGE, Python, and sockets to make a multiplayer game? Could I use the Blender Game Engine, Python, and Python's sockets module (internet data/communication module) to make a multiplayer Blender game?

Yes, you can.

Game aspect

You can use any Python network library (such as socket) to send and receive data. The BGE itself does not have a build-in network system.

Access method

I suggest to use a non-blocking polling operation. This means your python code asks the connection for the data received since the last run and applies it to the scene. When no data was received ... do not wait for data as this will block your game.

Threading

Avoid the usage of threads (as you often see in examples). This can cause conflicts inside the BGE game loop. Just Implement the inner code of the thread loop as a script.

Network business

The sole transfer of data (connecting, reading and writing) is pretty simple. The most work needs the business around that.

When to connect?

When to send what?

When to expect what kind of data in what format?

This strongly depends on your game.

Be aware you should think about:

Where to get the servers IP address?
How to authenticate a client?
How to create a lobby to bring the players together?
How to start a game session with known clients?
How do the participants of a game session communicate with each other?


How to achieve clean Topology at joining edge of dissimilar features? How can this topology be improved? Multiple attempts and several hours later, I have failed to create a successful all-quad mesh again. I keep trying to visualize face loops that define the edges I need on this object (a screw), but it is very difficult to join these dissimilar sections of geometry together. I have been watching tutorials/speed modelling sessions in an attempt to gain some further insight.

I am guessing that the round part needs to be spherical-ish, because if the verts are not distributed evenly, then it will appear lumpy instead of round/smooth...though clearly, the perimeter loop where the plus shaped area meets the round part has not-evenly-distributed verts all along that edge...

I tried to join the two edges and redistribute the verts to make them spherical, but it looks terrible. Here was that attempt (notice that the ridge is wavy and uneven...), I abandoned this approach after it seemed to be a lost cause:

And here is a later attempt, the round part is a bit lumpy/not-smooth...I also realized that there was a triangle here later on too (how would someone fix that? start completely over, since adding geometry would change the number of verts at the joining edge between the two surfaces?):

In Blender most of us would not model a screw by joining two separate meshes, one for the curvature and the other for the groove.

Other 3d packages such as AutoCAD / SolidWorks (and free alternatives) have a different internal representation of shapes. That's why boolean 'carving' is great for those kinds of programs. In those packages geometry remains a mathematical entity until converted to mesh-geometry for export.

In Blender we use mesh geometry (verts, edges, faces) all the way, and that means a different approach is worth considering. You've noticed that trying to match up two very different sections of mesh can be quite a  hassle.

Proportional Editing to the rescue!

I'd go for geometry roughly similar to this.

And the use Proportional Edition, move, to push the upper verts into that nice curve. Getting a dome curvature is the smaller problem with this kind of geometry. The biggest issue is thinking ahead about where you want sharp corners and you can do that as a flat surface first and extrude parts down later.

Enable proportional editing and press G to start moving, and Z to exclude the XY movement. Use Shift+Mouse wheel to adjust the sphere of influence. See the manual for more information about proportional editing
.

The outcome: (with some corrections to the base)


Match two planes with different origin locations (Blender Python Matrix Math) We see two identical Plane objects: A(blue) and B(red)
They are oriented arbitrarily in the 3D space.
Notice that the origin of A is located in the center and the origin of B is located in the lower left corner.
The problem:
What is the python code in Blender that will match the shapes of A to B perfectly.
I tried to match the matrices:
A.matrix_world = B.matrix_world

This matches location, rotation and scale of the objects but I still need to offset A by half width and half height in order to fit them perfectly.
Is it possible to do that with some of the available Matrix functions in Blender?

Face centre as "Pseudo Origin"

Given we have 2 single face planes, will make the face centre the "pseudo origin" and match that.

Test script, moving "Plane.001" to "Plane".  The difference in face centre coordinates vector is used to create a local transformation matrix. Premultiplying this by the matrix world will translate the "face centres" to match.

import bpy
from mathutils import Matrix
context = bpy.context
scene = context.scene
# going to match transform of p2 to p1
p1 = scene.objects["Plane"]
mw = p1.matrix_world
p2 = scene.objects["Plane.001"]

# local offsets
o1 = p1.data.polygons[0].center
o2 = p2.data.polygons[0].center
# match the face centers global coords
# local translation matrix
LTM = Matrix.Translation(o1 - o2)
p2.matrix_world = mw * LTM


Horizontal particle gravity I am trying to animate a collision between an asteroid and a planet. I have a particle emitter at the point where the asteroid hits the planet which emits particles, however they unrealistically fall down the Z axis.

Ideally I would like them to blow out from the planet then curve back and land on the planets surface due to the planets gravity. I would also like a smoke simulation to spread out from the area in a similar way, so a way that would do both would be great.

The closest I have got so far is animating force fields however they look very unrealistic.

My current situation:

Quick anwer, you can reorient gravity by changing the world setting on the scene tab.

From

to

However force fields can provide a more realistic collision at a planetary scale.

For example, here is a direct impact

and a glancing impact

To do something similar to this, do the following in Blender 2.76:

Create a new blend file.
Delete the cube.
Add a sphere for the planet.
Set the gravity in the scene to 0 for all axes.

Rename the sphere to 'Planet'. This is so we can refer to it easier later.
Set the physics for 'Planet'

On the physics tab select 'Force Field', 'Collision', and 'Rigid Body'. This will add several panels.
On the 'Rigid Body' panel, unselect 'Dynamic'. This will prevent the planet from moving due to the simulation.
On the 'Force Fields' panel set the force to a negative value. This will cause other rigid body object and particles to move towards 'Planet'. Use a value of -50 for this example.

Add another sphere. This will be the meteor which crashes in the planet. Rename this sphere 'Meteor'. You might also want to adjust the camera to keep both objects in view.
On the physics tab for 'Meteor', select rigid body. At this point, hitting play on the timeline (or alt-A) 'Meteor' should be pulled toward 'Planet' and stop when it hits the surface.

The final step is to add particles for the explosion on impact.
When running the animation note when the 'Meteor' hits 'Planet'. In this example it occurred at frame 27.
On the particle tab, add a particle system to meteor.

In the emission panel, Set the 'Lifetime' to a large number to make sure the particles persist through the animation. In this example, use 500.
Set the particle 'Start' and 'End' to the frame of the impact. In this example the value is 27. Adjustment may be required for the specifics of a simulation.
In the Velocity panel, set the 'Normal' velocity to a value large enough to overcome the velocity of the impact. In this example, a value of 15 was enough.
On the physics panel, select 'Die on hit'. This will cause the particles to disappear when they hit 'Planet'.

Play the animation using the play button or alt-A, and the result should include a shower of debris after the impact.

The blend file for the direct collision animation above is available at


Unable to match bevel curve to reference photo The problem
I'm sculpting an iphone. The project started with a plane. Then, to reproduced the outer curves bevel modifier was added. The problem is that after trying to match the curve angle, nothing is working.

The troubleshooting
After trying to change offset, profile and segment values the problem persisted.
How to solve it?
Thanks in advance.

I think your best bet is to make the bevel manually (without a modifier). You can use a custom bevel profile when you first create the bevel (this option is present in the modifier as well, but is much harder to work with, and doesn't always give the best results). You can then chose whatever shape you want by modifying the curve. You can do multiple edges/verts simultaneously this way as well (not shown):


Fluid simulation not working properly basically i wanted to create a fluid simulation in which the liquid (soy sauce) pours out of a kikkoman bottle. I've already set up the domain, the flow emitter inside the bottle (tried to use both geometry and an animated inflow to make the bottle fill up with liquid, without much noticeable change in the performance) and the collision effectors (the bottle itself and the cap, both with reversed normals to make the simulation run properly).
So this is kinda working, but just kinda, in the sense that the fluid is actually appearing without any problem but:

it looks like it's being "blocked" by something before it could even reach the cap, so that it can't get out;
maybe it is just a silly matter of preview/visualization/stuff-like-this, but  at a certain point the fluid (both particles and mesh) just disappears as if it was drained out of the bottle without being seen.

I'm not an expert of fluid simulation in blender at all, so it's very likely that i've just made a very stupid random mistake but i really can't figure out what the problem is.

front wiew of the simulation

upper view of the simulation

and here's the .blend file

Increase your solidify-moifier to a thickness of 0.2 and bake again.


Texture doesn't render with Cycles My Blender doesn't render textures in Cycles anymore. It worked before but if I now create a new project and apply a texture to an object it just gets rendered in a color present in the texture (see image).

I tried:
 * restarting
 * creating new prject
 * using different texture format (png/jpeg)
 * Changed render device (CPU/GPU)

I'm sure I didn't change any settings. I hope it's just something really simple I forgot :D

Thanks in avance for your help =)

You need to UV unwrap an object before an image texture will show up.

Here's a quick refresher on how it's done:

Select the object and hit TAB to enter edit mode
Change the selection mode to edges
Select all of your 'seam' edges
Hit Ctrl+E to bring up the edge menu and click 'Mark Seam'
Select all edges in the object by hitting 'A'
Hit 'U' to bring up the UV mapping menu
Select your unwrapping method. 'Unwrap' is the quickest

If your UV/Image editor window is open, you should be able to see the unwrapped object. From there you can mess with its position, rotation, and shape.

Hope this helps!


how to adapt a box to an object with a python script? First I create a bouding box around an object with this script :

selected = bpy.context.selected_objects
for obj in selected:
    #ensure origin is centered on bounding box center
    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='BOUNDS')
    #create a cube for the bounding box
    bpy.ops.mesh.primitive_cube_add()
    #our new cube is now the active object, so we can keep track of it in a variable:
    bound_box = bpy.context.active_object
    #copy transforms
    bound_box.dimensions = obj.dimensions
    bound_box.location = obj.location
    bound_box.rotation_euler = obj.rotation_euler

Then I resize the box like I wish :

bpy.ops.transform.resize(value=(1.4,1.4,3.5))

This is my result :

After that I want to resize only the highest face of the box so that it arrive 5 mm above the object, like this :

I already know this script to select the highest face of the bouding box :

object = bpy.data.objects['Cube']
object.select = True
me = bpy.context.object.data
bm = bmesh.new()
bm.from_mesh(me)
for face in bm.faces:
    center = face.calc_center_median()
    if center.z >= 1:
        face.select_set(True)
bm.to_mesh(me)
bm.free()

I equally know how to get the highest point of the object :

max = -9999
for i in obj.data.vertices :
    if i.co[2] > max :
        max_ind = i.index
        max  = i.co[2]

But I don't know how to position the highest plan of the box 5 mm above the highest point of the object ?

I found how to move the highest plan of the bounding box and position it correctly above the object :

activeob = bpy.context.selected_objects
cube = activeob[0]
bpy.context.scene.objects.active = bpy.data.objects[cube.name]
bpy.ops.object.mode_set(mode='EDIT')
mesh = bmesh.from_edit_mesh(cube.data)
ob = bpy.data.objects[cube.name]
matrix = ob.matrix_world
for v in mesh.verts:
    if v.select:
        v.co = v.co*matrix
        v.co.z += 20
        matrix_inv = matrix.inverted()
        v.co = matrix_inv*v.co


What is this U.V. artifact? So, I was just trying to really start mastering U.V. Unwrapping.  I was following this tutorial.  However, whenever I select the top of the mushroom and U.V. unwrap it: I get these strange artifacts in my mesh.  The overall screenshot can be seen here:  and you can see that I've highlighted the problem here:

What causes this, and how do I get rid of it?  (I assume that I should.)  What effect will this have on my wraps if left alone?

It's hard to say exactly what the items are that are perplexing you. One possibility is that they may be one or more faces on the inside of your mesh that you created by accident. If this is the case, you might locate them by switching to wireframe mode. To see if it's a poorly unwrapped face, switch to textured mode in the 3D viewport, and move the point that is active in the UV editor window and see where the texture on the textured mesh moves.


How to replace deleted vertices? New to Blender so sorry if this is a dumb question.  But it appears I forgot to turn off mirroring and accidentally deleted a vertex on the seam of my pants, leaving a hole in the texture.  How can I replace/recreate the deleted vertex?

I have tried merging the vertices but it messes up vertices.  I know right clicking is supposed to create a new vertex but that doesn't do anything when i try it.  I'm using 2.79 on Mac.  Any help would be greatly appreciated.  I'm so close to finishing my first project but I'm stuck until i fix this issue.  Thanks

As far as I understand your problem:

Select vertices 1 and 2. Press J to join them. This will create an edge, cutting through an existing face. Now you can right-click, subdivide and choose 3 as the number of new vertices (marked as 3, 4 and 5 above):

From here you could connect horizontal pairs 3 & 6, 4 & 7, 5 & 8, also by selecting a pair and pressing J. Then, finally, you can select vertices 9 & 10, press J to do a cut there as well to get quads. But then you need to press ⌘ + R for a loop cut to divide the quads above vertex 9 and below vertex 10. You would have to do the same right to 6 and 8.
Of course everything would be simpler if you just selected vertex 8, pressed G twice and moved it to the nearest vertex, similarly with vertices 6, 9 and 10, then if vertex auto-merging is disabled, you would press A then M then B to select all vertices and remove doubles, but I assumed those vertices are there for a reason.


The transform orientation after pressing 'g' and 'z' doesn't match 'Normal' transform orientation I've rotated the mesh to a position that no longer matches the global axis orientation but still want to transform my selection at right angles.

I have transformation selection set to 'normal', the z-axis becomes horizontal (which is ok I guess, as long as I can move in that direction.) but when I press 'z' to constrain my movement along that axis it locks it to the traditional z-axis vertical movement.

I can manually transform respective to the 'normal' transformation mode by grabbing the arrows but I want to input specific transformation values which is impossible with manual dragging.

First, as batFINGER says, the combination GZZ move object in local Z axis.

Second, why you said

  I want to input specific transformation values which is impossible
  with manual dragging.

Did you tried? Click and hold on the axis, and enter specific value from keyboard while you holding the mouse button.


Limit image planes to certain views In 2.79 you could limit which orthographic views you want to be able to see your image planes for references to be visible from. For example front, side, top, etc. For the life of me I can not find this function in version 2.80. All I seem to be able to find is to completely hide your images from all otho views, but no granular control over which ortho views. For instance, I want my "front" reference image to only be visible from the front otho view. Am I just overlooking this or was this removed in 2.80?

The functionality that is missing would be to see one reference image on every perspective. And yes you can no longer hide the image when you leave the front ortho view.

The easiest possibility is to set up a separate camera in Front-Ortho view and add a background image to the specific camera. If you leave the camera view the image will no longer be visible

To approximate what you want to achieve with a reference image you have to insert the image in "Front" View so the normal is aligned with the y-axis.Looking at the settings shown in this answer:

You have to uncheck "Display Perspective" so it doesn't show up in perspective view, And make sure you have "Front" Selected in the "Side" selector so it is transparent from the back.

You will however always see the outline of the plane.


setting color_set of armature to CUSTOM via python How can I set the color set for an armature to use custom colors by python? I know that when I choose one color set that it shows an info. The info looks like this:

bpy.context.object.color_set = 'CUSTOM'

But when I type this command in interactive console I get an error that Object has no attribute color_set

How is that possible?

import bpy
from mathutils import Color

obj = bpy.context.active_object
bone_group = obj.pose.bone_groups['Group']
bone_group.color_set = "CUSTOM"
bone_group.colors.normal = Color((1.0, 0.0, 0.0))
bone_group.colors.select = Color((0.0, 1.0, 0.0))
bone_group.colors.active = Color((0.0, 0.0, 1.0))


blender 2.83.2 viewport Render image color completely different System Information
Operating system: Windows-10-10.0.18362-SP0 64 Bits
Graphics card: GeForce RTX 2070 SUPER/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 451.48
Blender Version
Broken: version: 2.83.2, branch: master, commit date: 2020-07-09 05:50, hash: rB239fbf7d936f
Worked: 2.82 version of Blender that worked as expected
Short description of error

It's 2.83.2 version viewport render.

It's 2.82 version viewport render.
2.83 version has
The viewport image render result color is completely different compared to the viewport.
I tested in blender 2.9 alpha. the result is same.
Maybe Revamped color management update is cause.
How can I fix this mismatch?
Is it impossible because of technical problems?
Exact steps for others to reproduce the error

In viewport shading mode.
Click Viewport Render Image.
3.Compare result color
If It's hard to see. Tweak Exposure and Gamma and redo Viewport Render Image.

https://developer.blender.org/T77909
It's a bug at blender 2.83 may fix it blender 2.9


Split an edge in two? Is there a simple and quick way to add a vertex to an existing edge? I mean in a similar manner (Ctrl+R) like a loop cut for the whole object?

My current workflow is, deleting the edge completely, then I select one of the vertices and extend it via E shortcut. Is there an easier method to get an extra vertex like:

Select your edge, open the edge menu with Ctrl+E or the specials menu with W and select "subdivide"


How do I initiate a render from Python but still show progress bar and UI updates? When I run bpy.ops.render.render(write_still=True) from Python on large files, Blender goes into "(Not responding)" mode and the CPU spins like crazy for a few minutes. During this time, most users are confused as to what is going on in the application.

When you render manually from the GUI, it shows progress updates and gives the user a generally comfortable feeling that stuff is going on under the hood.

Is there any way to render from Python without freezing up the UI?

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

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

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


How to make rainbow ends fade out I needed to add a rainbow to a scene and found the info below that I used and made an awesome rainbow with just a few tweaks. The problem is that real rainbows usually fade out on the ends, the rainbow I make is from an extruded circle, and when I delete half of the circle the end is sharp and I can't find a way to fade out the ends of the rainbow. Is it possible?

Harold

BA thread How-to-improve-this-rainbow

One way to fix this is by placing the UVmap inside the texture space bounds :

then you can use the UV output directly in the ColorRamp input:

and here is the render :


How to add floating particles to a fluid simulation? I am trying to make a simple fluid simulation in Blender with floating particles in the fluid. I was able to create the fluid simulation, with materials and shadings to works. But I am having problems on how to add floating particles that follow the path of fluid.

I have come across this question myself and have not found an easy way to do it. I'm sure my answer isn't the best, but I hope it helps :D

Here we go:

Bake your fluid simulation
Create a plane and subdivide it a few times.
Shrinkwrap the object to your fluid simulation using the 'project' option.

Then use object constraints to bind the 'floating' object to the plane you just created on the z-axis. Remember to create a vertex group on the plane and assign it to the constraint.
Constrain the plane to the floating object on the x-axis and y-axis
Tweak the offset to get the correct depth

Best of luck with your project and I hope I helped,

BFB


Sharp tip in texture mode When I go in texture mode, there is soft circle to paint with.

Is it possible to paint with sharp lines like squares and circles with sharp edges?

I mean sharp edges when there is no soft gradient between black and white texture.

Circle brush

You can use Curve to change your tip sharpness. There are six presets for them and you can make your own as well.

Curve types:

Square brush

The best way to have square tip or any other shape is to prepare one in 2D software (Krita, Gimp, InkScape, Adobe etc.)

Make tip shape white and transparent background (for convenience sake) make it pretty big for good quality (4k in my example) and save it as PNG with Transparency then setup Texture Mask as below:

Blend file (square tip texture packed)


Camera switching in blender game engine 2.72 I am making a game in Blender 2.72, but in version 1.5a I decided to make a multiple camera view feature. I want it so that when you press C or F3(both are to do the same thing) the cameras will switch. I tried some tutorials, in which it was shown that actuators should work. I did all as said, but when I tested the game, it did not work as expected. I tried two different ways:

1.State 1
Keyboard C ------ And (state1) -------- State (set: 2)
Kayboard F3 ------/                  \- Scene (set camera: cam2)
State 2
Keyboard C ------ And (state2) ----------- State (set:1)
Keyboard F3 ---/                       \-- Scene (set camera: cam1)

2. State 1
Always(pulse) ------- And(state1) --------- Scene (set camera: cam1)
Keyboard C --------- And(state1) ---------- State (set: 2)
Keyboard F3 --/
State 2
Always(pulse) --------And(state2) ---------Scene (set camera: cam2)
Keyboard C ----------- And(state2) -------- State (set:1)
Keyboard F3 --/

Neither of these methods appears to have worked.

OK!
I found an answer:
This logic does not work, if 2 Keyboard sensors are connected to one And controller. Making different And controllers for each of buttons(C and F3) fixed this thing. Now it works for me!:)


Blenrig retargeting BVH motion I want to apply a BVH MOCAP to a Blenrig 5 rig.  I have tried re-targeting the BVH to the Blenrig using Mocap Tools, but can't select the performer rig to retarget.  Does Mocap Tools work with Blenrig?  Is there a better way to apply a BVH to a Blenrig rig?

OK, worked it out.  In case this helps someone else, shift click Right Mouse to select both rigs shows the targeting fields:


Adding sound in Blender can anybody tell me I tried to add sound effect of a chain falling in the floor in Blender? I tried it many time and it seems I did it in the wrong way! please help.

Sound can be added in the video sequence editor. Go to the video sequence editor, press Shift + A, click sound, and select the sound file you want to add.
Remember to change the audio codec, found under the Encoding scroll in the Render tab, from "none" to one of the other options.


Ellipse Construction Advice I'm working on a add-on for Blender, and part of this add-on requires me to calculate the position verts along the arc of an ellipse. At the moment, I'm using the { r_i^2 = (scale_x * cos(theta_i))^2 + (scale_y * sin(theta_i))^2 } equation with a fixed delta to the theta on the arc. This basically, gives you the same thing as if you were to scale a circle by different amounts along the x and y axis.

My issue with this is that the edges along the longer sides of the ellipse are longer than the edges along the shorter side of the ellipse. I want an algorithm that will create edges of (near) equal length.

I could do a binary search for the correct edge length. Yet, this algorithm runs quite often due to the different arcs with different edge counts, so a binary search for edge length might not work so well when I check to see if the edges fit the size of the given ellipse.

I was also thinking about trying the Parallelogram Method. The spacing of the points looks a bit better on the animated-image from Wikipedia, but I also noticed that that the image doesn't quite line up with instructions on creating an ellipse with this method I've managed to find on various sites.

I was wondering if anyone had any advice on fining equally spaced points along an ellipse when all you have are the number of points and the dimensions of the ellipse. I should probable add in that I'm only finding the points along a single quadrant, and I'm using mirroring to find the rest of the points.

I propose an adaptive approach :

The idea is to start from the simple x = a * cos(t) and y = b * sin(t).

Then calculate all the distances between the consecutive points, and progressively adapt the angle between them relatively to each distance compared to the average distance.

Note : this is to improve, as the last point (on top in the image below) does not "move". So its own angle does not vary as the others... edit : this note is false. After some tests, this is just matter of setting the good precision to reach (for instance set the precision to 0.00001 and all is ok and needs 6 iterations, so 6 * the amount of vertices calculations).

import bpy, bmesh
from math import radians, sqrt, cos, sin

rad90 = radians( 90.0 )
rad180 = radians( 180.0 )

def createVertex( bm, x, y ): #uses bmesh to create a vertex
    return bm.verts.new( [x, y, 0] )

def listSum( list, index ): #helper to sum on a list
    sum = 0
    for i in list:
        sum = sum + i[index]
    return sum

def calcLength( points ): #calculate the lenghts for consecutives points
    prevPoint = points[0]
    for point in points :
        dx = point[0] - prevPoint[0]
        dy = point[1] - prevPoint[1]
        dist = sqrt( dx * dx + dy *dy )
        point[3] = dist
        prevPoint = point

def calcPos( points, a, b ): #calculate the positions following the angles
    angle = 0
    for i in range( 1, len(points) - 1 ):
        point = points[i]
        angle += point[2]
        point[0] = a * cos( angle )
        point[1] = b * sin( angle )

def adjust( points ): #adjust the angle by comparing each length to the mean length
    totalLength = listSum( points, 3 )
    averageLength = totalLength / (len(points) - 1)

    maxRatio = 0
    for i in range( 1, len(points) ):
        point = points[i]
        ratio = (averageLength - point[3]) / averageLength
        point[2] = (1.0 + ratio) * point[2]
        absRatio = abs( ratio )
        if absRatio > maxRatio:
            maxRatio = absRatio
    return maxRatio

def ellipse( bm, a, b, steps, limit ):

    delta = rad90 / steps

    angle = 0.0

    points = [] #will be a list of [ [x, y, angle, length], ...]
    for step in range( steps  + 1 ) :
        x = a * cos( angle )
        y = b * sin( angle )
        points.append( [x, y, delta, 0.0] )
        angle += delta

    doContinue = True
    while doContinue:
        calcLength( points )
        maxRatio = adjust( points )
        calcPos( points, a, b )

        doContinue = maxRatio > limit
        print( maxRatio )

    verts = []    #edit : to add the edges
    for point in points:
        verts.append( createVertex( bm, point[0], point[1] ) )

    for i in range( 1, len(verts) ):
        bm.edges.new( [verts[i - 1], verts[i]] )

A = 2
B = 1

bm = bmesh.new()

ellipse( bm, A, B, 12, 0.01 )

mesh = bpy.context.object.data
bm.to_mesh(mesh)
mesh.update()

The algorithm seems to converge (stop) around 4 iterations for a 1% around the mean distance and around 6 iterations to be under 0.01%.

Not very mathematical, but it avoids complex analytical calculations...

 (edited : added edges)


Sub Surf and triangles Some of you might have seen my earlier question about how to make an edge in the hood of my car. I have now got that looking nice but with one exception: the edges of where the crease merges with the car have to be triangles as far as i am aware, which is causing subsurf to do some weird calculations. I have tried deleting and reentering the faces but that has not seemed to help.

Actually, Cole, they may not have to be triangles, only have to look like triangles. What I would do (I think), is to recast the triangles as quads where two of the vertices of the quad exactly co-incide, giving four vertices, and four edges, even though one of the edges has a length of zero.

Though not in this exact circumstance, this is a trick I have used in the past to good effect, though I've not tested it exhaustively, and it may not work, or may work with unanticipated side effects, in some cases.


Character's hands stretching when moved in Object mode I've been working on a character model that I have rigged, weight painted, and created poses and shape keys for. Everything has been going smoothly so far, with no unwanted distortion when I pose the armature. But for some reason, when I move the character in object mode, his hands become very distorted. It doesn't occur in Pose or Edit mode, only in Object mode. Does anyone know why this is happening and how it might be resolved?

(I would provide the blender file itself, but I can't seem to find a way to attach it to this post)

It's normal, the mesh is bound to your rig and when you move it away from it, you'll get weird deformations.
If you want to move the mesh object without the rig, you can temporarily uncheck its Armature Deform modifier's visibility.

Otherwise, the way to move the entire character is usually to move the rig object: because he is the parent of the meshes he deforms, they will move with them (unless you forgot some parts, which is also a way to check your work).
Though the most common way is to have an empty used as the parent of the armature object. This way you have the whole character wrapped in that empty's hierarchy, you get one more level of control, and it's more flexible. And you don't seem to have a root bone in your rig, so it would also fill this role.


Simply just adding a border of a different colour to a shape in edit mode It's incredible that I cannot seem to find a way of just simply colouring in the edges/verts differently to the colour of the faces of the shape. It ought to be simple right? And then... being able to just raise the thickness level on the line of the edge...

How do you do it?

I see at least 3 solutions. Note that if you want no shadow on your yellow, use an Emission shader:

1/ Create edge loops close to your angles, and assign your yellow color to all these edges.

2/ Duplicate your cube and give it a Wireframe modifier. Play with the parameters to increase or decrease the thickness of the wireframe.

3/ In Photoshop, create a picture with a blue square and yellow outlines. In the UV/Image Editor of Blender, open this picture, unwrap your cube and give it a material with an Image Texture node, with the cube picture as the image.