How can I add a panel to the properties area of the file browser? I would like to wrap my properties inside collapsible panels when using the ExportHelper or ImportHelper class but I can not figure it out how to draw them properly:

This is my code so far (reduced version of the Operator File Export template):
import bpy

# ExportHelper is a helper class, defines filename and
# invoke() function which calls the file selector.
from bpy_extras.io_utils import ExportHelper
from bpy.props import StringProperty, BoolProperty, EnumProperty
from bpy.types import Operator

class ExportSomeData(Operator, ExportHelper):
    """This appears in the tooltip of the operator and in the generated docs"""
    bl_idname = "export_test.some_data"  # important since its how bpy.ops.import_test.some_data is constructed
    bl_label = "Export Some Data"

    # ExportHelper mixin class uses this
    filename_ext = ".txt"

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

class SubPanel(bpy.types.Panel):
    bl_label = 'SubPanel'
    bl_idname = 'Sub_PT_Layout'
    bl_parent_id = 'export_test.some_data'
    bl_space_type = 'FILE_BROWSER'
    bl_region_type = 'TOOL_PROPS'

    def draw(self, context):
        layout = self.layout
        layout.label(text = 'test')

        use_setting: BoolProperty(
            name="Example Boolean",
            description="Example Tooltip",
            default=True,
        )

def register():
    bpy.utils.register_class(ExportSomeData)
    bpy.utils.register_class(SubPanel)

def unregister():
    bpy.utils.unregister_class(SubPanel)
    bpy.utils.unregister_class(ExportSomeData)

if __name__ == "__main__":
    register()

    # test call
    bpy.ops.export_test.some_data('INVOKE_DEFAULT')

Unfortunately I get the following error:

RuntimeError: Error: Registering panel class: parent 'export_test.some_data' for 'Sub_PT_Layout' not found

Q: How can I add a panel to the properties area of the file browser when using the ExportHelper or ImportHelper class?

You would have to add a draw() method along with a pass statement to the operator in order to skip drawing and declare a Panel class, get the actual operator from that class in order to draw it's properties. Demo based on the Operator Export template that comes with Blender:

import bpy

# ExportHelper is a helper class, defines filename and
# invoke() function which calls the file selector.
from bpy_extras.io_utils import ExportHelper
from bpy.props import StringProperty, BoolProperty, EnumProperty
from bpy.types import Operator, Panel

class ExportSomeData(Operator, ExportHelper):
    """This appears in the tooltip of the operator and in the generated docs"""
    bl_idname = "export_test.some_data"  # important since its how bpy.ops.import_test.some_data is constructed
    bl_label = "Export Some Data"

    # ExportHelper mixin class uses this
    filename_ext = ".txt"

    filter_glob: StringProperty(
        default="*.txt",
        options={'HIDDEN'},
        maxlen=255,  # Max internal buffer length, longer would be clamped.
    )

    # List of operator properties, the attributes will be assigned
    # to the class instance from the operator settings before calling.
    use_setting: BoolProperty(
        name="Example Boolean",
        description="Example Tooltip",
        default=True,
    )

    type: EnumProperty(
        name="Example Enum",
        description="Choose between two items",
        items=(
            ('OPT_A', "First Option", "Description one"),
            ('OPT_B', "Second Option", "Description two"),
        ),
        default='OPT_A',
    )

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

    def draw(self, context):
        pass

class CUSTOM_PT_export_settings(Panel):
    bl_space_type = 'FILE_BROWSER'
    bl_region_type = 'TOOL_PROPS'
    bl_label = "Settings Panel"
    bl_options = {'DEFAULT_CLOSED'}

    @classmethod
    def poll(cls, context):
        sfile = context.space_data
        operator = sfile.active_operator
        return operator.bl_idname == "EXPORT_TEST_OT_some_data"

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False  # No animation.

        sfile = context.space_data
        operator = sfile.active_operator

        layout.prop(operator, 'type')
        layout.prop(operator, 'use_setting')

# Only needed if you want to add into a dynamic menu
def menu_func_export(self, context):
    self.layout.operator(ExportSomeData.bl_idname, text="Text Export Operator")

def register():
    bpy.utils.register_class(ExportSomeData)
    bpy.utils.register_class(CUSTOM_PT_export_settings)
    bpy.types.TOPBAR_MT_file_export.append(menu_func_export)

def unregister():
    bpy.utils.unregister_class(CUSTOM_PT_export_settings)
    bpy.utils.unregister_class(ExportSomeData)
    bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)

if __name__ == "__main__":
    register()

    # test call
    bpy.ops.export_test.some_data('INVOKE_DEFAULT')

Make sure to add a poll() method to the panel, testing for the actual bl_idname of the operator otherwise the panel will appear for all other export operators as well.
@classmethod
def poll(cls, context):
    sfile = context.space_data
    operator = sfile.active_operator
    return operator.bl_idname == "EXPORT_TEST_OT_some_data"

Note: Once the export operator is registered you can use the python console and call its idname() method getting the proper bl_idname:
>>> bpy.ops.export_test.some_data.idname()
'EXPORT_TEST_OT_some_data'

Just for the sake, adding sub panels is possible as well:

import bpy

# ExportHelper is a helper class, defines filename and
# invoke() function which calls the file selector.
from bpy_extras.io_utils import ExportHelper
from bpy.props import StringProperty, BoolProperty, EnumProperty
from bpy.types import Operator, Panel

class ExportSomeData(Operator, ExportHelper):
    """This appears in the tooltip of the operator and in the generated docs"""
    bl_idname = "export_test.some_data"  # important since its how bpy.ops.import_test.some_data is constructed
    bl_label = "Export Some Data"
    bl_options = {'PRESET', 'UNDO'}

    # ExportHelper mixin class uses this
    filename_ext = ".txt"

    filter_glob: StringProperty(
        default="*.txt",
        options={'HIDDEN'},
        maxlen=255,  # Max internal buffer length, longer would be clamped.
    )

    # List of operator properties, the attributes will be assigned
    # to the class instance from the operator settings before calling.
    use_setting: BoolProperty(
        name="Example Boolean",
        description="Example Tooltip",
        default=True,
    )

    type: EnumProperty(
        name="Example Enum",
        description="Choose between two items",
        items=(
            ('OPT_A', "First Option", "Description one"),
            ('OPT_B', "Second Option", "Description two"),
        ),
        default='OPT_A',
    )

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

    def draw(self, context):
        self.layout.label(text="Hello World")
        #self.layout.prop(self, 'type')
        #pass

class EXAMPLE_PT_panel_1(Panel):
    bl_space_type = 'FILE_BROWSER'
    bl_region_type = 'TOOL_PROPS'
    bl_label = "Settings Panel 1"
    #bl_parent_id = "FILE_PT_operator" # Optional

    @classmethod
    def poll(cls, context):
        sfile = context.space_data
        operator = sfile.active_operator
        return operator.bl_idname == "EXPORT_TEST_OT_some_data"

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

        sfile = context.space_data
        operator = sfile.active_operator

        layout.label(text="This is the first Panel")
        layout.prop(operator, 'type')
        layout.prop(operator, 'use_setting')

class EXAMPLE_PT_panel_2(Panel):
    bl_space_type = 'FILE_BROWSER'
    bl_region_type = 'TOOL_PROPS'
    bl_label = "Settings Panel 2"
    bl_parent_id = "EXAMPLE_PT_panel_1"
    bl_options = {'DEFAULT_CLOSED'}

    @classmethod
    def poll(cls, context):
        sfile = context.space_data
        operator = sfile.active_operator
        return operator.bl_idname == "EXPORT_TEST_OT_some_data"

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

        sfile = context.space_data
        operator = sfile.active_operator

        layout.label(text="This is the second Panel")
        layout.prop(operator, 'type')

# Only needed if you want to add into a dynamic menu
def menu_func_export(self, context):
    self.layout.operator(ExportSomeData.bl_idname, text="Text Export Operator")

def register():
    bpy.utils.register_class(ExportSomeData)
    bpy.utils.register_class(EXAMPLE_PT_panel_1)
    bpy.utils.register_class(EXAMPLE_PT_panel_2)
    bpy.types.TOPBAR_MT_file_export.append(menu_func_export)

def unregister():
    bpy.utils.unregister_class(EXAMPLE_PT_panel_2)
    bpy.utils.unregister_class(EXAMPLE_PT_panel_1)
    bpy.utils.unregister_class(ExportSomeData)
    bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)

if __name__ == "__main__":
    register()

    # test call
    bpy.ops.export_test.some_data('INVOKE_DEFAULT')

Related: How do a create a foldout UI panel?

If you'd like to add a checkbox to one of the panel headers, declare a BoolProperty in your operator (alternatively use the scope of the window manager):
class ExportSomeData(Operator, ExportHelper):
    ...
    bake = BoolProperty(default=False)
    ...

And call Layout.prop() in the dedicated draw_header() method of the panel:
def draw_header(self, context):
    sfile = context.space_data
    operator = sfile.active_operator

    self.layout.prop(operator, "bake", text="")

Related: How to add a checkbox to a panel header?


Materials: How to compare two vectors? I'm looking for a method that compares two vectors in order to use a mix color/shader.

Example : If the camera looks at the object from atop (as the two vectors align) it should select material A. As the camera moves to a different angle away for top of the object, the material gradually change for B.

What I want to do :

It has to be based on the object orientation and not the world origin (x,y,z).
It should allow to select any angle as an input. This means calculations with the object orientation and the input vector.
It cannot be a Facing as it is based on face Normals and wouldn't select the material for the whole object but only for faces.

I thought I had to get:

Camera angle
Object Angle (pivot) + Any angle I choose (as an
input)

Input>Camera Data is the one for the camera (obviously).

I cannot find the orientation of the object (or something related). The nodes Input>Geometry and input>Object data do not seem to provide that data.

Converter>Vector Math seemed to be a good candidate.

Basically I thought a subtract or a Vec1,Vec2 angle comparison would be ok.

But everything I try is not working. Not even close. Any help is welcomed.

EDIT 1:
I hope those images will help understand the question.

Situation 1 : The camera is aligned with the purple vector. Suzanne has a blue material. BTW This vector is determined by user.

Situation 2 : The camera is NOT aligned with the purple vector. Suzanne has a completely different material.

EDIT 'going further with @Shady'
@Shady puck has provided step one solution. When the camera aligns with the Z axis of Suzanne the material is properly selected. I made a blend file and attached it here to document it properly.

more testing on solution A by @Shady puck

Edit 'Going further with batFINGER'

