Creating a resizable selection cursor in Python I'm writing a tool that would allow me to modify meshes within a circle of certain radius. I'd like to be able to change this radius with a mouse wheel, just like with proportional editing tool:

Here's the relevant part of my code. It blocks zooming by mouse wheel and use it to change the radius instead. Circle selection is called in the cursor position in order to select faces I want to modify.

import bpy

class ModalWheelTest(bpy.types.Operator):
    """Operator which runs its self from a timer"""
    bl_idname = "wm.modal_wheel_test"
    bl_label = "Test mouse wheel"

    _timer = None
    _radius = 10

    def set_wheel_zoom_state(self, state):
        """
        Disable or enable zooming by mouse wheel
        """
        for key_map_item in bpy.context.window_manager.keyconfigs.default.keymaps["3D View"].keymap_items:
            if key_map_item.name == 'Zoom View' and key_map_item.type in {'WHEELINMOUSE', 'WHEELOUTMOUSE'}:
                key_map_item.active = state

    def modal(self, context, event):
        if event.type in {'RIGHTMOUSE', 'ESC'}:
            self.cancel(context)
            return {'CANCELLED'}

        if event.type == 'MOUSEMOVE':
            for area in bpy.context.screen.areas:
                if area.type == 'VIEW_3D':

                    override = bpy.context.copy()
                    override['area'] = area
                    override['region'] = area.regions[4]

                    bpy.ops.view3d.select_circle(
                        override,
                        x=event.mouse_region_x,
                        y=event.mouse_region_y,
                        radius=self._radius,
                        gesture_mode = 3
                    )
                    break

        if event.type in {'WHEELUPMOUSE'}:
            self._radius = min(20, self._radius+1)
            print("radius: {}".format(self._radius))

        if event.type in {'WHEELDOWNMOUSE'}:
            self._radius = max(5, self._radius-1)
            print("radius: {}".format(self._radius))

        return {'PASS_THROUGH'}

    def execute(self, context):
        if context.area.type != 'VIEW_3D':
            print("Must use in a 3d region")
            return {'CANCELLED'}

        self.set_wheel_zoom_state(False)

        wm = context.window_manager
        self._timer = wm.event_timer_add(0.1, context.window)
        wm.modal_handler_add(self)
        return {'RUNNING_MODAL'}

    def cancel(self, context):
        self.set_wheel_zoom_state(True)
        wm = context.window_manager
        wm.event_timer_remove(self._timer)

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

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

if __name__ == "__main__":
    register()

My question is: how can I draw a white circle in the 3D view window so I can actually see what I am selecting? I'm expecting that I'd clear it on every modal method call and then redraw it with actualized radius and cursor position.

Thanks to this answer I've figured it out. I am drawing the circle using OpenGL calls. Here's updated code I can use to select faces in edit mode:

import bpy
import bgl
import blf

import math

def draw_circle_2d(color, cx, cy, r, num_segments):
    theta = 2 * 3.1415926 / num_segments
    c = math.cos(theta) #precalculate the sine and cosine
    s = math.sin(theta)
    x = r # we start at angle = 0
    y = 0
    bgl.glColor4f(*color)
    bgl.glBegin(bgl.GL_LINE_LOOP)
    for i in range (num_segments):
        bgl.glVertex2f(x + cx, y + cy) # output vertex
        # apply the rotation matrix
        t = x
        x = c * x - s * y
        y = s * t + c * y
    bgl.glEnd()

def draw_callback_px(self, context):

    bgl.glEnable(bgl.GL_BLEND)

    # ...api_current/bpy.types.Area.html?highlight=bpy.types.area
    header_height = context.area.regions[0].height # 26px
    npanel_width = context.area.regions[1].width
    transorm_panel_width = context.area.regions[3].width

    width = context.area.width - npanel_width - transorm_panel_width
    height = context.area.height + header_height

    # draw text
    bgl.glLineWidth(4)
    draw_circle_2d((1.0, 1.0, 1.0, 0.8), self._mouse_pos_x, self._mouse_pos_y, self._radius, 360)

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

class ModalWheelTest(bpy.types.Operator):
    """Operator which runs its self from a timer"""
    bl_idname = "wm.modal_wheel_test"
    bl_label = "Test mouse wheel"

    _timer = None
    _radius = 50

    def set_wheel_zoom_state(self, state):
        """
        Disable or enable zooming by mouse wheel
        """
        for key_map_item in bpy.context.window_manager.keyconfigs.default.keymaps["3D View"].keymap_items:
            if key_map_item.name == 'Zoom View' and key_map_item.type in {'WHEELINMOUSE', 'WHEELOUTMOUSE'}:
                key_map_item.active = state

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

        if event.type in {'RIGHTMOUSE', 'ESC'}:
            self.cancel(context)
            return {'CANCELLED'}

        if event.type == 'MOUSEMOVE':
            for area in bpy.context.screen.areas:
                if area.type == 'VIEW_3D':
                    self._mouse_pos_x = event.mouse_region_x
                    self._mouse_pos_y = event.mouse_region_y

                    override = bpy.context.copy()
                    override['area'] = area
                    override['region'] = area.regions[4]

                    bpy.ops.view3d.select_circle(
                        override,
                        x=event.mouse_region_x,
                        y=event.mouse_region_y,
                        radius=self._radius,
                        gesture_mode = 3
                    )
                    break

        if event.type in {'WHEELUPMOUSE'}:
            self._radius = min(200, self._radius+5)
            print("radius: {}".format(self._radius))

        if event.type in {'WHEELDOWNMOUSE'}:
            self._radius = max(5, self._radius-5)
            print("radius: {}".format(self._radius))

        return {'RUNNING_MODAL'}

    def execute(self, context):
        if context.area.type != 'VIEW_3D':
            print("Must use in a 3d region")
            return {'CANCELLED'}

        self.set_wheel_zoom_state(False)

        wm = context.window_manager
        wm.modal_handler_add(self)
        return {'RUNNING_MODAL'}

    def cancel(self, context):
        self.set_wheel_zoom_state(True)
        bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
        wm = context.window_manager

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

            self._mouse_pos = []

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

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

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

if __name__ == "__main__":
    register()


Which function for "pressed" on keyboard? How to code in python for BGE as detect "pressed" on keyboard ?

Example, AKEY to move x coordinate but when press A key it don't move infinitely however it does pressed...

How to solve it? Thanks

I found a link on blender.org here: https://docs.blender.org/api/blender_python_api_2_59_0/bge.events.html It covers keypresses using bge.events


Hotkey to Frame all Objects into viewport? Is it possible to set hotkey F to View/Frame All objects into all viewports, and if any objects are selected will frame that object within all view ports as well with key F.
I would be very grateful for any tips.

To frame all objects in one viewport do: Home or Ctrl + Home Both with the origin as the camera focal point
Or Shift + c
This will also bring the 3D cursor back to the origin.
Numpad . will frame the currently selected object or objects.
Numpad / will frame the currently selected object or objects and hide everything else, until you press it again.
You can change them here (to F):

This however will affect only the (single) viewport under the mouse cursor.
I imagine affecting multiple viewport at once will require a script, but i'm not sure.
EDIT:
If you want to experiment with a different hotkey layout you can always click Add Key-config Preset (the little "+" icon), to make a new preset and try some things without messing up you current key setup.


What is the 2.8 shortcut for "Operator Search" on Mac? I would like to know what key or key combination opens the search field in Blender 2.8 on a Mac. Can anyone answer this? "F3" does not do it.
Thanks!

You have to hold down function (fn) then hit f3.


How to use a PBR Material’s Mask Image I downloaded a texture from https://cc0textures.com/view?tex=Marble03 which includes a mask.jpg file.

How do I integrate that new file into a node map? Here is my current node map.

Masks are used to mix other things. Mask is usually a grayscale image that controls how much of one thing you can see through another. You can use masks to mix different textures, colors, shaders and you can even mask effects you apply to something with them so it's really hard to tell what this was originally supposed to be used for. You could try to see what feature it matches on the material and see if it might be useful to you for anything, but it may also be that it is included by mistake and is not needed for anything in this particular case.


What are the new 3D cursor features introduced in 2.73? Just noticed that while dragging the 3D cursor values for constrained axis can be entered, and the cursor can snap to faces. The status header shows MEDIAN,Global,FACE how can these properties be influenced?

This feature is added by the Enhanced 3D cursor addon it is best to read it's rather long usage entry to learn about it's functionality.


Python Modal Operator Selection Delay I made a small modal operator that prints the name of the object I select. however each selection made is one object behind.
example:
select object 1 then select object 2. when object 2 is selected it will print the name of object 1.
code:
# Import
import bpy

# Properties
class Blank(bpy.types.Operator):
    bl_label = "Blank"
    bl_idname = "blank.example"

    # TESTING ##################################################################
    def modal(self, context, event):
        if (event.type in 'LEFTMOUSE' and event.value == 'RELEASE'):
            # name = bpy.context.active_object.name
            name = bpy.context.object.name
            print(name)
        if event.type == 'ESC':
            return{'CANCELLED'}
        return{'PASS_THROUGH'}

    def invoke(self, context, event):
        context.window_manager.modal_handler_add(self)
        return{'RUNNING_MODAL'}
    ############################################################################

# Menu on the Sidebar
class Blank_PT_Panel(bpy.types.Panel):
    bl_label = "Panel"
    bl_idname = "OBJECT_PT_Blank"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = "Blank"
    bl_context = "objectmode"

    def draw(self, context):
        layout = self.layout
        # Button
        row = layout.row(align=True)
        row.operator("blank.example", text="Button", icon="QUESTION")

# Registration
classes = (
    Blank_PT_Panel,
    Blank,
    )
def register():
    from bpy.utils import register_class
    for cls in classes:
        register_class(cls)
def unregister():
    from bpy.utils import unregister_class
    for cls in reversed(classes):
        unregister_class(cls)
if __name__ == "__main__":
    register()

How do you make the selection display the name of the object without any delay.
P.S. Code edited to run from the Blender Text Editor as requested. it creates a tab called blank on the Sidebar(N-menu) and a single button inside. Press it to run the code in question.

I was poking around and I think I found a solution:
# Import
import bpy
from bpy.props import StringProperty

