Blender API... "context is not defined" Good morning,
I am currently updating an older AddOn and it went very well so far, but now im stuck with an error and I can't find the reason since my knowledge in Python and especially in the Blender API is very limited...
I appreactiate any ideas and suggestions
Nico :)

# Mesh object implementation of ExportObject
class MeshExportObject(ExportObject):
def __init__(self, Config, Exporter, BlenderObject):
    ExportObject.__init__(self, Config, Exporter, BlenderObject)

def __repr__(self):
    return "[MeshExportObject: {}]".format(self.name)

# "Public" Interface

def Write(self):
    self.Exporter.Log("Opening frame for {}".format(self))
    self._OpenFrame()

    if self.Config.ExportMeshes:
        self.Exporter.Log("Generating mesh for export...")
        # Generate the export mesh
        Mesh = None
        if self.Config.ApplyModifiers:
            # Certain modifiers shouldn't be applied in some cases
            # Deactivate them until after mesh generation is complete

            DeactivatedModifierList = []

            # If we're exporting armature data, we shouldn't apply
            # armature modifiers to the mesh
            if self.Config.ExportSkinWeights:
                DeactivatedModifierList = [Modifier
                    for Modifier in self.BlenderObject.modifiers
                    if Modifier.type == 'ARMATURE' and \
                    Modifier.show_viewport]

            for Modifier in DeactivatedModifierList:
                Modifier.show_viewport = False

            Mesh = self.BlenderObject.to_mesh(self.Exporter.context.scene,
                True, 'PREVIEW')

            # Restore the deactivated modifiers
            for Modifier in DeactivatedModifierList:
                Modifier.show_viewport = True
        else:
            Mesh = self.BlenderObject.to_mesh(self.Exporter.context.scene,
                False, 'PREVIEW')
        self.Exporter.Log("Done")

        self.__WriteMesh(Mesh)

        # Cleanup
        bpy.data.meshes.remove(Mesh)

    self.Exporter.Log("Writing children of {}".format(self))
    self._WriteChildren()

    self._CloseFrame()
    self.Exporter.Log("Closed frame of {}".format(self))

The presented error seems to have less to do with the blender API, and more to do incorrectly initializing the python object. You need to use the super function to properly call the parent class’s init method, but you don’t need it here anyway since you’re not changing the init method at all. Just remove that redefinition of the init method.
There may be other errors after you do this, but go ahead and try that.


Precise Mechanical Rigging (Intuitive method) https://youtu.be/86DtgBiUDvI

Hi,
I have done this using the y-rotation of the Blue rod to drive its z-location. The Top rod is driven by the z-location of the Blue rod.

As you can see, the animation looks imprecise, and the calculation behind it is also not intuitive (for one, the reverse control using asin(x) does not work). Sure I could tweak things to fit, but I'm instead looking for some method to precisely rig these bodies intuitively. So far I have known these methods for mechanical rigging: a) Constraints b) Drivers c) Armatures and d) Physics.

My questions:

a) Is there any way to actually rig (complexity does not matter)
by simply constraining the bodies wrt each other without actually calculating any of the mechanics of motion that the setup will entail?

b) Are there other methods that I have not mentioned above.

Thanks.

Note: I do not need a complete solution, just some useful directions and/or resources will suffice.

After a lot of trial and error here's what I could come up with.
It is not perfect and will glitch out at extreme cases, but otherwise works for the most part.

It relies on a system of three empties and relations between them.

The $Start$ $Empty$ - Has a Location constraint to prevent it from going anywhere away from $-0.90$ to $0.90$ in the $X$ axis

The $End$ $Empty$ - Has a Location constraint to prevent it from going anywhere away from $-0.90$ to $0.90$ in the $X$ axis and $0.2$ to $1.8$ in $Z$ direction. Additionally it as a Limit Distance constraint set to On Surface preventing it go further away than $1.8$ from $Start$ $Empty$

Lastly $Tracking$ $Empty$ is parented to $Start$ $Empty$ and has a locked track to the $End$ $Empty$.

The $Upper$ $Arm$ also has a Copy Location on $Z$ axis only from $End$ $Empty$so it keeps position correctly automatically


mirror modifier leaves a gap My mirror modifier leaves a gap and I can't move the edges in to close it. What's the fix?

Do you have subsurf on or something in the list before mirroring?
Sort of has that look.

Otherwise can, with clipping on for the mirror, drag verts to center.


How do I get Particle Boids to fight each other? In the Boid Brain there is a option called 'Fight' so how do I set up a scene where two groups of Boids fight each other? Or am I misunderstanding something here?

If you have a link for a tutorial that would be good.

You need to define at least 2 particle systems with a relation enemy to each other, you can define attributes like strength (this will statistically decide who wins [particle disappears when defeated]).

You could add Follow Leader to the boids brain and animate the leader, this would make the particles follow the leader (creates nice formations). There're so many options you need to play around and develop an idea of how it should like.

In the physics settings make sure you checked Allow Flight or restrict them to land.

I stopped playing with this because I wasn't able to create explosions when a particle dies.

Example:


How can I "un-merge" faces from a continuous mesh? How can I separate a set of faces from a continuous mesh in Edit mode, without moving the selected faces to another object? I'd like to keep the faces within the same object, if possible.

Select the face you want to disconnect from your mesh and press Y to Split the face.


How do I rotate object around a point without spinning the object itself? I want to create a London Eye kind of a thing and I want to rotate the whole thing. The problem is that I want those cabins to stay with their roof facing up. I want them to move in circle but not to rotate.
Do you know, how can i do that?

You can parent the cabins (here Suzanne) to the circle and give them a Limit Rotation constraint
Or you can parent empties to the circle and give each cabin a Copy Location constraint with the empties as Target:


How to Make Smooth Bevel Curve Without Extra Crease? I want to make something like a curve-shape pipe,
so I use curve (I make an edge and convert it to curve because I need it like that in original work) and bevel it with bevel>object> beziercircle and it looks like that:

After that I convert it to mesh, and do bevel of the angle edge loop in the middle

But it look like that:

So how can I make it even and smooth without these crease that indicated by red arrows?
I add subdivision modifier and auto-smooth but it still the same.

Maybe put an additional edge loop close to it, it should attenuate the problem:

If you ever want an alternative that works (but the whole profile is different so it may not be what you want):
Create your pipe with a series of vertices, when you want to curve an angle, bevel the vertex:

Convert to curve, go in the Properties panel > Object Data > Geometry, and bevel:


How can I change the color of node names? I'm using 2.69 and I'd like to make the node names much brighter, but I couldn't find a setting to do that. Did I miss it?

Thanks to Leon Cheung for this answer:

Theme -> Node Editor -> Theme Space Settings -> Text

Another alternative is:

Preferences -> Node Editor -> Node Backdrop


How to simulate magnetism In Blender? Is there a way to create magnetism in Blender? Using the physics engine or the game engine, I want to create BuckyBalls (the magnetic toys) within Blender.

Assuming that you are indeed referring to the magnetic toys and not the carbon nanomaterial, then you have a couple of different options.

Technically, you could model the magnetic attraction between all of the individual balls by using Blender's Force Field physics. You can enable this physics simulation in the Properties> Physics menu. However, this would be very inefficient. Since the magnetic attraction between these balls is so strong, they're almost always touching each other directly and you would hardly see any effects of the simulation.

Instead, you can just model the balls themselves, and keep most of them touching each other.
If you only have a few of them, it's probably fastest just to control their movements by hand. However, if you need to animate them more efficiently, you can use a combination of Array modifiers (parented to empty objects for convenience) and Transform/Relationship constraints as appropriate to keep the right balls locked to each others surfaces.

BuckyBalls:


I have better than optimal hardware but Blender keeps crashing I am trying to get started using blender and follow a simple tutorial to get used to creating abstract renders for design work.

While running blender even performing the simplest of tasks my computer starts to chug and then eventually crash when trying to add modifications to an object.

Every other program I have run perfectly fine and from what I understand I have more than suitable hardware, so I'm just really confused at this point.

My Hardware

CPU: AMD Ryzen 5 3600 6-Core Processor
GPU: Nvidia Geforce RTX 2060 Super (8GB dedicated + 16GB Shared)
RAM: 32GB (28 available)

Try to run blender from your system's console, so that when it crashed we can see there what happened eventually.

On windows, open you file explorer and navigate to Blender's installation folder (by default C:\Program Files\Blender Foundation\Blender).
From there, click on the folder path at the top of the explorer, type in "cmd" and hit ⏎ Enter. It's an easy way to open the console in a specific folder.

Once here, just type "blender" in the console and hit ⏎ Entrer. It will start Blender as usual, except the console will not close if Blender crashes and will register what happens.

Now, do whatever causes the crash, then look at the console. If you're lucky, the last few lines will tell you very clearly what's the problem and you will be able to solve it yourself in a few clicks and post here what it was.
If you're less lucky, you will have to show us the console's output and we'll see what we can do.

If it's a bug, then it's not something we can handle on this website.

Also, Blender 2.81 just got released, make sure you updated.


`pip install bpy` Not Working (LookupError: unknown encoding: future_fstrings) When I run pip install bpy I get this error:

Collecting bpy
  Using cached https://files.pythonhosted.org/packages/18/40/f8166da0a9c7f33bd0a942e9b86e83bd9ab07d85aabff6ffb7e0b939c3cf/bpy-1.2.3.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "/usr/lib/python3.7/tokenize.py", line 397, in find_cookie
        codec = lookup(encoding)
    LookupError: unknown encoding: future_fstrings

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib/python3.7/tokenize.py", line 449, in open
        encoding, lines = detect_encoding(buffer.readline)
      File "/usr/lib/python3.7/tokenize.py", line 436, in detect_encoding
        encoding = find_cookie(second)
      File "/usr/lib/python3.7/tokenize.py", line 405, in find_cookie
        raise SyntaxError(msg)
    SyntaxError: unknown encoding for '/tmp/pip-install-g68ruj02/bpy/setup.py': future_fstrings

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-g68ruj02/bpy/

I am using Ubuntu by the way!

You are missing the future-fstrings package. I'm not sure why it doesn't install automatically but a simple pip install future-fstrings should solve this.


