Create an array of a rendered image with each pixels xyz position Lets say I have a 3d scene with some objects in it
When I render the scene to an image, I would like to have an array of each pixels position of the image, each position or pixel filled with the x,y,z value of the objects surface that appears in that specific pixel in the 2d rendered image.
What would be the best way to do it ?

You can use the "Position" output from the "Geometry" node to get the pixel world position, but the color will only contain values between 0 and 1 (units).
My solution would be to scale the values. For instance if you know for sure your objects will be constrained in a cube going from -20 to +20 in each axis, you could use this setup to "remap" the values between 0 and 1.
Each channel of the RGB value of each pixel will then represent their X, Y and Z real position. You would just have to remap like this : XYZ(real) = (RGB -0.5) * 20

Result with a double array of cubes

You can CTRL + Right Click to get the RGB values once rendered. Notice how only 2 values change when scrubbing along a face of a cube.


Flat shaded mesh - missing separate colours/normals for connected vertices? I recently got started with python scripting, so I am still very new to this!

I am trying to set the vertex color of vertices looking'up' to white, otherwise set it to black.

I use a dot product to determine whether a vertex is pointing upwards or not (vertex.normal.dot(Vector((0,0,1))) > 0.9)

I run my script on the default cube, and it doesn't work correctly. I noticed that even though I have flat shading enabled, the vertices are all connected and 'share' a normal and color. For this reason, I can't make the 4 vertices that define the top of the cube white and the vertices that are a part of the sides of the cube black. They share the information. Here is what I get when I run my script:

If I separate the top faces and run the script again, the colouring is correct as expected. But whats strange is that if I remove duplicates to reattach the vertices back together again, the colour information is retained! This is what I expected it to do in the first place. Here is a screenshot. In the left image, the faces are still separated - you can see that the upwards facing faces have their own normals pointing straight up, as they are not attached to the rest of the mesh. In the right image, I have run the 'remove duplicates' command to merge everything back together. The normals on the corners now look like they are merged again, but the colour information is retained.

I was wondering how I can define this extra colour information via script, without having to detach the faces first (which defeats the purpose of the script)

You’ll want to use “split normals”.

Set your faces to 'smooth' shading, and enable use_auto_smooth mesh option).
Compute the normals (mesh.calc_normals_split()).
Access them from loops (mesh.loops[0].normal).
Don’t forget to free them once you do not need them anymore (mesh.free_normals_split()).


Let object follow joined path Suppose I create two paths A and B, then select both paths and join them using Ctrl+J creating AB. I then want a cube to follow the joined path AB, that is first along A, then jump to and follow B.

I add a "Follow Path" constraint to the cube and set keyframes for the Evaluation Time of the path. If I then animate however, the cube only follows A, as if A and B would not have been joined.

How to fix this? Obviously I could animate A and B separately but it would require more work and might get tedious if I had more paths than two and need to figure out how long each individual path is to let the cube traverse each path with the same speed.

Edit

Another path could look more complex like this:

Currently I model this to be four paths (one outer rectangle and three traversing straight paths) and control the cube with Keyframing the Evaluation Time and Influence properties. If I want the cube to follow the complete path (that is, all four paths) with the same speed however, I need to calculate how long each path is and model the evaluation time correctly. This is tedious...

You can use these 2 ways to make the mesh follow path which isn't contiguous.

Making the path contiguous

This way assumes keyframing either the Evaluation time property of the curve:

or the Fixed Position option of the Follow Path constraint.

You set the keyframes so the animated mesh jumps from one curve part to another.

The mesh will now jump over the connection of the curves.

Adding several Follow Path Constraints

You can leave curves as they are, and add adjacent quantity of the Follow Path constraints, animating both Fixed Position and Influence options.
For more details see How to make an object follow a complex curve


Is there a way to convert procedural textures to UV maps without rendering a final image first? I've often wanted to use procedural textures for UVs, but it seems that there is no simple way to do this from within the application. Is there some standard way to achieve this without first rendering a bunch of images and then stitching?

The only way to do this is to bake the render into an image.

Of course this requires you to first unwrap the mesh with non-overlapping coordinates ('Smart project' or 'Lightmap Pack' can help here to save doing it manually).

Note, this process could be automated through a script (probably someone has done this before, its not so hard to do for someone already familiar with our API).

For all selected objects:

Add UV layer
Unwrap.
Bake textures into the image.
Save each image to a name based on the object.


What are the most common beginner mistakes when learning Blender? I haven't found a question like this after a few searches. A lot of questions that come in are from beginners who are learning on their own. I know from experience what that is like, and how long it is before the sheer complexity and scope of Blender stop being very confusing. I don't know how many times I searched arduously to figure out how to undo something that was the result of one mistaken keystroke or click, or how often things have had to be rebuilt after an unnoticed mistake caused bad geometry.

I believe the most common mistakes are quantifiable and not a matter of opinion. I think it would be a real service to have the most common ones explained to beginners so they can be aware of them from the outset. I don't know of anywhere with such a guide. Maybe there is something like this here already and I didn't find it, if not, I hope this is considered not too broad or opinion-based.

Double Vertices - Most often caused by extruding something, cancelling the move afterwards, and then extruding again. Can be fixed by selecting all by pressing A, then pressing Ctrl + V, and choosing 'Remove Doubles'.
Flipped Normals - This can have many causes. It's visible as odd shading on a model, but is often a bit hard to pick out. Can be fixed by selecting all, then pressing Ctrl + N.
Unapplied Rotation and Scale - If the scale of an object is not 1 or its rotation is not 0 degrees on all axes, a lot of actions can have strange results. Unless there is a specific reason not to apply rotation or scale, can be fixed by pressing Ctrl + A and selecting the appropriate option.
Hidden things - Pressing H makes whatever is selected invisible. Pressing Alt + H unhides things.
Unnessesary Ngons - Faces with more than 4 connected vertices (Ngons) may cause shading issues, and should be minimized. Ctrl + T triangulates the mesh, and can help avoid these problems.


Axis scales in the f-curve editor Is is possible to decouple x and y zoom factors in the fcurve editor? I'd like to grow to y-scale without affecting how many frames are visible.

In the curve editor grab and slide the end points of the Y scale to zoom in and out :


Textures appears in Blender Render but missing in Cycles Render I have the following object loaded in Blender Render Mode

However, in Cycles Render my UV map disappears

Is there a way to get around this problem?

Thanks

Blender Cycles and Blender Internal are two completely independent rendering systems with different settings and material definitions.

Your UV Maps did not disappear, you just have to recreate your materials using the Cycles material nodes system.

Have in mind that even after recreating them, the Blender viewport does not support displaying material previews for cycles, only basic preview of image based textures, so you will only get to see them upon rendering or on interactive viewport render.


Why are node groups not being saved in my startup file? I made four node groups in blender and saved the blender file to my hard drive. I want these node groups to appear every time I start Blender, so I do have not append them every time I need them. So I opened up a new blender file, clicked on "append" and appended all of the node groups from other blender file. I click on save start-up file and exit. When I open blender again, the node groups appear but not all of them. Only one or two. if I append the missing node group again, and save it again, the next time I open up blender all node groups are gone. It is like random.

Am I doing something wrong or something is broken with blender?

Node groups have users linked to them, like materials or textures. If a node group has no user, it will not be saved to the blend file. After startup they will be gone. In some cases it takes more than one restart and save before all unused instances are gone due to internal dependancies.

You could, as aliasguru suggested, set fake users. This could be done by executing this line in the python console:

for node_group in bpy.data.node_groups: node_group.use_fake_user=True

Afterwards they should not disappear anymore. Note that you have to repeat it for every file and when you create new node groups.


Installation directory blender on a MAC I want to run an application that needs to know the blender installation directory on a mac. I have tried a lot but somehow I have not the very specific directory name. Who can give me this ?

Usually, you download a compressed folder, extract it and put it into the Applications folder. There's no real installation involved since all data is stored inside this folder which can be stored anywhere. So on mac the directory of Blender is individual on each system.