# Properties
class Blank(bpy.types.Operator):
    bl_label = "Blank"
    bl_idname = "blank.example"

    current: StringProperty()
    last: StringProperty()

    # TESTING ##################################################################
    def modal(self, context, event):
        current = bpy.context.active_object.name
        if event.type == 'MOUSEMOVE' and current != self.last:
            name = bpy.context.active_object.name
            print(name)
        if event.type == 'ESC':
            print("CANCELLED")
            return{'CANCELLED'}
        self.last = bpy.context.active_object.name
        return{'PASS_THROUGH'}
    def invoke(self, context, event):
        context.window_manager.modal_handler_add(self)
        self.last = bpy.context.active_object.name
        return{'RUNNING_MODAL'}
    ############################################################################

# Menu on the Sidebar
class Blank_PT_Panel(bpy.types.Panel):
    bl_label = "Panel"
    bl_idname = "OBJECT_PT_Blank"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = "Blank"
    bl_context = "objectmode"

    def draw(self, context):
        layout = self.layout
        # Button
        row = layout.row(align=True)
        row.operator("blank.example", text="Button", icon="QUESTION")

# Registration
classes = (
    Blank_PT_Panel,
    Blank,
    )
def register():
    from bpy.utils import register_class
    for cls in classes:
        register_class(cls)
def unregister():
    from bpy.utils import unregister_class
    for cls in reversed(classes):
        unregister_class(cls)
if __name__ == "__main__":
    register()


rendering without light only texture as they are I am new to blender and I only want to take pictures of 3d model from the side. I have everthing set up. Camera is looking exactly from the side and set to orthographic.

But either I have a light which leads to surfaces being differently illuminated as they would in reality or I don't have a light and everything is black.

All what I want to have is the texture (jpeg) on my model as they are in the jpeg.

How can I achieve this?

Thank you:)

I'm not sure if you're trying to do this. Here's my solution:

Hide all lights in your scene by selecting lights and pressing H.
Set your world to white. If there's no color selection, you may check "Use Nodes" to create nodes before you change the world color.

Use Node Wrangler. It's a built-in plug-in. Ctrl+Alt+U to call User Preferences. Go to Addons and search "Node Wrangler", and tick it, then save user settings.
Go to Node Editor, and build up your materials for the object. Once finished, you want to make a solo preview of your texture, so press Ctrl+Shift+LMB on an image node of your diffuse BSDF to make it solo in preview.

(The dotted line was the original line in final, but I make a solo preview of the texture, as you can see the Material Output receives input from a Viewer, followed with Image node.)

Render, or make a viewport render, by Shift+Z.

Alternatively, You can also make screenshots in Material viewport.

Hope that helps.


Absolutely no light showing...totally at a loss Really can't understand why I can't see anything.  Tried moving lamp and camera, increasing strength, but nothing.  Can't even see light in the lamp preview.  I'm pretty new to Blender, so I feel like I must've done something accidently along the way.

http://www.pasteall.org/blend/38975

It seems fine for me, I get quite a neat render.
But if you want it to light up all of the boxes, just change it to a sun lamp.

If this is not what you were asking for, or I am not clear, please tell me.
Thanks!


Single particle in proper place So. I am making a pantograph lifting animation and to achieve realism, on the moment when the pantograph touches the overhead wire I want to make a single perticle - spark but the single spark is emitted in the back of the overhead wire(see picture). How do I change particle's location?

you can change to emit at vertices and make the vertex exactly at your needed point, by changing the seed value.
the other possibility: just add a single vertex at the point where you want the emitter to be and add on that vertex your particle system -> done


My "Mix Shader" node doesn't have a "Fac" input socket I have seen some videos, but I noticed that there is a problem, is there no "fac" command on Mix Shaders?

i can't find it... (blender is in italian: "somma ombreggiature" ==> "mix shaders")

There is a Mix Shader node with a fac input and an Add Shader node with only 2 shader inputs, they are not the same node :

Or in Italian


Syntax highlighting in Python prompt The Blender Python documentation has a very attractive colour scheme:

Is it possible to get this colour scheme in the Python prompt?

Syntax highlighting in the Python command line is not supported currently.


When extruding, why can't I extrude any faces or edges because I am stuck on extruding vertices? I am trying to extrude faces but every time I click on a face, it changes to vertices

Select the object you want to edit by right-clicking it.

Tab into Edit mode.

Select the vertices, edges, or faces you want to extrude.
Use any of the selection methods listed in the previous section.

Extrude your selection in one of several ways:

Use the E hotkey.

Left-click Add→Extrude Region in the Tools tab of the Tool Shelf.

Choose Mesh→Extrude→Extrude Region from the menu in the 3D View’s
header.

After you extrude your selection, Blender automatically puts you into grab mode on the newly extruded parts.


Is there a way to place a material over other materials (subdermal base) i was investigating on how to properly make a realistic skin and i found that to make one i need to combine the skin texture (skin texture and imperfections) + a subdermal base (veins and such) + the subsurface scattering.

So, i was thinking: "Mmmm, okay, let's just use two image textures with a Mix RGB and and change the display to "Screen" or "Multiply" and both will be seen in my skin texture"