Floating objects from model after applying 'with automatic weights' I need help. I'm having a rigify error after applying 'with automatic weights'. My character's hair is floating after I move around the rig and it's frustrating that I have no idea how to fix it. I don't know how to manually weight paint either. (I'm a big noob)

Select your mesh and Switch to Weight Painting mode using ctrl+Tab
Select your armature and switch to Pose mode using ctrl+Tab
Rotate your head bone as shown in the figure you posted, which will leave the other parts of the head not moved.
Now select your head bone and start weight painting using Mouse left click as shown below until all these parts are red, where these parts of the head will be assigned to the bone head and will move with it. You may need to turn off the limit selection as highlighted below


Renders Not Using Values in 'Sampling' Section of Scene Tab (2.80, Cycles) OK, so something bizarre just started happening with a scene I'm working on.  I have 'Render' samples set to 128, and 'Viewport' samples set to 32 (this is in Cycles).

I don't know what I might have done, but NOW when a scene is being rendered in the viewport it's showing 'Path Tracing Sample x/1024'  as it's rendering the scene.  Normally, it would show 'x/32', as you would expect.

Needless to say-- now when I go to do a final render, instead of taking 2-3 minutes, it's telling me it will take HOURS.

When I start up a fresh scene, I don't have this issue, so I must have done something wacky with a setting somewhere, but I cannot figure it out!

Can anyone help?

Thanks!
Bryan

You have likely enabled Square Samples which results in Cycles using the squared number of samples. Therefore the number viewport render samples are:
$$32^2=1024$$

For the final render the number of samples are:
$$128^2=16384$$


"Cursor to Selected" Puts 3D Cursor to the World Origin Instead of Center of the Object (STL File) This is an STL file I imported to Blender for 3D print. I have similar problem when dealing with most STL files (downloaded from Thingiverse and a like).
I have 3D cursor sets in the middle of selected edges like below:

If I ⇧ Shift +  S then select Cursor to Selected while having the main model selected, the 3D cursor will be positioned like:

How can I make so that my 3D cursor positioned in the middle of the model?
Additionally, when I imported the STL file, the default position of the model is always not in the World Origin. So, that's why the model isn't positioned in the World Origin.

You need to recalculate your object origin.
select your object and go to object > set origin and pick one you prefer.

most imported assets, export with 0 for object origin to avoid unwanted problems.


Access to object location from previous frame in cycles Is there a way to access an objects location data from the previous frame in cycles? I want to make a shader that colors the object accordingly to the distance the object traveled between the current frame and the last one.
My goal is an animation with moving cubes colored by the "speed" they have.

Also, I guess thats information that is not available in osl?

See the docs about drivers, they're comprehensive.
Also see TextEditor -> Templates -> Python -> Driver Functions

Add a Driver

If your object is key-framed, you can evaluate the F-Curve using a frame number like fcurve[index].evaluate(frame-1)

Add a Driver to a custom property of your object.

Make a python expression text block with something like the code below, and Run the code so the expression is added to the driver_namespace

import bpy
from mathutils import Vector

def driver_delta_to_RED(frame):
    # triggered by a frame change, any code inside here gets run.

    p = bpy.data.objects['Plane']
    current_xyz = p.location
    fcurve = p.animation_data.action.fcurves

    x = fcurve[0].evaluate(frame-1)
    y = fcurve[1].evaluate(frame-1)
    z = fcurve[2].evaluate(frame-1)

    # may want to find the top speed first, and normalize
    # this value using that information
    delta = (current_xyz - Vector((x, y, z))).length

    nodes = bpy.data.materials[0].node_tree.nodes
    nodes[1].inputs[0].default_value = (delta, 0, 0, 1.0)

    # the return value is of no relevance and can be static.
    return 0.0

bpy.app.driver_namespace['driver_delta_to_RED'] = driver_delta_to_RED

Add the function call to the Driver

if it's a frame behind or ahead of what you want, then instead of the Driver, it might make sense to add an application_handler specifically the frame_change_pre or frame_change_post handlers.

The code for Drivers and frame_change handlers is slightly different, but the app handler docs will describe how to get the current frame from inside the handler function.


Python : hide collection (turn off the eyeball icon of collection) in outliner I want to hide (turn off eyeball icon) a collection by its name.
Refer to this : How to "Hide a Collection in viewport" but not "Disable in Viewport" via script in Python
i can't use bpy.data.collections[name].hide_viewport  as it will disabling rather than hiding (turn off monitor icon)
so have to use layer_collection :
collections = bpy.context.view_layer.layer_collection.children
colname = "mycollection"
for collection in collections:
    if collection.name == colname :
        collection.hide_viewport = True

That's 1 level down , if i have multi level collection, than i have to iterate recursively until i found it. it's too slow.
Is there new API or any simple method in 2.90 or 2.91 ?
Thanks

I don't think there is an API for that.
But some geeky experiments, as you said this is "too slow".
First build a test case for 40000 collections: 1000 root collections each having a 3 x 3 chidren hierarchy (1000 + 3000 + 9000 + 27000).
The code to create it (runtime will be a bit long):
import bpy
import random
import time

def generate_children(parent, amount):
    new = bpy.data.collections.new
    collections = [new("test") for i in range(amount)]
    for c in collections:
        parent.children.link(c)
    return collections

def generate_hierarchy(parents, amount, depth):
    children = parents
    for i in range(depth):
        children = [c for p in children for c in generate_children(p, amount)]

parents = generate_children(master_collection, 1000)
generate_hierarchy(parents, 3, 3)

Now, direct search (recursive) can be:
def search(parent, name):
    if parent.name == name:
        return parent

    for c in parent.children:
        result = search(c, name)
        if result:
            return result
    return None

And search using a map between a child name and its parent collection. The map is slower to build than a direct search but can be used several times:
def create_search_map():
    all = bpy.data.collections
    d = {c.name: p for p in all for c in p.children if p.children}
    return d

def search_on_map(d, parent, name):

    path = [name]
    while True:
        p = d.get(name)
        if p:
            name = p.name
            path.append(name)
        else:
            break
    path.reverse()

    result = parent
    for name in path:
        result = result.children[name]
    return result

So we can compare:
layer_master_collection = bpy.context.view_layer.layer_collection

start = time.time()
for i in range(1000):
    collection = random.choice(bpy.data.collections)
    search(layer_master_collection, collection.name)
end = time.time()
print(end-start)

start = time.time()
d = create_search_map()
for i in range(1000):
    collection = random.choice(bpy.data.collections)
    search_on_map(d, layer_master_collection, collection.name)
end = time.time()
print(end-start)

First print gives 17.58s, 17ms per call.
Second print gives 1.84s, 2ms per call (but again, use the map only if you need to search for several).


Render appears to have z-fighting but render view doesn't I'm trying to render an orange juice bottle, but the render appears to have z-fighting but render view doesn't, and I don't even know what could be overlapping. Both have 32 samples. The first image is the viewport, and the second is the render. I saw similar issue to this (the person was also rendering orange juice which is funny) but it was because their normals were facing the wrong way, but mine are right.

You have a "backup bottle" hidden in the viewport. Items hidden in the viewport will still be visible in renders. This is why you see Z-fighting. Either delete the object or move it to a separate (disabled) collection.


How do I register 'Scene' properties with Python in 2.8? I'm currently udpating some 2.7x script for 2.8. Everything is going fine except for one thing:

Currently the script uses a class to store some properties like so:

class MySettings(PropertyGroup):

lockHead = BoolProperty(
    name="Enable or Disable",
    description="Lock the head position of the bone",
    default = False
    )

which is registered in the registration part:

def register():
    bpy.types.Scene.my_tool = PointerProperty(type=MySettings)

def unregister():
    del bpy.types.Scene.my_tool

The issue is, Blender 2.8 doesn't want to register it in the Scene. I try to register it in the Window like so :

def register():
    bpy.types.Window.my_tool = PointerProperty(type=MySettings)

def unregister():
    del bpy.types.Window.my_tool

But then I can't get the property elsewhere (if I get it with context.window.my_tool I just have some weird tuple and can't reach the property itself). Here's an example where I try to get them in a separate  UI class:

def draw (self, context):

    layout = self.layout

    mytool = context.window.my_tool

    rows = 2
    row = layout.row(align=True)
    row.prop(mytool, "lockHead",  icon='NDOF_DOM', text="Head")

So the question is, where can I register the PropertyGroup class so I can access the properties inside in an other class? Or am I doing something commpletly wrong?

And side question, since the classes are no longer stored in the bpy.types "class", how can I get them?

Annotations in 2.80

Not sure of the problem here. 2.8 uses annotations, currently not doing so produces a warning message.

Test code to confirm operation in 2.80

import bpy

class MySettings(bpy.types.PropertyGroup):
    # use an annotation
    lockHead : bpy.props.BoolProperty(
        name="Enable or Disable",
        description="Lock the head position of the bone",
        default=False
        )

def register():
    bpy.utils.register_class(MySettings)
    bpy.types.Scene.my_tool = bpy.props.PointerProperty(type=MySettings)

if __name__ == "__main__":
    register()
    print(bpy.context.scene.my_tool.lockHead)

Test in console:

>> C.scene.my_tool
bpy.data.scenes['Scene'].my_tool

>>> C.scene.my_tool.lockHead
False

>>> C.scene.my_tool.lockHead = True
>>> C.scene.my_tool.lockHead
True

Trying on bpy.types.Window is an issue. The use of bpy.props is restricted to ID types.  As a rule of thumb  objects in the bpy.data collections are ID type..  Scene type in bpy.data.scenes.  There is no bpy.data.windows for the Window type.  (there is the window manager)

>>> isinstance(C.window, bpy.types.ID)
False

>>> isinstance(C.window_manager, bpy.types.ID)
True

>>> bpy.types.WindowManager.my_tool = bpy.types.Scene.my_tool
>>> C.window_manager.my_tool.lockHead
False

Only a rule of thumb test, as shown by a pose bone.

>>> bpy.types.PoseBone.my_tool = bpy.types.Scene.my_tool
>>> C.active_pose_bone
bpy.data.objects['Armature'].pose.bones["Bone"]

>>> C.active_pose_bone.my_tool.lockHead
False

>>> isinstance(C.active_pose_bone, bpy.types.ID)
False

A more robust test, If a blender object doesn't support ID properties, it cannot be used to store custom properties defined with bpy.props

>>> C.window["x"] = 3
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
TypeError: bpy_struct[key] = val: id properties not supported for this type


Is Blender suitable, or perhaps overkill, for making 2d graphic of water flowing in pipe? I'm in the market for a free or inexpensive program that will help me create a graphic of water flowing through pipes (2D is OK, and preferred at this point). Would Blender be suitable for this, or would it be overkill in view of Blender's reportedly steep learning curve?