The actual executable can be found within the Blender.app application bundle. Right click, select Show Package Contents and navigate to Contents/MacOS/ where the unix executable can be found (if the executable is what you're looking for). You can now drag&drop this file into the terminal to get the full path.

If the only purpose is to access blender from a program locally, this may suffice. If you plan to make your program available for others, some more steps would be involved like prompting the user to specify a path to blender.


Uniform wall thickness for a 3D print I have high quality scans of my leg, I am trying to print a 1/4" thick shell for it.  I assumed it would be something with the extrude function, but I cannot figure it out.  Anyone have a little walk through or willing to explain the steps to a complete newb?

Basically, I want the outside of my scan mesh to become the inside of my print model, with uniform thickness all around my calf and under my foot.

Many thanks for any help you can offer.

Instead of using the extrude function, try using the Solidify modifier on the object and play with the settings.


How to reset pivot point? I have multiple objects in my blender project, but the origin is faulty for all of them.

I would like the origin for each object to be at the center (geometry, or mass), but even if I select that for each of them, one by one, it does not appear to work.

It appears that my XYZ axis are at the cursor, rather than at the origin of the object. How do I change that?

(Feel free to edit question if unclear, incorrectly worded, or addressing something other than the origin point. I'd like my XYZ axis to be at the center of mess/geometry for each object automatically. This was originally so, but I did something to mess it up.)

Blend file: http://pasteall.org/blend/index.php?id=47595

UPDATE: It appears that, in addition to the "origin point" issue, my 3D cursor was set to "Bounding Box" rather than "Median Point". Thank you all!

First of all you need to change Pivot Center to Median Point from 3D cursor, and secondly you still have some parts that needs Ctrl+Alt+Shift+C > Origin to Center of Mass. Mostly on handle.


The OS shows rendered files as TextEdit Documents instead of PNGs Using the new 2.90 version, I made a simple animation using some cloths sims and rendered it out in PNG images. When I check the images inside my file browser (Both the Blender file browser and the native MacOS file browser) I see that they are not PNG images. My mac instead says that they are TextEdit Documents.
When I open the image, it opens normally inside the "Preview" app (the default mac app for opening images). Sometimes it opens inside the TextEdit app and it shows me a bunch of garbled text.

Most likely the files have no extension. The OS doesn't know what kind of files they are, or what program to open them with, so it shows the files as text files (the default icon for unknown file formats).
Rename the files to be *.png
In blender enable File extensions.


Boolean on Objects with smooth surfaces? Everytime I try to subdivide or use a boolean on an object with a smooth surface I get ugly artifacts as seen here. Is there a way to punch a hole through a smooth object while keeping sharp edges?

Without Edge Split modifier (left) and after applying Edge Split modifier (right).

Select the model Go to edit mode and press w and Remove doubles

Select the cylinder and add one subdivide

Now with the boolean modifier selecting the difference select the object.


Increasing faces using brush Watching a tutorial, the artist used a brush to increase the geometry (faces/polygons) by turning the brush strength to zero and moving it over the mesh.
I can not locate this part. Help would be appreciated.

To do this, enable dynamic topology in sculpting mode, which will increase the subdivison level based on the dyntopo settings on whatever section you are sculpting on. Then, if you set the brush strength to zero, it will increase the topology while having no additional effect.


Where is the transform tool? I just installed Blender v2.8 but I can't seem to find any Transform tool.
Has it been removed or do I have to show it?

Yes it has. As explained in April 15th's developer meeting notes:

  Transform gizmos can now be enabled in the 3D viewport independent of
  active tools, from a popover menu in the header. The same popover also
  has controls for display of other gizmos. The Transform tool was
  removed as it is now redundant. (Campbell Barton)


link nodes in compositor blender 2.8 While trying to link two nodes via python I get this error:

AttributeError: 'set' object has no attribute 'output'

I can't understand why, following the docs seems to be correct the code, which is:

def compile_met(image_selected):

        # switch on nodes and get reference
        bpy.context.scene.use_nodes = True
        tree = bpy.context.scene.node_tree

        prev = bpy.context.area.type
        bpy.context.area.type = 'NODE_EDITOR'

        area = bpy.context.area

        # clear default nodes
        for node in tree.nodes:
                tree.nodes.remove(node)

        # create input image node
        image_node = bpy.ops.node.add_file( filepath=image_selected)
        comp_node = bpy.ops.node.add_and_link_node(type="CompositorNodeComposite")

        # link nodes
        links = tree.links
        link = links.new(image_node.output['Image'], comp_node.input[1])

        bpy.context.area.type = prev

Any ideas?

There are two issues here.

The first is that bpy.ops.node.add_file does not return the new node, it simply returns a set containing a message of the status of the current operator. E.g. it will return {'FINISHED'} if it is successful.

bpy.ops functions are operators, which expect to be run from particular parts of the interface, not from code, hence why you are currently having to change the area.type to NODE_EDITOR before the code will work and why they're not returning the data they create. (You can read more here why bpy.ops should be avoided when possible.)

Instead, you can access the node data more directly (if a little more manually):

image = bpy.data.images.load(filepath="Your filepath")
image_node = bpy.context.scene.node_tree.nodes.new('CompositorNodeImage')
image_node.image = image

And then the same for comp_node:

comp_node = bpy.context.scene.node_tree.nodes.new('CompositorNodeComposite')

These functions do return the new nodes and by manually loading the image, instead of relying on an operator, and manually adding the image node and composite node you can a) return the new image and nodes to variables, b) use the returned data to link the image to the node and c) not have to set area.type any more because you're not using bpy.ops.

This will fix the first problem, but not the second. The second is that the nodes do not have an output or input property, they're plurals so they're called outputs and inputs, e.g.:

links.new(image_node.outputs['Image'], comp_node.inputs[1])


Checked everything, object won't show up in render I've been modelling a donut with the bells and whistles and run into an issue where the icing of the donut is invisible both in the render and in the rendered viewport. I have a situation of having the base donut with these random floating sprinkles (as the icing is not there).

Here's my file on blend exchange:

I checked that the camera icon was showing like the rest of the objects, checked the layers, the passes etc.

At one point I found an AttributeError in the console talking about "SpaceInfo" and "tree_type" but sadly I could not reproduce the issue to get it to trigger again. I scoured the web to find a similar issue but no one seemed to have what I do, i checked my modifiers on that object to see whether the subsurf was doing something weird but it wasn't, so I leave this up to you. Thanks in advance.

You must check the "Emitter" box in the Render panel of your Particle System settings, otherwise the mesh won't show up, only the particles.


how can I extrude curve shapes onto curve without tapering I'm stuck. Can't figure out how I can extrude a closed curve onto a NURBS curve without it looking tapered.

I notice that when it's set to "2D" there is no tapering, but I want to do it on 3d.

Thanks for help.

It's a known limitation of the current system, there is currently no elegant workaround for this as far as I know.

Either use only separate 2D curves for each segment (rotate them in object mode to their correct positions)
Add extra control vertex close to corners to minimize the tapering distance (clumsy and may not look good)

Or use independent splines inside the same bezier curve for each segments (may cause intersection artifacts under certain circumstances)

Choose the lesser evil for your particular use case.


Principled python script for selected object I want to ask a solution for blender scipt for principled. I have imported about 50 characters in FBX format, problem is that every one of them have about 10-15 materials with principled but they are wrong. I never scripted in python so Im in the dark right now. What I want to do I want create script for selected material that use Principled to set:

Specular and
Metallic

to 0.0

and disconnect(clear)

Alpha and
Normal

I found here this script and I try to recreate that but I'm afraid im too green to do that right. If anyone will be able to help it would be great!

import bpy

# I separated the creation of nodes to a function so it's easier
# to edit later if needed
def create_nodes(mat):
    mat.use_nodes = True
    nodes = mat.node_tree.nodes
    for every_node in nodes: # this removes all existing nodes
        nodes.remove(every_node)

    # creating Principled node and moving it:
    node = nodes.new('ShaderNodeBsdfPrincipled')
    node.location = (-190,100)

    # creating Output node and moving it:
    output_node = nodes.new('ShaderNodeOutputMaterial')
    output_node.location = (40,100)

    # creating the link between the two nodes:
    links = mat.node_tree.links
    link = links.new(node.outputs[0], output_node.inputs[0])

# this saves the currently active object so it can be restored later
active = bpy.context.object

# let's loop through all selected objects
for every_object in bpy.context.selected_objects:
    # I only want to work with objects capable of having a material
    if every_object.type in {'MESH','CURVE', 'SURFACE','META', 'FONT'}:
        if every_object.name not in bpy.data.materials:
        # if there is no material named after the object yet let's make one
            mat = bpy.data.materials.new(every_object.name)
            # and let's create the nodes for it
            create_nodes(mat)
        else:
            # if the material already exists let's just use it
            mat = bpy.data.materials.get(every_object.name)
        if len(every_object.material_slots) == 0: # if there are no material slots
            # let's make the current object active and create a material slot
            bpy.context.scene.objects.active = every_object
            bpy.ops.object.material_slot_add()
            # let's leave the active object as it was
            bpy.context.scene.objects.active = active

        # The only thing left now is to assign the material to
        # all material slots. We probably do not want to loose the info
        # about how the object is divided into separate materials
        for every_slot in every_object.material_slots:
            every_slot.material = mat

The following code iterates through all selected objects and their respective materials found in the material slots. If a Principled BSDF node is found in the material, the Specular and Metallic properties are set to zero and links to Alpha and Normal are removed.

Be aware that every material will be fixed that is present in the selected objects' material slots. If that includes a material that is also assigned to an unselected object, that change will affect the unselected object as well.

import bpy

def remove_links(socket: bpy.types.NodeSocket, node_tree: bpy.types.NodeTree):
    """Remove all links from or to the given socket"""
    for link in socket.links:
        node_tree.links.remove(link)

def fix_node(node: bpy.types.Node, node_tree: bpy.types.NodeTree):
    """Adjust the properties if the node is a Principled BSDF"""
    if node.type == 'BSDF_PRINCIPLED':
        node.inputs['Specular'].default_value = 0.0
        node.inputs['Metallic'].default_value = 0.0
        remove_links(node.inputs['Alpha'], node_tree)
        remove_links(node.inputs['Normal'], node_tree)

def fix_material(material: bpy.types.Material):
    """Fix the nodes of the given material"""
    for node in material.node_tree.nodes:
        fix_node(node, material.node_tree)

def fix_selected():
    """Fix the materials of the selected objects"""
    for object in bpy.context.selected_objects:
        for material_slot in object.material_slots:
            fix_material(material_slot.material)

if __name__ == "__main__":
    fix_selected()


How do you add a thin outline? I am new at this. I am extracting files a game. In the game they have thin black outlines, but they aren't part of a model. I am having trouble finding anything about this. What is the simplest way to do this?

Update: I think I am looking for something like freestyle. What is the simplest way to use this to create a thin black outline around a model?

In your render settings enable freestyle.

Under render layers add a freestyle line set.

The line thickness is a quick way to adjust the size of the line drawn. For more control over what edges are used to draw lines and how the lines are drawn, you will need to look through the freestyle documentaion.


Fading on additional materials to a section of an object I have a texture mapped material with additional bump maps, etc.  It looks fine.  I have created a shape animation where one end of the object becomes cratered (concave).  Inside the crater the material needs to gradually change to another color.  I have assigned the vertex group (inside of crater) the new material, but I can't figure out how to 'fade' it in while the object changes shape.  This is using cycles.

I'd upload the file but the client is sensitive about his IP.

Thanks for anyone's time

To fade from one colour to another you add keyframes to the factor of a mix node.

You can also get more control by using an animation to control which colour is used. Dynamic paint could be used to create the image sequence.


Access active spline from Bezier Curve I'm just starting to get familiar with bpy.types and application modules, but I didn't find an answer to this:

Concerning A Bezier Curve with multiple splines, is there a python way in EDIT mode to know on which spline I am working on (activated in the viewport) except iterating every single bezier_point inside ?

Thanks in advance,
jimflim

You can access this from the spline collections.

obj = bpy.context.object
curve = obj.data
spline = curve.splines.active

http://www.blender.org/documentation/blender_python_api_2_73a_release/bpy.types.CurveSplines.html#bpy.types.CurveSplines.active