Remarkable. The concept of using one object to provide the necessary data is good as it provides levers (sort of) that can be easily manipulated in the scene. I did implement your solution and did some tests. I only took the liberty of changing some names in your script. Also I took care of respecting name conventions (sort of speak).

A/ It seems I have to select the control object (in this case the yellow cone) before using the animation slider to be able to see a change. It non the less render.

B/ It seems when I press space (B2.80) the animation has trouble changing the colors unless I move the mouse cursor over the custom panel/TextInput named “angle” (in and out). Rendering it, doesn’t seems to work.

C/ If I clear all links and then “link” Suzanne and the Camera, it works but only sometimes and I don’t know why. Selecting one or the other isn’t a guaranty of success. Which makes me wondering about A a little more. Rendering in EEVEE also make the material flicker between 2 colors when I’m luck to see any change.

Maybe I did something wrong. Blend file provided.

You can use a modification of a Vector Product. Here is the node setup:

Let me explain how this works. First, Geometry > Normal gets the normal vector of each point on the object. The Separate XYZ and Combine XYZ nodes respectively isolate the z-component of each vector and return that value as a vector. Because vectors that lie more in the xy-plane than others will have a smaller z-component, it is necessary to normalize every vector.

At this point, it would generally do to use the Dot Product to compare the magnitudes of the two vectors. The Dot Product maximizes when vectors are parallel and minimizes when they are perpendicular. For some reason (someone please edit if they know why), the Dot Product is rather glitchy in this case. So I substituted the Cross Product, which maximizes when vectors are perpendicular and minimizes when they are parallel. This had the desired effect. I compared the z-vectors with the Geometry > Incoming vector, which gives the vector from a point to the camera.

Normal vector: A vector that is perpendicular to the surface at the given point.
Normalize: To make a vector or vectors all a standard length (usually 1 unit).

Vector math is a fascinating subject. Consider reading more about the cross product (sometimes referred to as the "Vector Product") here.

Edit 1

As the OP referenced, the above solution separates out the view from the $\pm$z-axis for material selection. Now for a custom view, the so-called pink arrow. Try as I might, I could not find an automated solution that directly pulls the rotation data from the pink arrow in the scene.

First, a note on how vectors are defined in three dimensions.

Google Images

A vector, like the one represented by the pink object above, has an x, y, and z-component. In the picture above, to "get" from the origin of the graph to the tip of the vector would require you to move +2 units in the x-direction, +3 units in the y-direction, and +5 units in the z-direction.

This data can be directly (by hand) entered into the node editor. To compare the camera view to the pictured vector, enter the pictured data into the Vector Math > Normalize node, as follows. This has the added advantage of normalizing (see above) the vector at the same time.

Now, with mostly the same node setup...

...we get this result (my pink vector is the (2,3,5) one). Note that the sphere aligns with the pink vector while Suzanne aligns with the z-axis.

For your vector of choice, use the above info on defining vectors to define yours and substitute its components.

Component: A part of a vector that gives its magnitude in one, specific dimension.

Edit 2

Looks to me like my edit worked, but you defined your vector in terms of local as opposed to global coordinates. I have modified your nodes in your .blend file to line up with the pink vector as follows.

I took these two screenshots of the global coordinates -- first of the base of the vector and second of the tip of the vector:

Let's call the ordered pair of the base $(x_0,y_0,z_0)$ and the ordered pair of the tip $(x_1,y_1,z_1)$. From this data, it is possible to find each component of the vector by subtracting$$n_0-n_1=\vec{n}$$
Therefore,$$\begin{align}
x_1-x_0&=\vec{x}=0.799\\
y_1-y_0&=\vec{y}=-2.203\\
z_1-z_0&=\vec{z}=0.657\\
\end{align}$$

If we plug these values into the Normalize node, we get the expected behvior.

Ordered pair: A group of elements denoting the one dimensional translations necessary to move from the origin to a point.


Animating a mesh deformation using python I have a 3D mesh in Blender that undergoes some modifications. The mesh is imported from python data. By using a python script, I modify the location of the vertices of the mesh to move them along the normal according to a function which is defined for every single vertex in the mesh. This function is also defined for N frames and determines the amount of vertex translation along the local normal for each frame, i.e. f(iVertex, iFrame). This can create an animation if played from frame number 1 to frame N. In addition, the mesh itself is not translating or rotating and in fact, it is its shape that undergoes gradual deformation and change. I am looking for a strategy that can animate this shape deformation using a python script.

As suggested by Chebhou, the problem can be addressed perfectly and very elegantly by using frame_change_pre. I was inspired by the example that was posted here and I bring it here for the readers' convenience:

import bpy
import math

# for demo it creates a cube if it doesn't exist,
# but this can be any existing named object.
if not 'Cube' in bpy.data.objects:
    bpy.ops.mesh.primitive_cube_add()

frames_per_revolution = 120.0
step_size = 2*math.pi / frames_per_revolution

def set_object_location(n):
    x = math.sin(n) * 5
    y = math.cos(n) * 5
    z = 0.0
    ob = bpy.data.objects.get("Cube")
    ob.location = (x, y, z)

# every frame change, this function is called.
def my_handler(scene):
    frame = scene.frame_current
    n = frame % frames_per_revolution

    if n == 0:
        set_object_location(n)
    else:
        set_object_location(n*step_size)

bpy.app.handlers.frame_change_pre.append(my_handler)


Script to separate shared vertices that have different UV's, normals and colors So i'm making a model format for my Unity game, and i ran into an issue: Normals, UV maps and vertex colors in Unity are per-vertex instead of per-triangle, so i'll need a python script that automatically duplicates the vertices that have more than one UV, normal or color and rearrange the triangles accordingly. I can't do this myself yet cause i'm a beginner when it comes to Python, what i've been doing is saving each triangle separately and stitching them inside the game, but that takes AGES.
Thanks in advance :)

As you noted most data is stored per-face in blender; in the UI it is called "face corner data", the API calls it "loops".

This is fairly simple: just loop over the polygons, get all vertex data you need, pack it into hex, append the vertex to a list if it is a new one (using a dummy vertex to avoid duplicating too often due to inconsistent normals) and finally index the polygon's vertices in the vertex list to get the polygon's exported indices.

#output
mesh_vertices = []
mesh_triangles = []
#used to ignore the normals for checking equality
dummy_vertices = []

for polygon in me.polygons:
    tri=[]
    for loop_index in polygon.loop_indices:
        vertex_index = me.loops[loop_index].vertex_index
        co = me.vertices[vertex_index].co
        no = me.loops[loop_index].normal

        bfb_vertex = pack('3f',co.x, co.y, co.z)
        bfb_normal = pack('3f',no.x, no.y, no.z)
        if me.vertex_colors:
            bfb_col = pack('4B',int(me.vertex_colors[0].data[loop_index].color.b*255),
                                int(me.vertex_colors[0].data[loop_index].color.g*255),
                                int(me.vertex_colors[0].data[loop_index].color.r*255),
                                int(me.vertex_colors[1].data[loop_index].color.b*255))
        bfb_uv = b''
        for uv_layer in me.uv_layers:
            bfb_uv+= pack('2f',uv_layer.data[loop_index].uv.x, 1-uv_layer.data[loop_index].uv.y)
        #we have to add new verts also if the UV is different!
        if bfb_vertex+bfb_uv not in dummy_vertices:
            dummy_vertices.append(bfb_vertex+bfb_uv)
            mesh_vertices.append(bfb_vertex+bfb_normal+bfb_col+bfb_uv)
        bfb_vert_index = dummy_vertices.index(bfb_vertex+bfb_uv)
        tri.append(bfb_vert_index)
    mesh_triangles.append(pack('3h',*tri))


Cylinder becomes deformed at corners with curve modifier I'm trying to use a rectangle converted into a curve, used with a scaled down cylinder combined with an array modifier to use as decorative trim around some woodwork but the cylinder becomes deformed pinches inward around the corners. Is there a way for me to compensate for the deformation and maintain the scale around the entire modified curve?.

!!! Check out my other Answer which avoids using the curve modifier.

If you don't want a curved look at the corners but you have to use the curve modifier then you might do this:

Since the curve modifier tries to displace vertices along the curve you need some more vertices so the deformation can be closer to the real shape of the curve. So a simple solve would be to add some loop cuts to your rope or do the detail modeling of the rope first (because then the rope will probably have many more vertices anyway).

Also for the modelling part of the rope-like ornamentation maybe have a look at the rope-modeling answer by @Robin Betts:
How to make a rope curving in a certain way

Happy Blending! :)


Emition Bake is partly too dark So, I was trying to bake an albedo map with emission shader and for some reason, some part of the texture is always too dark. It's not the normals, I flipped them many times, tried different texture sizes, used a different UV map and practically tried every trick in the book to make it work.
Here is the render from emission shader + bake

And here the applied material

Please can someone help? I'm out of ideas...

Okay, I found a solution which works for me. I tried to bake an albedo together with the ao-node. Part of it doesn't show correctly on the texture...
AO Bake didn't solve the problem either, so I baked an ao-texture as an emission texture which solved my problem.
Still don't know why blender did this or what went wrong, but it did work for me


How remove mask texture I was painting a texture on an object, and then i click on 'Mask' tool. But i have an error:

My question is simple: how i retrieve my paint tools? I don't want to use a mask.

Thanks

The brush you have selected has it's type set to mask and there is no image chosen as the stencil image. Most likely you selected the mask brush.

To get out of it, you need to select a stencil image, then you can change the brush or the brush type. You then need to remove the stencil image from the slots menu or by disabling the "Mask" checkbox.


Scale F-curve from time/ 3D cursor A while ago I saw a demo where the f-curve could be scaled from a specific point in the time line - if I remember correctly determined by the 3D cursor - but I have not been able to recreate it. What I want to do is scale the points along the X-axis from a certain start frame. The default behavior seems to be the scaling is always from the middle which is not helpful in my case. Any ideas what I am missing?

I overlooked the 'hidden' menu, obscured by my small window. With thanks to Mr Zak for pointing out the 'change pivot', and my discovery of the 2D cursor.


Cycles generates distorted depth The depth map generated by the Cycles rendering engine seems to have (radial) distortion, while the Blender renderer does not.

However, I could not find anywhere information on the internal camera model used by the Cycles engine, leading to this very post.

Specifics

With the Blender default scene and default parameters, I use a Viewer node connected to the Z Render layer and a python script to read the generated depth map, compute 3D point coordinates and export as OBJ.

The node graph is very simple:

The export python code too:

import bpy
import numpy as np