Yes it's possible to create a 2D graphic like this in Blender. Perhaps it's a bit much, but Blender is pretty easy to use for this kind of stuff. Here's an animation I whipped up in Blender of something like what I think you're describing:

Simply switch the render engine to cycles in a new scene, align the camera to front view (NUMPAD 1 and then ctrl-alt-NUMPAD 0) and add in shapes such as planes and make sure to use emission materials for everything. Use the displace modifier with a texture and keyframe the size values at frames 0 and 70 to be 0.25 and 0.7.


Problem with imported obj textures Hello everyone (sorry if my english is not perfect),

First, I just want to say that I did researches for my problem and I didn't find any solution, so thank you if you can help me :-).
I use blender 2.79b and 2.80, and the problem is the same with both : when I import an obj file downloaded from the website free3d.com, even if there is the mtl file in the same folder and the name is the same, there is no material in render mode, whatever I'm using Evee render, Blender render or Cycles render. And the materials seems to be there in the hierarchy, but when I select a material, it's just grey....

Thank you for your help]1

I believe Blender hasn't support material with texture import from .obj file even though we have the .mtl file.
So you still need to assign your texture manually.


How to connect bezier curve endpoints with straight line I create beziel curve like this:

Then I press alt+c to connect endpoints and I get this:

But I want this:

Can somebody please help me?

Here is a method to do it:

Select your vertices and press V to switch to Free Handles mode.
Select your vertices and the bottom handles and press S Y 0 to flatten on the Y axis.