But i found that the results are not very "convincent" (maybe i'm doing it wrong), so... there's an alternative or "correct" way to do this?

The thing is that i want to make something like this:

Use a Subdermal Base with the veins and muscle red colours

The skin texture over the subdermal base which will give the skin a realistic look

Try using the Principled shader. It has SSS, diffuse, and roughness all built in. Connect the subdermal texture to the SSS color input, the skin texture to the color input, and set the SSS amount to something other than 0. You will probably have to adjust the subsurface radius to get it looking right. If I recall correctly, you want the red value (the top one) to be the highest by a fair bit, then green, with blue slightly below green. The radius is essentially the 'depth' of the scattering effect for each light color (RGB). Human skin is red when you shine a light through it, so that is why you will want the red value to be higher. I believe the radius is in blender units, so keep that in mind with the scale of your object. You don't want the radius to be larger than the width of your model, as that will make the entire hand translucent, and look fake.

Some other things to consider to get great looking skin is some subtle bump and a roughness texture (using the Principled roughness and normal). That will really help make the skin look realistic, as skin has some subtle reflections and surface texture.


Is there a way to render particles as if they were a single liquid? I don't want to use the fluid simulator beacuse i've been getting more controlled results with the particles system feature + using a guide as a force field.

What i'm trying to accomplish is water flowing inside a pipe. I don't need it to be realistic but i need an inner flow to be perceived.

So i was thinking of using a particle system guided with the same curve that models the pipe (so it follows its shape) and maybe add a smooth modifier to the result, to make it appear as though the multiple particles are only one fluid.

Of course if you think there's a way to achieve this easily with the fluid sim, or maybe there are ways to control it more preciselly, I will be glad to listen to your suggestions. But if what i'm asking is possible i would like to go that way or even a lower-tech solution (without any kind of simulation at all!)

Thanks!

If you set up a particle system that works, you can use metaballs as the object it emits, so it looks like it's one smooth "fluid". Metaballs will merge together into one smooth shape. The result isn't perfect, but it's decent:


how to texturize correctly an interior using ONLY the reference image with which it has been created This interior :

is a 3D representation of this reference image :

I would like to learn how to texturize it also exactly. It means that I would like to know what's the workflow that should I use if I want to convert the only reference Image that I have into the needed textures to reproduce exactly its look.

On youtube I found a tool and a tutorial that teach how to convert a single image into its textures,it's called "Materialize -- An AMAZING Free Texture Map Generating Tool" Please give a look at it going here.

I should only give the original picture to the tool and it creates all the textures that I need : diffuse ; edge ; height ; metallic ; normal ; smoothness.

Also,on blender 2.8 I'm using the addon "rapid PBR material creator",that you can find here. It creates all the material nodes with one click.

The problem is that the ground does not seem like that on the original picture,I think because it's not enough to do a simple UV unwrapping :

So,what can I do here ? thanks.

That is not possible.
(in the context of a result of practical accuracy or quality)
The image you have is the result of complex light interactions with various surfaces. One image simply does not contain all the data required to reconstruct the scene at this level. Think of it this way - if you add 15 and 45, you get 60, however if I only tell you the result, there is no way for you to know it was 15 and 45 I added together, it could be 30 and 30 for example or any other numbers that make 60 when you add them together. Your image is exactly the same way only a result. It is possible to interpret the image and then reconstruct the scene using artistic interpretation, however that will require a lot of experience, guesses and additional images for texturing as well. If you have a look at the floor for example, since we are viewing it from an angle we are seeing a lot of specular reflection instead of the diffuse color of the floor - many kinds of dark brown floor could look like that from this angle. It would also be impossible to recreate the painting without even seeing it as well as many other objects.
It seems the path you are trying to take does not lead anywhere. The logical thing to do would be to reevaluate your broader situation, context and goals and see if what you are trying to do might be possible some other way.


"ValueError: could not convert string to float: b'0,000000'" when import obj file Imported obj file of a OSM
size 22 Mb

Is it a bug?

The significant trace in plain text: "ValueError: could not convert string to float: b'0,000000'" with the ',' (instead of '.') can be seen.

Yes, i opened MTL file with Notepad and replaced all the "0,0" expressions with "0.0" and it is working now


Glossy Shader not what I need it to be I am trying to make a die that looks glossy (as most dice do), but using the glossy shader in the way I did fades out the texture underneath. The pips turn into a grayish metallic color, and the whole image texture looses its strength.
So I need to find a way to make it look glossy but still an obvious texture underneath. How can I do this?

This is on 2.73.

This answer won't be an answer to your question directly, but I believe it will help you achieve what you want.

Before you do anything in blender, first try this:
place a lightsource low on a flat, slightly reflective surface, for example a wooden table. Look at the reflection of the lightsource on the surface from a high point of view and a low point of view. You will see that the surface is more reflective when looked at from a low angle than a high angle. Basically, the angle at which you are looking at the surface influences how reflective the surface is.

Now back to blender.
In order to create a realistic looking material, you need to use the same principle. In your current node setup, you are simply mixing a glossy shader with a diffuse shader. This means that your object will be half the color of the texture, and half the color of the light it is reflecting, which is most often white. And a black texture and a white reflection create, as you can probably guess, a grey mess, no matter from what angle you are looking at it.

In order to fix this problem, you need the material to behave like a real world material, like the surface from earlier in this answer. This sounds much harder than it actually is, the only thing you have to do is connect a fresnel node to the fac input of the mix shader, and you're done.

The fresnel shader connected to the mix shader:

From left to right: a diffuse only material, a material with diffuse and glossy mixed with a value of 0.5, and the above material with the fresnel node.


Background grid warping when zooming in User Persp New Install
Blender 2.7b
Ubuntu 16.04LTS

Whenever I zoom in User Perspective mode, the background grid warps alot as you can see on the bottom right of the first image below:

it returns to normal when I zoom out or in orthographic mode:

I think this might be because of the small screen size that I have (1366x768), or because of some settings in Ubuntu, but I can't quite work it out. What should I do to fix this problem because it is very annoying. Thank you for your time.

--A Blender newbie

This is a normal wide-angle perspective distortion. To reduce it, you need to look at your subject through a longer lens from further away.

Bring up your right-hand panel (hotkey N) find the 'view' section, and change the 'lens' length to a higher number, and track back using the middle mouse wheel.

The longer the lens, and the further away you pull back the camera, the more closely the view will approximate to orthogonal, just as in real-life photography.


An edge turned pinkish but it's not seam after putting subdivision surface modifier I am making the Blender Guru donuts. I noticed this edge of this reddish color after putting subdivision surface on the donuts icing. It's not seam cause I can't remove it with U -> Clear seam.

What is it and how do I remove it?

I guess it's the Crease, select this edge loop, open the N panel > Item > Edge Data and bring back the Crease to zero, or select, ShiftE and drag. It is used to sharp angles.


I am trying to animate an object with a very simple animation but it does not work I am not very good at blender but I know the basics.
I am trying to make a simple animation in Blender. I add the keyframes, and play the animation, however, when I play the animation the keyframes between the main keyframes, does not seem to play or happen.
I have searched for this problem, but i could not find any helpful answers to my exact problem.
Edited:

On the first frame it looks normal, but it is after the first frame that the problem occurs

On this screenshot, the cube is still at the original place but it is further in the animation. Lastly

Here the cube has finally moved, but it teleported there instead of "moving" there.
What do I do?

I think you accidently set your animation to constant interpolation(documentation).
You can make the cube move(not teleport) by setting interpolation by setting interpolation to linear or bezier. To set the interpolation, select the animation point or points(Diamond shape in timeline), press t and select linear or bezier.


Custom image format importer I've created an importer for an obscure texture format and I can invoke it as an operator successfully. Because I'm chaining two addons together, (a model importer that also automatically imports textures), I really want to get the resultant image object from the texture import operator so that I can properly . However, because operators can only return success or failure codes (eg. {'FINISHED'}), I can only really guess as to what the resultant image name might be.

The texture importer execute function looks like this:

def execute(self, context):
    dtx = DTX(self.filepath)
    image_name = os.path.splitext(os.path.basename(self.filepath))[0]
    image = bpy.data.images.new(image_name, dtx.width, dtx.height, alpha=True)
    image.pixels[:] = dtx.pixels[:]
    # I want to "return" the image to the caller, indirectly, somehow.
    return {'FINISHED'}

The model import script calls the texture importer like so:

bpy.ops.io_lithtech.import_dtx(filepath=texture)

Is there a way to indirectly return anything from the execution of an operator?

Normally you should implement the Operation as a wrapper on existing code. This way you can call an internal method what can return more information. This is also faster as operations creates undo files.

def load_dtx_texture(filepath):
        dtx = DTX(filepath)
        image_name = os.path.splitext(os.path.basename(filepath))[0]
        image = bpy.data.images.new(image_name, dtx.width, dtx.height, alpha=True)
        image.pixels[:] = dtx.pixels[:]
        return image

class MyTextureImporter(Operator):
    def execute(self, context):
        load_dtx_texture(self.filepath)
        return {'FINISHED'}

class MyMeshImporter(Operator):
    def execute(self, context):

        ....

        image = load_dtx_texture(self.filepath)

        ....

        return {'FINISHED'}


How do I preview in composing? I'm watching a lecture.
When a YouTuber added and changed nodes in composing, the image below changed according to that.
How do I get a real-time rendering image?

The main window is the Compositor, and not visible in the screenshot there must be a Viewer Node to the right. Backdrop is disabled, so you don't see the composite behind the nodes.
In the bottom left corner is the UV/Image Editor and below your red frame you can see that the display is set to Viewer Node instead of the default Render Result.
So everything changing in the Compositor which you normally watch in the backdrop is displayed in the Image Editor.


Unable to sculpt a cube I wanted to practice with the sculpting tools, so I tried them on the starting cube but none of them do anything I think? Or if they're doing anything it's not inherently noticeable.

Nascent Space's comment:

If you didn't add enough geometry to sculpt, it won't do anything unless you click on the corners of it. Make sure to either turn on dyntopo at the top right of the sculpting viewport or add a subdivision surface in the modifiers tab, or just subdivide the cube in edit mode.


In animation nodes rotation around an object I'm trying to find how to make rotating an objet around an other object using animation nodes.
It seem something basic to me but there is not so much solution in google for this problem.
Thank you.

Use Combine Matrices node. You can add more to the matrix list for more complex transformations.


How to remove extra materials from a mesh if the mesh has more than 1 material? I am trying to write a little script that checks if mesh has more than one material, and if it does, remove materials until there is only one left on the item. Here is what I have so far:
import bpy
for ob in bpy.data.objects:
    number_of_mats = len(ob.material_slots.items())
    if number_of_mats > 1:
        for i in range(number_of_mats-1):
            # remove material here?

I cannot seem to figure out the method to remove a mat at this point. Any suggestions?

You can set the index of the list to 1, iterate through the upcoming slots, call and override the context of material_slot_remove(). Demo on how to remove all slots > 0:
for obj in bpy.context.selected_editable_objects:
    obj.active_material_index = 1
    for i in range(1, len(obj.material_slots)):
        bpy.ops.object.material_slot_remove({'object': obj})


How to model a ridged cone (using modifiers)? See the picture at the bottom for what I want to model.  I’m using Blender 2.8 Beta.

I was thinking an open cone (that is, bottom face removed) with some modifiers applied, and a creative texture, should do this.  But as a beginner I'm in over my head.

I was first inspired by something I had seen with the wireframe modifier, which can produce the nest-of-spikes effect on a cone.

But it doesn’t quite work right (I could cut off the bottom using a Boolean, though) and I don’t have any control:  Make the creases shallower but still broad enough to span to the next.  With “Relative thickness” it gives points that extend past the end, but they are far too long, and again, I can’t control that separately.

Meanwhile, I was thinking the top-to-bottom scale-like ridges could be done with a modifier, as I see there are some named “Wave” and “Displace” but I can’t figure those out when I just tried it to see what happens.

The final bumpiness could be done with a bump map procedural texture, I’m sure.  I’m familiar with the concepts from POV-Ray (years ago), but looking at the node editor I was again at a loss as to how to do that.

Any suggestions, or pointers to tutorials or .blend files that contain similar features that I can learn from?

Here is a way to do it:

Create a plane, go in Edit mode, rotate on the X axis and scale it, move it a bit away from its origin on the Y axis.
Cut it in half with a vertical edge loop, give it a Mirror modifier, enable the Clipping option.
Create an empty on the same position as the plane origin.
Select the plane, give it an Array modifier, deactivate Relative Offset and activate  Object Offset, choose the empty as the Object. Choose a Count of, for example, 18. Activate the Merge and First Last options.
Rotate the empty 20° on the Z axis.
Select the plane, go in Edit mode and edit the plane mesh, move the vertices, add some vertical edge loops.
Give your plane a Subsurf modifier, add some horizontal edge loops.
When you'll be glad with the result, keep a copy, then apply all the modifiers except the Subsurf, remove the doubles, close the top with some altM > Merge.


When I Change My Frame Rate from 24 the 60 fps the particles go ultra fast and are not normal speed anymore I have been using blender for a while. I just tried a youtube video on using bubble to match with music and realized my frame rate was 24 so I changed it to 60fps nd my animation was ultra fast and was ruined. thankful it was easy to redo so I tried he whole old map and new map trick and got nowhere. it just broke the animation. Any help on how to make this run at a normal speed but be in 60 fps instead of 24 or 30. I am using cycles by the way.
 . When I changed the thing around that you guys recommended they go from bouncing to flat.

This Is How It Is Suppose To Look.

Note that the frame rate is back at 24 and the map is set back to 100.

Ok, I see what's happening now.  The reason it's going wonky is because you need to bake the particles first:
Just to make sure it's right, do it before you change the framerate.

After it's completed baking (it could take a minute depending on your processor speed), set the end frame and framerate settings as shown below:

Here's the final, notice the fps in the upper left hand corner:


Is there something you're supposed to write in for blender scripts in BGE? I couldn't find anything online and well... when I bring up my code, which makes a simple sphere in BGE blenders game engine it doesn't run til after I close the game and that's where it creates the mesh. Is there something you're supposed to put into the code for blender to run it outside of the viewport?

here's my code, it runs and does what I want it to... only after I've closed BGE which noone else seems to have run into.

import bpy
for obj in bpy.context.selected_objects:

    bpy.ops.mesh.primitive_uv_sphere_add(location=origin)
    bpy.ops.transform.translate(value=(ObjX,ObjY,ObjZ))
    setMaterial(bpy.context.object, blue)
    bpy.ops.object.shade_smooth()

if __name__ == "__main__":
    run((0,0,0))

here's my code, it runs and does what I want it to... only after I've closed BGE which noone else seems to have run into.

Your code is Blender code rather than BGE code.

You basically tell Blender what to do. But you want running a BGE game session.

BGE behavior is setup via Logic Bricks (Logic Editor). You can create a custom Controller brick. It refers to a text block (script mode/module mode) or an external python file (module mode).

The code should not refer to Blender (do not import bpy). When you distribute your game Blender will not be available and running such code will result in errors.

More information can be found at Blenderartists.org. E.g. The BGE Guide to Python Coding

Just to let you know: The BGE does not support mesh creation. All objects and meshes must be loaded either at startup or via Python code while running the game. You can make copies of loaded objects as long as they are inactive (reside on an hidden layer).


Curve Modifier doesn't work at all in some curves Not even deformation of shapes I've been working on a project that is basically just a lot of bezier curves that I have to put some complex shapes on, I use the common Array with Follow Curve and then the Curve Modifier, it works wonderfully but there are some curves that for some reason seem to not work at all.

They don't even deform the shape on any axis, it just sits there doing nothing. Why is this? I checked all the settings in the curve tab but everything looks the same as the ones that work!

Blend File

Example of 2 curves

Edit: Updated file, as you start up you can see 2 curves, one that works with the modifiers and one that doesn't.

I think curve called Problem Curve does really has problems. I couldn't reproduce this behaviour which is the fact that neither Fit Curve option of Array modifier doesn't work nor mesh can't be curved with it. Re-adding modifiers also won't change that.

The possible solutions are:

model another curve and use it instead of this one;
refresh several settings of Array modifier and clean existing curve.

If using the second solution, the steps are:

With Problem Curve_Model selected in settings of Array modifier set Fit Length, set some random value, then return option to Fit Curve.
In order to finish solution you should clean the curve; it has too many vertices which is overkill in this case (and for some reason it allows modifiers to work further on mesh object).
Select curve, in Edit mode select all, make any vertex active and in 3D View header choose Select > Checker Deselect operator. When vertices are selected one by one, delete them via X > Vertices. The mesh will become curved. Make sure to recalculate normals on the mesh (Ctrl+N in Edit mode with all selected).


How to cut with Knife Tool parallel to the other edge in Ortho\Persp view? How to cut with Knife Tool parallel to the other  edge in Ortho\Persp view? Blender 2.79b

In this case Offset Edge Slide will suit the situation, although it will create additional geometry.
Select the edge you want the new one to be parallel to and run the tool from the left area of the viewport (depending on Blender version) or Shift+Ctrl+R.
The tool has the same properties as Knife which means you can make edge being created parallel to the edge you choose to. To make it parallel to the top one in this case enable Even in the tool options (press E while operator is running) and choose orientation by enabling Flipped (or with F) as desired.
Then select the other edge created on the other side of the main edge and dissolve it.

Note that with topology in question you might need to make a clean-up depending on the purpose of the model. For example, the shown topology isn't suitable for Subsurface modifier and might provide artifacts if bevelled.

Regarding the Knife tool for this case. It is not possible to cut with it as shown in your screenshot. Knife tool can only cut under certain angles (0, 45 and 90) and it can't use perspective as a guide for the straight cut.


My bullets dont make the enemy die? I have a physical bullet that spawns and that has an always motion.  When it hits the enemy it does not make him die.  I am trying to have a collision sensor on the enemy to make it end the object with the Edit Object actuator.  Also, on the collision sensor on the enemy, no propertys are in the list even though I added a property to the bullet?  Should the property be in a certain way?  I left it default cause I did not think that mattered.  Please help!

You must type in that property which you added to bullet(there aren't any lists in this sensor) or set collision to bullet's material(M/P, than choose the one that bullet has).


Missing UVs, Detected! I'm trying to texture paint a character in Blender, and I am loosely following a tutorial, just so I know what I'm doing. So this is what I've done:

Went to the Texture Paint tab.

Created a new material (on my character) and then in Base Color, clicked on the dot on the right side and then clicked Image Texture. I then created a new texture with the size of 2048px.

In Object Mode, I clicked on the Shading arrow on the right, near all the viewport shading buttons, and then clicked Flat.

(This was either step 3 or 4,) but I saved the texture and placed it near my .blend file.

That's where I stopped, because it gave me the warning. This is the current screenshot of what the editor looks right now:

I've searched on the net already, and saw this article, but the suggestions weren't really helpful.
Also in the same question, I was wondering how the person got this:

Menu to show, as the GIF was to fast for me to catch it.
Also I have seen these questions:

I am not able to use texture paint (2.8)
missing files blender 2.82 Missing UVs, Textures, detected!

But none of those worked. In the question number 2, I did try to change mode to Single Image, but nothing worked.

Maybe I'm changing it in the wrong place?

I've finally fixed the problem in the answer to this question. I needed to click Add UVs and then upload the (blank) texture I had.
In the tool bar, I clicked Draw and then it gave me the options to paint the character.
However, I had another problem, which is that when I try to paint my character, the paint did not show. I fixed it by this answer.


HDRI Renders in preview but not in final render I am having an issue with using an HDRI environmental image to light an indoor scene. It was working correctly when all of the sudden the shadows stopped showing in the render.

I don't recall doing anything particular between one try and the other, except for adding a plane lamp to brighten up the scene a little bit. After this happened I deleted the plane of light just in case that was the reason but still no shadows.

I leave my environment settings, my render settings, the preview of how the shadows should be and the render after hitting F12.

One thing that is worth mentioning is that my graphic card ran out of memory for the first time. I solved this by switching to CPU and back to GPU Compute, but maybe it has something to do with the main problem. I leave also my system info and I have a NVIDIA GeForce GTX 960.

So, I was able to solve the problem by cleaning up the model. I deleted a lot of objects and now it renders correctly as usual. I guess it was a problem with my system and nothing with the model itself. Thanks again to everyone for the assistance and help! Have a great day


Compositing with render layers that are unchecked I am making an animation that has two render layers RL1 and RL2. Frames 1-10 contains only RL1, Frames 11-20 contains a mixture of RL1 and RL2, Frames 21-30 contains only RL2.

In order to save time I have animated the check mark (see picture) of the RL1 and RL2 so that they are only checked in frames 1-20 and 11-30 respectively.

The compositing nodes are shown as the picture below. Frames 1-20 outputs what I want. However, between frames 21-30 the output becomes black as RL1 doesn't output an image.

Are there any neat ways to ignore a render layer with no output?

This link is the closest answer I've found:
"How to stop rendering a renderlayer at any moment of the animation?"
However, as gandalf3 admits, the method doesn't work if the render layers contain alpha values

It could be more efficient not to animate the renderability of the Render Layer rather than to animate amount of samples for that Render Layer instead.

Find and animate Samples option which will override scene setting for samples.

This amount of samples can be set up for each Render Layer separately. So when that layer should be empty, drop the samples amount to some small value (but not to 0 as it will mean default which is the scene values) and the perfomance will be increased.

The layers still will be overlayed; you can bypass data from one of them animating the Factor of the Alpha Over (or Mix) node (e.g. setting it to 1 to make only bottom layer visible).


Weird artifacts appeared in eevee because of normal map I'm was working on a shotgun and suddenly for some reason some weird artifacts appeared on the metal materials.

I know that removing the image texture and leaving only a noise texture+bump on the normal input makes the artifacts disappear and also I don't see it when rendering in cycles:

It was working with no problem before. I already tried copying the model to a new file and it didn't work.

the file:
http://pasteall.org/blend/index.php?id=51576

You should delete your UV Maps in the Object Data. Since you're not using UV Map based texturing.

Otherwise, you'll get unwanted UV Map data assigned to your mesh.
Best to just delete them when they're not being used.

In your case, (as shown in the picture above) because you are not using UV Map based texturing for any part of your model; you should delete the UV Maps for all the parts of the model.


Rotating an image in a scene After looking at other solutions on this, I'm not sure how to proceed, as I'm just new to Blender. I have an image mapped onto a picture frame asset and I'm changing a parameter but it's not the correct one. The Displacement angle value (bottom right) doesn't seem to do it. How might I adjust it to display in the correct orientation? Thanks for any help.

Displacement is entirely the wrong place! Displacement is for elevating or lowering the surface (like if you wanted to emboss something).
What you want to do is alter the texture coordinates somehow.
In this case, probably just rotating the UV map 90 degrees will do the trick. You can do this in the UV Editing screen.


part of mesh not rendering New to blender, ive made a hood to add to the clothing of a character, but when i export to the programs im using for modelling its only partially rendering. Its rendering fine on blender, but ive tried loading it on a couple other programs to the same results.
enter image description here

Other programs might have "Backface Culling" enabled by default, which means the faces become invisible / transparent when viewed from the inside or backside of the face (i.e. it's normal is pointing away from the camera).
To correct this you can press Shift+N as suggested in the comment, but you have to be in Edit Mode for that. You can select single faces you want to recalculate - if you don't know which faces are flipped it's better to hit A to select all faces before recalculating. The Recalculate Normals function also has a tickbox "Inside", which usually makes the inside pointing outwards but can be helpful if Blender miscalculates the normals on a more complex mesh.
You can also press Alt+N for more options of manipulating the face normals like "Flip" for example, to simply flip the direction no matter if Blender thinks it's outside or inside.
If you clearly want to see which faces are flipped before you export a mesh, you can do this by enabling Face Orientation in the overlays. With this option Blender shows the outside of faces colored in blue and the inside or backside of faces colored in red. In my screenshot you can see some red faces, this indicates their normals are flipped. The color overlay is shown in Object Mode and Edit Mode.


Is it possible to auto generate and superimpose Frame# over images imported into video edit? I imported a series of images into the video editor and I would like the rendered output to show the frame number, or better yet the file name of each image, on each image. Is there a way to automatically generate that number?
Why do you ask? The still images are used in reports and frame numbers or file names would make it easier for my customers to find the desired image.
  Thank you,
    Paul

Yes it's possible.

You just have to open the Metadata section in Render Tab of Properties panel, check Stamp output, adjust the size and colors, and check the Seq. strip box (uncheck all other if not needed), and it will print the filename of the current rendered image on the top right corner of the output.


Simple rotation animation using command-line python script I've been trying to generate a simple rotation animation entirely using a python script from command-line. The animation file gets generated with the configured frames and all, but the rotation applied to the cube object doesn't reflect in the animation. Could you please point out to me what I'm doing wrong?

My code involves sample.blend, which is a blender file with the default scene with cube, and renderAnim.py (code given below). I invoke this from the command-line as: blender -b sample.blend -P renderAnim.py

import bpy

scene = bpy.data.scenes["Scene"]
mycube = bpy.data.objects['Cube']
mycube.rotation_mode = 'XYZ'

scene.frame_start = 1
scene.frame_end = 100

scene.frame_current = 1
mycube.keyframe_insert('rotation_euler', index=0 ,frame=1)

scene.frame_current = 100
mycube.rotation_euler = (0,0,180)
mycube.keyframe_insert('rotation_euler', index=0 ,frame=100)

scene.render.use_stamp = 1
scene.render.stamp_background = (0,0,0,1)

scene.render.filepath = "render/anim"
scene.render.image_settings.file_format = "AVI_JPEG"
bpy.ops.render.render(animation=True)

In these two lines, you are rotating on the z-axis and then keying the x-axis, which means you aren't doing any animation.

mycube.rotation_euler = (0,0,180) # (x, y, z)
mycube.keyframe_insert('rotation_euler', index=0 ,frame=100) # index=0 is x-axis

Changing the axis you keyframe will most likely not provide the expected result. While by default blender's UI uses degrees for rotation, when setting rotations in python you need to specify in radians, which means it will be rotating over 10,000 degrees in 100 frames.

Also note that to properly change the current frame you should use frame_set(), but you don't have to change frames in your script as the keyframe_insert() specifies what frame the value is set for.

import bpy
import math

scene = bpy.data.scenes["Scene"]
mycube = bpy.data.objects['Cube']
mycube.rotation_mode = 'XYZ'

scene.frame_start = 1
scene.frame_end = 100

mycube.rotation_euler = (0, 0, 0)
mycube.keyframe_insert('rotation_euler', index=2 ,frame=1)

mycube.rotation_euler = (0, 0, math.radians(180))
mycube.keyframe_insert('rotation_euler', index=2 ,frame=100)

scene.render.use_stamp = 1
scene.render.stamp_background = (0,0,0,1)

scene.render.filepath = "render/anim"
scene.render.image_settings.file_format = "AVI_JPEG"
bpy.ops.render.render(animation=True)


Change the color of the default (no) material (Cycles) In the idea of having a faster workflow, I would like to know if it is possible to change the color of the default (no) material of Cycles.
I mean, if you don't assign an material to an object, it is by default a diffuse material that is light grey (0.8 white).

I like to have my objects having that default light grey because then I can give certain meshes more emphasis simply by assigning them a pure white material; which give the scene some contrast.

How could I change the color of that default light grey so I could darken it and accentuate the contrast ?

The idea being to be able to do this using no materials (default color), because assigning ALL meshes a material would be too long in my work process.

Actually I use a light to make my subject more bright.  But this has a lot of inconvenients, that is why I ask !

Thanks!

Open Blender, go to the Materials tab from the drop down select Material. Make your required changes, you code enable Nodes and do something really complex or just change the colour. Then go to the File menu and Save Startup File.

Now when you open Blender the default material will be your custom one.
You can also do this to have a default background.

Alternatively, you can set a single material for all objects from the Render Layers tab. Handy for Clay renders.


How do I rotate the viewport, without leaving the x/y-plane? I'm looking at an object, sometimes very close, to check visual heights. I'm in orthographic view, straight front.

Now I want to rotate slowly to the left/right side, without leaving the xy-plane (while constructing, not for animation). But every slightest move of the mouse kicks me into space, and I can't check exactly.
I know rotating while pressing alt key. But this is very crude snapping. I need to rotate smoothly or at least in about 5° steps.
I'd like to press Z key, and then keeping movement always stable in xy-plane (like on grap or rotate). It also could help on other axes, or even local coordinates.
How can this be done?

Updated based on the comment:

The option you look for is the "Orbit left" using the Numpad 4 and "Orbit Right" using Numpad 6 respectively. At least in my logic that is the only way to rotate the viewport(as in the title of the question) and is not leaving the xy-plane. Not sure how "Roll and Orbit is different here as the result seems to be the same.

The increase or decrease in angle is set default to 15 degree in the preferences here:

Setting the Rotation Angle to 1.0, would result in the "Orbiting" to be a lot smoother.

Here a little visual demonstration:

Happy Blending


How to free hand draw curve object with drawing tablet? 2.8 Hey i figured out easiest way of creating custom neon light sign would be to draw it with curves. I know in 2.79 such option exists - https://docs.blender.org/manual/es/2.79/modeling/curves/editing/draw.html "The Curve draw tool allows you to free-hand draw curves." Where is it in 2.8 ?
I want to achieve this: https://warszawskieneony.files.wordpress.com/2009/05/28h28ac.jpg?w=440 but for much longer text 'Happy new year' or sth stylized
I could do it manually but that would be really a lot of work fiddling with curve vectors few hours for sure...

Create a Curve > Bezier, go in Edit mode, and choose the Draw tool:


Why are there no key_frames created with Python code? Thanks to the answer on my question Python convert curve to object, I can now extrude SVG curves and move and rotate the objects in Python.

Now I want to start with animation in Python, and I was hoping to insert some keyframes in a similar fashion as done in the example below which I found here

import bpy

positions = (0,0,2),(0,1,2),(3,2,1),(3,4,1),(1,2,1)
start_pos = (0,0,0)

bpy.ops.mesh.primitive_uv_sphere_add(segments=32, size=0.3, location=start_pos)
bpy.ops.object.shade_smooth()
ob = bpy.context.active_object

frame_num = 0

for position in positions:
    # bpy.context.scene.frame_set(frame_num)
    ob.location = position
    ob.keyframe_insert(data_path="location", index=-1, frame=frame_num)
    frame_num += 10

This works and lets a sphere move around. For my project with movement and rotation I came up with the following code:

import bpy
from math import *

context = bpy.context
scene = context.scene
bpy.ops.object.select_all(action='SELECT')
bpy.ops.import_curve.svg(filepath = "~/tmp/barkruk.svg")
newcurves = [c for c in context.scene.objects if not c.select]
# deselect all
bpy.ops.object.select_all(action='DESELECT')
# create an empty make it the active  object
empty = bpy.data.objects.new("Holder", None) # use filename maybe
scene.objects.link(empty)
scene.objects.active = empty
empty.select = True
# loop thru the curve objects
for c in newcurves:
    print("Curve: %s", c.name)
    # make it selected
    c.select = True
    # make the parent the empty if not already set
    if not c.parent:
        c.parent = empty
    # change some curve details
    curve = c.data
    curve.dimensions = '2D'
    curve.extrude = 0.003
    # sane object names
    c.name = curve.name
    # location
    #c.location.x += 0.332

empty.scale *= 2

bpy.ops.object.origin_set(type='GEOMETRY_ORIGIN', center='BOUNDS')
scene.objects[1].location.x=-1
scene.objects[3].location.x=1

bpy.context.scene.frame_set(0)
scene.objects[3].rotation_euler=(radians(90),0,0)
scene.objects[3].keyframe_insert(data_path="rotation_euler", frame=10)
scene.objects[1].rotation_euler=(radians(90),0, radians(90))
scene.objects[1].keyframe_insert(data_path="rotation_euler", frame=20)
scene.objects[2].location.z=0.12
scene.objects[2].keyframe_insert(data_path="location", frame=30)
scene.objects[1].location.x=0
scene.objects[1].keyframe_insert(data_path="location", frame=40)
scene.objects[3].location.x=0
scene.objects[3].keyframe_insert(data_path="location", frame=50)

But this doesn't do anything more than the answer in my previously asked question. At least I don't see the keyframes appearing on the timeline. Where do I go wrong and how can I generate keyframes?

Each curve object is still in the newcurves collection, hence newcurves[index] can be used rather than scene.objects[index]

The behaviour in the example sphere script you posted appears to rely on obj.location = (x,y,z) being set as opposed to obj.location.x = x etc.

My advice would be call scene.frame_set(f) update your props, insert keyframe, repeat.  The frame argument of keyframe_insert defaults to scene.frame_current.  Also to keyframe in only the x location pass index=0.

# set initial locs / rots here
newcurves[0].location.x=-1
newcurves[2].location.x=1

bpy.context.scene.frame_set(0)
# keyframe in all at frame 0
for curve in newcurves:
    curve.keyframe_insert(data_path="rotation_euler")
    curve.keyframe_insert(data_path="location")

# call frame set (updates the scene as well)
scene.frame_set(10)
# update the properties
newcurves[2].rotation_euler=(radians(90),0,0)
# insert the keyframes
newcurves[2].keyframe_insert(data_path="rotation_euler")

scene.frame_set(20)
newcurves[0].rotation_euler=(radians(90),0, radians(90))
newcurves[0].keyframe_insert(data_path="rotation_euler", frame=20)

scene.frame_set(30)
newcurves[1].location.z=0.12
newcurves[1].keyframe_insert(data_path="location", index=2)

scene.frame_set(40)
newcurves[0].location.x=0
newcurves[0].keyframe_insert(data_path="location", index=0)

scene.frame_set(50)
newcurves[2].location.x=0
newcurves[2].keyframe_insert(data_path="location", index=0)


How can I temporarily disable an animation? I have this file with an animation in it. Now I added a smoke simulation. But every time I play the smoke simulation also the animation starts running. How prevent this ? In fact I would like to make the animation "inactive" but not delete it. How to do that ?

In all 3 windows

Graph editor Window
Dope Sheet Window
NLA Edit Window

... it is possible to toggle the mute button of the channel transformation.  Contribution can be active or inactive.

Thus if the timeline were on frame 88 and the sphere was animated to rotate and the Blender User decided to disable the contribution of the channe .... then the sphere would no longer rotate dynamically and it would be frozen at the rotation of frame 88.  Later the contribution can be turned on again.  Blender uses the word mute so I am partially conforming to that jargon.

Image above. [Contribution/No Contribution] or Mute button has the shape of a speaker.  Speaker has no sound marks. Contribution inactive.

Image above. Speaker has sound marks.  Contribution active.


How to apply "duplicated" child object? As you can see I made ChildObject (sphere) a child of ParentObject (arrow), and in object data of the ParentObject I set Duplication/Verts.

That's looking ok to me, but I would like to edit one of "duplicated" spheres. I can not do this right now, because as far as I know I can edit only the ChildObject which will effect all other duplicated spheres, and I don't want that.

How to apply duplication?

And also how can I render only duplicated spheres? In current situation I have to render ChildObject in order to render duplitates of ChildObject, but I don't want to render that one out of order sphere, I just want spheres in shape of the arrow...

Please Help!

Use the make duplicates real function Ctrl-Shift-A


Does anyone know how to fix this weird Faces in Blender? Flipping faces is not working, neither recalculate normlas.

Thanks for your help!

Regards!

Enter edit mode (Vertex) press 1 on top of your keyboard to filter by vertices. You´ll notice you have double vertices on the corners. Since they're together, select the corner with weird normals and hit ALT+M (merge at the middle). This will join those vertices and correct the normals.

Else, you have more vertices on the faces that you need to delete. Select a vertex, press "X and D" in that sequence.
If you find this is the answer, thank you for your consideration to vote me as the answer by clicking to the left :the icon with a check mark and upvote this answer.

BFCT_Schiller


animate between pose/reset position in object data I made a deformation in reset position, and I can switch between pose and reset position using the buttons in Properties> Object Data> Skeleton. However, I can't find how to animate between pose/reset position.

Rest (not reset) position is the original position that your character is set to, prior to any poses being made. It shouldn't be changed once you've finished creating and rigging your character.

Pose position allows you to set different poses and save then in a Pose Library or record them as keyframes. You normally start with a starting pose and then save/record as you move it through a series of poses to create the movements you want the character to take over a number of frames.

Rest position doesn't play any part in your animation. The animation uses only the poses you save/record.

A simnple experiment is to create an initial pose, keyframe it to frame 1, then set your character to another pose and keyframe it to frame 20. Now press Alt-A to animate the character and watch what happens. Add more poses and keyframe them at various points along the timeline. This will familiarize you to the basic procedure and give you a better idea of how to use poses.

For info on using the Pose Library to save/use poses, consult the documents.


How to straighten a jumbled line? How can I straighten the shape line in the picture without losing the objects solid form? I usually use ctrl s and 0 to do it, but, that doesn't work in this case.

This is one way to do it, by using the 3D cursor.


Blender 2.8 Shader editor : I can't add any node As you See on Photo I cant add something on shader editor. What am i supposted to do?

You need to create a material by clicking on the NEW button in the Shader Editor header.


how to speed up a video sequence in blender 2.8? How to speed up a sequence using the video editor in blender 2.8? All tutorials I find online use older versions of blender.

Speeding up the video framerate (which is what I believe you mean by video speed) can be done the same way in 2.8 as it can be in 2.79 and before. In the render settings, switch the default 24 FPS to whatever is faster than that. It should speed up the video speed.


Can't get the active_object in Operator I try to get the active object by "bpy.context.scene.objects.active" in my operator, but I receive a error 'Context' object has no attribute 'objects', what's wrong?My scripts is as follow:

import bpy
from bpy.props import *

cube=bpy.data.objects["Cube"]

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

    my_property= BoolProperty(name="my_property", default=True)
    def execute(self, context):
        print("--------------------------------")
        if self.my_property:
            print("do something......")

        #set the active object as a existed cube
        bpy.context.scene.objects.active =cube
        print("objects:",bpy.context.scene.objects)
        print("cur_active:",bpy.context.scene.objects.active.name)
        return {'FINISHED'}
def register():
    bpy.utils.register_class(HelloError)
def unregister():
    bpy.utils.unregister_class(HelloError)
if __name__ == "__main__":
    register()

And the blender The file will be uploaded soon(It seems that the website"https://blend-exchange.giantcowfilms.com/"cannot be accessed now in my computer, i will upload the file once it is accessible)

You need to be aware that Blender, when changing such custom properties, internally runs an undo step, and then re-executes the script. The trouble with your script is that you define the content of the variable cube right in the __main__ area of your script. This means it is only run once when the script registers. When the undo->redo happens, this can get lost. In fact, when I just copy-paste your code into a new file, run the script, run the operator and toggle the property, the pasted script disappears (pasting it is also undone in the undo step).

To fix it, get the cube while executing. It could also make sense to get it in the invoke() function, but let's keep it simple for now. So try this modified script instead:

import bpy
from bpy.props import BoolProperty

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

    my_property= BoolProperty(name="my_property", default=True)
    def execute(self, context):
        print("--------------------------------")
        if self.my_property:
            print("do something......")

        # get desired object within execute() function instead!!
        # also, retrieve it from the current scene objects,
        # this ensures it exists within the scene and can be set active
        cube = context.scene.objects.get("Cube")

        #set the active object as a existed cube
        context.scene.objects.active =cube
        print("objects:", context.scene.objects)
        print("cur_active:", context.scene.objects.active.name)
        return {'FINISHED'}

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

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

if __name__ == "__main__":
    register()

I've done a few other style modifications to it, namely using the context variable that is passed into the execute() method instead of constantly grabbing it from bpy.context, and using context.blend_data instead of bpy.data (a call which I removed later on, see next paragraph).

Finally, batFINGER pointed out in a comment that it is recommended to pull the cube object from context.scene.objects instead of context.blend_data.objects, as this will make sure the cube is already linked to the scene, and later on can be set as active object. Using the get() method, the variable will be set to None if there is no object named Cube, instead of throwing an error immediately. You could later on use a sanity check like:

        if not cube:
            return{'CANCELLED'}


how do I make to recognize the body of the robot, as blender recognize just the body? I tried to create a very simple robot. I started with a cube as head and then I extrude the neck and the rest of the body. I used the mirror modifier. But when I put a plane under the robot and I  press P, the robot is falling until the head meets the floor, not until the legs meets it. Floor is a static and the robot is a character.

Hint: You can enable Main Menu/Game/Show Physics Visualization. It allows you to see the physics mesh while running the game.

When you use the mesh object as presentation object and as physics object - ensure to select the right Physics/Collision Bounds/Bounds.

When you use one of the primitive collision shapes (box, cylinder ...) the mesh should be symmetrical around the origin. This means the origin should be in the middle of the object. According to your description, this is not your current situation.

Example:

The origin of this mesh is not in the vertical middle. With the primitive shapes the mesh will be out of the bounding box and out of shape:

When you use detailed shapes the origin does not need to be at the middle. But they need much more processing power:

In all cases the origin should be inside the bounding box of the mesh. Otherwise the physics might calculate results you do not expect.


How to select vertices by their color? I know this has been asked, but the answer form here: https://gist.github.com/tamask/2590850 doesn't work for me. I get an "out of range error" in the first loop.
I tried modifying a solution from here: Vertices—loop indices vs. unique indices but nothing.
Here's the code:
import bpy
from collections import defaultdict

obj = bpy.context.active_object
col = obj.data.vertex_colors.active
polygons = obj.data.polygons

color = (0, 1, 0, 0)

vertex_map = defaultdict(list)

for poly in polygons:
    for v_ix, l_ix in zip(poly.vertices, poly.loop_indices):
        vertex_map[v_ix].append(l_ix)

for v_ix, l_ixs in vertex_map.items():
    for l_ix in l_ixs:

        if col.data[l_ix].color == color:

            obj.data.vertices[v_ix].select = True

I would really appreaciate any help.

It is a comparison issue.
col.data[l_ix].color == color

You can:
from mathutils import Vector

color = Vector((0, 1, 0, 0))

Then compare with:
color == Vector(col.data[l_ix].color)

Alternatively, to avoid rounding issues, define an epsilon and compare using:
(color - Vector(col.data[l_ix].color)).length_squared < some_epsilon


Is it possible to assign a parent to a control point of a curve using animall? I have a robot neck connected to its head. The neck is just a cylinder with array and curve modifiers. I'm using AnimAll (which is awesome) to animate the neck, but it's a pain to keep the spot where the neck and head connect seamless. At a glance, I would like to parent the control point that meets the head to the head itself, but I don't see a way to do that. Can that work, or is there another way to achieve the same goal?

I am not sure how this works with the AnimaAll addon but the way I would approach this is to:

Select the control point of the curve in edit mode that you would like to attach to the head.
Press Ctrl+H to 'Hook' the control point, choose 'Hook to New Object'.
A new empty will have appeared that the control point will be parented to via the hook modifier that was just added. Parent this empty to the head in object mode by Shift selecting the empty and then the head and press Ctrl+P and choose 'Object' as the parenting type.

The control point is parented (via the hook modifier) to the empty and the empty is parented to the head.

The hook modifier can also be added by manually choosing to add a new hook modifier to the curve like you would add any other modifier.


How to edit normal direction I am trying to point the face normals to another direction than the face is facing. I want the face to be about 45 degrees and the normal pointing straight up. But no matter what I use, normal edit, as seen in this screenshot

http://prntscr.com/md9u8w

I am trying to get the normals to point straight up. I had luck making trees on a similar kind of geometry (where it's only planes with normals pointing straight out, torwards a sphere instead of the direction of the face). But for some reason, now the same thing, done the exact same way, in the exact same scene, with exact same objects used to data transfer or normal edit modifiers, it just won't work, no matter what setting I change or object I use.

If you need all the normals to point upwards it's quite simple.

Create a new plane.
Enable Auto-Smooth on your main object.

Add a Data Transfer Modifier to your main object.
Set the Plane as source Object and check Face Corner Data and enable
Custom Normals. Your object will now copy the normals from the Plane.

If you want different normals to point in different directions you can do the same using Vertex Groups.

Create a new plane and angle it to the direction you want your normals to point. Create a new plane for every direction you need. Name them accordingly.

Create a Vertex group for each direction. Name them accordingly. Assign the vertices  you need to their desired vertex group.

Enable Auto-Smooth
Add a Data Transfer Modifier for each Vertex group. Set the desired Plane as source Object along with its Vertex group. Check Face Corner Data and enable Custom Normals.


Novel Use of Drivers I am having no luck with the following:  I would like to set up a driver that looks at the Z position of an object falling per RB physics (not BGE) and controls some constraint settings based on Z position.  To be more specific, I am trying to use a driver to break a constraint or reduce its breakable threshold as the object (constrained with other falling objects) nears the passive ground plane.  Any thoughts would be appreciated.

i posted exactly how to do this in your other post almost a month ago.

Can I use Weight Paint to Control Animation Properties?

The following code will work on an object i fractured using  Cell fracture, the object named "Cube". then i used the Bullet Constraint tools 'Single constraint' to make the constraints.
this code wont work if you have used Empties to constrain the objects together.

and a blend file.

https://dl.dropboxusercontent.com/u/14364171/constraint_control.blend

press alt A, you will see the box stays together.
run the script (alt P in textblock) and then animate again. you will see the box stays together, until the plane moves above each object.

object_name = "Cube"

import bpy

for obj in bpy.data.objects:
    if  object_name+"_cell" in obj.name:
        driver = obj.rigid_body_constraint.driver_add('enabled')
        driver.driver.expression="this_obj<mask_obj"
        driver_variable = driver.driver.variables.new()
        driver_variable.name = "this_obj"
        driver_variable.type = 'TRANSFORMS'
        driver_variable.targets[0].transform_type = 'LOC_Z'
        driver_variable.targets[0].id = driver_variable.id_data

        driver_variable = driver.driver.variables.new()
        driver_variable.name = "mask_obj"
        driver_variable.type = 'TRANSFORMS'
        driver_variable.targets[0].transform_type = 'LOC_Z'
        driver_variable.targets[0].id = bpy.data.objects['mask']


Cycles Material + WeightPaint + Drawing Is it possible to assign a shader or texture to certain parts on the mesh where the weightpaint was drawn? just like we would use it with particles + weight paint?

Nevermind!
This is typical, search for an answer, found nothing.
Post in stackexchange, found the answer immediately..

Here is it described what i was looking for!


Creating enterable buildings Im new to blender itself so I was wondering if anyone knew anywhere good to learn how to use it, Im fairly quick on the pickup with a good guide on hand.
Anyway Ive been looking all over the internet and can't find anything to help in regards with this.

Im looking for a good way to create from scratch multiple different building structures that can be exported for later use into my gaming enviroment in Unity.
I have no issue building them one by one over time. So if there's something that'll help me render them before moving onto intricate inside details, awesome! (I came to Blender because it seems to be the most commonly noted one for this task, but can't find any guides to do this)
Anyway any help on getting started and working through all this would be massively appreciated.

Thank you in advance.

Best begginers tutorials i know are at gryllus.net after finishing all tutorials in there you can just pick some from blender tutorials. As for enter-able buildings: just move pivot point to the edge of door so you can rotate around it, and animate it so it will look like door opening.
Example:


Modify driver target (or any property) I have a shape key which is controlled by a driver. The driver was created manualy by the user. How would I get the target of the driver from the shape key?
I know how to make a driver for a shape key:
import bpy

#Defines the selected shape key index.
selected_shape_key_index = bpy.context.object.active_shape_key_index

#Defines the selected shape key name.
selected_shape_key_name = bpy.context.object.active_shape_key.name

#Defines the selected shape key collection.
selected_shape_key_id = bpy.context.object.active_shape_key.id_data.name

#Defines active object name.
active_object_name = bpy.context.active_object.name

meshKey = bpy.data.meshes[active_object_name].shape_keys
valDrive = meshKey.key_blocks[selected_shape_key_name].driver_add('value')

valDrive.driver.type = 'AVERAGE'
drvVar = valDrive.driver.variables.new()
drvVar.name = 'DriverName'
drvVar.type = 'TRANSFORMS'
drvVar.targets[0].id = bpy.data.objects['Armature']
drvVar.targets[0].bone_target = 'ShapeKeyController_L'
drvVar.targets[0].transform_space = 'LOCAL_SPACE'
drvVar.targets[0].transform_type = 'LOC_Y'

print("target name is", drvVar.targets[0].bone_target)

But I don't know how to edit/read an existing driver. I thought that it would be something like this but it is not:
import bpy

#Defines the selected shape key index.
selected_shape_key_index = bpy.context.object.active_shape_key_index

#Defines the selected shape key name.
selected_shape_key_name = bpy.context.object.active_shape_key.name

#Defines the selected shape key collection.
selected_shape_key_id = bpy.context.object.active_shape_key.id_data.name

#Defines active object name.
active_object_name = bpy.context.active_object.name

meshKey = bpy.data.meshes[active_object_name].shape_keys
valDrive = meshKey.key_blocks[selected_shape_key_name]

print(valDrive.driver.type.targets[0].bone_target)

You can access it at shape_keys.animation_data.drivers.
import bpy

shape_key = bpy.context.object.active_shape_key
if shape_key is None:
    raise()

shape_keys = shape_key.id_data
if shape_keys.animation_data is None:
    raise()

for fc in shape_keys.animation_data.drivers:
    print(fc.data_path)
    print(fc.driver.type)

Hierarchy

Direct access
>>>
>>> def fn(name):
...     if name == "":
...         print(False)
...     else:
...         print(name)
...
>>> fn(bpy.data.shape_keys['Key'].animation_data.drivers[0].driver.variables[0].targets[0].bone_target)
False

>>> bpy.data.shape_keys['Key'].animation_data.drivers[0].driver.variables[0].targets[0].bone_target = "Bone.001"
>>>
>>> fn(bpy.data.shape_keys['Key'].animation_data.drivers[0].driver.variables[0].targets[0].bone_target)
Bone.001


Index Error: bpy_prop_collection[index]: index 0 out of range, size 0 So, here's the code i'm trying to implement:

import bpy

#remember to bpy.ops.mesh.quads_convert_to_tris()

ob = bpy.data.objects

#create an output file
import os
file = open(os.path.splitext(bpy.data.filepath)[0] + ".txt", 'w')

for objects in ob:
    #get vertices, normals, and texCoords
    if(ob[objects.name].type == 'MESH'):
        for face in ob[objects.name].data.polygons:
            for vert, loop in zip(face.vertices, face.loop_indices):
                coord = ob[objects.name].data.vertices[vert].co
                normal = ob[objects.name].data.vertices[vert].normal
                layers = ob[objects.name].data.uv_layers
                for MeshUVLoopLayer in layers:
                    #the problem is here
                    uv = ob[objects.name].data.uv_layers[MeshUVLoopLayer.name].data[loop].uv
                    file.write("v {co.x} {co.y} {co.z}\nvn {n.x} {n.y} {n.z}\nvt {uv.x} {uv.y}\n".format(co=coord, n=normal, uv=uv))

this was working when i wasn't doing the for loop and it was '...uv_layers.active', but when i replaced it with what it is now i get this error.

i know the bpy_prop_collection isn't empty it should have two items in it and i checked it with the console using bpy.data.objects["Suzanne"].data.uv_layers.items() and it came out with UVMap and UVMap.001. Suzanne is the only object in the scene, plus it checks the objects first if they're meshes.

Any ideas, on what's causing the error? Or what i'm obviously doing wrong, but am completely oblivious to?

You need to run the script in Object Mode, make sure that you meet all requirements (material and unwrapping) read the bullet points here,


How to use python to copy video settings from the compositor to the 3D viewport I have 15 short videos, created in Celestia (which will grow to 100+), that I'm using as backgrounds for a music video.

I previously used one long video for the background, but it was inefficient. I'm constantly going back and forth between Celestia and Blender making fine adjustments to short sections.

So I changed my workflow so that I now have short video backgrounds listed in the Compositor, and use a python script to select which video becomes the background for each mini-scene.

Unfortunately, there is no way in Celestia to start video capture frame-accurately, so I have to adjust the offset in Blender each time I make changes to the Celestia backgrounds.

That much is unavoidable, but I would really like to avoid the next step, which is to select the video and adjust the offset AGAIN in the 3D viewport.

By naming the clips and the background, I've managed to change the clip in the 3D view using python e.g.

bpy.data.images["background_b"].filepath = bpy.data.images["Moon.b1"].filepath

However, I'm stuck with the start frame and offset. The tooltip says

bpy.data.screens["Animation.back"]..frame_start

but that gives a syntax error.

Can anyone tell me the proper syntax to reference the frame_start and frame_offset for the background in a 3D viewport, and an image node in the compositor?

OK!!! I finally worked it out.

In case anyone else needs this, here are examples:

Set-up Variables

clip = 'your.video.filename.mp4'

bg = bpy.data.screens['your.screen'].areas[n].spaces[0].background_images[0]

node_im = bpy.data.scenes['your.scene'].node_tree.nodes[clip]

Copy Video and Properties

bg.image = bpy.data.images[clip]
bg.image_user.frame_start = node_im.frame_start
back_im.image_user.frame_offset = node_im.frame_offset

Notes

Blender automatically assigns e.g. 'your.video.filename.mp4' as the image reference when you load a video into an image node. You can change that if you want, but beware that if you reload the clip, the field will revert to the clip's filename.

Finding 'n' from 'areas[n]' takes a bit of trial and error, especially if you have a complex screen.

for area in bpy.context.window.screen.areas: print(area.type)

outputs a list of the areas of your screen, so at least you can narrow down which are viewports.

After that:

bpy.data.screens["your.screen"].areas[n].spaces[0].background_images[0]

will tell you what,if any, image has been assigned to areas[n]'s background.

I have to say I'm surprised that this hasn't come up before - seems to me that duplicating a video background node in a 3D viewport would be a common need.


Extrude along an edge loop by vertex I have two mesh objects.

I want to extrude one object in such a way that it traces another object.
I could have sworn I'd seen this done in a tutorial once, but I can't remember how and can't find it via googling or other Stack Exchange posts.

In the image, I've extruded once along the edge and once continuing away from the loop. I'd like to have each extrusion match the vertices of the loop in both position and rotation.

I looked at the possible duplicate, and it's based on both objects being curves. I was able to convert the loop to a curve, but not the circle quarter. I'm not sure why. And trying to recreate it as a curve opened another can of worms I'm too inexperienced to deal with.

Maybe another way you could use bezier curves, modify your curve until you get your desire form and transform it into mesh, so you can extrude after that.


how access to new vertices after bmesh.ops.bisect_edges? I'm trying to access to new vertices after apply  bmesh.ops.bisect_edges

API say that newly created vertices and edges will be in geom_split.  I can print"geom_split" data, but I can't access to new vertices, only I can see the information in console.

here code... thanks for any help

import bpy
import bmesh
import mathutils
import math

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

edges= [e for e in bm.edges if (e.select==True and not e.hide)]

if len(edges) < 2:
    print("please select minimun 2 edges")
else:

    newmesh = bmesh.ops.bisect_edges(bm, edges=edges, cuts=5) #for example 5 cuts

    bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
    print(newmesh['geom_split'])

bmesh.update_edit_mesh(me, True)

bmesh.ops.bisect_edges returns a dictionary that only has one item geom_split, that one item is a list of the data you want. You can easily find what everything is in the python console -

>>> newmesh.keys()
dict_keys(['geom_split'])
>>> newmesh['geom_split'].keys()
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
AttributeError: 'list' object has no attribute 'keys'
>>> len(newmesh['geom_split'])
12
>>> type(newmesh['geom_split'][0])
<class 'BMVert'>
>>> type(newmesh['geom_split'][11])
<class 'BMEdge'>

If you replace your print() with the following you can see the returned data.

for i in newmesh['geom_split']:
    if type(i) == bmesh.types.BMVert:
        print("Vertex",i.index,"positioned at",i.co)
    elif type(i) == bmesh.types.BMEdge:
        print("Edge from vert",i.verts[0].index,"to vert",i.verts[1].index)

While the api states that bisect_edges returns "newly created vertices and edges" I only see two edges returned.


Glossy material affecting color of another objects I need to make this blue vectors appears blue inside this orange material.

In other words, how I can "preserve" material color from color interferences of another objects?

I'm using cycles render.

Thank you very much.

I made the steps proposed and achieved this result:

Edit:

My bad, your cube is actually opaque, which was hard to guess from the pictures, I don't know if it's feasible with the Light Path node (?) so, as Thedigitalzorn said, the solution is probably to use the Compositor.

Another simple trick would be to launch a render of the arrow only, in the Properties panel > Render > Film, enable Transparent to make sure that the video has a transparent background. Then render the cube and the setup. At last, stack the 2 sequences in the Video Sequencer.

Old answer:

Give your arrow an Emission node instead of a Diffuse. And if you don't want it to emit any light, deactivate its Diffuse option in the Properties panel > Object > Visibility.


Cycles render time increases drastically upon adding simple planar backdrop I have made a simple studio setup to showcase a toy car model. In Cycles I am getting an estimated render time of about 1 hour which is unusual for a scene this simple. Upon making tweaks I realised that hiding the studio backdrop from the render cuts my render time to 8 minutes.The backdrop is a simple beveled plane consisting of 36 quads. I have my max bouces relatively low as well as the indirect light clamping

This is the shot I am trying to render in Cycles as rendered in EEVEE

This is the size of my backdrop

And here are my render settings, which seem pretty tame all things considered.

Nodes for the cove.

The render-time difference isn't too surprising, given that without the background most of the camera rays would simply miss all of the geometry and so those tiles to the side would render extremely quickly compared to the rest. Adding the background means that those camera rays hit a surface and Cycles then needs to determine Diffuse rays from the rest of the geometry to shade each point on the surface.
One potential solution would be to use the new(ish) Adaptive Sampling option. This way you can set a noise threshold and those tiles far from the "track" should render quicker than they otherwise would, while still having enough samples to avoid noise.


Set active layer for created objects I noticed when I add objects to my scene they will be created in the layer 3. It isnt like that from the beginning but it suddenly starts to place new objects into the third layer after some time working.

I dont have any problem with that since I just can use the third layer as "main" layer. My question is if there is a possibility to set an active layer where new objects get placed into? So that I have control over the objects placements in layers from the beginning. For example when I know I place a lot of "unnecessary" stuff I choose one of the last layers and dont have to manually drop them into that layer after i created them.

Thanks in advance

Uncheck and check on your "active" layer with Shift.

Objects adds on last selected layer, so if you turn off and on the layer, it will be  "active"

Also, you can read about it: Active Layer Indicator


How do I copy and paste nodes? Good day. I need to "copy and paste" all the nodes of the Node Editor from one object to another. Can I do that? I need it for tomorrow, please help me.

You can copy nodes with Ctrl+c and paste them with Ctrl+v in the Node Editor. This will work with one material or multiple materials,lamp node trees as well as compositing nodes and World node tree. You cannot copy and paste compositing nodes into material node trees and material nodes into compositing node trees, but it seems you can copy/paste between material,light and World node trees.

If you need multiple objects to have the same material, you can select them all with the one with the desired material being the last selected(active) and hit Ctrl+l -> Materials. They will then have the same material that will change on all of the objects if edited. If you want to edit the material of an object separately, you need to make it unique(single user) by clicking this number icon identifying how many users the material has:

or you could select multiple objects in the 3d viewport, hit u and choose "Material+Tex".


Bevel doesn't work on all edges I have a problem with bevel. Here u can see one half of the mesh bevels fine, but the other one doesn't work. I applied scale transform, removed doubles, recalculated normals, object wasn't mirrored, but it was extruded out of itself on the right half and on the left it was merged with another part, which is where it's not working. I tried creating new model and yes, basically, as long as I extrude geom it's fine, but where I make a loop and merge vertices it doesn't work. Pls help, I'm obviously missing smth and idk what :')

It looks like you have an extra face inside the geometry, if you delete it, the bevel should work.


How to use set up transparent background on VSE (alpha file combined with mp4) I received one of my very short clips edited from Unscreen website (which removes background of the vid) but they sent me the mp4 of the video (with the background) and an alpha file which I have no idea how to work with on blender (neither on any other software anyway!)
I want to import my video with a transparent background and apparently I have to mix somehow the mp4 and the alpha file.
Does anyone can tell me a simple procedure to do so on VSE?
Thanks in advance
Roland

As mp4 doesn't support alpha channel, the file you have is a black and white movie that brings the alpha information.
White means matte, while black means transparent.
In Blender compositor (or any other) you can plug it into a color mix node, where black will bring the top input image, white the bottom input.
In VSE you can add a mask modifier to the video strip that needs transparency, targeting the alpha strip.
Alpha strip has to stay under the visible strips.


AttributeError: '_RestrictContext' object has no attribute 'object' I'm trying to make an add-on with this code but keep getting this error. I've tried putting this line obj = bpy.context.object in execute but then i'll get another error wich i've sollved by putting this line outside of execute. Any help please?
bl_info = {
    "name": "test",
    "author": "Aziz",
    "version": (1, 0),
    "blender": (2, 80, 0),
    "location": "...",
    "description": "...",
    "warning": "",
    "doc_url": "",
    "category": "Mesh",
}

import bpy

class ReducePolygons(bpy.types.Operator):

    bl_idname = "reduce.polygons"
    bl_label = "Reduce Polygons"
    obj = bpy.context.object

    def execute(self, context):
        bpy.ops.object.modifier_add(type='DECIMATE')
        self.obj.modifiers["Decimate"].decimate_type = 'UNSUBDIV'
        self.obj.modifiers["Decimate"].iterations = 1
        bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Decimate")
        return {'FINISHED'}

class LayoutDemoPanel(bpy.types.Panel):

    bl_label = "test"
    bl_idname = "SCENE_PT_layout"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "scene"

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

        layout.label(text="Mesh Optimizations:")
        row = layout.row()
        row.scale_y = 2.0
        row.operator("reduce.polygons")

def register():
    bpy.utils.register_class(LayoutDemoPanel)
    bpy.utils.register_class(ReducePolygons)

def unregister():
    bpy.utils.unregister_class(LayoutDemoPanel)
    bpy.utils.unregister_class(ReducePolygons)

if __name__ == "__main__":
    register()

I've tried putting this line obj = bpy.context.object in execute but then i get this error message on launch:
'NoneType' object has no attribute 'modifiers'

Also tried deleting this line obj = bpy.context.object and replacing self.obj with context.object as  Robert Gützkow suggested but unfortunately i got the same AttributeError.
Any idea on how to fix this?

Some edits
Give operator a poll method so it requires an active object of type mesh (or a type that can have decimate modifier)
Add the modifier using the api method.
bl_info = {
    "name": "test",
    "author": "Aziz",
    "version": (1, 0),
    "blender": (2, 80, 0),
    "location": "...",
    "description": "...",
    "warning": "",
    "doc_url": "",
    "category": "Mesh",
}

import bpy

class ReducePolygons(bpy.types.Operator):

    bl_idname = "reduce.polygons"
    bl_label = "Reduce Polygons"

    @classmethod
    def poll(cls, context):
        ob = context.active_object
        return ob and ob.type == 'MESH'

    def execute(self, context):
        ob = context.active_object
        dm = ob.modifiers.new(name="Foo", type='DECIMATE')

        dm.decimate_type = 'UNSUBDIV'
        dm.iterations = 1
        bpy.ops.object.modifier_apply(modifier=dm.name)
        return {'FINISHED'}

class LayoutDemoPanel(bpy.types.Panel):

    bl_label = "test"
    bl_idname = "SCENE_PT_layout"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "scene"

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

        layout.label(text="Mesh Optimizations:")
        row = layout.row()
        row.scale_y = 2.0
        row.operator("reduce.polygons")

def register():
    bpy.utils.register_class(LayoutDemoPanel)
    bpy.utils.register_class(ReducePolygons)

def unregister():
    bpy.utils.unregister_class(LayoutDemoPanel)
    bpy.utils.unregister_class(ReducePolygons)

if __name__ == "__main__":
    register()


Image texture to partially mask part of material Please forgive me if I used beginner terminology.

I would like to have a bottle in color "provided by the simple diffuse shader" (ie. with pure red). I would like to put a test texture (222222 on the screenshoot) only on part of bottle which was UV unwraped (only box with 22222 has been cover by unwrapped faces).

I know how to do this with image with transparency (alpha) as decals however the question is if there is any simple option just to put part of texture on object and leave the rest with pure shader without texture?

I've found on blender manual that if I set texture as "clip" it will set exterior pixels as "transparent black". No idea what transparent black means, but it is not transparent.

The mix node always mixes the rest of bottle with texture and does not give pure color (red). I tried to put an alpha texture node into mix factor to separate the texture part from rest (as manual states remaining pixels are transparent "black") but the result is well..bad.

I would appreciate your support. No idea where is my mistake.

TL;DR: Invert your mask image

"No idea what transparent black means, but it is not transparent."

It means that the area outside the image canvas will be considered transparent, as in Alpha value = 0, some image formats also have the ability to still save color for transparent areas, like PNG, and so will also paint that area black, besides making it transparent, in case you are not using the alpha map, or use it separately for other purposes.

In your particular image it is white all around the canvas borders, which generally means it opaque in terms of alpha channels, so it won't mix well with the remaining surrounding material.

Clipping in Blender will not work because as you already found out from the manual, the surrounding will be considered black which never matches your image border.

Don't use the Invert Cycles node in Blender, because it will invert the image color but also the black transparent area applied by the clipping effect, leading to surroundings that never match the current color of the image border.

You have to explicitly use an external application to invert the colors before using it in Blender.