Unable to Edit New Keyframes I'm using version 2.79 of Blender and I can't edit my mesh to create an animation.

The Problem:  I cannot edit my mesh when I create a new shape key (Key1). I can edit fine when I switch to the Basis key. When I try to scale the image in Key 1 a red line appears showing the axis I'm trying to scale but the vertices don't move.

The steps I took: Object mode > select object > create Basis shape key > create Key 1 > Edit mode > begin editing the object

I previously created an animation that worked so I'm pissed, extremely frustrated, and ready to jump off a bridge (smh, j/k of course). I've done too much work to start over. Please help.

Change the weight of Key 1 to be
 - Full 1.0

The weight must be set to 1.0 to see the full effect.

The value is under the word Relative. It is in  the blender screen capture above.

Temporarily changing the eye icon next to a shape key name may help you to isolate the effects of a shape key and its weight.


Stars background in cycles I'm trying to make a short animation in space and I need stars as my background. I found this nice tutorial, unfortunately it was made in blender render and doesn't work in cycles.

https://www.youtube.com/watch?v=sb4ryQMvRi4

Can someone tell me how to recreate this in cycles?

First you need to jump over the the Node Editor view, then select Shader Nodes and World.  Also make sure Use Nodes is checked.

Then add a Noise Texture node and a Color Ramp node.  Plug the Fac of the noise texture into the Color Ramp, and the Color of the Color Ramp into the Color of the default Background shader.

You can then adjust the Color Ramp and Noise Texture how you would like to create the desired starry effect.

Noise Texture Scale.  This controls the size and amount of stars.  Higher scale means more, smaller stars; smaller scale means less, larger stars.
Noise Texture Detail.  This will adjust the shape and variation in brightness in the stars.  Higher value will mean more irregularly shaped stars, but there will be a greater variation in the brightness of the stars.
Color Ramp Swatches.  Adjusting the color swatches on the Color Ramp will change the size and shape of the stars.  The farther apart the swatches are the bigger and more irregularly shaped the stars will be.

Shown above are the settings I used to create the below render.


How to connect end and beginning of a "ring" with a cutout? I am an absolute beginner in blender and failing at a very simple thing. I have a line lying in a plane. I want this line to have an extension in that plane, i.e. I want to make it a two-dimensional object. I do so by increasing the extrude parameter in the section geometry of the menu to 0.1. What I then get is the following:

I now want to connect the end and the beginning of that object, i.e. to close the cutout of it. From other questions I know that I can achieve this by marking the field U in the section Active spline of the menu. The problem is that the shape of the whole object changes in a very undesired way...

How can I perform the aformentioned connection in a way that preserves the shape shown in the first picture, i.e. in a way in which the extension of the the object stays in the plane defined by the original line etc.?

I attached a blend-file of this minimal-example:

Toggling Cyclic on your curve should not (and does not) affect the shape of existing curve, especially since it is poly type. That could only happen if there were any Automatic control points in it.

If it truly is a 2D curve then press the 2D button to ensure it actually is bidimensional.

In your case you will notice it will ruin your geometry because it is not correctly oriented in local space. Enter edit mode, rotate it 90 degrees in the X axis before making it 2D.

You can finally press Alt+C in edit mode to make it Cyclic.


How to disable different undo history for Edit Mode and Object Mode? I understand the thought process behind having a different undo history for different modes, but to me it seems like an idea that should have been scrapped once it left the idea stage.

I don't know how many times I've destroyed my entire history just because I was in the wrong mode when I hit Ctrl-Z and thus had to redo the part I was working on from scratch. If I need to go back far, it's like navigating a mine field. One wrong undo in the wrong mode and wham! History destroyed!

So... how can I disable this dangerous mechanic?

Yes, you can change the Undo behavior, but it has some implications.
From the Manual:

Global Undo
This enables Blender to save actions done when you are not in Edit Mode. For example, duplicating Objects, changing panel settings or switching between modes.
Warning
While disabling this option does save memory, it stops the redo panel from functioning, also preventing tool options from being changed in some cases.
For typical usage, its best to keep this enabled.

To ease the pain of the normal mode, there is an Undo/Redo history which may allow you to recover accidentally undone actions.
Again, from the Manual:

Undo History
There is also a Undo History of your actions, recorded by Blender. You can access the history with Ctrl-Alt-Z.
Rolling back actions using the Undo History feature will take you back to the action you choose. Much like how you can alternate between going backward in time with Ctrl-Z and then forward with Ctrl-Shift-Z, you can hop around on the Undo timeline as much as you want as long as you do not make a new change. Once you do make a new change, the Undo History is truncated at that point.
Repeat Last
The Repeat Last feature will Repeat your last action when you press Shift-R.
In the example Images below, we duplicated a Monkey Mesh, and then we moved the Object a bit. Using repeat Shift-R, the Monkey was also duplicated and moved.
The Repeat History feature will present you a list of the last repeated actions, and you can choose the actions you want to repeat. It works in the same way as the Undo History, explained above, but the list contains only repeated actions. To access Repeat History, use F3.


Render a wireframe animation where only half of the mesh has wireframe How can i render a wireframe on an animated rotating mesh, where only
the right side of the camera view is shown in wireframe, but the other half shows the mesh withouth it.

Only the parts of the mesh that are on the right half of the screen should be in wireframe, but when the animation rotates the mesh, the faces that where rendered in wireframe should become normal again (when they leave the "wireframe" area.).

Edit: When the mesh is not rotating, i could create a vertex group and apply the wireframe modifier to the parts i want to be wireframe, but i don't know how to do this when the mesh rotates.

I think that the only easy way to achieve the result is to render the animation two times: one showing wireframe and one normal; then use a video editing tool (even Blender itself) to show on the left part of the screen the normal render and on the right the wireframe one.


Difficulty with multiple overlaying textures on one material I feel like this is quite a long winded and complicated issue but I really appreciate any help I can get!

(I have included the blender file at the bottom for reference.)

I am making a cloth object which has lots of different sections and textures. To keep the geometry as simple as possible I am attempting to paint on the textures using multiple image masks on the same material and UV mask in order to keep the geometry intact. Here's where I am at so far to give you an idea of what I am going for, I have made decent progress but it's getting quite complex:

I'm fairly new to the node editor and blender in general so this is already getting over my head. The main difficulty I am having at the moment however is firstly where to connect my displacement outputs in my bump maps. I connected the first one to the displacement input on the material output node which had an effect (although I feel it might have had an effect over the whole object instead of just the painted map)

but now that slot is occupied I don't know where to connect my other ones:

The second problem is fairly related. I want to have some of the patterns that are "printed" on top of my cloth to be slightly raised. I am guessing this is probably done by applying a bump node to the mask but I'm not really sure how to achieve it. Here for example is the image texture node containing the black and white mask I used for one of the yellow patterned sections at the top of the cloth:

I would like to have this raised very slightly to make it a bit more dynamic but can't figure it out.

Thanks for bearing through that explanation, I hope I have explained it with enough clarity and again I appreciate any help that can be offered!

Here is the blender file:

There are several choices to make multiples bumps on one object.

Make it via the different shaders.
Not relevant in your case because Chocofur fabric shaders don't have input for normals/bumps, so you would need to modify all shaders.
Make it via different materials.
Would need more work at this step.
Make it in the material by combining several bumps maps.
The picture explain it well I think:


How do I achieve this sort of graph wireframe effect in my 3D objects? Blender 2.8 I want to achieve this cool translucent see-through effect with a graph wireframe background in my 3D objects as shown in the images below. How do I do this?

I have regular low poly objects with materials. This effect comes in really handy when you want to explain the architecture of an opaque object.

So, for an object I need to have both the effects. The regular opaque material design look & the translucent see through look;

I am using Blender 2.8

The screenshots are from a youtube channel called the Real Engineering