print("exporting depth pointcloud to OBJ...")

scale = bpy.context.scene.render.resolution_percentage / 100

pixels = bpy.data.images['Viewer Node'].pixels
img = np.array(pixels[:]).reshape(int(bpy.context.scene.render.resolution_y * scale), int(bpy.context.scene.render.resolution_x * scale),-1)

camdata = bpy.data.objects["Camera"].data

sensor_height = bpy.context.scene.render.resolution_y / bpy.context.scene.render.resolution_x * camdata.sensor_width

f = open("/tmp/pointcloud_blender.obj","w")

for u in range(0, img.shape[1]):
    for v in range(0, img.shape[0]):

        d = img[v, u][0]

        if d > 100.0:
            continue

        x = d * (0.5 - float(u) / float(img.shape[1])) * camdata.sensor_width / camdata.lens;
        y = d * (0.5 - float(v) / float(img.shape[0])) * sensor_height / camdata.lens;
        z = d;

        f.write("v " + str(x) + " " + str(y) + " " + str(z) + "\n")

f.close()

print("DONE")

When rendering with the Blender internal engine, the generated point cloud looks like the square as it should (white), but the Cycles rendering engine gives a distorted point cloud (red):

When looking at the depth maps, one can clearly see a radial distortion (Blender render vs Cycles render, exported with File Output node):

This is a cut of the depth maps (blue, green) and difference image (red) at row 240:

(the two depth maps being different are not really the problem here, as long as I have the correct unprojection model)

Research

I looked in the documentation, in this answer stating that the Blender camera has no distortion coefficients, on this blog that is the correct model I use for the Blender camera.

I also studied the code for Cycles (src/render/camera.cpp, src/util/util_projection.h, src/util/util_transform.h) but could not find any trace of radial distortion.

Question

Does anybody have an idea of the internal camera model used by the Cycles rendering engine ? Or how to compute correct camera intrinsic parameters ?
I guess the lens has distortion, but I could not find parameters or even code running this.

I need to be able to use the point cloud from the depth maps from different views, but with distortion they are not usable.

Thanks !

Thanks to the Blender dev forum, I figured it out.

The Cycles camera is a pinhole model that "uses the distance between a given point and the pinhole as its Z depth".
So we cannot apply the depth to points on the camera plane, but rather points that lie on the unit sphere, hence normalized.

Here is the correct formula to unproject a camera pixel into a 3D point :

    import math

    # coordinates on camera plane
    x = (0.5 - float(u) / float(img.shape[1])) * camdata.sensor_width / camdata.lens;
    y = (0.5 - float(v) / float(img.shape[0])) * sensor_height / camdata.lens;
    z = 1.0;

    norm = math.sqrt(x*x + y*y + z*z)

    # normalize = project point on unit sphere, then apply depth
    x = d * x / norm
    y = d * y / norm
    z = d * z / norm

The relevant code is in kernel_camera.h


Game animation from other video file into blender animation (adding to the existing video file) I made tablet model in Blender. I also made animation where object is moving but I want to add some game animation (from other video file) on tablet display but I don't know how. If you have any link with tutorial where it is shown please send me it.

I want obtain such an effect video

This is possible by assigning to your tablet model "screen" surface (probably a rectangle) a "image or movie" texture (obviously choosing your movie). Of course you need to learn how to correctly assign the texture to your mesh. You could do this either by UV mapping or using a separate material for the "screen" surface...

To add the video after the tablet animation is done, you can use video tracking to map your video to the screen area, but you will need to have  some good tracking feature in the animated screen, to get a good result (you need to be able to set good markers)


How to round multiple faces in Edit Mode is there a way like in the subdivide window in Edit Mode to round faces? I want a round arm.

The feature in the subdivide pane is Smoothness

@JohnEason pointed it out. With the Looptool Addons it is possible.

enable Loop Tool Plugin in User preferences
Select faces
use Circle ub the editor tab


Output to printable file 3D model so i created a really detailed model of what I need 3D printed. but when I try to export it to a 3D printing software it does not do what I want.
It creates infill in spots that I specificly designed to be empty,
it makes up empty layers, while in my model in blender its completely filled
it just in general does not do what I want.
I made the model with exact sizes that it needs to be etc. I really could use the help.

I exported the file as an STL into Cura, and I saw your problem. The way I fixed it was by adding a solidify modifier to both of the meshes. You don't need to add a lot of thickness, but you do need some (I added 0.02 m).
Let me know if it works.


Blender export to Unity I tried to export blender assets to Unity.
I know it's a common thread in this Stack.
But I still didn't figured it out.

Blender crash like half a time whenever I try to bake.

I figure out how to get the baked images, and save it in a texture folder.

But the FBX export doesn't have the required material in UNITY and show only in with grey mat.
Whenever I try to make my own material with the baked image and apply to the models, it doesn't fit to the models, it is not following its UVs.

Is there a "easy" way to export to fbx including its materials.
I tried FBX addon bundle exporter but it did not work.
(Missing files I guessed ?)

I'm using the Cycle render with the PBR Materials Add on Blender 2.79.

Exporting from Cycles to FBX is somewhat fiddly at the moment still.
As far as i'm aware the exporter reads only trough a principled node - and then not all slots.
I found this Method to somewhat work, its essentially the same as it has been with the old Blender render:

1. For the images to be packed into the .fbx there are two important parts, first you need to connect them to certein inputs of a principled bsdf node. Sadly not all work tough (at least for me atm) i expected the normal input to also work, but it didn't.

2. When exporting to .fbx theres two settings you need to change:

You need to change "Path Mode" to "Copy" and hit the small icon behind it, i'm currently on 2.8 but the method should apply to 2.79

After that, you can try to reimport the texture into Blender, your Textures should show up in the image/UV Editor.


Sphere distortion when attached to path I'm new to Blender. Now I'm working on a low-poly model of Earth orbiting Sun and I have a strange problem. I added Follow Path constraint to my Earth so it follows elliptic path around the star. But for some reason if I rotate Earth by Z axis (and follow path is added) there is a distortion (see image). How can I fix this? I need animation of following path and rotating by Z axis too. Thanks

To make my path elliptical I scaled it by X axis and object on it's path has been automatically scaled too.


Weird shading transparent texture for grass Im trying to make polygon grass using the addon images from plane to import a grass texture with transparent background and im using particles to place them all over a plane. When they are widely spread between each other the texture looks normal but if they are close they have some weird black shading/shadow. I upload a picture to show what i mean...

This could have something to do with your render settings. Try to increase the values under Light Paths -> Transparency.


What's The Library Blender Uses to Draw? ok, I tried to use PIL library in blender to render Particle system just by drawing circles in given locations, but this is not a good Idea, it takes much longer than expected, but the worst thing about it's the strange circles that the library makes with the Draw.ellipse() function, those are more like Exagons.

I was wondering what's the Library that Blender uses to draw like preview or to make compositing too.

Blender's drawing code is all custom C code calling opengl functions. Even the ui widget toolkit is custom. There is no python library.

As suggested by batfinger, you can use bgl, blender's opengl wrapper for python if you need custom drawing.


How do I clean up text characters converted to mesh? I have found a time consuming way to create one mesh object per character.

Start with a text object:
"abcdef ...etc..."

Alt+C -> Select object and convert text to mesh.
Tab -> Go to edit mode.
Z -> Enter wire frame view
B -> Select each character with box select one at a time.
Select bridge edge loops
P -> separate by selection

Repeat for each character.

Is there a way to bridge edge loops for all loose parts? A faster simpler way? Script?

Example of the problem with the mesh from text:

Instead of using Bridge Edge Loops, use Remove Doubles.

W > Remove Doubles.


Flatten surface on inclination Trying to model a Hull of a sailboat, but i get this line in the middle. I use Mirror modifier, and in intersection the line appears. Is there any way to solve this?

In the linked file I can't see the same thing as you, but for example you have this artifact:

It's because you have ngons, face with more than 5 vertices, which tends to create artifacts, especially on non-flat surfaces (it stretches the triangles):

Here is a way to fix it, there might be a better but it's just to show you how to keep quads:

Also, you use crease and Bevel modifier, if you begin in modeling perhaps you should bevel "manually" instead, and avoid crease and Bevel modifier, they are tricks and you won't always be able to use them, but it's only my opinion...


Edge split to make flat edge not working I've been struggling with this one for a day now.

I will have to tackle why all of a sudden everything I put in game is extremely pixelated as well. However the issue I have here is the strange "x" shaped shadow that seams to lead into the handles at the centre. That is directly mirroring the triangulated mesh. In the past with weird artifacts like this usually marking the edge around it sharp and doing edge split modifier works but it is not working here. You can see the cyan lines where I tried to mark sharp edges usually this sort of thing would solve it. I have no idea what alternatives there are to flatten the plane of each drawer. Is it a normals thing? Do I need to fix those in some way too? I'd like to find something else besides Edge Split since it piles onto the mesh making it bigger in size.

Thanks in advance.

Blender file

The X shaped shadow in your shader might be due to the triangles leading to the inner circle, you could try deleting those triangles and recreating using quads instead:


How to do Trammel Of Archimedes Animation? How does one make a Trammel Of Archimedes?

  Trammel of Archimedes

  A trammel of Archimedes is a mechanism that generates the shape of an
  ellipse. It consists of two shuttles which are confined ("trammelled")
  to perpendicular channels or rails and a rod which is attached to the
  shuttles by pivots at fixed positions along the rod.

  As the shuttles move back and forth, each along its channel, the end
  of the rod moves in an elliptical path. The semi-axes a and b of the
  ellipse have lengths equal to the distances from the end of the rod to
  each of the two pivots.

How does one do a looping animation like this?

Animate both "shuttles" moving on different axis by keyframing their X and and Y positions in sync. Start at say $X=-1$ at frame $0$ then $X=1$ at frame $30$, and back at $X=-1$ at frame $60$, repeat for Y axis for the other shuttle.

In the Curve Editor move their animation curve keyframes so that they are offset by "half a cycle". That is if one apexes every $x$ frames, the other one should apex at frames $x+1.5x$.

Add a Cycles modifier to both curves so they repeat indefinitely.

Create a "bar" object, move it so that it's origin it is exactly coinciding with one the shuttles, then parent the bar to that shuttle with Ctrl + P.

Add a Track to Constraint pointing to the other shuttle, adjusting the axis settings as necessary.

As mentioned by Robin Betts, for a mathematically perfect animation the f-curve should be a perfect sine wave. Use a Built-in Function f-curve modifier instead of manually keyframing the shuttels and using the Cycles modifier.