Stuck at the "Part 5, Level 1: Sculpting", where Andrew works on the fixing the Icing droplets Hello good people around here!
So I was following the "Part 5, Level 1: Sculpting" section of the Donut Tutorial by Blender Guru, where Andrew basically grabs a singular vertex of an Icing and fixes it, but making the droplets hug the donut without any form of clipping.
But when I tried to do so exactly how he did it, instead of the entire droplet hugging the donut, only one side of the icing touched the dounut.. but Worse, the vertices of the droplets got stuck with the donut in a horrifying manner. And The Worst of all.. the Vertices of the droplets got clipped inside the Donut and got all messed up. The more you try to make the Icing Droplet hug the donut, the more messed up the vertices get. :(((((((
Can Anyone help me out regarding where am I doing wrong?
Thanks in advance~ ^-^

I don't know what process you used, but here's the proper way to do it:
Press 'o' on your keyboard to enable proportional editing in edit mode (first remember to undo your process of making the icing stick to the donut) and then grab one vertex on the icing which you want to stick to the donut. then press 'G' to move. You will see a circle surrounding that vertex. Use the scroll wheel on your mouse to change the size of the circle. Then, make the circle big enough to cover the part of the icing you want to stick to the donut. Then just move (remember to press 'G' or you won't see a circle or you won't be able to move your icing.) the vertex. You will see that some more verticies re moving with that single vertex. Change the size of the circle by using the scroll wheel on your mouse to specifiy how many verticies you want to move. That is how you can stick the icing to the donut.


How does the Vertex Weight Mix Modifier Work Internally I've gone through all of the documentation and been fiddling around with this modifier for an hour.  Can someone tell me how it works?  What is it actually doing?  My understanding right now is that it mixes different weights (which you set by vertex groups) and I understand all of the blend modes and what not).  Essentially, I understand a lot of what it's doing but I can't wrap my head around this problem.  In the vertex groups you set a weight for your vertex group and then in this modifier you have an A and a B group and you set default weights for the A group and the B group.  What is the interaction between these different weight settings?  How does it work together?  Also, how would you use a texture map on this (I looked up the blender post for this at Remove vertices based on texture but couldn't figure it out).

Thanks so much for the help!

Have a slow read through the manual page on the vertex weight mix modifier, it has an example at the end to help explain it.

The points I think are most relevant -

  Vertex Group A
      The vertex group to affect.
  Default Weight A
      The default weight to assign to all vertices not in the given vertex group.
  Vertex Group B
      The second vertex group to mix into the affected one. Leave it empty if you only want to mix in a simple value.
  Default Weight B
      The default weight to assign to all vertices not in the given second vertex group.

  Mix Set
      Choose which vertices will be affected.
      All vertices
          Affects all vertices, disregarding the vertex groups content.
      Vertices from group A
          Affects only vertices belonging to the affected vertex group.
      Vertices from group B
          Affects only vertices belonging to the second vertex group.
      Vertices from one group
          Affects only vertices belonging to at least one of the vertex groups.
      Vertices from both groups
          Affects only vertices belonging to both vertex groups.

  Texture Mask
      An additional texture, the values of which will be multiplied with the global influence value for each vertex.

So Vertex Group A is the group that gets the result, you use this in modifiers after the mix.

The mix mode defines how the two values are mixed, while the set decides which vertices get the weight.

The texture mask can then limit the result to certain areas of the mesh.


Why doesnt my mesh follow my bones the way i want? (Video) I am new to Blender and in the video below you will see a simple water creature mesh with an armature connected to it. The bones of the armature are placed inside the arms and body of the creature.

The body bone seems to deform the mesh ok, but when i move any of the arm bones the whole mesh is affected in a way thats not optimal i think... The end goal is to have each arm bone only move the mesh arm its placed inside of.

Is there any solution to this?

https://youtu.be/MSDIy4V8DFM

Clear the parenting (Alt P), then select the mesh, in edit mode select all, and choose "recalculate normals", then in object mode apply (Ctrl A) rot and scale to both mesh and armature, then redo the parenting (Ctrl P) choosing "Automatic weight".


Why the mapping/coordinates/size have no effect on displacement modifier texture? I am coming from 3ds max and spent all night long trying to understand how the texture mapping work specially when use in the displacement modifier.

When i adjust the texture size in mapping only the image change and not the displacement.

I know there is another tab call image mapping where i can change the size of the texture but it is less convenient than the mapping tab where i can scale the texture in the negative.

Here a gif to explain it more precisely :

it looks to me that you are trying to modify the material texture not the modifier texture as they are not the same for blender. I am no blender internal expert though


How can I make a repeating wave? What is a good way to make a repeating wave without having to manually select every other face and drag it along an axis? I'm trying to make a very long wave and it would save me a lot of time on this project.
I'm trying to make something similar to the metal part of this image but a lot longer and more curved.

Add a curve object and create the basic shape.

In the geometry section of the curve, give it some extrusion to get the height you want.

Use an array modifier to get as many copies as you need.


Formula (According to Blender) to create an Enneper Order 3 This is what an Enneper looks like in Blender, according to Math Functions - XYZ:

This is an Enneper, Order 3

The XYZ Functions (Enneper Blender) are as follows:

Is there a way to modify the default XYZ formula for Enneper, XYZ to create an Enneper Order 3?  Is it better suited to Blender Python?  Or perhaps Sverchok, especially now with Sverchok Extras - with an eye to minimal surfaces (of which Enneper is one)?
Can it be done, and if so how? If not, what would be a better avenue to pursue?
Addendum:
I did come up with this modified for Blender from MathMod.  It's different.  It's no Order 3.  Missing a side.

From the formula here:

If a stands for n (so 3 in our case) and b for 2n-1 (so 5), then:
x = u*cos(v)-(u**b * cos(b*v) / b)

y = u*sin(v)+(u**b * sin(b*v) / b)

z = 2 * (u**a) * cos(a*v)/a

with:
0 < u < 1.2
-pi < v < pi

And:
a = 3
b = 2 * a - 1

Which is:

Then:

If you want to push u to its limits, set it between:
0 < u < sqrt(2)

And you can change the order setting a and b differently (b = 2 * a - 1), for instance:

If useful, here is the preset file "enneper_n.py" that can be stored into the preset directory (on Windows):
C:\Users\userName\AppData\Roaming\Blender Foundation\Blender\2.90\scripts\presets\operator\mesh.primitive_xyz_function_surface

Its content is:
import bpy
op = bpy.context.active_operator

op.x_eq = 'u*cos(v)-(u**b * cos(b*v) / b)'
op.y_eq = 'u*sin(v)+(u**b * sin(b*v) / b)'
op.z_eq = '2 * (u**a) * cos(a*v)/a'
op.range_u_min = 0.0
op.range_u_max = 1.2000000476837158
op.range_u_step = 32
op.wrap_u = False
op.range_v_min = -3.1415927410125732
op.range_v_max = 3.1415927410125732
op.range_v_step = 128
op.wrap_v = False
op.close_v = False
op.n_eq = 1
op.a_eq = '3'
op.b_eq = '2*a-1'
op.c_eq = '0'
op.f_eq = '0'
op.g_eq = '0'
op.h_eq = '0'
op.show_wire = True
op.edit_mode = False


Blender Python and pass settings Try this:

Manually set checkbox "Denoising Data" on
Log shows bpy.context.scene.denoising_store_passes = True
Copypaste exactly that into console and hit enter
Throws AttributeError: 'Scene' object has no attribute
'denoising_store_passes'

Same with i.e. cryptomatte. Am i doing anything wrong or is this simply not supported yet?

The Python tooltips are currently a bit broken for property groups, which also affects the commands displayed in the Info area.

The correct command for setting this option for the current view layer is:

bpy.context.view_layer.cycles.denoising_store_passes = True

If you want to refer to the scene and view layer by name:

bpy.data.scenes['Scene'].view_layers['View Layer'].cycles.denoising_store_passes = True

Whenever you see a Python tooltip with an ellipsis (...) the command in the Info area is inaccurate.

The issue is known and reported in T69803.


Struggling to Understand Vertices Behaviour 2 This is the second time I am posting this as I was unable to post the screenshots above the first time. I apologise.

Blender Guru Anvil Tutorial

In the above link, the tutorial has a step a minute before the end in which he completes an extrusion with a clipping mirror modifier. At this point, the vertices at the ends of the semi-circle on the bottom of the anvil become locked to their actual vertex locations, instead of being near them due to the shade smooth and subsurf mod. I am unsure why this is occurring. Any help would be greatly appreciated.

you probably did press E and then Esc. That always results in duplicate vertices. If you dont undo that step and just carry on, you will be left with duplicate vertices in your final mesh, which will always break subsurf (will make a hard edge with lots and lots of duplicate vertices)

To fix it select everything and press Alt+M and select "by Distance".


How to disable entire tracks (or multiple clips) in VSE I'm using Blender to do the video editing for one of my projects.  The interface is somewhat counter-intuitive, but I use it because it gives me crazy amounts of control and it's very dependable.  I'm working with multiple layers, and just because playback can be so slow, I was wondering if there is a way to disable a given layer for playback and then turn it back on when it's time to render (for example, if I had a music track or a color correction clip).  I know that I can press the "eye" icon on individual clip properties, but I don't have time to do that for maybe 100 sound effects clips every single time I want to switch between rendering and playing.  Thanks!

To disable within the VSE, use Mute Strip.

Mute Strips: H

Un-Mute Strips: Alt + H


"Join as Shape" error when trying to import a file for shape keys from ZBrush This is my first time asking a question on this forum and I'm new to Blender, so hello everyone! This is pretty much my first time using ZBrush, Substance Painter, and Blender. Web searches got me a long way but I've hit a snag. There doesn't appear to be a solution online for my problem. The closest thing I found was another post on this site from over two years ago [link], but there wasn't a clear answer then.

My workflow was: sculpting in ZBrush > Substance Painter > Blender. I exported an .obj from Blender back into ZBrush (I love its sculpting tools), and there I sculpted my desired shape key on a layer, split the parts and then exported it from ZBrush as an .obj. I imported it back into Blender and then tried the "Join as Shapes" function. Here are the results. It's not pretty... the mesh basically explodes. I tried applying transformations, but still no good.

Here is a link to my project files. I hope someone has an answer!

Okay, so I found an answer. To reiterate, the problem was: I have an alien character with a frill (like the Dilophosaurus is Jurassic Park), and I wanted a shape key for the frill to go down. I made the original mesh in ZBrush. I exported it from ZBrush and imported it into Blender (after making texture maps in Substance Painter). I exported the mesh from Blender and imported it into ZBrush. After I adjusted the mesh so his frill was down, I exported it from ZBrush back into Blender. When I tried to do the "Join as Shapes" option, the error occurred.

Now, the workaround: I imported the un-adjusted, frill-up version of the mesh from Blender into ZBrush, then I exported it right back into Blender without making any real changes. Now both the frill up and frill down versions are both exported from ZBrush (from Blender). Not sure why, but now "Join as Shapes" works, so I'm happy. Since the vertex count never changed, the texture maps I made in Substance Painter still work too.

Thanks!


Move camera on a straight path while on a Z rotation I'm working on a project and my camera is at a 45 degree angle on the Z axis. I want to do a simple push in pull out to my object with the camera on a straight path, but I can't seem to get it right. Is there anything I can do here?

You need to set transform orientation to local.
That way Blender will treat local transforms such as the 45-degree as a default value.


Need Help Creating DNA Model I am a beginner in Blender, I know how to use the basic commands but don't have much experience creating models. I am trying to create a circle of ribbon-like DNA with the base pairs detached in the center like this, except with a few caveats.

The base pairs should be able to freely rotate around the "vertical" axis, and somehow I can control the loop so it can writhe/contort (like go from a circle to an "eight"). Could anyone please help me figure out how to do this or point me to some resources that could help?

Another way this can be done is to add a circle, then in edit mode, duplicate it and move the two pieces, so they are on either side of the origin (equally distant):

From here, just add a Screw Modifier. You need to increase the "screw" value to make it stretch upwards. You can adjust the other values to your liking:

You can adjust the size and shape of the helix by adjusting the size and shape of the two initial circles, as well as their distance from one another. You can also play with the screw angle to adjust the "tightness" of the helix. More turns may require you to increase the number of "steps" to keep the curves smooth:

If you want to curve the whole object into a ring, you can do so by using a Bezier Circle and a Curve modifier. First make sure you have access to the Bezier Circle by going into User Preferences > Addons and search "curve" to enable the " Curve Tools" addon. (This may or may not be necessary to access the Bezier Circle - I have had the addon enabled for so long, I can't remember if the circle is there without it)

Once this is done, the Bezier Circle should appear in your Add menu. Add one to your scene:

Scale the curve in edit mode to an appropriate size (I did 20x based on my initial mesh size), and rotate it in Object mode by 90 degrees so it lines up with your helix:

Add a Curve Modifier to the Helix object, and select the Bezier Circle as your curve object. You can see I needed to increase the iterations of the helix as well to make it fit better (I know it's not perfect - we'll fix that):

To make the ends "meet" properly, you will have to fine tune the values of the Screw modifier. You can see I had to go a bit off the 720 degree mark and increase the height a little to make the ends match perfectly. Make sure you have merge checked as well.

After that, you can apply the modifiers if you want to, and then you can delete the circle as well (also if desired). You can also do a merge-by-distance just to be safe, but things should be fine already if you matched it right.


Strange shadows in 2.8 rendering with Eevee When I render my image with Eevee, I have strange blocky, dotty shadows that appear in the image. If I zoom in very, very close in render preview they disappear. See below images for an example. Does anyone know what is going on here? Shall I report this bug to blender, or is this a modeling issue by me? (I'm brand new, hence the doughnut scene)

Zoomed in:

Super close:

I figured out the error. Having multiple light sources with contact shadows on appears to be the issue, I just toggled around until I had one primary light source with contact shadows on. Cross contacting generated these blips.


Quick Effects Smoke Rendering as square I rendered a png file which has appeared as with a box where the smoke should be. There's also a screenshot of the materials setting selected which does show the smoke. Whats going wrong here?

I don't think I have any materials for the emitter? The smoke is created from the quick effects menu.

You have no material in the smoke domain, so the smoke domain will render as a white box.

Read the following link to set the materials correctly.

Rendering smoke in Cycles?


Create a screencast with exactly one image per animation frame I need to export an animation that runs in the 3D Viewport as a sequence of screenshots with one image per frame. So i created a small class :

class MyAnimationCast(bpy.types.Operator):

bl_idname = "my.animation_cast"
bl_label = "Animation to Image sequence"
bl_description = "Capture an Animation from 3D View to image sequence"

def execute(self, context):
    scene   = context.scene
    folder = scene.render.filepath
    format = scene.render.image_settings.file_format.lower()

    for frame in range (scene.frame_start, scene.frame_end):
        filepath = os.path.join(folder,"%04d.%s" % (frame, format))
        print("Render to file", filepath)

        scene.frame_set(frame)
        scene.update()

        bpy.ops.screen.screenshot(
            filepath=filepath,
            check_existing=False)

    return{'FINISHED'}

This class creates the expected number of images at the expected location. But all images contain the frame that i can see when i call the operator. What is missing in the code?

My preferred method would be to use a frame_change handler and an update method on a bool to turn it on off.

import bpy
import os

from bpy.props import BoolProperty

def remove_handler_function(handler, name):
    ''' Removes all functions with name starting with name '''
    fns = [f for f in handler
                   if f.__name__.startswith(name)]
    for f in fns:
        handler.remove(f)

def screenshot(scene):
    frame = scene.frame_current
    in_frame =  scene.frame_start <= frame <= scene.frame_end
    if not in_frame:
        return None

    folder = scene.render.filepath
    format = scene.render.image_settings.file_format.lower()
    filepath = os.path.join(folder,"%04d.%s" % (frame, format))
    print("render %d" % frame)
    bpy.ops.screen.screenshot(
        filepath=filepath,
        check_existing=False)

def capture_screen(self, context):
    # turn on the handler
    handler = bpy.app.handlers.frame_change_post
    if self.render_screencast:
        handler.append(screenshot)
    else:
        remove_handler_function(handler, "screenshot")

bpy.types.Scene.render_screencast = BoolProperty(default=False,
                                                 name="Screen Shot Cast",
                                                 update=capture_screen)

#testing
bpy.context.scene.render_screencast = False

My testing shows that the operator will do as desired with

        bpy.ops.screen.screenshot(
            filepath=filepath,
            check_existing=False)
        for area in context.screen.areas:
            area.tag_redraw()

but it will lock up blender until finished.  Pretty sure there is no need to call scene.update() after scene.frame_set(f), and not sure how much this effects performance, if at all.

Another is a modal timer operator, which enables the chance to cancel. (The handler is much better).  The link of @ideasman42 I mentioned is here How to handle modal operator events in a single loop?  Which may make handling canceling easier.

class ModalTimerOperator(bpy.types.Operator):
    """Operator which runs its self from a timer"""
    bl_idname = "wm.modal_timer_operator"
    bl_label = "Modal Timer Operator"
    wait = 10
    _timer = None
    renderframe = -1
    def modal(self, context, event):
        scene = context.scene
        rendering = self.renderframe == scene.frame_current
        folder = scene.render.filepath
        format = scene.render.image_settings.file_format.lower()

        if event.type in {'RIGHTMOUSE', 'ESC'} or scene.frame_current > scene.frame_end:
            self.cancel(context)
            return {'CANCELLED'}
        if event.type == 'TIMER' and self.wait:
            self.wait -= 1
            return {'PASS_THROUGH'}

        if rendering:
            return {'PASS_THROUGH'}

        else:
            self.renderframe = scene.frame_current

            print("render %d" % scene.frame_current)
            self.report({'INFO'}, "Render: %4d" % scene.frame_current)
            filepath = os.path.join(folder,"%04d.%s" % (scene.frame_current, format))
            bpy.ops.screen.screenshot(
                filepath=filepath,
                check_existing=False)

            scene.frame_set(scene.frame_current + 1)
            self.wait = 10
            for area in context.screen.areas:
                area.tag_redraw()

        return {'PASS_THROUGH'}

    def execute(self, context):
        scene = context.scene
        wm = context.window_manager
        self._timer = wm.event_timer_add(0.1, context.window)
        wm.modal_handler_add(self)
        scene.frame_set(scene.frame_start)
        return {'RUNNING_MODAL'}


How to bevel gpencil point? Is it possible to bevel the point of grease pencil (in edit mode), just like doing bevel to a vertex ?

Thanks

You can subdivide the angles and smooth them, even in sculpt mode.


Some parts in render mode white when trying to animate some parts are white in render view, not sure what causes it.

Fixed it, remove all materials then add them back


triangulate faces obj format problem This is probably a noob question but here goes. I don't remember how to export correctly to my own obj parser.

this is how I want the faces to be exported (How they used to be exported correctly):

f 5/1/1 6/2/1 1/3/1
f 6/1/2 7/2/2 3/4/2
f 7/1/3 8/2/3 4/4/3
f 8/1/4 5/2/4 1/4/4
f 1/1/5 2/2/5 3/4/5
f 8/1/6 7/2/6 6/4/6
f 6/2/1 2/4/1 1/3/1
f 2/3/2 6/1/2 3/4/2
f 3/3/3 7/1/3 4/4/3
f 4/3/4 8/1/4 1/4/4
f 4/3/5 1/1/5 3/4/5
f 5/3/6 8/1/6 6/4/6

But everything I try with the exporter now only gives me something like this:

f 5//1 6//1 1//1
f 6//2 7//2 3//2
f 7//3 8//3 4//3
f 8//4 5//4 1//4
f 1//5 2//5 3//5
f 8//6 7//6 6//6
f 6//1 2//1 1//1
f 2//2 6//2 3//2
f 3//3 7//3 4//3
f 4//4 8//4 1//4
f 4//5 1//5 3//5
f 5//6 8//6 6//6

What am I doing wrong? I have tried converting all quads in edit mode to triangles manually in vain, and tested all export variables. I've tried different versions of blender too.

In the Wavefront file-format, the second number for every element for a face is the texture-coordinate

The quick way to get it running:
Select your object, go into edit-mode, press U and select Unwrap.

When exporting, make sure you have Include UVs selected.

Outcome (only faces):

f 2/1/1 3/2/1 4/3/1
f 8/1/2 7/2/2 6/3/2
f 5/1/3 6/2/3 2/3/3
f 6/1/4 7/2/4 3/3/4
f 3/4/5 7/1/5 8/2/5
f 1/1/6 4/2/6 8/3/6
f 1/4/1 2/1/1 4/3/1
f 5/4/2 8/1/2 6/3/2
f 1/4/3 5/1/3 2/3/3
f 2/4/4 6/1/4 3/3/4
f 4/3/5 3/4/5 8/2/5
f 5/4/6 1/1/6 8/3/6


How do implement the effect of blur on transparent materials? I'm trying to create a blur effect when a clear light passes through a transparent material. Here's a quick summary of the picture:

And when an object is close to a transparent material, it should be more visible than it is away from a transparent material.

Here's a quick summary of the picture:

I've seen this tutorial for implement this, but I'm not trying to implement glass, because I'm trying to implement a protective film, so it doesn't fit my procedures.

A very simple solution is to create a render pass for the glass and use it as a mask to add blur in the compositor. Of course, to implement the depth effect, you would also then need to render out a depth mask to use as the blur amount, and then your passes are adding up. That's a lot of rendering and compositing just to avoid a glass material, but this method can sometimes end up rendering faster because it avoids some of the typical issues associated with rendering glass.


How to not make scaling snap to 3D Cursor? Whenever I try to rescale the points in my cup, they always scale in the direction of the 3D cursor. How can I make it so that they are scaled independent of the position of the 3D cursor?

Sorry if this is a really easy thing to configure - I have spent almost an hour looking through stack exchange and the blender docs and could find nothing on this. Thanks in advance!

I guess you need to come back to Pivot Point > Median Point instead of 3D Cursor.


'Context is incorrect' error when using 'bpy.ops.object.mode_set(mode='OBJECT')' if I'm already in object mode I'm trying to do things that only work in object mode. This gives me three choices:

I can hope I'm in object mode, and my script will raise an error if I'm not.
I can hope I'm in pose mode (or some other specific mode) and use bpy.ops.object.posemode_toggle() to switch out of it.
I can hope I'm not in object mode, run bpy.ops.object.mode_set(mode='OBJECT') to switch into it, and my program will raise an error if I'm already in it.

If I go with that last option I'm getting the error message

Traceback (most recent call last):
  File "C:\Users\daniel\Desktop\BlenderMusic\keyboard.blend\fingers", line 5, in <module>
  File "C:\Program Files\WindowsApps\BlenderFoundation.Blender_2.82.1.0_x64__ppwjx1n5r4v9t\Blender 2.82\2.82\scripts\modules\bpy\ops.py", line 201, in __call__
    ret = op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.object.mode_set.poll() failed, context is incorrect

There's nothing I can do to just let my script run no matter what mode it's in without crashing. Am I missing something?

Also, why is posemode_toggle() even a thing? How can you be in a situation where you don't know whether or not you're in pose mode, but if you're in it you need to not be in it and if you're not in it you need to be in it?

You can check which mode you're in with the following line:

mode = context.active_object.mode

And then do things correspondingly, such as switching to object mode when you're in pose mode for example.

Or you could use a try/except statement:

try:
    bpy.ops.object.mode_set(mode='OBJECT')
except:
    pass

Hope this helps.


Merge these two meshes and export as .obj I'm attempting to merge these two meshes together. They are already right beside each other in the way that I want to merge them.

The top mesh, highlighted in orange, and the bottom mesh, which is a flattened cube that I've curved using a path (the black line on the right)

I'm trying to follow this question and answer to join the two meshes but I can't get past the first step of selecting both of them at one time - is this because of the curve?

Thanks,

P.S. Here's the .blend

When joining [⎈ CtrlJ] objects, the new object will have the modifier stack of the active object.

If you (e.g.) select the mesh with the modifier and then the mesh without, the last selected becomes the active object (in this case the mesh without the modifier). When joining them, the new object will have no modifier and the mesh part which needs the modifier will be wrong.

The solution is to apply the modifier first by selecting the mesh and pressing apply on the modifier.

(legoparrot beat me, still going to leave the answer since there are some more details)


Confused about how to define a class This is how I sofar define a class for a panel inside the tool shelve.

class ObjectLayer(bpy.types.Panel):
    bl_label = "ObjectLayer"
    bl_idname = "ObjectLayer"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    bl_category = "Claas"

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

        obj = context.object

        row = layout.row()
        row.prop(obj , "layers")

Then I got this amazing script in how to show the modifier stack in the tool bar but it uses a very different format for declaring a class

import bpy
from bpy.types import Menu, Panel, UIList
from bl_ui.properties_data_modifier import DATA_PT_modifiers as PT_MOD

@classmethod
def poll(cls, context):
    return (context.object is not None)

def make_panel(name, poll, funcs):
    overwrites = {
        "bl_space_type": "VIEW_3D",
        "bl_region_type": "TOOLS",
        "bl_label": "Test",
        "bl_context": "objectmode",
        "bl_category": "Test",
        "poll": poll,
        "draw": getattr(funcs, "draw")
    }

    for f in dir(funcs):
        if f.isupper():
            overwrites[f] = getattr(funcs, f)

    return type(name, (Panel,), overwrites)

RigPanel = make_panel("OpenStudioAddRigPanel", poll, funcs=PT_MOD)

def register(): bpy.utils.register_class(RigPanel)
def unregister(): bpy.utils.unregister_class(RigPanel)
if __name__ == "__main__": register()

This is what I tried:

import bpy
from bpy.types import Menu, Panel, UIList
from bl_ui.properties_data_modifier import DATA_PT_modifiers as PT_MOD

class ObjectLayer(bpy.types.Panel):
bl_label = "ObjectLayer"
bl_idname = "ObjectLayer"
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
bl_category = "Claas"

def poll(cls, context):
return (context.object is not None)

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

ob = context.object

layout.operator_menu_enum("object.modifier_add", "type")

for md in ob.modifiers:
    box = layout.template_modifier(md)
    if box:
        # match enum type to our functions, avoids a lookup table.
        getattr(self, md.type)(box, ob, md)

def make_panel(name, poll, draw, funcs):
overwrites = {
    "bl_space_type": "VIEW_3D",
    "bl_region_type": "TOOLS",
    "bl_label": "Test",
    "bl_context": "objectmode",
    "bl_category": "Test",
    "poll": poll,
    "draw": draw
}

for f in dir(funcs):
    if f.isupper():
        overwrites[f] = getattr(funcs, f)

return type(name, (Panel,), overwrites)

RigPanel = make_panel("OpenStudioAddRigPanel", poll, draw, funcs=PT_MOD)

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

def unregister():
bpy.utils.register_class(ObjectLayer)

if __name__ == "__main__":
register()

Traceback (most recent call last):
  File "C:\Users\info\Desktop\untitled.blend\Text", line 58, in
  File "C:\Users\info\Desktop\untitled.blend\Text", line 52, in register
AttributeError: expected Panel, ObjectLayer class to have an "draw" attribute

Use the regular class definition scheme as shown in the TextEditor Python Templates -- unless you have a good reason to use a class Factory.

As Sambler shows in the new answer to the previous question: You can do this much simpler with standard class definitions -- the use of the "class Factory" was not appropriate in this scenario because it wasn't the least complicated solution.

However, to answer this question anyway; the make_panel function is what we might call a "class Factory".

Positive

It generates unique classes on the fly, requiring little code to  individualize each class. Especially useful if you need many classes which differ only in small but important ways.
This avoids explicitly writing the full class out in code for every class if you just need to change a couple of lines or functions per class.

negative

The downside to a class factory is it becomes tricky to reason about the code, especially for newcomers. If you don't know how to introspect a class it becomes a bit of a black-box.
classes generated this way must be registered with bpy.utils.register_class(...)

register_module(__name__) won't find these classes automatically.

How to use such things correctly is better discussed on a programming QA like StackOverflow. See this question / answer " How can I dynamically create derived classes from a base class " . If that question is over the top of your head, probably wait till you get more Python experience before using the code.


Shortcut for centering the 3D-cursor in a view Is there a keyboard shortcut for centering the 3D-cursor in the current view? The cursor itself should stay in the same spot in space (i.e. its coordinates shouldn't change).
Right now I have to manually center the cursor using shift + press scroll wheel, which is tedious.
ADDED: the GIF shows that "Center view to cursor" does not work. The cursor remains out of center (left lower corner)

There is a menu for that: "Center view to cursor"

But no predefined shortcut. You can assign the one you want with a right click on the menu (or add it to the quick favorites):

But that won't move it the view center is locked to 3d cursor's location:


Emissive shader does not change much in changes of orders of magnitudes I'm trying to make some LED lamp but the EMISSIVE feature doesn't react as I expect.
I read on the Blender manual that the emission power is defined in Watts per Square Meter.
It doesn't really seem to work the right way.
From 0 to 1 it works well, but then, raising it to 10, it's not decuplicating the light, and even shooting it to 100000 won't really change much.
You can see in the images how the change from 1000 to 10 millions doesn't change anything in the final image.
For a test, I added an area light on top of the emissive model, and a 1 W light assigned to it makes faaaar more light than the emissive material.
You can see the difference in the final image.
What may be happening here?
Now, I may trick and just use the area lamp, but I want to know what is happening so to know how to work in the future.

Real world sizes. Emissive surfaces are exposed, nothing in between.
Actually, Eevee is not really lighting anything with the model, it just adds glow, a lot of it XD
Tried in a brand new scene, same problem: emissive power doesn't do anything past a certain threshold. It looks like the power is logarithmic.
You can download it here:
Also added the original file:

The problem is the light clamping setting.

Set "Direct Light" to 0 to fix the power issue.
Setting the clamping to 1 means that any value brighter than 1 is clipped (or ignored), therefore it doesn't matter if the lights are set to an intensity of 1 or 1 million. Setting it to 0 means that the lights are un-clamped, therefore using their real values.
Read: What is Clamp Direct/Indirect?
Additionally, I would recommend setting the color management to filmic for more realistic tone mapping. Standard transform is usually used for video editing.


How to use the Freehand Curve drawing add-on? Enabled/Installed the add-on, can not get it to work though...

There's the Options tab in the T-Tools panel, but there is no Draw Curve button in the Create tab.... Shift+LMB does not work as well...

Any idea why this might be?

Thanks

Peter

Took me some tries to figure it out myself:

Add a Bezier curve to your scene
Tab into Edit Mode (with said curve selected)
Shift+LMB draw your freehand curve
Delete the Bezier curve from step 1


Why light distribution for smooth and flat shading is so different in Blender Render? Here is a quick comparison test in both Blender and Cycles. Mesh is default cube with one deleted vertex and Point lamp in the center.

Generally speaking, smooth or flat shading regardless of subsurf level doesn't affect Cycles so much in this case. Maybe a bit brighter or darker for different combination, but equal overall. Light is concentrated more in the center of polygons.

But in Blender Render only unsubdivided smooth mesh can be a little closer to Cycles, other combinations are totaly different. Moreover, higly subdivided smooth mesh looks pretty much the same as unsubdivided flat.

Are there any animation-friendly ways to transform light distribution for Blender Render?

Blender Smooth Unsubdivided

Cycles Smooth Unsubdivided

Blender Smooth Subdivided

Cycles Smooth Subdivided

Blender Flat

Cycles Flat

Smooth shading is an attempt to programmatically and dynamically make triangular meshes "look" rounded (smoothed).  Even though the reflection looks smooth, the geometry remains unchanged:

With a perfect cube, there should technically be nothing to smooth; but you applied the shader, so it's gonna try to do something.  The problem that you're seeing in the first two pictures is that those faces are not technically four-sided... at least in the graphical/mathematical sense.  Four-or-more-sided polygons are only for the human eye and mind, not the graphics engine.  Those three faces are actually made up of six triangles.  When the smooth shader is applied to them, it's attempting to "smooth" all the edges and faces and that's why it looks like triangles (the Cycles version is less pronounced but if you rotate it, you'll see it).

When you subdivide it, though, you're adding a lot more geometry to the mesh (especially at level 6, that's 6 orders of magnitude more triangles).  So the shader has more geometry to draw from in order to "approximate" the look you're going for.

The same effect can be achieved by using the Edge Split modifier which adds weights to the edges (essentially doubling the edges, it adds more geometry to the mesh) at specified angles of incidence.  In this case, the edges at 90 degrees could be given the weights but the diagonal in the middle of the faces would be outside the threshold of the edge split.

As for the differences between BR and Cycles rendering, they're two totally different engines and they both have their own ideal uses.  But there's a lot out there on that subject.

EDIT: I should add, for plenitude, that the Edge Split modifier effect can be obtained without increasing filesize.  It's called "auto-smooth" and it's located under Properties Pane-> Object Data-> Normals.


how to do rays trough stone fissure Hello guys I want to simulate a morning sun shining trough this stone gap like seen in the pictures below. It would help me extremely when you could explain it rough how i could achieve smth like on the first ref image.

Best regards Marc!

The rays in that image are actually most likely diffraction spikes caused by the aperture in the lens. To simulate that, you might try using the glare node:

Note that it helps if you have a very bright light source for the glare node to pick up on. Sun lamps are pretty good for this, but won't show up in the render directly. In the above example I made a refractive plane for the sun lamp's light to pass through, allowing it to be seen by the camera.


How can I add vertices to intersection of two edges? I need to put a point at the intersection of two edges. Below is a picture with red circles around where I need points to be placed.

If all you really want is to add a vertex at the position of intersection, then something like this script would work: (this even adds the vertex at the  projected intersection of two lines, or the closest point if they never intersect)

import bmesh
import bpy
from mathutils import geometry

def add_vertex_to_intersection():

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

    edges = [e for e in bm.edges if e.select]

    if len(edges) == 2:
        [[v1, v2], [v3, v4]] = [[v.co for v in e.verts] for e in edges]

        iv = geometry.intersect_line_line(v1, v2, v3, v4)
        iv = (iv[0] + iv[1]) / 2
        bm.verts.new(iv)
        bmesh.update_edit_mesh(me)

add_vertex_to_intersection()

this does not attach the vertex to any edges/faces. Here it is packaged as an addon accessible from: W > Place vertex at intersection

This is now part of mesh_tinyCAD

A while back I added this feature to mesh_tinyCAD, and called it (Vertex to Intersection) V2X. I use it to add guide-vertices to intersections and it is less potentially destructive than the XALL or VTX operations.


Strange shading on flat surface I am trying to model a snooker table for an Unity game and I have an issue with strange shadows on the cushion:

This is how I modeled the curved edge:

It's not an Unity issue because if I choose smooth shading on Blender, I get some strange behavior too:

I tried to recalculate the normals and I also checked if the top vertices are on the same plane and they are. Am I modeling it wrong?

Sometimes you get this issue with orphaned vertices, which can be fixed with Merge By Distance option. And sometimes it needs to be UV reunwrapped, as I think you have discovered.


how to apply a time function in this script to add ob2 to the scene after ob1 without being together? import bge
import bpy

scene = bge.logic.getCurrentScene()

ob = bge.logic.getCurrentController().owner

ob1 = scene.addObject("stone",ob)

ob2 = scene.addObject("twin",ob)

Its hard to tell if that's the optimal solution, but a "time function" in python can be summoned using the following commands:

import time
time.sleep(2)  # argument in seconds, int or float

The above function instructs the computer to wait idly for the determined amount of seconds.


How to Get Object's Coordinates to Display as 0,0,0 when Parented, and Update Transform Values as if Parent was at World Space Origin? When child object transforms are zeroed out, I want the child object to return to the current world space location of its parent, and report 0,0,0 in the child's location transform fields. In addition, applying the location transforms for children should likewise be based off of this same parent world space location, and not the world space origin. This is how parent-child behaviors commonly work in other programs. But seemingly not in Blender.
I've been researching this problem both on and off this site. It appears that other people are asking similar questions, both here and elsewhere, and are not getting answers. Or are getting the wrong answers. Or they are being told that scripting is the key. How could scripting be the key?
I want to zero out child transforms and have the child object end up wherever its parent is currently located. Can this be done in Blender? If it can't be, then what is the workflow I'm expected to adopt so that I won't need children to return to parent locations when their transforms are zeroed out? The only thing i can think of as a workaround is to create everything that needs parenting at the world space origin. That is not always practical.
Why are all location transforms always global coordinates in Blender? Even the use of Delta transforms doesn't make for an intuitive workaround. In some ways, conceptualizing the spatial relationships between parents and children becomes even worse with Deltas. It's also inconvenient to need to go somewhere else in the UI to manage transform values.
In Edit Mode, there is both a Local and Global way of viewing coordinates for selected components. But no corresponding option exists for objects in Object Mode. That is not consistent nor convenient.
I don't expect anyone to read the below linked thread in its entirety, but it highlights a discussion on this very topic. If anyone is so inclined, and partakes, they will discover that, apparently, the devs don't see this as a problem in need of fixing. Also, someone in the thread evidently made an in-house addon to make parenting work in Blender the way it works in every other program, and wanted everyone else to know they made it. But they evidently didn't want anyone else to have it, because they didn't mention whether it was available publicly. https://developer.blender.org/T68190
The Parent Inverse seems to be an extremely cryptic and convoluted concept, in part because its value is always hidden. It's also a reference entirely too dependent on mathematical jargon to be encouraging to artists and non-programmers. But it's also one that is central to this issue. My understanding is that this value is an offset, and is needed to prevent newly parented objects from automatically snapping to parent origins. It keeps child objects wherever they already are in world space after parenting. Okay. But then, why is this value not used to zero out the child's transforms, since the inverse data would actually be useful for this purpose? Why even have the Parent Inverse function if it is not going to be used to provide this kind of functionality?
This is one of the most frustrating things about Blender for anyone who has ever used another 3D software program. This is especially true for riggers/animators, who want to be able to quickly zero out transform values and get children immediately returned to parent positions.
If I am simply failing to understand the right way to do things, I would love to be told, so long as the right way to do things was demonstrated afterwards.

An example of object parenting
Object A has its origin in world space at x=10.0, y=10.0, z=10.0
Object B has its origin in world space at x=2.0, y=2.0, z=2.0
When parenting Object B to Object A, Object B ends up in the coordinate space of Object A.
The new coordinates of Object B in local coordinate space, relative to its parent, are: x=-8.0, y=-8.0, z=-8.0
What Blender displays in the UI
Blender does the exact same thing as described above.
Object B does end up in the coordinate space of Object A.
But the coordinates you see in the UI - in the item panel of the 3D view - are still displaying x=2.0, y=2.0, z=2.0. I guess you expected it to display the coordinates in local space like x=-8.0, y=-8.0, z=-8.0.
What you see in that place of the UI is the "location" tied to the so called "Input Matrix" resp. matrix_basis.
The "Input Matrix" is neither the global matrix nor the local matrix, but a particular matrix for user input. Citing the docs:

Matrix access to location, rotation and scale (including deltas),
before constraints and parenting are applied

https://docs.blender.org/api/current/bpy.types.Object.html#bpy.types.Object.matrix_basis
So it’s kind of an unspoilt matrix that is not "polluted" by constraints or parenting.
You could add a "Limit Location" constraint to Object B, limit its location to 0/0/0, but the input matrix remains on 2/2/2.
The "location" that is actually displayed in the UI is the input matrix without delta transforms.
On the one hand it’s a pretty clean and stable matrix to keep user input separate from other influences.
On the other hand I can understand that you’d like to see and edit the final/actual coordinates in local space after parenting.
Possible Solutions
Here’s a corresponding feature request with some discussion:
https://blender.community/c/rightclickselect/hLdbbc/
In there they’re mentioning an addon that adds direct access to world and local matrix in the object properties:
https://gitlab.com/blender3d/addons/object-location-edit/-/releases#v0.03
And here’s an addon that transforms the matrix values in a way that the values of the input matrix become those of the local matrix:
https://github.com/drewcassidy/blender-apply-parent-inverse
You can see and edit all these matrices without any plugin in the Outliner:

Set the Outliner’s display mode to "Data API"
Object -> "Object B" -> Matrix World / Local Matrix / Input Matrix / Parent Inverse Matrix

Checking out the local matrix you’ll see Object B's coordinates are: x=-8.0, y=-8.0, z=-8.0 indeed.


UV Wrap seen through object [EEVEE] Apologies, I'm not entierly sure how to the title this post without it being super long.

But to summerize, I use blender for my day job, doing artwork mockups on products, and eevee has sped up this process 10fold compare to waiting for cycles renders, but one crucial thing i'm missing at the moment is to see the back side of my UV Wrap on a transparent/glass object in eevee, I've searched high and low but can't seem to find any answers, is it currently possibly with how eevee is right now?

If so please help me correct my setup to show this.

Node setup is not mine, I found it elsewhere, but currently gives the most accurate real world result to what i'm mocking up.

Images below:

sambler's reponse spured me on the mess around with things something, and i've managed to 'fake' the transparency I guess.

Firstly I changed the blend mode to Multiply with Show Backface ticked.

With this though, the artwork shown on the backside of the cup was at max brightness (for lack of better words) which isn't what I want, nor realistic.

So I duplicated my material, and applied to the back half of the back, and shoved a colorramp node inbetween the image texture and diffuse node with a mid-ish grey which muted the colour to be how it would look on a final product.

Here is my complete node setup in the hopes it helps anyone, it's a bit fiddly but it's doing the job.


Is there a way to restrict the operation of a driver or even record the action of the driver in Blender I have a small animation playing and I have made use of some trajectory equations in order to obtain a more realistic jump in the form of a driver, but I also want to add some additional movements to the object, is there a way to record the action  of the driver to form an f-curve and then delete the driver?

In pose mode go to Menu: Pose-Animation-Bake action. Check the visual keying option. Then you can use the newly created action on a copy of the armature without any costraint or driver.


Enabling OpenCL GPU rendering for Cycles on Linux? I followed the answer on this question for blender 2.7x, but I still don't see the option to enable GPU rendering for cycles, as shown in this screenshot:

I'm using an RX 560 on Debian 11

contrib non-free enabled in my sources.list
CYCLES_OPENCL_SPLIT_KERNEL_TEST=1 inside /etc/environment
ocl-icd-opencl-dev installed

How do I enable GPU Cycles rendering?

To enable opencl on linux working with blender, the only way is to install the official amd-pro driver, or, as I did, only the opencl part.
Unfortunately, the only Linux distro officially supported are:
RHEL 8.0 / CentOS 8.0 and 7
Ubuntu 18.04.3 (and derivative) (so, all the kubuntu, xubuntu, lubuntu etc and mint)
SLED/SLES 15 SP1 (and opensuse leap)

So, with Debian You are in a bad spot, unless You play around quite a bit


Python: Add existing NodeGroup to Material My goal is to add a NodeGroup I created earlier to the shader nodetree of an object using python. (Actually a few hundred times, hence the script)

This is what I know how to do:

iterate over all the objects of which I need to change the Material.

Here is where I get stuck:

I can add a new NodeGroup with object.data.materials[0].node_tree.nodes.new("ShaderNodeGroup")
This only creates a generic NodeGroup and I'm unable to select the actual Nodetree within this new Group.
py.ops.node.add_node(type="ShaderNodeGroup", use_transform=True, settings=[{"name":"node_tree", "value":"bpy.data.node_groups['MyNodeGroup']"}]) is the operator to add the Nodegroup that I want, but when I try to use that in my script, I get an error that I'm in the wrong context.

How can I make any of these methods work for my script?

You can do something like this: create the node group instance and set the existing node group as node tree for this new instance.
import bpy

C = bpy.context

def instantiate_group(nodes, data_block_name):
    group = nodes.new(type='ShaderNodeGroup')
    group.node_tree = bpy.data.node_groups[data_block_name]
    return group

instantiate_group(C.object.material_slots[0].material.node_tree.nodes, 'NodeGroup')


Locked / unmovable vertices in part of a Combined Mesh I created a humanoid but, after merging the parts together, I can't seem to move the hand vertices in any way in vertex mode. I can't even select them. It's all one Mesh without any modifiers exept for an armature modifier.
Here Is a video Showing the problem: https://youtu.be/ySUpQvKpPbE

Thanks to moonboots I found out that it can be solved by entering edit mode and then unhiding everything.


How to create a mirror pose for a pose bone (using Python)? I've done pose mirroring for characters in some other 3D software using scripting / matrices.

However in Blender I don't have the same helper methods / functions available (or haven't found them yet) and I'm not that much familiar with Matrix math in general.

For example - I could define some plane like ZY-plane and mirror left side bone pose (rotation) to right side along this plane. Can't remember the exact details. I would also limit myself to same limitations as Blenders pose mirror does, i.e. knees bend along x-axis and Y-axis is along bone length.

However, I haven't been able to do this in Blender yet. First of all, I'm not even sure how Blender's matrix is setup. To me it seems third item in its list is rotation:

pBone.matrix[3]  # this is rotation?

Any help is appreciated.

P.S.
I got a setup to mirror pose bones using bpy.ops.pose.copy and by.ops.pose.paste(flipped=True) but this is not what I'm asking.

Edit - this is what I got now. Similar to what I've used in other software. But it naturally is negatively scaled after mirror and I should be able to somehow restore it back to 1,1,1 scale while keeping the rotation.

def mirror_bone_pose(bone):
    # mirror matrix
    mmtx = Matrix.Scale(-1, 4, (1, 0,0))

    # mirror
    mtx = bone.matrix
    mtx = mmtx @ mtx
    bone.matrix = mtx

    # remove neg scale in one axis, not enough... but flips normals of bone
    # bpy.context.object.pose.bones["Bone"].scale[0] = 1

# test
mirror_bone_pose(bpy.context.object.pose.bones[0])

OK, I probably have butchered all the rules for doing matrix math, but it works.

Basically, multiply the bone to have mirror matrix then scale it back, but it is now in reverse orientation, pointing towards opposite direction.

To counter this, I rotate it 180 long z and y axis. For some reason, updating / refreshing scene was needed for this to work.

This yields the rotation I was looking for (so far it seems to work like intended):

def mirrorPose(bone):
    m = bone.matrix.Diagonal((-1,1,1,0))
    bone.matrix = m @ bone.matrix
    bone.scale = (1,1,1)

    bpy.context.view_layer.update()

    z = mathutils.Euler((0,0,math.radians(180))).to_matrix().to_4x4()
    bone.matrix = bone.matrix @ z
    bpy.context.view_layer.update()

    y = mathutils.Euler((0,math.radians(180),0)).to_matrix().to_4x4()
    bone.matrix = bone.matrix @ y


Weight painting an object In the picture above I have two feet. The blue one is the one I have selected and gone into weight paint mode. I'm trying to change some vertices to red in weight paint mode but don't really understand how to do this. When I use the brush on the foot, nothing happens. It simply remains blue. It also doesn't show me vertices. It appears solid. If I enable wire frame mode, it shows all the vertices but doesn't allow for selecting certain vertices.

How can I paint specific vertices along the seam of my foot red?

In your screenshot the weight and radius of your brush are set to 0, and you are using the subtract brush.

If you set them to higher values and pick a brush like mix, then it should work:


Blender is not rendering in the viewport In the viewport, it doesn’t render (when using cycles because eevee doesn’t look right) on the top left corner it says initializing but it never starts rendering. I have let it sit for more then 15 minutes. I do have a slow computer but not that slow. here is a pic of the viewport:

Your render is paused .
Click on the top right icon shown in the image to switch it back on.
Don't mind the clipping... (The one in the second circle)
This function is normally used to prevent a view port render from updating even if we make any changes to any thing or try to mave in the viewport.


Need help with a clean Normal map for a character in Blender First of all thank you for your time reading this.

I am new to Blender and I managed to make my very first character.
my low poly mesh has been created and I sculpt one for more defined details.

But the problem is, I can not seem to fix the baking process to get a nice blue normal map, and I am not experienced enough to know how to fix this.

Some of these parts are inside the mouth, so can I just remove them?
Since I will be using textures for the teeth and tongue and mouth in general.

I think my main problem is with overlapping meshes.
Does any more experienced blender artists know how to deal with this?
And can take a look at my file:

https://www.dropbox.com/s/ecoxbtog60wwc6h/Ossy.blend?dl=0

This character will be used in animation so maybe this isn't all necessarily.
Thank you all for your time and I hope to hear from anyone soon.

Most likely, the overlapping geometry is rendered in the baking process, there's a method called explosion when you do baking, which consider you taking apart each element of your mesh. Here's a example:

Since your model is simple, you can do this manually, by duplicating your model, and separating each mesh element, you can do this easily by pressing L on edit mode, which will select entire elements, and move them apart. After you done this, test to bake it again and see if you get the clear results you're after.

After you have your map baked, you can delete the exploded mesh and return to the original one, finally applying the normal map.

Would recommend you to Apply Rot & Scale (CTRL+A+Apply Rot & Scale in object mode), and make Normals Consistent (CTRL+N in edit mode) before your baking process, generally many problems can be fixed with this.

Cheers,


how to make an object blend with the background without looking fake? i use blender 2.79
if you look at the object in this case the moon, it looks so fake compare to the background
i used a plane with an image of fog on it
does anyone know how to make my object blend with the background ?

I think it's a problem of contrasts, you need to either:

Push up the black levels of your planet

Or decrease the medium values of your background so that the 2 elements work together.

Also, maybe it's weird that some fresnel comes on the edge of the planet that faces the darkest side of space, try to rotate it (not sure about that but it may work on the perception)? And add some stars?


how to connect two paths I am trying to connect 2 separate paths somewhere along its centre, see picture:

Is there a way to do this?

Select the points you want to connect and press "F".


How can I duplicate a UV map on the same object? I want to have an object with two identical UV maps, but I don't know how to duplicate them. I feel like the answer is simple but I just can't figure it out.

When you add a new uvmap it will duplicate the selected uvmap.

If you want them to stay identical there is no advantage to having multiple uvmaps, the same map can be used for multiple image textures and in multiple materials.


Array modifier's coord. system I want to make array from sphere along line i marked red. I've already converted it into curve and choose it in "object" box of array modifier - didn't help.

As i understand, the coordinates of array modifier i marked red are global. Is there any way to make them different (local, for exemple)?

Add a curve with 2 control points
Edit mode, change type to Poli
On the sphere, add an Array Modifier select Fit Type=Curve and select the curve as target object
add a Deform/Curve modifier select the curve as target


Combining vector displacement and standard black and white displacement nodes I am currently working on an ocean scene. The water uses a subdivided plane with waves that are displaced via the vector displacement node in the material.
I would like to add another whirlpool effect displacement on top of this, using a black and white image I have created in photoshop.

What is the best way to mix these two displacements together, with the whirlpool jpeg displacement added onto the existing vector displacement?
Thanks in advance!

Try this setup with a Vector Math set to Add.  It should work for you.


how do i navigate blender on a vaio z canvas I recently acquired a Vaio Z Canvas which has a very useful shortcut key menu that I can display on the left of my screen as can be seen in the image. Up to this point I've been using these shortcuts to help navigate with the use of "emulate 3 button mouse" setting with alt allowing me to orbit, ctlr+alt to zoom and shift+alt to pan. The problem I'e experienced is that these navigation functions have just stopped working...All the other shortcuts I on the panel still work and the navigation is still possible when i use an actual keyboard. if anyone knows how i can fix this problem or even better, show me a way to navigate with the use of like non-pen touches i will be eternally grateful

I'm not familiar with the Vaio Z, but if it supports multi-touch, try dragging/pinching with two fingers. (This is how it works on a Mac OS X trackpad.)


What does the geometry node mean with the point the shading point is being viewed from I am trying to implement a laser line that I can move freely along an object to simulate a prototype we are developing. I am following the answer provided at Using Nodes for Laser Line and I have some doubts regarding how it works.

I am familiar with algebra and dot product, but still don't understand how this works. What is the Geometry node output? Is it the vector from every point lighted to the lamp? What is this point it talks about in the documentation: https://docs.blender.org/manual/en/dev/render/cycles/nodes/types/input/geometry.html

I'm assuming it lights a point only if the dot product of the declared vector and the vector from point to lamp are in a 90º angle (hence the "less than") but I intend to do a clipped laser line and I would need confirmation and the documentation is not clear.

I find it helpful to think about this as naive, simplified reverse ray-tracing.

So a ray is fired from the camera through a pixel in the screen, and hits a shading point on a visible surface. That ray is then split, and bounced off the surface towards all the lamps it can 'see', asking of each lamp: "what light contribution are you making to my color calculation?" The 'incoming' output of the lamp shader's Geometry node  is the vector representing the direction of that last segment of the ray, which hits the lamp. (To or from doesn't matter in this case).

The CombineXYZ, Mapping, and Normalize nodes establish an easily rotated unit vector P, whose origin we can think of as being at the lamp.

The DotProduct and Absolute nodes return the positive dot product of the incoming ray and P. The closer this is to 0, the smaller the angle between the incoming ray and the plane whose normal is P, passing through the lamp. We want the light to emit only if the incoming ray's origin is close to that plane.

The angle won't do. We want a measure of the distance between the origin of the ray and the plane. We don't want our beam to spread as it gets further from the lamp. The Light Path>Ray Length and Multiply nodes multiply the our dot product by the length of the incoming ray, giving  us a number which varies linearly with the distance of the ray origin from the plane. (Think similar triangles.)

The Less Than node returns 1 if that distance falls within a threshold, 0 if not.

The Light Falloff>Constant>Strength and Multiply nodes give us a light whose intensity is a constant Strength value, irrespective of the length of the incoming ray, if the threshold requirements are met.

The result: a planar sheet of light, which doesn't decay with distance, with an adjustable rotation, strength, and thickness.


How do I bake animation for exporting animation created by Wave modifier I've first created animation using armature for each and single leaf on my plant 3D model. But the wave modifier gives the same effect.

The thing is that once I export to .fbx, the animation is gone.

I've read several threads about this subject and none is giving a clear answer.

Is it possible to export the animation created by the modifier? I need to export for Unity3D.

How to apply the ocean modifier to get an animated object? - This one seems to give a clear answer except for stage 4: HOW DO I DO THAT?

You could try exporting alembic.. that would export the deforming geometry into an .abc file that can be ready by unity and other animation packages.


Problem baking normal map hi ive just recently installed version 2.73a and i am trying to bake my normal maps. I am doing it the same as i have in previous versions but now i keep getting the same error, as circle on attached picture. Can anyone help me with this or direct me to a current tutorial on baking normals?

According to your screenshot you're using cycles, the workflow is different.

In Object Mode

Select your object RMB
Add an image texture node with the image selected.
Press Bake

To bake from one object to another select two objects and tick the Select to Active option.


How to bake a generated texture from displace modifier to UVs Is there any way to bake a texture that I generated for Displace modifier? Or any way to recreate it one to one in the shader editor? I need to make a few fixes (to redraw it a bit) and also use it for generating my color map. Thanks T_T

I may be wrong but it looks like there's no automatic way to bake the height map of a Displace modifier.
If your object is flat with 3D relief, you can apply the Displace, give it a black and white gradient texture on the Z axis, plug it into an Emission, create a plane above and bake the Emit.
If it's a more complicated object, Ilakya gives here a method to do it, with the Multires and Shrinkwrap modifiers:

Create your model with its Displace modifier.
Create a second object that will contain the model as a sort of cage.
Give this second object a Multires modifier. Give it also a Shrinkwrap modifier, Wrap Method > Project, with the model as Target. Hide the model.
Subdivide the Multires of the second object until it looks like the model. Lower down the Level Viewport down to 0.
Apply the Shrinkwrap modifier.
Give your object a material, create an Image Texture, keep it selected but don't plug it for the moment, create a new image for this Image Texture.
Go into the Render panel, choose Cycles. In the Bake panel enable Bake from Multires and Bake Type > Displacement, click on Bake, it should work.


Resolving a Dependency Cycle I've been having a lot of fun rigging, but I've run into a problem. I have knowingly created a Dependency cycle, thinking it wouldn't be problem. It kinda works, but weird bugs appear sometimes, and my system console gets spammed with Dependency cycle detections :/
In this excample I have two bones. One the parent of another. (The parent is on the right)

now, using a transformation constraint, the parent bone is supposed to rotate and move upwards when the child bone gets rotated to the left:

This is obviously the cause of the dependancy loop, but I don't see any way to resolve it.
The child bone has to follow the rotation of the parent, even if that rotation is indirectly caused by the child itself.
edit:
let's say I'm making a mailbox. The child is the door, and the parent is the rest.

When the door opens, the entire mailbox should rise up slightly:

So, the child bone is what I use to control the door, and I can't simply use the paerent bone :(. Hope that makes it more clear.. thanks :)

So what about the other way around, parenting the door bone to the box bone, and give a Transformation constraint to the door bone so that when you rotate the box bone it makes the door follow (as it is parented) and rotate (with the constraint)? You can also limit the rotation of the box for more comfort.
Unless you have a good reason to manipulate the door bone only?


Render pixel color information in the Image Editor I'm fairly new to Blender and really like it's capabilities.
However, coming from Maya there's one thing i really miss, I can't seem to find a eyedropper tool that shows me the color values of my rendering in a stats bar for example.

In Maya, we had something like this.

It gives the information from the cursor location in the renderview for all the passes you need while shading ( RGB values, Z-depth values, object values, etc.).

Does anyone know if Blender got something like this or maybe a addon that gives such information?

I found the Historgram in the rendering tab but it's not that useful since you need to render the image first before you can use it.

In the image editor, hold down right-click on the image. Pixel stats will appear on the bottom of the window. This tool also works while the image is still being rendered.

Here is a demo (Notice the bottom):


PyNodes API: transferring data between nodes with sockets I'm developing a custom NodeTree using the PyNodes API (on Blender 2.70) for scientific analysis and am having trouble choosing the best way to transfer data between nodes via sockets.

Right now I can think of two options, neither of which seem satisfactory:

Accessing input socket links from the node itself on each update, for which purpose I'd have to create a dummy "input socket" with no associated properties which seems a little hacky (although I've seen similar dummy input sockets used in blendgraph)
Traversing the NodeTree links list, copying input socket data to their respective output sockets and updating nodes sequentially

Is there a specific method for transferring data between sockets that the API is intended for? I haven't managed to find any definitive examples so far.

The way I have found to get input values is

if self.inputs['inY'].is_linked and self.inputs['inY'].links[0].is_valid:
    iny = self.inputs['inY'].links[0].from_socket.default_value
else:
    iny = self.inputs['inY'].default_value

Add calculations in the middle here then pass on output values -

self.outputs['result'].default_value = res

The key point being read inputs from a connecting node socket default value and write to our output default value for other nodes to read.

You don't need dummy sockets to store values, sockets are for connecting other nodes to pass on values. You can use property definitions to add properties to your nodes. These can be shown on your node in it's draw() without having input connections available.

If your concern is that updates don't just happen, then you've found that pynodes don't just automatically update yet. The solution is manual updates, sverchok adds a panel with update buttons and has a 'Bake' button on some nodes to do the updating, it also implements a caching system. Another consideration is to register a function as a handler for frame changes so that animations aren't an issue.

def handler_node_update(scene):
    for n in node_tree.nodes:
        n.update()

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

There is also a nodes internal_links property to consider, it's for "Internal input-to-output connections for muting". It is a collection of NodeLinks and I guess we use something like -

self.internal_links[0].from_node = self
self.internal_links[0].from_socket = self.input['inY']
self.internal_links[0].to_node = self
self.internal_links[0].to_socket = self.outputs['result']

I have got this far from this pynodes tutorial and looking through some of the sverchok source (luxblend is another project using pynodes) with this blender wiki page about the only other helpful source of info so far.


Are there such things as "root objects"? For some reason, Shywu's model has what I can only assume is a "root object". After I exported her model as an FBX and imported her into Blender, the last object I placed/edited (an eye) was thought to be the main thing that moves everything.

If you want to make an object the parent of several objects, select the objects, then, at last, the parent, and press ctrlP (Set Parent To) > Object. You can also create an empty, shiftA (Add) > Empty > Plain Axes, and make it the parent of your object with the same Set Parent To operation. To deparent, select the object and altP > Clear Parent. You can know what's the parent of an object if you select it, go in the Properties panel > Object > Relations > Parent.

Does it answer?