Try a Translucent Shader any shader, lol, with the blend mode (if you're using Eevee) set to additive.  The Principled shader works well : )  GL OP


why is light propagated wrongly? I am a new in Blender. I am creating a house and collided with problem. I created 2 windows. The first window is ok but the stranger things are happenning with the light of the second window.

I helped to add a thickness to my window since I made a window from plane. Also i helped to change paramert IOR to 1.000. Maybe normals were flipped too.


Boolean modifiers do not work, when boolean objects are in certain positions I have 3 simple objects: one cube and two cylinders. For some reason, I cannot get simple boolean operations to work.

Example:

One issue seems to be the fact that the union object has the same width as the target object. If I decrease the width of the union object slightly or move the cylinders a little bit out of their perfect position it works. Unfortunately, this is not what I want.

Finally, there is another issue. I cannot bevel the combined object, even if I apply the boolean modifiers first.

This is a link to the test file: https://www.dropbox.com/t/0YCbtRBy4TgEtHA4

or here:

Boolean doesn't work when faces are overlapping, at least until the recent versions, maybe they will fix that, so you need to find another method for the union one, maybe simply do it manually.

About the Bevel modifier, you've choosen None mode, so it will bevel every edge, and you've enabled Clamp Overlap option, that won't allow you to do any overlapping. With the given topology you won't be able to bevel anything without overlapping. So what you should choose is the Angle mode, or perhaps Weight if you want various bevel strengths depending on the edges, and disable Clamp Overlap. But even with those options I'm not sure it will be easy to manage your topology.


Intersection of more than 2 mesh objects I've managed to select the intersection edges of 2 given mesh objects, using Wiltor Jaworski's plugin (http://airplanes3d.net/scripts-253_e.xml).

However, I couldn't find any reference as to how to get the (possible) intersection of more than 2 objects.

For example, if I have 3 planes A, B and C that intersect in a given point, how can I select this point?

There is a way to do this. It is not ideal, but it works and is also non-destructive. Select one of the meshes that is part of the intersection. Add a Boolean modifier to it, choose one of the other objects as the Object in the Boolean modifier. Copy that modifier and chose the other mesh as the Union Object this time. After yo do this there will be a vertex at the intersection

Select one of the meshes, any will do (A)
Add a Boolean modifier to it:

Operation: Union
Object: one of the other ones (B)

Copy the Boolean modifier

Object: the other one (C)

Optional: If you would like to use the intersection in edit mode to move around mesh components. If all you want to do is to get the intersection just add the empty

add an empty, plain axis will do fine
snap the empty to the intersection: Set the snapping type to vertex. The empty acts as a vertex in this case
in edit mode snap the geometry to the empty if you want to.

Note: You can delete the modifiers when you no longer need them.


Moving user perspective in Blender with Python How can I move the user perspective in Blender with Python? I did some research, but I wasn't able, to find anything.

For clarification: I want to move the user camera in the 3D view. I want to achieve the same effect as the user pressing his middle mouse button and moving the mouse.

You can use bpy.ops.view3d.view_pan() to do the same as Ctrl+Numpad #, e.g.:

for area in bpy.context.screen.areas:
    if area.type == 'VIEW_3D':
        override = {'area': area, 'region': area.regions[-1]}
        bpy.ops.view3d.view_pan(override, type='PANRIGHT')

The amount of the panning can't be controlled.

If you manipulate the view_matrix (or view_location etc.) directly, there's a lot more control. But you will have to calculate the proper matrices and vectors, and if something went wrong, you may end up with strange view or navigation reaction:

r3d = C.screen.areas[2].spaces[0].region_3d # region_3d of 3D View
r3d.view_matrix.col[3][1:4] # translation part of the view matrix

Have a look at the FPS Fly addon to see what can be done and how:
http://www.ewocprojects.be/fpsfly.html

AFAIK viewport navigation is a bit weird after use, as the addon might manipulate the wrong property to fly around. The C-implementation will be different.


Subdivide a face into smaller faces Here is my sphere:

I want to subdivide the face I'm selecting into four, like I did with the other ones. But, when I go to W->Subdivide Smooth, the surrounding dots just move closer to the face, and the face doesn't subdivide in four. Why is this and how can I fix it?

the faces you're subdividing are NGons, not quads or tris, because you subdivided the surrouding faces. Subdividing them adds vertices but no edge.

What you can do is dissolving the non desired vertices with X

Then joining them to make edge and faces, select 2 vertices and hit J

subdivide smooth on the new edge and join


How to make ivy's leaves colored randomly? In order to make ivy created by IvyGen addon more attractive and convincing I'd like its leaves to have different colors, not repeating several times across a leaf (with that sharp and easy-to-see transition just in the leaf's center). The main problem here is that the leaves are all joined in one mesh, so the ColorRamp stops (used in material) assign to them as to one object.

How to make the leaves colored differently and not repeating ?

I will post several possible ways to achieve this kind of task.

First way

Basically, the most intuitive way is to use separating every single leaf into new object by using P > By Loose Parts and it's already described here (also some tutorials about modeling and rendering ivy use this technique as well).

The main downside for this is that it needs large amount of computations and may freeze PC for some time. More than that, after the procedure is finished, the 3D Viewport still will response much slower because there will be way more objects in the scene to take into account (in case of one not very large ivy  ~5000 objects, i.e. leaves).

Second way

Some great solutions are provided in this thread. There are several of them (at least 3 different ones):

using Random group connected to Color Group;
using UV Align\Distribute addon (thus creating UV Map) and a script executing
and the third one already listed here above

The main reason why I decided to go further is that I wanted to get possibility to setup this color randomness really fast so to test some ivys while modeling environment scene (and also I didn't find that thread from the beginning).

Third way

This way assumes using 2 UV maps, one for different leaves' color, while another - for actually the texture (image based). Basically it is one of those listed in the BA thread (except for the script), only combined with another solutions.

After the ivy is created, it has UV map by default, and it's for actually image texture as is told above.
Therefore create one more UV map (I called it "Leaves-1"), it willl serve for different leaves' color task. With this map selected and set to active, enter Edit mode, U > Lightmap Pack (you may also use Smart UV Project option as well, it will fit ivy leaves' needs).  After this is done, with leaves still selected, in Object Data tab, UV maps scroll hit that small camera button next to the default map so it to be one used for rendering.

Now, setting nodes part.
Basically, the nodes will be the same as they are in case of leaves / plants creating - with alpha mask using, along bump and normal maps etc. except for one thing. Instead of using Object Info node (with Random output used) what should be done if using  first way, UV Map node will be used with newly created UV map name assigned:

ColorRamp used here will determine difference between leaves' image texture color. The result on the left is with bottom ColorRamp used. The result on the right is an attempt to add several hues, so I added Mapping and Separate XYZ nodes and added one more color stop in the ColorRamp:

It is possible to change ColorRamp interpolation mode to Constant, the difference of the leaves' color will be somewhat sharper. Also some colors will become more visible (brownish in my case)

Advantages

There shouldn't be done no additional computations
Only one extra step required - this may be set up very fast
The color manipulation is rather easy and comfortable (with ColorRamp)
The result is looking somewhat convincing

Disadvantages

Some sharp color transition within one leaf sometimes may happen, especially with Interpolation mode set to Constant in ColorRamp
It's not the best solution if adding more colors to color stops is needed, it may not handle them all correctly
Because of combining color and image texture is done with MixRGB node image texture may become less visible (if the color appearence is set to high)

Addition

And with mixing one of solutions from the Second way with this one the result may look like this:

This can be achieved by connecting Random group (instead of UV Map node) to the ColorRamp from the 3rd solution. Random Group is proposed in that BA thread:


Read And save custom data outside .blend I need to create an addon that load and save pieces of armatures and I want to make the addon capable of loading these saved data in any file.
Almost like a preset system but with entire objects.

something like:

def when_addon_loads():

    data = load_from_user_settings("c:/file_path.txt")
    snippets = parse_all(data.split("\n"))
    context.scene.armature_snippets = snippets

You can save individual data blocks to blend files using the bpy.data.libraries.write() function:

import bpy

filepath = "//new_library.blend"

# write selected objects and their data to a blend file
data_blocks = set(bpy.context.selected_objects)
bpy.data.libraries.write(filepath, data_blocks)

# write all meshes starting with a capital letter and
# set them with fake-user enabled so they aren't lost on re-saving
data_blocks = {mesh for mesh in bpy.data.meshes if mesh.name[:1].isupper()}
bpy.data.libraries.write(filepath, data_blocks, fake_user=True)

# write all materials, textures and node groups to a library
data_blocks = {*bpy.data.materials, *bpy.data.textures, *bpy.data.node_groups}
bpy.data.libraries.write(filepath, data_blocks)

See the API documentation for more info.


Could I have a camera complete an animation then follow a path? Currently I have a camera following a car moving across the scene. The car's animation is repetitive and the camera only follows the car for one repetition. Once it's done with the first repetition i would like the camera to pan away from the car and circle around my scene at a constant speed. Is there a away to animate the camera so once it is done following the car it falls on to a path that circles the scene?

With your camera selected, go to Properties -> Constraints. Add 2 'Child-Of' constraints to the camera. In the first Child-Of constraint, make the target your car. In the second Child-Of constraint, make the target a static object in the scene, such as the ground model.

Go to the last frame in which the camera needs to follow the car. Set the first Child-Of influence to 1.0 and keyframe it (hit I over the influence bar). Then set the second Child-Of influence to 0.0 and keyframe it.

Go to the very next frame. Set the first Child-Of influence to 0.0 and keyframe it. Set the second Child-Of influence to 1.0 and keyframe it.
Now you are free to animate the camera with respect to the moving car. Then, you can animate the camera with respect to the scene in general.


Make an object disappear by moving through a mesh is it possible for me to make an object disappear by making it move through a mesh. For an example. I have a car modeling, and i want it to disappear after the end of the road. I don't want the car to suddenly disappear like turning off the visibility or restrict rendering. I want the mesh to work like a mask for the car. So that when the car go through the mesh. It will vanish. I'm sorry i am bad at explaining. I hope the image can help me a little bit.

You could use a Boolean modifier:

Create a cube. It will be the object that will make your car disappear.
In the Properties panel > Object > Display, choose Maximum Draw Type > Wire. In the Properties panel > Object > Cycles Settings > Ray Visibility, disable everything. Your cube is now transparent in both Object and Render mode.
Select your car, give it a Boolean modifier, choose Operation > Difference, and choose the cube as the Object.
Now when you move your car, the part that touches the cube becomes invisible.


Fixing Non-manifold edges for 3D printing This is my first model for 3D printing, and I'm trying to fix non manifold edges. I included a screenshot, there are 6 non manifold edges. Things I already tried:
- recalculate normals
- remove doubles

To me it looks like there are no double edges left, so I'm clueless to what causes this problem. :) Who can help me?

The way I created this part is deleting two faces in the wall, extruding the floor face and merging the vertices to make it 1 piece again.

Non-manifold geometry is geometry where an edge is shared by more than 2 faces:

This is what you should be looking for. It's easy to find using Select -> Select All by Trait -> Non Manifold

Once you find it you can fix it by deleting some unnecessary faces, or separating the edges. You could use Edge split for that:

Note that it splits  them all so you need to move one and then remerge the two you like connected(you can use Merge by Distance for that)


Volume scatter object invisible I'm trying to create a lightsaber sword in blender and im using Volume Scatter for the glowing part of the sword. But the object with volume scatter is completly black. You can still see the sword inside but you cant see the handle because the volume scatter object is too dark and the handle is black. So is there any way to make the volume scatter object invisible?

Here is an image to show what im talking about

First off, make sure that you have everything disconnected from the "Surface" node on material Output.

And as a side note, an easier on render time way to make an emission object glow is to do compositing.

In the render layers tab, you can check 'emission' under passes.

Then just overlay a blur of the emission pass like this:


Switching between Image Sequence and Movie Clip for Compositing So I used an image sequence as a video and edited it using masks. However, I want to insead use a movie clip because I will be able to do more things with it.
However, when I replaced the image node with the movie clip node, the scale of the video was changed and all of my masks were misplaced. I don't want to go back frame by frame and change each mask, but I also don't want to render the current video (with the image sequence) because I want to be able to edit the masks if I wanted down the road.

With Image Sequence:

With Movie Clip:

the video seems larger, however I can't zoom out for some reason.
Also, the masks seem to be in the right place, but they do not render as such. I didn't move them or anything, they were automatically there when I put in the movie clip.

Any ideas?

Nevermind, found a workaround.
Just used a scale node on the image.


How can I make a material for jam? Well, I thought of something like this:

But I couldn't figure out, how to achieve a similar material.
I messed around with the nodes and that's how my material looks like:

Can someone help me? -Thanks, beforehand.

(Sorry for my English, but I'm Austrian.)

Watch out, you have an unconnected socket shader socket in your node tree.

Anyway maybe mix a little translucent shader into your glass one. You setup looks quite good to me already, much of the remaining work needed is probably pertaining to setting up a proper scene and environment. "Jam in the void" will never look like proper jam.

You might optionally also want to add a particle system to your jam object to simulate the seeds in suspension.


Microscopic Material in Cycles How would I make this material in cycles?

Thanks

The foundation of a shader like this is the Fresnel function, which you can access with either a Fresnel Node or the Layer Weight node. From the wiki:

  Dielectric fresnel, computing how much light is reflected off a layer, where the rest will be refracted through the layer. The resulting weight can be used for layering shaders with the Mix Shader node. It is dependent on the angle between the surface normal and the viewing direction.

In this case, the Layer Weight's Facing output might be better since it gives a more linear falloff whereas Fresnel is more exponential.

Here Fresnel is passed through a Color Ramp to change the colours to a range of blues and purples before connecting to the Color of an Emission shader. A procedural Noise texture is used for the bump map, and some transparency is mixed as well. The transparency is mixed more where the surface is facing the camera using the same Facing output.


How do I change the layer of certain objects in a group? I've encountered this problem a few times from workaround, but it keeps coming back. I have no idea how I solved it initially, but now the problem has persisted for quite some time.

What I want to do:

Is to have my player and weapons all in one .blend, and to let the player switch out weapons, whereby a given weapon is added or deleted whenever a weapon change occurs.

Problem:

This is requiring the weapons to be in a separate layer. Linking object doesn't seem to support this. I've tried using different groups for each set of assets, but that also did not appear to do anything.

Picture related, the groups I am referring to in game. Any help is greatly appreciated. I can provide additional information if necessary.

Be aware the BGE does not know about layers (in terms of logic and object management). The differs between

active objects (residing in visible layers inside Blender) and
inactive objects (residing in hidden layers inside Blender).

This assignment is fixed. You can't change it while running the game.

Finally you do not need to do that.

The trick is to place the linked objects inside the hidden layer. This makes them inactive and therefore available for AddObject.

I usually assign linked objects (even single objects) to a group. I link the group from the target blend file.

This allows me to instantiate the group as often as I like in any scene and any layer.

In your case you can create an instance in an hidden layer. While you run your game you can addObject() all objects of the instance.


How can I move a UV Island to simulate the Movement of an Eye SO I have a Plane instead of a Sphere for the Eye, I want to be able to move the UV Island instead of moving parts of the plane or using a Sphere.

The eyes are Oval Shaped so I have to use a plane for the eyes. So I would like to be able to Slide, Scale, and Rotate the UV Island (Not move any of the Geometry) instead of the traditional methods. I know AnimAll is a choice but AnimAll causes the Program to Freeze then Crash for me. So is there a way I can move the UV Island using a Bone that I move around kinda like in this image below.

Ok... it seems it is needed to complete a previous answer (Creating an eye/eyelid rig for dragon without shape keys)...

You are more or less in this situation with a single UV map and a single texture. The eyes are here selected on the left.

On the right, you can see two vertex groups (named WarpLeftEye and WarpRightEye) : each of them is assigned the corresponding eye vertices.

Now, add two empties. Here I created a sphere and a cube one (in order to see who is who). Then setup the UV Warp modifier this way, using the two empties (or any objects or bones) and the vertex group for the left eye (do the same for the other eye) :

Here is the result :

Surely, you'll need to have enough space around the eyes in your texture. If not, add another one as suggested in the comments.
You can also use the UV map field of the modifier to use another UV map done for the eyes.

Note : scaling and rotating work too... more or less easy to do but simply scale and move and/or rotate the empty (scaling will shift too : so you'll need to scale a bit, realign, scale a bit, etc.)


Scopes & Mask Tabs disappeared from UV/Viewer screen Any idea how this could have happened?  I have my keyboard connected to 2 computers (via a/b switch) and occasionally type a key sequence into Blender that is meant for the other computer.  I have no idea what I might have typed to remove those tabs and no clue how to get them back.  I'm doing some color correction and really need my scopes back.  BTW, when I open a new Blender session the tabs are missing.  When I open a backup copy of my color correction, the tabs are there (but I would have to trash all my changes to get back to where I left off.)

I figured it out.  I looked in space_image.py and found the following code.

class ImageScopesPanel:
    @classmethod
    def poll(cls, context):
        sima = context.space_data
        if not (sima and sima.image):
            return False
        # scopes are not updated in paint modes, hide
        if sima.mode == 'PAINT':
            return False
        ob = context.active_object
        if ob and ob.mode in {'TEXTURE_PAINT', 'EDIT'}:
            return False
        return True

I could not quickly figure out the meaning of each of the variables, but decided to take a look at what could turn off the "scopes" tab.  As soon as I turned the "3D View" from "Edit Mode" to "Object Mode", the "Scopes" tab re-appeared on the "UV/Image Editor".


My spotlights are making weird shape reflections on glass I am a Blender beginner and I'm trying to create an interior scene for my exam, but at this moment my lights create a weird reflection effect on the glass.

I imported a spotlight from an .obj file and assigned a PBR metal to the mesh and an Emission Node to the central surface of the spotlight for the light.

I realized it was to weak to light up my scene so I also added a Blender spot. It's probably not the way I should do it, but that's the only one I know to avoid fireflies and get a good result, although on the glass my lights are creating a weird hemisphere reflection, really bright and with sharp edge.

I set the bounces to 1 to check if it was a reflection problem or not and that's the result.

Could you please help me, what did I do wrong? Thank you so much.

I'd advise getting rid o additional duplicate lamps overlapping in one spot, if one is not enough to light your scene up increase its strength.

Having double lamps overlapping is redundant and will likely lead to issues, besides the obvious performance issues. Having multiple lamps realistically distributed across your scene is of course ok and encouraged.

Anyway, you are most likely using either Area or Point lights, not spots, these are never visible in reflections, as far as I know.

Try disabling the Lamp object visibility to Cycles Glossy component.

Alternatively use a node setup in your lamp with a Light Path node limiting it's visibility to glossy components.


How to attenuate an area light so that it falls off more rapidly than Quadratically I am using some area lights to illuminate the interior of a cabinet:

However I want to attenuate the lights so their area of influence is much smaller. Like this reference image:

I've tried playing around with the light falloff node but can't get it to do what I want.
Any help at all is greatly appreciated.
Edit 1:
Getting much closer by trying what Rich Sedman linked here. I changed the light attenuation to cubic by dividing the light falloff by the ray length. It's still not where I want it, but progress nonetheless.

Edit 2:
More progress:

Looking a lot better, but now I'm getting really bright fringing close to the light sources. I am immensely frustrated that it's so difficult to match VRayLight settings in Cycles. I feel like VRay's emission "algorithm" looks much more natural then cycles.

Here's a setup to get any falloff power - Constant, Linear, Quadratic, Cubic, etc. and everything inbetween :

Control the overall strength of the light by changing the Strength of the Light Falloff node. Changing the 'Power' changes the falloff with 0 being 'Constant' (ie, irrespective of distance), 1 being Linear falloff, 2 being Quadratic falloff, 3 being Cubic falloff, 4 to falloff to the power of 4, etc. You can adjust the power to any value including, say, 2.5 to be somewhere between Quadratic and Cubic.

EDIT : To get a bit more control over the effect close to the light source you add an extra Maths node to add an offset. This allows you to limit the lower end of the response by making so that it's as if the light is never closer than the specified amount. eg, setting to 0.5 the light will never be in the extreme range.

Another option would be to swap the 'Add' to, say, a Maximum. This way any distance below the set value will be treated as that value (and so not 'blow out') but it will still behave as the required falloff above that threshold.


Pouring liquid from one cup to another So, the title basically explains it. I am trying to create an animation in which I want to pour liquid from one cup to another but I don't know my way about it. Any help will be appreciated.

A litlle bit more information of what you tried and where you got stuck wwould be great - there are a lot of Tutorials out there that can help you.
Once you get stuck and can`t figure it out update your question.


SSS - How to get a nice falloff between glowing translucent areas and dark spots? I'm new to Blender and I'm trying to recreate this effect with Cycles. The  render below was made with Modo.

I've tried using Cycles SSS but results are very different. Can't seem to get that nice falloff between the glowing translucent areas and dark spots.

Any ideas?

Okay, I was finally able to replicate it!! I imported the same model to Blender to really compare. All I needed was to pump  up the transulcent BSDF amount and I just did it with an 'Add Shader' node. It looks great now and renders so fast with GPU enabled. I'm so impressed with Blender and I think I'll stick with this software for now. :-)


How to align modal draw to the middle of the 3d viewport? I have a question about the opengl modal draw :

How to align text from a modal draw to the middle of the viewport and and keep it automatic between Tool Shelf and Property Shelf, when i changing them?

I want to avoid that the property shelf overlapp the modal draw on the right viewport side, when i change the scale of left toolshelf.

Maybe there is a similar question always done?

According to the API, Area.region collection holds all "regions of the screen area" as well as their dimensions. In case of the 3d Viewport: Header, Transform Panel and N-Panel.

The following code is based on this answer, extended with a simple calculation to get the correct position of the text in the 3d Viewport. Notice that you can also iterate through the collection and sum up the dimensions instead of doing that stepwise.

import bpy
import bgl
import blf

def draw_callback_px(self, context):

    bgl.glEnable(bgl.GL_BLEND)

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

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

    # draw text
    text = "Hello World"
    font_id = 0  # XXX, need to find out how best to get this.
    bgl.glColor4f(*(1.0, 1.0, 1.0, 1))
    blf.size(font_id, 70, 72)
    dim_x = blf.dimensions(font_id, text)[0]/2
    dim_y = blf.dimensions(font_id, text)[1]
    blf.position(font_id, width/2-dim_x, height/2-dim_y, 0)
    blf.draw(font_id, text)

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

class ModalDrawOperator(bpy.types.Operator):
    """Draw a line with the mouse"""
    bl_idname = "view3d.modal_operator"
    bl_label = "Simple Modal View3D Operator"

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

        if event.type in {'RIGHTMOUSE', 'ESC'}:
            bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
            return {'CANCELLED'}

        return {'RUNNING_MODAL'}

    def invoke(self, context, event):
        if context.area.type == 'VIEW_3D':
            # the arguments we pass the the callback
            args = (self, context)
            # Add the region OpenGL drawing callback
            # draw in view space with 'POST_VIEW' and 'PRE_VIEW'
            self._handle = bpy.types.SpaceView3D.draw_handler_add(draw_callback_px, args, 'WINDOW', 'POST_PIXEL')
            context.window_manager.modal_handler_add(self)
            return {'RUNNING_MODAL'}
        else:
            self.report({'WARNING'}, "View3D not found, cannot run operator")
            return {'CANCELLED'}

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

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

if __name__ == "__main__":
    register()

To display the text as well as allow the user to interact with the UI, you can change the return statement of the modal function from {'RUNNING_MODAL'} to {'PASS_THROUGH'}:

...

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

    if event.type in {'RIGHTMOUSE', 'ESC'}:
        bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
        return {'CANCELLED'}

    return {'PASS_THROUGH'}

...

Also see the API on Modal Execution: https://docs.blender.org/api/blender_python_api_current/bpy.types.Operator.html#modal-execution


How to copy NLA strip without creating a new track? I would like to make many linked copies of a strip. This strip controls the eye blinking. When I press Alt+D, it creates a new NLA track for the new copied strip.

This will end up having a new track whenever the character blinks lol

Yes, maybe I miss something but it doesn't seem logical, maybe it's worth a report to Blender developers? That said, you can either:

Duplicate one or several times your strip, it will create one new track but you can delete it later (put your cursor over the track's name and press X).
Put your cursor where you want to create a copy of your strip and press ShitA > Strip Name, but it won't keep all the edits you could have made in the NLA "N" panel.


Adding Particle System through blender script I am trying to make a particle system through the blender script, but I am unable to do so. I do not know much about scripting in blender. This is what I have and could you tell me how I could create a system?

obj = context.active_object
if len(obj.particle_systems) == 0:
        obj.modifiers.new("part", type='PARTICLE_SYSTEM')
        bpy.ops.object.modifier_apply(modifier = "part")

It seems modifier_apply() only works for those modifiers that have an Apply button, but when you add a Particle System as a modifier the only button on the modifier is Convert, which calls bpy.ops.object.duplicates_make_real() , that's probably what you want instead of Apply.

Something like this:

import bpy

obj = bpy.context.active_object

if len(obj.particle_systems) == 0:
    obj.modifiers.new("part", type='PARTICLE_SYSTEM')
    part = obj.particle_systems[0]

    settings = part.settings
    settings.emit_from = 'VERT'
    settings.physics_type = 'NO'
    settings.particle_size = 0.1
    settings.render_type = 'OBJECT'
    settings.dupli_object = bpy.data.objects['Cube']
    settings.show_unborn = True
    settings.use_dead = True

    bpy.ops.object.duplicates_make_real()


Dividing terrain mesh up into multiple tiles with script - border gap issue Having found a fantastic Script for dividing up terrain from user batFINGER

within this post - blender.stackexchange.com/questions/80460/slice-up-terrain-mesh-into-chunks/133258

import bpy, bmesh
from bpy import context
from  mathutils import Vector
# bounding box helper methods
def bbox(ob):
    return (Vector(b) for b in ob.bound_box)

def bbox_center(ob):
    return sum(bbox(ob), Vector()) / 8

def bbox_axes(ob):
    bb = list(bbox(ob))
    return tuple(bb[i] for i in (0, 4, 3, 1))

def slice(bm, start, end, segments):
    if segments == 1:
        return
    def geom(bm):
        return bm.verts[:] + bm.edges[:] + bm.faces[:]
    planes = [start.lerp(end, f / segments) for f in range(1, segments)]
    #p0 = start
    plane_no = (end - start).normalized()
    while(planes):
        p0 = planes.pop(0)
        ret = bmesh.ops.bisect_plane(bm,
                geom=geom(bm),
                plane_co=p0,
                plane_no=plane_no)
        bmesh.ops.split_edges(bm,
                edges=[e for e in ret['geom_cut']
                if isinstance(e, bmesh.types.BMEdge)])

bm = bmesh.new()
ob = context.object
me = ob.data
bm.from_mesh(me)

o, x, y, z = bbox_axes(ob)

x_segments = 2
y_segments = 2
z_segments = 1

slice(bm, o, x, x_segments)
slice(bm, o, y, y_segments)
slice(bm, o, z, z_segments)
bm.to_mesh(me)

bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.separate(type='LOOSE')
bpy.ops.object.mode_set()

I'm then trying to make use of it in combo with BlenderGIS

Cutting up the heightmap works well, but when I try and layer sat image tiles (already divided up within QGIS) over the top, I notice there is a tiny anomaly on all the edges - a gap to some extent. which it seems to be trying to fill with a different part of the image - which stands out.

When posting about it on BlenderGIS - github.com/domlysz/BlenderGIS/issues/172

It was noted that an additional rows + 1 and columns + 1 might be added so borders overlap.

Not being a Python wiz just yet, can anyone help me understand the tweaks required to adjust the above script to potentially handle the gap issue?

Update - 18/05/19

So one thing I also noticed was a loss of data when importing my heightmap (.asc) into blender, here is the header detail on asc -

When importing into blender I expected 1250 faces along one edge - but in fact it seemed to lose one, and only had 1249:

This might not be a huge issue, however when I then run the script to split into 4 x 4 - dividing 1249 by 4 seems to prompt the faces to be split into 3 sections of 313 x 313 (rounding up) but the edge faces are squashed:

Because I thought this might be contributing to the issue I regenerated my square heightmap with dimensions of 10020 mtrs which made following:

so losing 1 face when imported to blender gave me faces of 1252 which cleanly divides by 4, so now my edges look neat:

My next conundrum is that if I shift the objects following the dividing of heightmap using ob.location = (0, 0, 0)
then I am unable to import jpg sat tiles using BlenderGIS as it returns error 'No Overlap Data'
Clearly it want's the sat tiles to match with the heightmap's converted blender geo location (however it does that within BlenderGIS)?

and if I try and import the sat tiles at the heightmaps imported location:
Vector((644784.5, 4979542.0, 0.0))

I still get the usual edge anomaly:

perhaps shifting all 16 tiles to the origin will resolve that - but I'm unsure how to move all of them in one batch move?

I'm also wondering if I should just try laying the sat images over the divided heightmap sections using default UV editor / texture config, rather than relying on BlenderGIS custom import feature, as maybe the Geo location element is confusing things? I think I tried one tile like that, but had other issues getting it to lay over terrain without the texture falling through the mesh.

Finally got this working, turns out you require an overlap on both DEM and Sat image

and I had to tile both in QGIS before bringing them into Blender

Full description of the resolution here:
https://github.com/domlysz/BlenderGIS/issues/172

And summary of fix for issue:

  The overlapping of 1 pixel for DEM tiles help to compensate the loose
  of last column and line when connecting only pixel's center, this
  trick allows to obtain perfectly joint tiles.

  The overlapping for satellite tiles help to compensate the difference
  of tiles size between the 2 rasters datasource because even if the 2
  rasters have the same extent, as long as they don't have the same
  pixel size in meters then dividing the number of pixel by 4 will not
  produce a cut at the same coordinate.

Figures for my assets:

DEM 1253x1253 >> retile 315x315 with 1px overlap
SAT 10020x10020 >> retile 2600x2600 with 95px overlap

I used GDAL process 'Retile' in QGIS to divide tiles + overlap.


The material surface selection field is not available in 2.79b A tutorial is telling me to assign the material to glossy, but my version of blender 2.79b, is completely different from his version of blender 2.79. How can I select a glossy texture using my version of blender? Which version of Blender can I change to which will be the same as his version?
Thanks for your help!!!

You probably need to switch from Blender Render engine to Cycles Render:


Control what image you bake to I want to make a script that automatically bakes out several passes to several different images. In the standard baking setup, it bakes to the image you have in a texture node in your material. This gets strange when you have multiple image nodes. In my material I have a Diffuse, Gloss, AO, Normals, etc each as separate images. I want to bake each pass to the appropriate texture.

Is there a way to do this?

If we bake passes manually, they are baked to the selected texture node in the active objects material node tree.

We can create a texture image node, make it active, then assign it an image and bake a desired pass.

import bpy

BAKE_TYPES = ['DIFFUSE', 'GLOSSY', 'AO', 'NORMAL']

nodes = bpy.data.materials[0].node_tree.nodes
tex_node = nodes.new(type='ShaderNodeTexImage')
nodes.active = tex_node

for type in BAKE_TYPES:
    img = bpy.data.images.new('bake_' + type, 500, 500)

    # if you have images prepared, load them instead
    #img_diff = bpy.data.images['image_diff']

    nodes.active.image = img
    bpy.ops.object.bake(type=type)

nodes.remove(tex_node)


Is bpy props able to create a list of lists? I'm trying to create an export dialog for an add-on I'm creating, and I want to be able to do something like

Replace texture names
-------------------
Replace    With
[TEXTBOX] [TEXTBOX]
<ADD BUTTON>

Where the user can click "ADD BUTTON" and add more rows of textboxes. So in the end they could have something like

[YELLOW] [RED]
[YELLOW] [GREEN]

Would it be possible to use something from bpy.props to achieve this?

Have a look at the templates UI List Simple from Text Editor -> Templates -> Python

Here is an example

import bpy

def get_color_enum(self):
    return self.get('color_enum', 0)

def set_color_enum(self, value):
    COLORS = (
        (1.0, 0.0, 1.0), (1.0, 1.0, 0.0), (0.0, 1.0, 1.0),
        (1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0))
    self['color_enum'] = value
    self['color_value'] = COLORS[value]

def get_color_value(self):
    return self.get('color_value', (1.0, 0.0, 1.0))

def set_color_value(self, value):
    self['color_value'] = value
    self['color_enum'] = 6

class MyListItem(bpy.types.PropertyGroup):
    name = bpy.props.StringProperty(name="Name", default="Name")
    color_enum = bpy.props.EnumProperty(
        name="Color",
        items=(
            ("PINK",    "Pink",   "", 0),
            ("YELLOW",  "Yellow", "", 1),
            ("CYAN",    "Cyan",   "", 2),
            ("RED",     "Red",    "", 3),
            ("GREEN",   "Green",  "", 4),
            ("BLUE",    "Blue",   "", 5),
            ("CUSTOM",  "Custom", "", 6)),
        get=get_color_enum,
        set=set_color_enum
    )
    color_value = bpy.props.FloatVectorProperty(
        name="Color",
        subtype="COLOR",
        min=0.0,
        max=1.0,
        get=get_color_value,
        set=set_color_value
    )

class MyExportSettings(bpy.types.PropertyGroup):
    colors = bpy.props.CollectionProperty(type=MyListItem, name="Colors")
    active_color_index = bpy.props.IntProperty(name="Active Color", default=-1)
    # ...

class SCENE_UL_my_color_list(bpy.types.UIList):
    def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
        layout.label("", icon="COLOR")
        layout.prop(item, "name",  "")
        layout.prop(item, "color_enum", "")
        layout.prop(item, "color_value", "")

class MyExportPanel(bpy.types.Panel):
    bl_label = "Colors Export Panel"
    bl_idname = "SCENE_PT_my_export_panel"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "scene"

    def draw(self, context):
        layout = self.layout
        settings = context.scene.my_export_settings

        layout.template_list(
            "SCENE_UL_my_color_list",
            "my_color_list",
            settings,
            "colors",
            settings,
            "active_color_index",
            type='DEFAULT'
        )

        row = layout.row(align=True)
        row.operator("scene.add_my_list_item")
        row.operator("scene.remove_my_list_item")

class AddMyListItem(bpy.types.Operator):
    bl_idname = "scene.add_my_list_item"
    bl_label = "Add Entry"
    bl_options = set()

    def execute(self, context):
        settings = context.scene.my_export_settings
        settings.colors.add()
        settings.active_color_index = len(settings.colors) - 1
        return {'FINISHED'}

class RemoveMyListItem(bpy.types.Operator):
    bl_idname = "scene.remove_my_list_item"
    bl_label = "Remove Active Entry"
    bl_options = set()

    @classmethod
    def poll(cls, context):
        return context.scene.my_export_settings.active_color_index >= 0

    def execute(self, context):
        settings = context.scene.my_export_settings
        settings.colors.remove(settings.active_color_index)
        settings.active_color_index -= 1
        return {'FINISHED'}

def register():
    for cls in (MyListItem, MyExportSettings, SCENE_UL_my_color_list, MyExportPanel, AddMyListItem, RemoveMyListItem):
        bpy.utils.register_class(cls)

    bpy.types.Scene.my_export_settings = bpy.props.PointerProperty(type=MyExportSettings)

if __name__ == "__main__":
    register()

For further information see the section about bpy.props and their examples, the page of the UIList base class and the description of the of UILayout.template_list function


I am using the gLTF addon, how do I make my node group glTF Metallic Roughness exactly the same as my Diffuse BSDF When using the Diffuse BSDF

When using the glTF Metallic Roughness

As you can tell the colour of the cubes looks different from each other. Additionally when using the glTF Metallic Roughness, you can see it is reflecting this white colour and I don't want that.

How do I make the glTF Metallic Roughness Exactly the same as Diffuse BSDF so that the object looks exactly the same?

(I installed this addon from this place https://github.com/KhronosGroup/glTF-Blender-Exporter/tree/master/docs)

They're different shading models; it may not be possible to exactly match one with the other and vice versa. If you're creating a model for export into some 3D engine, you should try importing both and verify that it looks correct there, as ultimately the engine will determine how it looks.

In the future the glTF Blender Exporter will work with the Principled BSDF node, and then you won't need a special addon glTF PBR node like this.


Assigning Array and Curve for a large number of curves I have a very large number of curves (OpenStreetMap data imported as curves) on which I wish to array objects (streetlights).
Since there are thousands of curve objects, duplicating my streetlight object and then manually adding an array and curve modifier and point them to the right curve is a slow if not impossible process when there is this many curve objects.

The best solution I can think of is a script, however I am not familiar with the process. I've only gone as far as making the script add an array modifier.

The imported curves are all numbered as Road0, Road1, Road2, Road3, etc

Here is my script so far

import bpy

bpy.ops.object.duplicate_move(OBJECT_OT_duplicate={"linked":False, "mode":'TRANSLATION'}, TRANSFORM_OT_translate={"value":(-0, 0, 0), "orient_type":'GLOBAL', "orient_matrix":((1, 0, 0), (0, 1, 0), (0, 0, 1)), "orient_matrix_type":'GLOBAL', "constraint_axis":(False, False, False), "mirror":True, "use_proportional_edit":False, "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "use_proportional_connected":False, "use_proportional_projected":False, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "gpencil_strokes":False, "cursor_transform":False, "texture_space":False, "remove_on_cancel":False, "release_confirm":False, "use_accurate":False})
bpy.ops.object.modifier_add(type='ARRAY')
bpy.context.object.modifiers["Array"].fit_type = 'FIT_CURVE'
bpy.context.object.modifiers["Array"].relative_offset_displace[0] = 50
bpy.context.object.modifiers["Array"].curve = bpy.data.objects["RoadTertartiary0"]

I basically need a way to make that last 0 increment every time I run the script

Sample Blend file:

Any help is appreciated.

Thank you lemon, your script is very useful, it is just what I need from a year ago.
I edited the script (names for a more generic work and not linked to the lamp), Mainpath for curves and Mainclone name for object. I changed the type of displacement to Constant Offset.
import bpy
import bmesh

# Scripting: lemon
# https://blender.stackexchange.com/users/19156/lemon
# Aug 15 '19 at 12:37
# get an existing collection or create it if it does not exist
# if created, the collection is added to the scene main collection
def get_or_create_collection( scene, collection_name ):
    collection = bpy.data.collections.get( collection_name )
    if collection is None:
        collection = bpy.data.collections.new( collection_name )
        scene.collection.children.link( collection )
    return collection

# duplicate an object and link it to a collection
# copy_data allow to know if the objects will share their data or not (are dupli or not)
def duplicate( obj, collection, copy_data ):
    new_obj = obj.copy()
    if copy_data:
        new_obj.data = obj.data.copy()
    collection.objects.link( new_obj )
    return new_obj

# get the scene
scene = bpy.context.scene

# get the base main clone
base_Mainclone = bpy.data.objects["Mainclone"]

# names of the collections
mainpath_collection_name = "Mainpath"
clones_collection_name = "Created_clones"

# get the source collection
mainpath_collection = bpy.data.collections.get( mainpath_collection_name )

if mainpath_collection is None or base_Mainclone is None:
    print( "will not work" )
else:
# get the destination collection
clones_collection = get_or_create_collection( scene, clones_collection_name )

for mainpath in [r for r in mainpath_collection.objects if r.type == 'CURVE']:
    # Duplicate the base main clone (True => not linked)
    Mainclone = duplicate( base_Mainclone, clones_collection, True )
    # Set the lamp at the road location so that curve can work
    Mainclone.location = mainpath.location
    # Add the array modifier
    array_modifier = Mainclone.modifiers.new( "array", 'ARRAY' )
    array_modifier.fit_type = 'FIT_CURVE'
    array_modifier.use_relative_offset = False
    array_modifier.use_constant_offset = True
    array_modifier.constant_offset_displace[0] = 10
    array_modifier.curve = mainpath
    # Add the curve modifier
    curve_modifier = Mainclone.modifiers.new( "curve", 'CURVE' )
    curve_modifier.object = mainpath

print( 'done' )


Bezier curve interpolation not uniform I generated a bunch of points using mathutils.geometry.interpolate_bezier() but noticed the points are not uniformly distributed on the curve. Please see attached screenshot.

I think it has to do with the interpolation function processing each segment individually which can be dense or sparse depending on how stretched the segment is.

Is there is a better way to interpolate bezier curve and obtain a list of uniformly distributed points?

Thanks!

Use offset factor of follow path constraint.

Use the offset factor of follow curve constraint.

Test script, select the curve in object mode and run script.

import bpy
context = bpy.context
scene = context.scene
curve_obj = context.object
spline = curve_obj.data.splines[0]
bpy.ops.mesh.primitive_ico_sphere_add(size=0.05, location=(0, 0, 0))
sphere = context.object
fp = sphere.constraints.new(type='FOLLOW_PATH')
fp.target = curve_obj
fp.use_fixed_location = True

res = len(spline.bezier_points)

spheres = [sphere]
o = 0 if spline.use_cyclic_u else 1
r = spline.resolution_u + 1
pts = (res + o) * r
for i in range(1, pts + o):
    s = sphere.copy()
    sc = s.constraints[0]
    sc.offset_factor = i / pts
    scene.objects.link(s)
    spheres.append(s)

To remove the constraints, and keep their constraint location

# remove constraints
scene.update()
for s in spheres:
    sc = s.constraints[0]
    s.location = s.matrix_world.translation
    s.constraints.remove(sc)


How to make a simple spiral w/ arrow like the Weatherman I'm making a YouTube video about a tornado in a campfire I videorecorded. I want to show my viewers the mechanics of the tornado.

Here's a screen shot of what I'm after:

I'm not looking to be a Blender expert (although it looks like a neat program to learn.) I just want to render a 2 turn spiral that I can rotate.

I tried making a spiral from the add curves. I made it taper as it got higher. I extruded the curve in the Z direction and hacked my way thru disconnecting a segment and connecting two, to complete a mesh. It's exactly what I want, but Blender doesn't see it as a solid. (No faces.)

When I made a "flat" spiral (that is, no taper in Z), I can extrude it in Properties and Blender sees that as a solid. But I can't figure out how to taper it in Z after the fact.

None of the suggestions already on StackExchange specifically addressed what I wanted to do. Here's what I finally came up with:

my weatherman-type rendered spiral http://s1.postimg.org/hewpl3ym5/rendered_spiral.jpg

I created a spiral; in Geometry, I used a custom bevel and taper. I assigned it a material. I used hemi light in Blender Render. (So no shadow where one part of the ribbon crosses the other.) I added a 3 point mesh triangle for the arrow and made that a child of the spiral so that it would rotate with the spiral during animation. I added a black border in BR post processing. (Whew! Took 3 days with lots of reading and watching youtube tutorials.)


Relative reference to object property in material driver? Is it possible to get a value such as the dimensions (object.dimensions) of an object in the material node editor, without referencing a specific object?

In other words, I want to get the dimensions of whatever object is using the material. How can I do this?

A driver is the only way I can think to access the object dimensions from a material.

Using a simple material example -

Add a driver to the field in a value node. Either right-click and select Add Driver or press D while the cursor is over the field. Setup the driver as -

Driver settings are shown in the properties panel of the Graph Editor when Drivers is selected in the header. This then mixes between the two diffuse nodes based on the dimension[0] value.

Note that auto-run python scripts needs to be enabled for drivers to work.

Obviously that is also rather rigid to the dimensions of one object. The Expr: of the driver can be any valid python, not sure of the path but there should be a way to go from the node with the driver to the parent object to choose the dimension value, which would be a more flexible way to use one material on multiple objects. I haven't had any luck accessing active_object in a driver.


Why are some faces lighter than others? As seen below, the faces in the centre are lighter than the others. All have the same material.  Recalculating the normals didn't help. What is causing this?

This is Due to your smooth shading.

  Smooth shading fake smoothness by bluring the normals of faces,In some cases there isn't enough geometry to produce good approximation and this cause unexpected shading.

Here is a cube which is smoothed,It has very few faces which doesn't help in producing a good smooth results.

Read my article here for full demonstration.


Is it possible to create a node group in animation nodes? I have a big node tree that I would like to collapse into a single node with custom inputs  (in shading you can do that pressing ctrl-g), is that possible?
Thanks!

You can, but it works differently than in the Shader Node tree. You don't have a "Sublayer" tree where you go and edit the node group's insides.
You first add a Group Input node by going Add > Subprograms > Group
Then you can add operations like in regular subprograms. Make sure you don't have circular dependencies and that all the group logic is contained within it. The nodes will take the color of the group by default.

To get ouput values, click on Output Node on the bottom of the Group Input node and link it as you wish.

You can Invoke the Group by going Add > Subprograms > - My Group (You can change the name in the Input node).


How can a Method from a startup Script be invoked? This is a follow up of How could a single Python script run when Blender is started?.

Simply adding a method to a newly created file in Blender\scripts\startup didn't work:

Warning! 'C:\Program Files\Blender Foundation\Blender\2.68\scripts\startup\global.py' has no register function, this is now a requirement for registerable scripts.

I used snippets from:

Cannot-display-a-render-preview-of-a-scene-by-using-python-script-need-advices
Adding a custom shortcut for sculpt mode

The script current looks like (Uses Ctrl-R to toggle between rendered and textured mode in Cycles) and adds a dump method I really need):

import bpy

class U(bpy.types.Operator):
    bl_idname = "object.util"
    bl_label = "Toggle Render Mode"

    def execute(self, context):
        # bpy.ops.sculpt.sculptmode_toggle()
        for area in bpy.context.screen.areas:
            if area.type == 'VIEW_3D':
                if area.spaces[0].viewport_shade == 'RENDERED':
                    area.spaces[0].viewport_shade = 'TEXTURED'
                else:
                    area.spaces[0].viewport_shade = 'RENDERED'
        return {'FINISHED'}

    def dump( obj, ctx="", level=0):
        for attr in dir(obj):
            print( "%s.%s = %s" % (ctx, attr, getattr(obj, attr)))

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

addon_kmaps = []

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

    wm = bpy.context.window_manager
    km = wm.keyconfigs.addon.keymaps.new(name='Object Mode', space_type='EMPTY')
    kmi = km.keymap_items.new(U.bl_idname, 'R', 'PRESS', ctrl=True, shift=False)
    addon_kmaps.append(km)

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

    wm = bpy.context.window_manager
    for km in addon_kmaps:
        wm.keyconfigs.addon.kmaps.remove(km)
    del addon_kmaps[:]

if __name__ == "__main__":
    register()

The toggle button works, but how can the dump() method be invoked from the python console?
I noobishly tried U.dump(obj) and bpy.U.dump(obj)

EDIT:

I finally modified the existing scripts/modules/console_python.py and added (starts add line 100):

# weak! - but highly convenient
namespace["C"] = bpy.context
namespace["D"] = bpy.data
namespace['dump'] = bpy.types.OBJECT_OT_util.dump # my one

To answer your question:

Operator types are automatically added to bpy.types on registration.

This is how a method on an operator your register can be called.

bpy.types.OBJECT_OT_util.dump(bpy.context.object)

Note that it is very rare to ever access operator types like this, its more of an internal implementation detail.

normally you would access the operator via bpy.ops.object_utils() but this is only for calling the operator and won't expose its original class.

Suggested alternative

In this case I would suggest not to having dump() as an operator class method at all.
If you have a function that can run outside of the operator, you're better off having it as a utility function in a module other scripts can import and use, then have the both the operator and external scripts use it.

my_module.py:

def dump(...):
   ... do stuff ...

class MyOperator(Operator):
    ...
    def execute(self, context):
        dump()

So now any script can do:

import my_module
my_module.dump()

This way we bypass Blender/Python API internals where its not helpful and let Python modules interact as they would typically  (outside of Blender).


How to make translucent glossy soap-like material? Hi thanks for your help!!
I spent 4 days trying to make this soap but I don't feel satisfied with the result. What can I do?
I tried to add volumetric absortion but it didn't provide good enough result either.

Reference photos:

Rendered result:

This is closest I can get. It is kind a partial answer but it could be starting point for you.

I've used fot this Subsurf Scattering shader added to Translucent shader and then mixed with Glossy shader by Fresnel to give it fake PBR look.

Here is a node setup:

And .blend file:


Non-Destructive Mirror of a Multires Modifier Sculpt I am in the process of modeling a simple couch. I am sculpting in fabric details using the multi-resolution modifier and various cloth brushes. I'm running into a problem after modeling the first armrest. All I want to do is duplicate it and then mirror it along the X so I don't have to start from scratch.
See this image:

So I duplicate A, position it where I want, and then mirror it by setting X to -1.000. Everything looks peachy so-far. See this image:

If I try to sculpt at this stage, I get a warning that my scale is non-uniform. Sculpting is a big buggy if I ignore the warning. So I need to apply the scale somehow without losing the data from the multiresolution modifier. Unfortunately if I apply the scale, I lose a lot of the sculpting detail. See this image:

So my question is, how can I mirror the first armrest and still retain the multires modifier data? Is this not possible due to the nature of how the modifier works? Is there another (better) way to do this?
Thanks much.

Use Animation Nodes add-on, it is open-source and totally free. I'd suggest a setup like this:

The node tree duplicates A then modify its scale (new y = y*(-1)). In your case, you may want to do it with x instead. I tried to sculpt A.  After I mouse-released the sculpt brush, B would be updated too. In this approach, I can't sculpt the new object (so-called B) directly.

This issue as well as a few similar ones will be solved by Everything Nodes project for vanilla Blender but the implementation is not done yet and there is still a long way to go.

Here are some of Chris-P's Animation Nodes Youtube tutorials. I have no affiliation with the author. However, the first few episodes of the series were very useful to me as beginner. Feel free to comment about better tutorial please.


Is it possible to apply textures of different color to a surface on each side? blender 2.9 As stated I was wondering if it was possible to put a texture of a different colour on the the other side of a surface.  If one side is the external surface, and the other the internal, can this be done without extra geometry.  It seems as if it should be. Blender 2.9.
I tried adding these nodes together as mentioned in the comments but I am obviously doing something wrong.

You can use "backfacing" from the "geometry" node:

Here is something closer to your setting:


NLA Editor moving tracks up or down Following a tutorial there should be a possibility to move tracks up or down in the NLA editor with the Page Up or Page Down keys but I can't get it to work. I tried several options with no result.
How can I change the tracks vertically?

PS: I use Blender 2.8x on Windows 10 latest updates.

Finally I got it work -> Track ordering:


What does Save As Render do to the image when saving it? So you render your image in cycles, and then go to save it, then in the bottom left corner is options, and both ticked are save as copy and save as render, and I'm wondering what "save as render" does?

Save as Render will apply the Display Transform set on the Color Management section.

Without the Display Transform the image saved will be saved unprocessed, maintaining the Scene Referred Values, up to the inherent limits of the file format chosen.

For images that require linear values (or non-color-data) leave that box unchecked. (For example when saving normal or depth maps)

Images meant to be saved as Display Referred can be saved as render, so that all color transformations are applied and baked into the picture.

As an example, see how this two images produced with the same scene have different values depending on how they were saved:

There are some notable exceptions to this rule as follows:

The DPX format is unfortunately hard coded to always store a Blender specific transfer curve. It skirts around OCIO in unreliable ways.
The EXR format will always store the internal reference buffer as float or half float. Even with the check box selected, EXRs will not bake any colour transforms, desired or not.
Most other file formats follow the above rule of thumb for display referred formats.


Set keyboard shortcuts for accessing specific render slots? I want to press '1' to go to 1st Render Slot, '2' to go to the 2nd, and so on.

I did this before but my keyboard shortcut file got corrupted. I don't recall how I had set it up in the past.

I'm looking at the Image Generic shortcuts and see no such listings. I am clueless as to what shortcut code to type in. Help?

Found it.
API to enter for the shortcut is:
wm.context_set_int
Make sure Value is set to the slot number minus 1.
Context Attributes must be: space_data.image.render_slots.active_index

That's how you get the render slot numpad shortcuts back, if they disappeared like mine did and you don't want to reset everything.