Set it to a Sine function, so the shuttles have mathematically correct motion relative to each other. With the previously described technique you will notice a wobble between the second bar hole and the corresponding shuttle caused by the manually keyframed animation.


Mapping for Displacement Modifier I'd like to create procedural rocks and so I checked out some tutorial videos. The techniques should be similar, so I also checked out 3ds max tutorials.

This one caught my attention:

3dsmax Environment Modeling #1 Procedural Stone

It basically uses a displacement modifier, creates a Voronoi diagram and applies a spherical mapping to the model. These steps look like this:

Question

Does anyone know if Blender has a mapping option for the displacement modifier? I can't find it. Or does anyone know a similar or better approach to create that kind of rocks in Blender?

Start with a simple cube, add Subdivision Surface to produce enough geometry for decent displacing (you can add another one after Displace modifier for more smoothing).

Add Displace modifier, press New button, go into texture tab and select Voronoi texture.

In Displace modifier settings there are some options for texture coordinates: UV, Local, Global, Object.
There is no usual coordinates offset as in materials, so you need to bind texture to some object. Thus location, rotation and scale of this object will affect texture.

"Wire sphere" around the rock is Empty, which is controlling texture:


Transfer weight paints / copy vertex groups results in destroyed mesh My goal is to have one blend file with many characters (meshes) which
are all assigned to the one armature.

Currently i have a well designed and (already rigged) character, originally imported as collada file (and created with adobe fuse).

I added some control bones and IK to make the character more flexible. So until this point everything works perfect.

But now my problem:

When i try to add an other character mesh and assign it to my current existing armature i have to transfer my vertex groups and weight paints because i also want to reuse them. But the transfer weight / copy vertex groups results in a strange deforming mesh.

EXPERIMENT 1:

The second (deformed) character mesh
after the usage of "Copy vertex group to selected"

RESULT: Mesh is heavily deformed

EXPERIMENT 2:

The second (deformed) character mesh
after the usage of the modifier "Data transfer"
-> Vertex Group(s) / All Layers / By Name

RESULT: Mesh is a little bit deformed

It should be possible to copy the vertex groups and weight paints without quality issues, but i don't get it :-/

Warning I answer here about the weights transfer problem but this answer does not handle the "one armature" mentioned at the begining of the question.

From my experience, this approach can work only if the 2 meshes (the prerigged source and the destination to be rigged) are very close to each other.

This can be done more or less easily using mainly mesh deform and shrinkwrap modifiers and eventually doing a quick parenting (with automatic weights) on the source mesh (a copy of it).

Mesh deform or the parenting are here to bring the source mesh closer to the destination. And the shrinkwrap is here to give more accuracy to the correspondance of the two meshes.
In this process, you'll need to take into account each bones junctions by placing the (temporary) deformed mesh in accordance to these junctions.

If all these conditions are not met, the data transfer wont work correctly (this is at least my experience).
Also, the point is to evaluate the shorter process : rigging again your other meshes or using this kind of method.

If you choose the data transfer, you'll probably need to use "projected face interpolated" option and eventually the ray radius value (not to low and not to big). Becareful : these options may needs much more calculation time.

Edit 1/note : I encountered some problems with the "data transfer modifier" as the "Data transfer / data" in the tool panel works well (shortcut CtrlShiftT) (same function and options but not a modifier).

Edit 2 : another approach, dependy on the accuracy you need for the rigging :

Copy the armature
Adapt it (edit mode) to your destination mesh
Parent the destination to this armature copy with automatic weights
Reparent to the original armature (with empty groups)


How can I change an objects scale, and rotation using an Empty? So I previously asked a question on how to separate the faces of an object like an Icosphere. I decided that this next part would be best for a separate question.

Taking that Icosphere and an Empty, how would a best be able to achieve the results shown in these tutorials? Here is what my object looks like:

So I need to be able to drag an Empty through the sphere and have the triangles scale, and or rotate inward or outward as seen in the image.

One way I found that gets a similar effect, is using hair particles to emit triangles:

Add a sphere as an emitter mesh:

Add a plane and merge (AltM) two vertices to create a single tri:

Set the Particle settings for the sphere to hair, select the tri as object in Particle settings > Render, disable Emitter so the emitter mesh is not rendered, and enable Rotation in Render.

Now rotating the tri causes the particles to rotate as well:

Force fields will also effect the hair particles, so you can get effects with them too.

Duplifaces

This can also be achieved with duplifaces:

Parent the tri to an icosphere
Select the sphere, and enable Duplifaces in Properties > Object panel > Duplication > Faces
(Optional) Enable Scale and tweak scale settings.
You can apply the dupli objects with Ctrl+Shift+A (With the sphere selected)
Add a constraint to one of the now separate triangle objects (you might want to make these a Group with Ctrl+G so you can select them all easily with Shift+G > Group)
You can then constrain each tri individually, select them all with the constrained tri active (yellow) and object > constraints > copy constraints to selected objects:

Note that with Duplifaces the trick of rotating the original tri still works, but force fields do not.


How do you keep a single object from casting a shadow? Is there a way to prevent a single object from casting shadows?
If I shut down "Cast Shadows" on the light source then all shadows will be lost. That is not what I want. I want to be able to prevent a single object from casting shadows.

A use case may be a laser. If I were to use a cylinder to model my laser, and that laser was positioned between a wall and a light source it will cast a shadow on the wall, but it should not cast a shadow.

Objects not casting shadows? easy, un-tick the shadow box.

In Cycles 2.79+, Ray Visibility was renamed to Cycles Settings.

As for the lighting, Cycles simulates the physical behaviour of light with some reasonable accuracy. All techniques used in real photography can be applied to lighting setups in cycles, The video also discusses the composite of various render passes, I think you'll find they are all possible in Blender. Be specific about what you want to know and you will get accurate answers.


Select the outermost contour of an imported SVG I would like to programmatically import an SVG (see top left) and process the offset of the concave outline, that are the outermost edges of the imported SVG (see top right). Finally I want to have the result like the image at the bottom.

The only part I stuck with is how to select the outermost edge loop programmatically via a script. Manually it works by 2xALT+RMB. But how to make the script know, which is the initial edge?

Is there a way to either

Iterate over the curve data and just remove all inner elements,
select the first outermost edge and firing 2xALT+RMB,
preprocess the SVG to remove the inner elements or
fill the inner holes and simplify the mesh again?

I went for the solution to iterate over the imported object. For reference the import routine, to see how the SVG gets imported in detail. The data is avail in the objects data.spline collection then.

The correct function relies on that the remaining element has to be the first object in the collection (key not in 0). At least for exported SVGs from corel draw this is true, I guess for others, too.

code snippet I use for now:

# remove all inner elements
svg_splines_collection=obj.data.splines
splineset_to_remove = [value for key, value in svg_splines_collection.items() if key not in (0,)]
for spline in splineset_to_remove:
    svg_splines_collection.remove(spline)

if someone comes up with a better solution I'd appreciate.


Why is Blend4web's 'pick_object' giving a 'null' value? var x = m_mouse.get_coords_x(e);
var y = m_mouse.get_coords_y(e);

var obj = m_scenes.pick_object(x, y);
console.log(obj);

This gives a null value and it does not get the object inside the mouse's 'x' and 'y' coordinates.

How can I solve this?

the object must have Selectable option enabled in its Blender settings.


Blender is applying only part of texture onto plane ? -- No Shading -- Bug? turning to you with a really strange issue - Blender only applies part of my texture onto a plane! I have an image texture that ranges from RGB black [0,0,0] to green [0,1,0] and red [1,0,0]. When I apply this texture onto a plane, without any shading, i.e., just the image texture node into material output, Blender only puts a part (roughly 80%) of the texture onto the plane (namely the part until green [0, 0.8, 0] and red [0.8, 0, 0]).
This can be verified in UV Editor mode, when using the color picker tool and picking from the image texture and the texture plane, respectively: the image texture will give you [1.0, 1.0, 0.0] in the upper right corner, whereas the textured plane will return [0.8, 0.8, 0.0].
My problem is that I need the entire texture on the plane. I already tried experimenting with plane size, etc., but didn't have any success. Does anybody know what's going on here? This seems really strange. I attached the blend file and the texture!
Attached blend file:

I think your problem is in view port settings.
As you wrote, your image RGB goes over variety of colors and the corners should give absolute number of the color (as 1.1.0 in case of yellow) This can be picked by color picker in UV editor or texture paint as the texture is shown without any view port shading.
In fact, the view port has some basic shading and light from the very beginning and the colors in 3D view port are always distorted by the environment as the pure color is not reachable in a real world normally.
There is no problem with the texture. If you want the absolute color output you have to set up you render, color or material to give you this output.
If you want it to be seen just in view port then change your shading.


I get this weird white line as I zoom out a view When I zoom into the character everything is clean and clear, but as I zoom out this white line gets more and more visible even thicker. Any idea ?

Most probably the edges of your UV-map faces are to close to the edge of the corresponding texture imagery underneath.
As you can see in the four zoomed-in UV Editor windows, the UV-map is neatly within the borders of the blue square in the texture.
But because the texture is blurred (or smoothed), the orange background color bleeds into the UV-mapped area. This causes the plane in the 3D Viewport to have blurry orange edges.
The texture is blurred because the top entry on the Image Texture node is set to Linear. Note how a single green pixel in the bottom right corner is blurred.

To fix it you can simply move the edges that suffer from the color bleeding away from the border and away from that color.

Alternatively, if you set the top entry on the Image Texture node to Closest, it will also solve the color bleeding problem, but you will get a pixel perfect display of the texture on your material and corresponding model, as commonly seen in Minecraft models and textures. (The single green pixel now looks like a pixel)


How can I scale map texture relative to each oriented faces? I don't know if the question's title it's clear (if you suggest one more clear I can change it later?).
I wanna use a noise map for making some vertical blurred lines on my wall, so I'm scaling that map using mapping node along X axe, but in this way this is good only on aligned faces (left side of the attached image), on it's perpendicular face wall this is not scaled due to different orientation, so is there a way to get the same effect on that last one without duplicate material and assigned it and scaling the noise texture on the Y axe?

If you want to have the vertical lines using a noise texture on both sides of the wall, this can be done simply with mapping nodes. Simply add a noise texture connected to a color ramp.  then add a texture coordinate node attached to a mapping node.  Scale up the material the same amount on both the x and y axes to get the desired result.  I will show you may node setup:
using this setup, I got this result:
you can adjust the color ramp and other settings as needed


Why has the boolean modifier created new vertices? As you can see in object mode there are 4 vertices that have separated the front of the cartridge into multiple faces when I use boolean modifiers on cartridge.001. How can I fix this?  I imagine it has to do with good topology.

Here's the cartridge in object mode showing faces:

Here is the cartridge with the unwanted vertices:

Attached is the .blend

The topology you see in wireframe mode is real topology of your mesh if the modifiers were applied. The edges (and not vertices) are added because it is impossible in Blender (as far as i know) to have a face with an hole in it, with a connected vertex. To create a hole you need to create a cut to join the two edge loop of the new face.
The wireframe view can avoid to display some edges if the faces have the same normal, but for that you need to apply the modifiers, then go to Edit Mode and back to Object Mode.


How to add windows in a workspace which has no handles? I am using Blender 2.75a, and usually use the handles very often to create a  workspace that is relevant to the models I am creating.

However, I have recently downloaded models that were placed for free on the internet, and I was surprised to see that when opening some models, the windows of Blender (still the same 2.75a version) didn't have handles, which was making it hard to work.

Were they disabled by the person who made these models, or did these handles appear later? In any case, is there a toggle that turns them on/off?

It could be a maximized area.... try pressing Shift+space, Ctrldown, or Ctrl↑ Up


force unbuffered output for the console I'm trying to capture blender's console output to a file (as a result of a great suggestions from @Rich Sedman in another post) with something like

$ blender > /tmp/output.txt

The problem is that I need output.txt have always the content of the console but blender is buffering this output and not always I can access the text. I tried all kinds of flushing (line sys.stdout.flush(), or sys.stdout = fopen(sys.stdout.fileno(), 'w', 0), etc) and nothing seems to force an unbuffered output.

Is there a way to really force blender to use an unbuffered console?

Thanks!

Figure out the problem. The python interpreter can be forced to use unbuffered prints if we set the PYTHONUNBUFFERED environment variable. Just use
export PYTHONUNBUFFERED=on
Nevertheless that still did not solved completely my problem because I had a piped  grep together with blender. Hence, although blender was running unbuffered outputs to console, grep was... Just used grep --line-buffered (saw that in s very good post about stdout here https://eklitzke.org/stdout-buffering)
Hope that helps somebody! Thanks for everyone that tried to help!
/edit:
Since 16.01.2020, to make this work you have to launch blender with --python-use-system-env to make it work.
Source: https://developer.blender.org/rBS7c2f0074f3fe2411daa7a6e351d7cbc535246871


List of objects in scene with counts (verts, faces, tris)? Is there a way to see a list of all objects in the scene with the number of verts, tris, faces of each object?

I know you can click on a object and go into edit mode and it shows the numbers, but if you have many objects in a scene and you have to decrease the amount of verts in the scene this procedure gets tiresome.

A list with all objects of the scene and their counts where you can immediately see where you could possibly remove some verts would be very handy.

------------------------------------------------------------

Edit: If anyone is interested the user sambler and i (independently) both wrote an addon.
Look further down for his solution.

Mine is downloadable here:
pasteAll download

The addon shows the geometry information of the scene.
It is sortable and you can select an object by clicking on the button.

With some inspiration from the other answers I made an addon to show mesh information.

You can save this link to your addon folder or to somewhere convenient and use the Install from file button in the preferences. As awi's step of using bmesh to calculate the vertices after modifiers are applied takes some time in larger scenes, even without modifiers (a few seconds with a million verts scene) I have displaying that count as an option.

When you enable the addon there is an option to set how many mesh objects are listed (default is 5). The list is sorted by the true vertex count so you can easily see what objects have the vertices. Also large numbers are nicely truncated with k,M,G suffixes to make for easier reading.

Once enabled you can find the Mesh Information panel under scene properties.


When going to render mode i can't see other objects only my modeled object So i have a pretty basic scene just a cat, a lamp set to sun, a camera and an empty object. But when going to render mode to see how light is falling on my cat i can't see my other objects.

Please help me, if you didn't understand what i said please leave me a comment, thanks!

Render mode renders your final result in which wireframe objects will not show (that is by design as that is not desirable).

That render mode is interactive, so you can have 2 3d viewports open, one in shaded/wireframe/material mode so you can see all the objects and the other in render preview to see the lighting. What you do in 1st will update in 2nd. For Cycles and Blender Internal render engines the response will not be realtime though.

As you are using Blender Internal and there is no Global Illumination, you can get a phong shading preview also by switching from Multitexture to GLSL shaded viewport. Note that only spot lamps will produce shadows. You will get the same shading as in Blender Game engine.

You can also download an EEVEE Blender testbuild and play with this new realtime engine. You will be able to see all the wireframe in viewport an the shading at the same time.


Why does the rig generate below my mesh? Need help with generating a rig. It generates below the mesh.

In Object mode, select your mesh and apply (Ctrl A) location, rotation and scale, do the same with the generator rig, then generate.


Using Grease Pencil (Annotation) from Modal in Blender 2.8 In my addon, I need to do a bunch of stuff while running modal.  One of those things is drawing with a grease pencil, and then processing the curve.  By grease pencil, I mean just the simple annotation tool.  However, I am not able to get the grease pencil to draw from modal.  If I call my draw_curve() function defined below from a button, it works fine.  But from modal, the cursor does not become a pencil, and I cannot draw.  What am I missing?

(I guess it might have something to do with detecting the left mouse press to actually commence drawing a stroke, but this worked in modal in Blender 2.7x without any further steps, and I'm having trouble figuring out what else 2.8 wants.)

Thanks in advance!

class MYADDON_OT_modal_operator(bpy.types.Operator):
    bl_idname = "myaddon.modal_operator"
    bl_label = "Modal Operator"
    bl_options = {"REGISTER", "UNDO"}

    def invoke(self, context, event):
        bpy.ops.object.mode_set(mode='OBJECT')
        context.window_manager.modal_handler_add(self)
        return {'RUNNING_MODAL'}

    def modal(self, context, event):
        if event.type == 'D' and event.value == 'PRESS':
            draw_curve()
        elif event.type == 'ESC':
            return {'CANCELLED'}
        return {'RUNNING_MODAL'}

def draw_curve():
    bpy.context.scene.tool_settings.annotation_stroke_placement_view3d = "SURFACE"
    bpy.ops.wm.tool_set_by_id(name="builtin.annotate")
    bpy.ops.gpencil.annotate()

The answer is simple: the gpencil.annotate() call on the last line needs to include the argument "INVOKE_DEFAULT".

bpy.ops.gpencil.annotate('INVOKE_DEFAULT')


How to rotate an object from a reference plane How can I rotate a plane to make it have the same orientation of another plane. Until now I have:

import bpy
# The object to rotate
ob = bpy.context.active_object
# The object world normal vector
ob_local_normal = ob.data.polygons[0].normal
ob_world_normal = ob.matrix_world * ob_local_normal
print(ob_world_normal)
# The plane to be aligned/parallel with
pl = bpy.data.objects['Plane']
# The plane world normal vector
pl_local_normal = pl.data.polygons[0].normal
pl_world_normal = ob.matrix_world * pl_local_normal
print(pl_world_normal)
# Now I need to rotate the object...

In Python rotate a polygon to face something was also helpful but I need the 2 planes beeing parallel each other.

import bpy
from mathutils import Matrix, Vector

def scale_from_vector(v):
    mat = Matrix.Identity(4)
    for i in range(3):
        mat[i][i] = v[i]
    return mat

o1 = bpy.data.objects['Object.001']
o2 = bpy.data.objects['Object.002']

loc_src, rot_src, scale_src = o1.matrix_world.decompose()
loc_dst, rot_dst, scale_dst = o2.matrix_world.decompose()

Apply the rotation of object o1 to object o2

o2.matrix_world = (
    Matrix.Translation(loc_dst) *
    rot_src.to_matrix().to_4x4() *
    scale_from_vector(scale_dst)
)

If you only want to align an axis use the following code instead:

#only align z-axis
axis = Vector((0.0, 0.0, 1.0))
z1 = rot_src * axis
z2 = rot_dst * axis
q = z2.rotation_difference(z1)

o2.matrix_world = (
    Matrix.Translation(loc_dst) *
    (q*rot_dst).to_matrix().to_4x4() *
    scale_from_vector(scale_dst)
)


Can not make proper selection to make a face Here is what I'm trying to do.

This is what is happening.

Learning from scratch and this is my biggest problem so far. Any help??

i think you are hitting ALT as stated above, try this ... go to EDGE SELECT and select the two edges (easier then selecting 4 vertices anyways) then press F key


Why don't my constraints and rig update when the target moves? So I have this basic rig. I have an empty for each bone. Each bone has 'Damped track' to its empty. Each empty has 'limit distance'(from head). No problem with 'limit distance',
but the 'Damped track' causes a few issues.
Grab the Empty and move, click Esc instead of Mouse buttons. The Empty comes back to its original position, but the bone does not keep track.
 PressG(grab) and Esc again without moving the mouse. Then it tracks again.

This is making animation really difficult. I am having to render each frame manually because of this issue. Please help.

Use the arrow keys to go one frame forward and one frame backward.  This will cause a reposition and repaint.

Currently that is the least burdening user action I have.

Also you have a Circular Reference.

Check your [Console Window] to see a troubling circular reference. Remove the circular reference.

This menu selection opens the console. Image above.

Often software needs to determine a work order by sorting dependencies of Constraints.  Precedence sorting.  Topological Sorting.  For explanation simplicity allow G->D to mean G depends on D. Clear chain of command is easier to understand.  Clear example A->B->C.  Unclear example A->B and B->A

Desired Situation

Your empty constraint should refer to another bone prior to the current one, or the armature itself, or some other created object.

Current Situation Undesirable

Your bone has a constraint that refers to the empty.  The empty has a constraint that refers to the bone.  A->B  and B->A.  Circular Reference.


cant get the sub-surf right (Blender guru beginner modeling tutorial) So I have been following the Blender Guru modeling tutorial with minor changes every thing looked OK till he added the sub-surf modifier and I have no idea how to fix  (followed tutorial https://www.youtube.com/watch?v=WxMwa0njGSM )

this is my edit view with and with out sub surf

and this is how it should look like

I guess your mesh has something different in the bottom: I think you have a single bottom face (N-gon), which is causing this issue...

if you have this (sorry for the horrible mesh, I'm before breakfast...)

subsurf behaves well

while if you have a single N-gon face

subsurf behaves like in your model

if unsure, share your model through

http://blend-exchange.giantcowfilms.com/

then edit your question and post the provided link...

edit:
after getting your file I found that this model has (still) several issues: at the base there are still n-gons, ruining the subsurf effect, but overall it has some other modeling issues... giving aso bad mirroring results.

About the ngons, this what you have one side

and the opposite is even worse

then below you have some faces with inverted normals

then again, its quite irregular on lines that are supposed to be quite linear instead: this ruins both mirror and subsurf

eg: here

Nothing terrible, and it can be corrected, but I suggest you to try to model keeping an eye on such things, because it helps you model better, and get better results. First, I recalculated normals (select  all in edit mode, then CTRLN)

Then I tried to remove those ngons, getting something like this

if you enable subsurf now, it looks better, but not at its best:

it lacks some subdivision at the base, eg:

with this further subdivision,

the base becomes more defined when you subsurf later

Here is the file a bit corrected (imho, it could still be improved)

Hth, Marco


Understanding official blender documentation - reset button in an Addon example I did the Addon examples of the oficial documentation and there is something I don´t understand. In the section called "Bringing it all together" there is something about a reset button that appears below on the left. I don´t see it in my blender program.

At first I thought it was something of the script code. But as you can see below, there isn´t anything in the Addon code related with a reset button.

bl_info = {
    "name": "Cursor Array",
    "category": "Object",
}

import bpy

class ObjectCursorArray(bpy.types.Operator):
    """Object Cursor Array"""
    bl_idname = "object.cursor_array"
    bl_label = "Cursor Array"
    bl_options = {'REGISTER', 'UNDO'}

    total = bpy.props.IntProperty(name="Steps", default=2, min=1, max=100)

    def execute(self, context):
        scene = context.scene
        cursor = scene.cursor_location
        obj = scene.objects.active

        for i in range(self.total):
            obj_new = obj.copy()
            scene.objects.link(obj_new)

            factor = i / self.total
            obj_new.location = (obj.location * factor) + (cursor * (1.0 - factor))

        return {'FINISHED'}

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

# store keymaps here to access after registration
addon_keymaps = []

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

    # handle the keymap
    wm = bpy.context.window_manager
    km = wm.keyconfigs.addon.keymaps.new(name='Object Mode', space_type='EMPTY')
    kmi = km.keymap_items.new(ObjectCursorArray.bl_idname, 'SPACE', 'PRESS', ctrl=True, shift=True)
    kmi.properties.total = 4
    addon_keymaps.append(km)

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

    # handle the keymap
    wm = bpy.context.window_manager
    for km in addon_keymaps:
        wm.keyconfigs.addon.keymaps.remove(km)
    # clear the list
    del addon_keymaps[:]

if __name__ == "__main__":
    register()

How can I see this button?

In Blender 2.64 there was indeed a "Reset" button. If you download blender 2.64 and do the same tutorial you will find the Reset button. Blender added this button automatically right under your operation panel.

In a later version the Reset button has been removed hence you don't see it anymore.


Noise in Blender Internal Smoke Sim? I'm trying to make a background using this tutorial and I've been doing some renders, and they've been going well. (if only baking didn't take so long... )
Anyway, I have a problem, as you can see in this image,

the smoke has weird noise within the transparent parts of it, does anyone know how to fix this? I upped the resolution, so that's not the problem... I'm not too experienced with Internal so I don't know if noise is normal.
Do you guys have any ideas?

You need to decrease the Step Size in Properties > Materials > Integration > Step Calculation:


Physics object with force field render oddly shaped and jagged This question still puzzles me: When f-12-rendering (both Cycles and Eevee) frames with a cloth animation the banner-object behind the airplane appears oddly shaped and utterly jagged.

Please inspect the blend-file -->

EDIT: Modifier settings added

In the viewport its seems ok and I can’t figure out where to look for a better result. What may I have done wrong? I would be very glad for your opinion.

Kind regards, Mikael

The order of the modifiers was the cause of jagged shape!

Changed the subdivision modifier after the cloth simulation.


strange shadows and artifacts on cycles render I'm getting some unexplained shadowing artifacts after rendering in cycles.

As you can noticeably on the end of the nose, and more subtle under the green eye.

I'm using a 3 point lighting system that can be seen here

I've tried playing around with the lighting, and no matter what I do with the lights, the shadow is still there.

Anyone any suggestions for what could be causing this and what settings I could try playing around with to resolve this?

It looks like you are having duplicated meshes intersecting each other on your mesh, if not then it should be normals that are not represented correctly. Try to removing double and recalculate your normals and see if it helps. Also select all your face and apply smooth shading.

Attaching a portion of your mesh would let us help you diagnose the issue too. You could just leave the nose portion in the file where the artifact is showing up.

Preliminary Probe

Probing into the file, I found that you have meshes that have all the edges "mark as sharp"
to unmark the meshes. Go into edit mode, select all the edges ... hit CtrlE and select "Clear Sharp".

After which, I also found out that your faces are not joined as a single mesh ... to solve that.
Do this ... With all the faces selected , Hit W select "remove doubles". This will weld all the triangles into a single mesh and remove vertices that takes up the same 3d space.

At this point I apply "shade smooth" with the W "special meun. This mess up the normals. Then I proceed to add a modifier "Normal Edit" under then modify column. The strange shadows are gone but some harsh edges still persist.

Solution

Note
You can read about why this happens here. http://www.blenderartists.org/forum/showthread.php?370090-Cycles-Glass-render-Black&p=2864146&viewfull=1#post2864146


What language are the shaders in Blender written in? What language are the shaders in Blender written in? Like the Principled BSDF and the rest.

Most of them are written in OSL, OpenShadingLanguage, a language specifically designed for shaders. It's similar to C and can be compiled, so that it's fast.

You can find it in the Blender sources at

intern\cycles\kernel\shaders\node_principled_bsdf.osl

OSL is comparable to RSL, Renderman Shading Language and GLSL, OpenGL Shader Language.


Experiment with Polystyrol Balls I'm writting my Thesis about a method for an additive manufacturing method for thinks like styrofoam aka EPS.

Now I want to simulate the light distrubution in small balls of Polystyrol hit by a concentrated sun beam (with a telescope with an angle) and with a normal laser ray (parallel monocrome light).

My first question is if there is a possibility to get the color distortion of PS like shown in the wikipedia picture. In the nodes I don't see a possability.

Cycles, or really any renderer for graphics is not a completely physically accurate model of light. Cycles in particular uses an rgb based model for colour, rather than a spectral model (luxrender does use a spectral model for colour which may get slightly better results for stuff like this). As far as I know, neither bother to model things like coherence or polarity or anything like that.

Either way, material properties and light effects are vastly simplified in order to provide visually appealing results in a reasonable amount of time and to make it easy for artists to build materials without detailed scientific knowledge of the interactions between light and various materials.

These kind of rendering engines are not and never will be scientific simulations. If you want to find a scientific simulation of light, you will need to look elsewhere for programs build for that purpose.


Unable to identify frame for cut in VSE - Bug? in addition to my other question, I have another problem with the Video Sequence Editor in Blender.

I am editing a screen capture, where I need to identify that one frame in which a window disappears. I found the correct frame and cut the clip. Afterwards, I searched for that frame again. When I approach the frame in which the window disappears from the left, frame number 1044 is the very first frame, in which the window is gone. I would expect that if I go one single frame left, the window would appear again. But in fact, it doesn't. I have to go left until I reach frame 1040, which is then the very first frame, in which the window appears again.

So in summary, I am unable to find the right frame for separating the screen capture as it makes a difference whether I am approaching it from the left or right.

Do you consider this a bug? And if not: Could anyone tell me how to get rid of this "feature"?

I am using Blender v2.75 on a Win7 system.

I tried to follow 3pointedit's instructions and it seems to reveal a problem with the screen capture clip.  I started a complete new Blender-project and added the screen capture as a movie. Then, I did "Rebuild Proxy and Timecode Indices" with the settings attached. Unfortunately, Blender crashes immediately without any error message, it just exits.

I tried the same with one of the GoPro clips and it works perfectly (same settings).

So obviously, there is something wrong with the screen capture clip...

You can also generate a timecode file for the clip (it lives in the proxy panel of strip properties), when creating the TC you can choose to NOT render a proxy. The playback of media should be much better. But transcoding to a more simple codec is best (less compression, more real frames).


Rotate Edge to Be Perpendicular to the Ground How can I rotate a diagonal edge, in edit mode, so that it becomes perpendicular to the ground?

This is how I usually do it...

Go to navigation panel > Mesh Display turn on display edge length.
Select the vertex point you want to rotate the line on ... (but we DO NOT rotate)
Instead, Hit E then Z for the axis you want the point to extrude in and key in the edge length revealed in step 1.
Select the diagonal edge and hit delete

Now you have the new edge perpendicular to the ground.

Hope that helps.


Automatically inherit an imported video's encoding I use the Visual Sequence Editor to compile highlights from my aerial drone. After editing the source(s), I want the exported video to have the same dimensions, fps, encoding, and quality as the original(s).  I manually set these at the moment, then save them in a preset for future use.  However sometimes I forget what camera I have used that day and load the wrong preset, this isn't a big problem but it is a waste of time to render the sequence again.

Is there a way to automatically set the output parameters to mimic the source video in Blender?

Currently there is no way to do this. However you would be able to do this via python.

I dont think the ffmpeg libraries (which is what blender uses to read and write video and audio files) have python bindings included with blender.

To write a python script to do this, you will need to use another python library, such as pipeffmpeg


Displace modifier does not work in 2.81 if i want to add a procedural texture to displace modifier which works with "Texture Node Editor" (Shift F3) it will never works am i doing something wrong ? or is this a bug ?
the texture always outputs black , the only way to use the texture is to paint it in a "Image" texture which will not be procedural anymore ,
texture Type : None
colors setting are default
it works with texture paint but not for displace
Please respond as fast as you can .
i want a full description if its possible .
i told every thing don't ask my system specification or my birth date or other irrelevant stuff thank you .

You are trying to use a brush texture as a displacement texture. That does not work.
If you want to use a texture to displace the object, you need to create one by clicking the "New" Button in the Displace Modifier and then change the settings in the texture menu. Easy to reach with the button to the right.

THERE you can change the texture. This does NOT work with nodes.
Keep in mind: The Texture system in Blender is End-Of-Life and will be replaced at some point with a node based approach. (afaik)


How to script the motion blur shutter curve? I am trying to script the motion blur shutter curve (image below) for each frame of a render. I want to control the "openness" of the shutter curve with a list of values between 0 and 1. Ideally I would also like to be able to change this from one frame to the next within a single animation. I believe the variable I need to change is bpy.context.scene.render.motion_blur_shutter_curve. How do I convert a list of values to a curve and pass it to this variable?

I'd suggest read the values and create a dictionary out of point positions per frame, which allows to structure as well as access the values in a reasonable way:
dict = {
    frame_number : [
        (LOC_X, LOC_Y),
        (LOC_X, LOC_Y),
        (LOC_X, LOC_Y),
        ...
    ]
    frame_number : [
        (LOC_X, LOC_Y),
        (LOC_X, LOC_Y),
        (LOC_X, LOC_Y),
        ...
    ]
}

One pitfall is that the minimum point count for a curve is 2, means that you can not remove all the points of any existing curve.
The following demo sets the shutter curve based on custom data. Notice that set_curve() is a slightly modified version of the reset_curve() function from this Q&A:
import bpy

frame_dict = {
    1: [(0.0, 0.0), (0.07, 0.5), (0.25, 0.9), (0.5, 1.0), (0.75, 0.9), (0.92, 0.5),  (1.0, 0.0)],
    2: [(0.0, 0.0), (0.125, 0.44), (0.375, 0.95), (0.5, 1.0), (0.625, 0.95), (0.875, 0.44), (1.0, 0.0)]
}

# Based on 'reset_curve()' from https://blender.stackexchange.com/a/64461/
def set_curve(curvemap, custom_points):

    curve = curvemap.curves[0] # Get the curve
    # Remove redundant points
    if len(curve.points) > len(custom_points):
        n = 0
        while len(curve.points) > len(custom_points):
            curve.points.remove(curve.points[n])
            n += 1
    # Generate missing points
    if len(curve.points) < len(custom_points):
        n = 0
        while len(curve.points) < len(custom_points):
            curve.points.new(0.1, 0.5)
            n +=1
    # Set the values and update UI
    for c, point in enumerate(curve.points):
        point.location = custom_points[c]
    curvemap.update() # Optional call

C = bpy.context
shutter_curve = C.scene.render.motion_blur_shutter_curve

# test call
set_curve(shutter_curve, frame_dict.get(2))

In order to set the curve and render each frame, go through the key-value pair of the dict and call Scene.frame_set(your_frame) per iteration to update the scene:
for frame, points in frame_dict.items():
    # Set the curve
    set_curve(shutter_curve, points)
    # Set the frame
    C.scene.frame_set(frame)
    # Render the frame
    bpy.ops.render.render(write_still=True)

Alternatively you can setup a frame_change_post handler which allows to preview and set your values on the fly, when changing the frame in the timeline (before rendering):

def set_curve_frame(scene):
    shutter_curve = scene.render.motion_blur_shutter_curve
    if scene.frame_current in frame_dict:
        set_curve(shutter_curve, frame_dict.get(scene.frame_current))

bpy.app.handlers.frame_change_post.append(set_curve_frame)

Related:

Can python access control points of Hue modifier?
Python Render Specific Frames


How to rotate all the keyframes of root bone? I found an animated character online. I want to rotate this character for all the keyframes by 180 degrees along the Z-axis. This can be done by rotating the root bone. But how do I go about rotating the root bone for all keyframes?

The animation use quaternion rotation.

Here's the .fbx file

I think the easiest way to do this - it just rotate all armature as object. To do this:

Make sure, that you select armature in object mode. If you are in Pose mode, switch to object.
Then rotate object as you need.

Also, you can add new root bone, and parent "old root bone" to the new one. In this case you can use it to position and rotate all bones in pose mode.


Blender Render Image not showing nothing I tried to render a frame in my scene and didnt show anything. I did that already but now suddenly this doesnt work!Im trying to render the frame in evee
Can you help me?

This worked for me. Disable the "Sequencer" checkbox in Output Properties:


How to delete all animation from an appended file? So, I have appended a file to a blender scene, and now I want to delete all the animation from the previous appended scene. I have tried going into the dope sheet, selecting all keyframes with A and hitting X, but to no avail. Any tips/is this possible?

Is is possible the channels are locked / protected?

You can click the lock icon to toggle this, or press Tab while your cursor is hovering over the channel.


Render very slow using GPU from Radeon Sapphire RX 580 vs CPU After installing Blender in Windows 10 and configuring the cycles compute device to use OpenCL with Radeon RX 580 Series, the render using cycles and GPU Compute takes much more time tan single CPU rendering...

CPU Rendering: 2.05 seconds

GPU Rendering: 63.44 seconds

The render is just so simple as the cube that appears when you open blender.

Graphic card is a Radeon Sapphire Nitro+ RX 580 8Gb GDDR5 and I updated the drivers to have the last ones.

Could you please help me with this issues?

Thanks in advance.

First of all the GPU needs to compile the Kernel first ( which takes more time in case of your cube than the actual render itself ) - this is done on the cpu.

Second Radeon need bigger tiles to have enough work to even get remotely saturated. 256x256 is a bare minimum and in case 2.79 or below is used you should even go Fullscreen ( 1 or 2 tile ) for best performance ( dont use progressive ! ) - each call to the Gpu halts it for a short time - the more of theese calls for example when progressive is used come together - like when eavery sample needs to be updated to the cpu the gpu spends most of the time waiting for data.

Take a more complex scene and try again.


Assigning parameters or constraints to a model? I want to build model with certain parameters and constraints.

For example, I built a tissue box model in blender. I then want to assign parameter name hole width and hole length such that when I tweak these parameter, the hole of tissue box will resize automatically according to the parameters.

I am not sure if blender (and general 3d software) support this figure.

You could add Shape Keys to change the size of things in the object. Also you could try to do it with hook modifiers. Another way to do that thing with the hole you mentioned would be to add a boolean modifier to the main mesh and set it to difference. Then add a Cube (Or whatever the Hole has to be shaped like) and translate it to the correct position. Put the name of the cube in the boolean modifier field and then you can control the hole by scaling that cutout object.

But your task sounds more like a thing to do in scad.


How can I make particles rise softly? I'm trying to make particles rise softly, as if floating on hot air. I've added drag, increased particle mass, and lowered wind strength, but it isn't getting slow enough.

Is this just a matter of finesse (right wind strength/particle mass), or is there a trick to it or a certain setting necessary?

Instead of using wind etc. to blow the particles upwards, try disabling gravity for just the particles:

In this case the emitter plane's normal is facing upwards, so the particles start with a initial upwards motion.

I've also added a turbulence force field along with some random initial and brownian velocity, to give it a bit of randomness.


Masking microdisplacement map I have painted the area on plane where I would like to have one microdisplacement map and the the invert of that with no microdisplacement.

So white area is with microdisplacement map and black area without.

How should I connect the material to get that?

It's essentially the same as you're doing to mix between shaders for your surface:

Here, I'm using the exact same texture to mix between shaders and to mix between displacement.  Since displacement doesn't use shaders, I'm using colors and a mix RGB node instead of a mix shader node, but it could as easily be done with values and math nodes:


Clear Parent and Keep Transformation When I select the Mesh (scaled by empty), hit Alt+P choose "Clear Parent and Keep Transformation", it clears parenting, but transformation is not kept.

Is there any visible reason why the operator is not working on this specific model (blend file, collection 02)? What kind of hidden setup can cause this issue?

For now it seems like different rotation (mesh and empty), cause the issue. If empty and mesh is the same rotation (collection 01 and 03) Alt+P works fine. Since Empty is rotated it fails (see collection 02).

Blender does not support shear or skew transformations, thats why the state you request can not be reached on object/transform level but only on data/mesh level. I have added a possible workaround at the end of the post.
Translation, Rotation, Scale
First, let's confirm that Blender only supports translation, rotation and scaling transformations. Select the untransformed default cube.
Open up the Blender Python console, type bpy.context.object.matrix_world and press enter.

Cool, we are confronted by 16 numbers of a matrix. bpy.context.object is simply a reference to this object. matrix_world is the transformation matrix. A transformation matrix contains the objects transformation: translation, rotation, resizing, shearing and skewing.
Look at these slides for a brief overview or this beautifully crafted blog post for a more detailled explanation.
The _world part in matrix_world simply refers to the resulting matrix with all parents transformations applied. Since the default cube has no parents, we could also use matrix_local.
We can not only output the matrix of the default, we can also assign it using python. Obviously we usually only work with partial components of the transformation matrix of object (tranlation, rotation, scale) since the matrix is not very intuitive. Open Blenders Text Editor and paste the following script.
import bpy
import mathutils
from math import cos, sin, pi

mat = mathutils.Matrix( [ [1, 0, 0, 0],
                          [0, 1, 0, 0],
                          [0, 0, 1, 0],
                          [0, 0, 0, 1] ])

ob = bpy.context.object
ob.matrix_world = mat

Here we assign a matrix to the active object. Pressing ⎇ AltP or the Run Script button will assign this matrix to the cube. We don't see a change, because this is the so called identity matrix, which doesn't transform the object (or it transforms all points in place).
However, we can do simple transformation with a matrix via python code. Here are three examples (for translation, rotation and scale) which you can replace in the above code snippet. The results are seen in the image below.
# translate x by -1
mat = mathutils.Matrix( [ [1, 0, 0, -1],
                          [0, 1, 0, 0],
                          [0, 0, 1, 0],
                          [0, 0, 0, 1] ])
# rotate z by pi/8 (~22.5°)
mat = mathutils.Matrix( [ [cos(pi/8), -sin(pi/8), 0, 0],
                          [sin(pi/8), cos(pi/8), 0, 0],
                          [0, 0, 1, 0],
                          [0, 0, 0, 1] ])
# scale y by 2
mat = mathutils.Matrix( [ [1, 0, 0, 0],
                          [0, 2, 0, 0],
                          [0, 0, 1, 0],
                          [0, 0, 0, 1] ])

Shearing or Skewing
As far as I understand, the following matrix should shear the object along the objects X axis. You may be familiar with Shearing from Edit Mode, where you can shear points with ⎈ Ctrl⇧ Shift⎇ AltS.
[1, 1, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1]

However, in the 3D view, we can see, that assigning this matrix with the code snippet from earlier will only scale and rotate the object. What happened? I guess, Blender is trying to show the transformation in the GUI, converted it to TRS and displayed it in the Transform panel. The other parts of the matrix were ignored and the matrix reconstructed without the shear/skew.
In fact, if we go into the python console and execute bpy.context.object.matrix_world it shows an entirely different matrix, than what we just inserted.
<Matrix 4x4 ( 0.9210,  0.5395, 0.1117, 0.0000)
            (-0.3815,  1.1907, 0.5395, 0.0000)
            ( 0.0790, -0.5395, 1.3025, 0.0000)
            ( 0.0000,  0.0000, 0.0000, 1.0000)>

What can happen when unparenting?
When unparenting an object, it can require a transformation matrix, which includes shear/skew and can't be expressed with just TRS.
Let's look at an example, where everything is fine first. The Empty is the parent of the Cube.
The empty is scaled to 0.5as can be seen in the Transform panel.
The Cube is scaled to 2 on the Y-Axis.

Even before doing any unparenting, we can figure out, what's going to happen. The Cube must have a scale of 0.5, 1.0, 0.5 to remain in its current transformation.
We can also figure this out, by multiplying the matrices.
[ 0.5 0   0   0    ]         [ 1   0   0   0    ]       [ 0.5 0   0   0  ]
[ 0   0.5 0   0    ]    x    [ 0   2   0   0    ]   =   [ 0   1   0   0  ]
[ 0   0   0.5 0    ]         [ 0   0   1   0    ]       [ 0   0   0.5 0  ]
[ 0   0   0   1    ]         [ 0   0   0   1    ]       [ 0   0   0   1  ]

This is the same as what Blender would tell us when calling matrix_world of the child Cube.
>>> bpy.data.objects['Cube'].matrix_world
Matrix(((0.5, 0.0, 0.0, 0.0),
        (0.0, 1.0, 0.0, 0.0),
        (0.0, 0.0, 0.5, 0.0),
        (0.0, 0.0, 0.0, 1.0)))

In this second case the cube is rotated by an angle which is not a multiple of 90° and the empty has a non-uniform scale of 1, 0.5, 0.5.

[ 1   0   0   0    ]         [ 0.7 1.4 0   0    ]       [ 0.7 1.4 0   0  ]
[ 0   0.5 0   0    ]    x    [-0.7 1.4 0   0    ]   =   [-0.3 0.7 0   0  ]
[ 0   0   0.5 0    ]         [ 0   0   1   0    ]       [ 0   0   0.5 0  ]
[ 0   0   0   1    ]         [ 0   0   0   1    ]       [ 0   0   0   1  ]

Even though we can't see it in the numbers, we end up with a transformation matrix which is not representable with only translation, rotation and scale.
Unparenting the cube results in it's shear changing.

And it's obvious, that we can't scale the right cube towards the shape of the left. We need to scale along the green arrow, but there is no axis of the cube which points in that direction. If the rotations were done at 90° angles, this would not be a problem. Again ...
Most transformations can not be reached using only location, rotation and scale.
But wait, right before unparenting, we were able to see the correct transformation matrix using matrix_world of the child Cube, right? Yes, and that is a way to "apply" the transformation to the points.
What happens to the matrix when unparenting?
How does the matrix change when unparenting since shear and skew are ignored?

We can reproduce this process by extracting TRS from matrix_world with python and the mathutils module.

Get the matrix_world of the child Cube.
Extract the location, rotation and scale using the the matrix' decompose() function.
Assemble a new matrix from the location, rotation and scale.

The result will be the same matrix as the one we receive, when we unparent the Cube. It is different from the original matrix.
import bpy
import mathutils

mat = bpy.context.object.matrix_world

loc, rot, sca = mat.decompose()

mat_loc = mathutils.Matrix.Translation(loc)
mat_rot = rot.to_matrix().to_4x4()
mat_sca = mathutils.Matrix.Identity(4)
mat_sca[0][0], mat_sca[1][1], mat_sca[2][2] = sca

mat_out = mat_loc @ mat_rot @ mat_sca
print(mat_out)

We want the points of the mesh to be transformed by the original mat, but we are left with the reduced mat_out after the transformation.
The Workaround
We want to apply the missing transformation directly to the points, so that the unparented resulting transformation matrix is "enough" to reproduce the original transformation.
Using the naming from the previous code snippet:
mat_out @ mat_h = mat

mat_h is the missing part of the transformation, which is needed to return to the original transformation (mat). We can get it's value with the following line:
mat_h = mat_out.inverted() @ mat

And we can apply this to the cube, before unparenting is with a short script.
import bpy
import mathutils

ob = bpy.context.object
mat = ob.matrix_world

loc, rot, sca = mat.decompose()

mat_loc = mathutils.Matrix.Translation(loc)
mat_rot = rot.to_matrix().to_4x4()
mat_sca = mathutils.Matrix.Identity(4)
mat_sca[0][0], mat_sca[1][1], mat_sca[2][2] = sca

mat_out = mat_loc @ mat_rot @ mat_sca
mat_h = mat_out.inverted() @ mat

# Unparent the object.
bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM')

# Move the vertices to their original position,
# which the mat_out can't represent.
for v in ob.data.vertices:
    v.co = mat_h @ v.co

Paste this script in Blenders script editor and press Run Script or ⎇ AltP. It will unparent the mesh and apply the transformations, which can no longer be represented by location, rotation and scale, directly to the points.


How to add edge which follows geometry I have created a rough head model and added a subdivision surface modifier then set the mesh to follow geometry with the 'adjust edit cage to modifier'. See below:

I want to add a couple of edges back but when I click two vertices and press F, I get the following result:

I don't know why this 'pinching' is occurring but is there a way I can add the missing edges so that they are smooth and follow the geometry?

F creates an edge between the 2 vertices but it won't cut the face, it will just create an edge over the face, what you need to use is J, which will cut the face. You can also use the knife tool: K to activate, C to cut perpendicularly to the view, Z to cut through.


Upgrading an Old Python Script : Change all Image Paths at once I found those script i Think it was for Blender 2.49 to change all imagePath at once,
but I cant get it to work in Blender 2.8...
Can some one help , it would be very handie for flies with lots of images?
import bpy  #Original import Blender

from bpy import context, data, ops
#from ORIGINAL from Blender import Texture, Image, Material

#insert the path which should be replaced
oldpath = "C:\\OLDpath\\"

#insert the new path which replaces the old one
newpath = "D:\\NewPth\\"

image_count = 0

for tex in bpy.data.textures.get():

    image = tex.getImage()
    #print image.name

    filename = ""

    if (tex.getType() == "Image"):

        if (len(image.getFilename()) > 0):

            i=0
            while i < len(image.getFilename()) :

                if image.getFilename()[i:i+1] == "\\" :
                    filename += "/"
                else :
                    filename += image.getFilename()[i:i+1]

                i+=1

        if (oldpath == filename[0:len(oldpath)]):

            temp = filename[len(oldpath):len(filename)]
            temp = newpath + temp

            image.filename = temp
            image.reload()

            image_count += 1

print ("image path's changed:")
print (image_count)

I did a few changes, but cant find the rest od my errors.
I thing some stuff is now depricated but I cant find the 2.8 Version
here is the Path to the ORIGINAL Script
https://blenderartists.org/t/script-to-change-paths-for-all-images/460733

You are right, this script is severely outdated (2009 !) This should do :
import bpy

# The path which should be replaced
oldpath = "C:\\OLDpath\\"

# The new path which replaces the old one
newpath = "D:\\NewPth\\"

image_count = 0

for image in bpy.data.images:
    if not image.filepath.startswith(oldpath):
        continue
    image.filepath = image.filepath.replace(oldpath, newpath)
    image.reload()
    image_count += 1

print(f"Image paths changed: {image_count}")

We take advantage of the python string method string.replace(old_string, new_string) to swap the paths. Note that they must both be written the same way, like in your example.


mach/shock diamonds in blender I'm working on a jet in blender.
While thinking about the final scene, I wondered if there was a way to create schock diamonds(also known as Mach diamonds, Mach disks, Mach rings, donut tails or thrust diamonds) in blender.

Hopefully somebody can help, I haven't found anything online.

Wikipedia link on shock diamond

picture from wikipedia

picture from Tom Clancy's H.A.W.X

thanks for any tips.

tags: mach, schock, diamond, jet, exhaust, afterburner, engine, Physical phenomena

edit: added some pictures,

I had the same issue a while back.

First, this tutorial gave me the general idea on how to achieve a basic exaust

However, since you just need to make an image it should be easier

I came up with two ways to do it:

1. The fast way

Create a exhaust shaped cilinder (I used a cylinder, scaled down one face and welded it to an half sphere on the other end), a toroid and a small UV sphere.
Join the toroid and the sphere, then add an Array Modifier to them (or just duplicate them many times).
Play with the materials using the Emission Shader in the Volume socket of the Output Node (a Volume BSDF with 0 density and Emission turned on will do the trick as well): the toroids and spheres will have a simple orange color with some noise, the material of the main shape is shown in the next method

2. The long and (probably) better way

This method requires a bit of math knowledge, so be warned

create the main exhaust shape described before without the toroids and spheres
make this material

The fist color ramp (the purple/blu one) is creating the main exhuast material, the second is creating the rings. The main idea behind this material is to create cylinders in the exhaust shape that you will then use to model the entire thing.

It can be fairly complex if you don't like math or if you are not experienced with Blender, but with some tweaking the results will be awesome, and you can make it more versatile as well

As you can see, these are not complete ideas: it's 1 AM in the morning here so I don't have time to finish them now.

You still need to add some horizontal noise and the little balls in the second method, and you need to tweak the materials to make them look good (I just tryied to explain you the methods, I'm not doing it for you)

Don't panic!

Here you can download the .blend file ;P


Making an Emission shader emit a different colour of light than the colour assigned to the object? I am making a skydome and I have a texture hooked up with an emission shader for it, however, since the dome is blue it only emits blue light. Is there a way that I can have the whole sky illuminated and have the light reaching the rest of my scene be a different colour?

Assuming you are using Cycles (which you never state what render engine you are using) use a light path node with the Is Camera output socket.

This will tell Blender that the visible color of the object is the one specified, but the emission remains whatever you specify in the above node.


Particles floating above procedural surface I am trying to add particles to a surface over which I have added a texture and they look like they are floating in the air. I know this is because they are sitting on the actual model but is there a way to get around this?

As Gorgious says, it seems like the particle system can't take the Displacement node into account, in that case what you can do is baking the current displacement setting:

Unwrap you object with the Smart UV Project option
In the Shader Editor plug the wave texture only
Create a new Image Texture node, create a new 32-Bit Float image, keep the node selected:

Bake with Bake Type > Emit:

Here is what you should get:

Create a Displace modifier, put it above the ParticleSettings modifier, choose Coordinates > UV:

Load your texture:

In the Shader Editor, replug only the Principled BSDF:

It should work: