Cycles: Texturize a feather made from particle system? I have a quill pen created in much the manner described in this exhange but I need to give it character, like a peacock feather.  I gave mine a Texture based on a greyscale PNG, but as I move the feather around my scene the texture moves all over the feather -- in my viewing I'd say it's "projected" on to the feather.  I've played with the options on the Texture pane of the Particle System, but they all "project" too.

Is there a technique to apply a texture onto a particle system?

Writing this makes me wonder if the changes I made to the Texture pane of the Particle System aren't having an effect because once you comb the particles they are baked.

When the feather is horizontal:

When the feather is vertical:

And here, then, is the node structure that got it to work this far.  I'll be the first to admit node construction to me is trial and error with black magic; but I can see where Geometry at Position is probably not what I want -- I do know I tried a lot of constructions that felt like they'd make sense before settling for this!  Totally open to advice here!

For completeness, and because I know some community members like to play along, here's a reduced version of the image I threw
 together to give character to the feathers:

The Geometry node, which you're using, produces coordinates in world space, so the position, rotation and size of the object do affect the result. In a sense your texture is being projected, just as you suggest. Instead you should use the Texture Coordinate node.

The Generated socket gives coordinates from (0, 0, 0) to (1, 1, 1) for the bounding box of the object, regardless of the object's size.

The Object socket gives the coordinates in the object's local space.

I replicated your node setup, but used the Texture Coordinate node instead, and I skipped the Mapping node.

This image is with Object coordinates.

And this is with Generated coordinates.

The Suzannes in the images above are identical in every respect except being at different locations and rotated differently.

Consider taking a look at Bartek Skorupa's excellent explanation of texture coordinates, Manipulating texture coordinates like a boss, which goes into a lot more depth about how texture coordinates work.


How to share node value with another node to keep them sync How should I setup a driver to keep two values same across blend file?
Like ...
World > Mapping node > Z Rotation  value to Object > Mapping node > Z Rotation
It would be handy in case like when you reconstruct environment from equirectangular texture set for World shader and same texture is used for an object I reconstruct like here.

You can simply copy-paste the driver, the values should be the same.

RMB > Copy Driver from one Mapping node
RMB > Paste Driver into the second one
Done.


Why would a displacement with a periodic image not tile smoothly? I am using a periodic image of noise (1/f noise) to displace a plane, with the displace modifier, into a random lumpy shape. When I connect 2 surfaces the seam is clearly visible and I don't know why. The image is definitely periodic, and if I don't use UV space the texture tiles seamlessly in the middle of the surface, but always shows at the seam of 2 pieces

Any way to get rid of this so I can tile several planes seamlessly?

The problem is in the smoothing function. As one surface get's near one edge, it doesn't know how the curvature will continue on the other side and the smoothing function sets it as if the object ends there, using no interpolation between the disconnected edges. This happens from both sides of the common edge, and therefore it's quite noticeable.

To correct this, one must edit the vertex normals from each side, to include the derivation from one surface's normal to the other.
However this might be very tedious to do by hand, so I advise a good normal editor addon. For example, Y.A.V.N.E. has one function for this (the merge normals), and all one need is to join the meshes (if in different objects), select the edge vertices, merge the normals and separate the meshes again (if needed).


Render Blender's object with size defined in pixels Let's say I have a 3D scene in Blender - I need to make an orthographic image where 1 Blender's unit will be exactly 1 pixel. Camera from above the scene, looking down (vector (0, 0, -1)).

Please don't offer post-processing scaling in the another 2D editor - that will break the quality and accuracy will not be good enough.

How can I achieve this?

I don't know if I get what you want, but this setup seems to get something like that: I put some colored cubes (each has one of three shadeless materials) on the diagonal of a a 10px x 10 px square.

The camera is ortho and its orthographic scale matches the output size. Antialiasing is obviously off.

This is the output (tiny 10px by 10px image):

setting resolution to 100x 100 and ortho scale to 100 you get this somewhat bigger image, but still each BU is a pixel:

Obviously you can change the aspect ratio, but keep the ortho scale equal to the bigger X/Y pixel value, like this:

Maybe this can work for you...


What is the python script to export the selected meshes in .obj? I want to export my selected meshes in .obj in a relative path from the .blend file in python.

export obj to relative file path script:

import bpy
import os

blend_file_path = bpy.data.filepath
directory = os.path.dirname(blend_file_path)
target_file = os.path.join(directory, 'myfile.obj')

bpy.ops.export_scene.obj(filepath=target_file)

further export obj options:

bpy.ops.export_scene.obj(filepath="", check_existing=True, axis_forward='-Z', axis_up='Y', filter_glob="*.obj;*.mtl", use_selection=False, use_animation=False, use_mesh_modifiers=True, use_edges=True, use_smooth_groups=False, use_smooth_groups_bitflags=False, use_normals=True, use_uvs=True, use_materials=True, use_triangles=False, use_nurbs=False, use_vertex_groups=False, use_blen_objects=True, group_by_object=False, group_by_material=False, keep_vertex_order=False, global_scale=1, path_mode='AUTO')


How to select all faces that have no texture? I have a barn on which I have nearly finished the texturing, but there are many untextured faces, which all need the same texture. There must be a quicker way than manually selecting each face.

This image shows some of the untextured faces:

Note that I'm not using materials.

Select one of the faces which doesn't have a face texture assigned and press ⇧ ShiftG> Image.


Error importing several meshes from single dir I have been trying to figure out an error message I get with attempting to script blender to import all stl's from a dir, edit them, then export them back to the same dir with the filename appended.  I have had luck doing this with a single specified stl, but cannot get this to work so far with multiple files.  Here is the code I am using to try this with multiple files (it is very hamfisted, this is my first experience with python or scripting):

import os
import bpy
import sys

file_path = ("C:\stlfiles")
dir = os.listdir("C:\stlfiles")

for file_path in dir:
 if file_path.lower().endswith('.stl'):
  try:
   bpy.ops.object.delete()
   bpy.ops.import_mesh.stl(filepath=file_path, filter_glob="*.stl")

   bpy.ops.object.select_all(action='DESELECT')
   bpy.ops.object.editmode_toggle()
   bpy.ops.mesh.tris_convert_to_quads()
   bpy.ops.object.editmode_toggle()

   bpy.ops.object.modifier_add(type='BEVEL')
   bpy.context.object.modifiers["Bevel"].width = 0.056
   bpy.context.object.modifiers["Bevel"].segments = 2
   bpy.context.object.modifiers["Bevel"].profile = 1
   bpy.context.object.modifiers["Bevel"].limit_method = 'ANGLE'
   bpy.context.object.modifiers["Bevel"].angle_limit = 0.698132
   bpy.ops.object.modifier_add(type='SUBSURF')
   bpy.context.object.modifiers["Subsurf"].levels = 2
   bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Bevel")
   bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Subsurf")

   bpy.context.object.scale[0] = 10
   bpy.context.object.scale[1] = 10
   bpy.context.object.scale[2] = 10

   bpy.ops.object.select_all(action='DESELECT')
   bpy.ops.object.select_all(action='INVERT')

   bpy.ops.export_mesh.stl(filepath=file_path + '_exported.stl', check_existing=True,
    filter_glob="*.stl")
   bpy.ops.object.select_all(action='DESELECT')
   bpy.ops.object.select_all(action='INVERT')
  except:

   print ("Couldn't open file")

Here is the error I am getting (test01.stl, and test02.stl are in the stsfiles dir):

{'CANCELLED'}
Error: Traceback (most recent call last):
  File "C:\Program Files\Blender Foundation\Blender\2.79\scripts\addons\io_mesh_stl\__init__.py", line 151, in execute
    tris, tri_nors, pts = stl_utils.read_stl(path)
  File "C:\Program Files\Blender Foundation\Blender\2.79\scripts\addons\io_mesh_stl\stl_utils.py", line 261, in read_stl
    with open(filepath, 'rb') as data:
FileNotFoundError: [Errno 2] No such file or directory: 'test01.stl'

location: C:\Program Files\Blender Foundation\Blender\2.79\scripts\modules\bpy\ops.py:189

Couldn't open file
{'CANCELLED'}
Error: Traceback (most recent call last):
  File "C:\Program Files\Blender Foundation\Blender\2.79\scripts\addons\io_mesh_stl\__init__.py", line 151, in execute
    tris, tri_nors, pts = stl_utils.read_stl(path)
  File "C:\Program Files\Blender Foundation\Blender\2.79\scripts\addons\io_mesh_stl\stl_utils.py", line 261, in read_stl
    with open(filepath, 'rb') as data:
FileNotFoundError: [Errno 2] No such file or directory: 'test02.stl'

Can you point me in the right direction to resolve this please? Thanks in advance.

os.listdir only return name and extension and subdir for a Dir, you didn't indicate the relative directory path or absolute path for filepath to search the file by name.

You could use os.path.join() to join your path:

dir_path = ("C:\stlfiles")
files = os.listdir(dir_path) # if you just create a reference to dir, why not use it directly?

for file_name in files:
    if file_name.lower().endswith('.stl'):
        full_file_path = os.path.join(dir_path,file_name)
        pass #do something to full_file_path


Solidify with overlapping vertices I have the following simple "2d" animation of a Pentagon:

I'm trying to convert it to 3d using the solidify modifier, however, I'm getting very odd behavior right at the end when the vertices overlap:

Is there a way to fix this issue?  If not, what's the best way to handle it?

In part you answered your own question. Solidify gets confused, when at the end the vertices overlap. I don't know how you animated your mesh, but instead of animating all the way to the point, where vertices overlap, stop a very little bit right before that point, like 0.00001 units away.


Blender only renders one frame instead of the frames I selected I have made a smoke simulation (cache 17 GB) 300 frames (300 sampling with denoising on).

(I turned it down and off for troubleshooting).

I had no problem rendering it, but after I looked into the image stripe it shows that I had 13 (266-278) frames blank, so I tried to re-render those frames, but it is only rendering one frame and saving it {blender save file}.

How can fix this problem? I could not render with the sequencer on.

It is because you set Frame step value:

Set it back to 1

This value use to render every N-th frame, with skipping others.

Also, you have a video strip in sequencer (VSE). So blender render from sequencer instead 3d-scene

Remove this strip, or uncheck sequencer in post progressing tab:


Importing normal maps from obj/mtl I need to import a mesh with more than 100 normal maps and diffuse textures.
The mesh is in Obj/mtl format, and Blender loads  the mesh and the textures. However, it doesn't set the normal map as normal map: I need to check Texture/Image Sampling/Normal Map to get it working.
However, doing this to more than 100 textures is too bad.

How can I do this automatically?

This is obviously an old post that perhaps no one answered. However for the sake of information I will attempt to answer.
Firstly have you atlased the normal map and diffuse map?
This consists of using something like Unwrapper Pro to open the model and move each component part into an individual location to produce one set of UV's for the entire model. Then print out the UV's as a template and cut and paste the relevant parts of the various diffuse and normal maps to all fit onto one image. That is one image for the Diffuse Map and one for the Normal map.
Obj files can have both mesh groups and material groups. So while your model retains all the mesh groups you can select the entire set of UVs and assign it to one material group. So instead of having 100 material groups you have one and this should allow you to only have to set the normal map once.
This is the reverse of what most modelers do where they usually set up only one model group but have many material groups. This is also helpful if you have an animated model as mesh groups are usually where bones are added or weighted.
cheers


Is there a way to "virtually" rotate a face normal to get a different shade without actually rotating the face? I was wondering if there's a way to only virtually rotate a face so it gets its light from a different angle, yet the geometry stays the same (like a normal map, but manually face per face) So in essence - rotate a face's normal (which kind of conflicts with the meaning of "normal")

It's a low poly style where I want to have some shading like in a bump map, only it's very low poly and I'd like to design it face per face.

So f.e. - I have a face along an edge where I know its "virtual" angle is slightly more upwards (like bevelling an edge) - but the geometry regarding that face and the ones connected to it did not change.

Especially a problem in a corner where some of those faces would meet and if rotated in geometry intersect and would have to have additional faces that also have additionally different shades due to the geometry.

Cheers and thanks a lot!

What you are looking for are generally called Split-Normals, these are normal values that are stored independent of the geometry they belong to.

Blender has built-in support for them, and even has a modifier that allows basic editing. It can be found in the Properties Window > Modifiers > Modify and is called Normal Edit modifier.

It  provides basic control, but as of version 2.78, as  far as I know it can't be manually controlled as you desired. To best of my knowledge there is no builtin way to manually adjust per-vertex or per-face normals in Blender natively.

There may be third party addons that do allow this though.

One such example is Blend4Web's normal editor. The addon's greater goal is completely different, but if you are willing to install its considerable size it does provide normal editing tools among its functionalities. It can be found under the 3D View > Toolshelf > Blend4Web Tab > Normal Editor.

EDIT Fresh from the news page, it seems that for GSOC 2017 there will be a project tackling normal editing


How do you add orderly wrinkles to faces? I want to add some wrinkles on the side faces of the lid like the left image

I'm a beginner so detailed explanation would be much appreciated. Thank you.

If you want your lid to stay flat, so you can put a nice bevel on it, extrude the cylinder's cap-poly first. This will create a circular loop to hold that edge.
Get enough separations in the side of the cylinder to hold your
detail.
Select the parts you want to push in, the "valleys".
If you have a lot of those, after selecting the whole row of edges, use Mesh > Checker Deselect to get the pattern of selection, that you want
Shrink/Fatten the faces in or out (Alt + S)or Extrude them into or out of the cylinder (E) by using Individual Origin as the Pivot Point.


Change tile grid shape I'm trying to change the tile_grid_shape in the UV Editor window located in the UV Editing workspace. The problem is that the only way to do this that I found is bpy.context.... but using context is not an option in my case since the context is actually a different window. If I change the context to be UV Editor it changes the tiles in that window and not in the one in the UV Editing workspace.
This is what I tried with no success:
for area in bpy.data.screens['UV Editing'].areas:
    if area.type == 'IMAGE_EDITOR':
        area.type.uv_editor.tile_grid_shape[0] = 3

In this case I'm getting an error that 'str' object has no attribute 'uv_editor'
I also tried this:
bpy.data.screens['UV Editing'].uv_editor.tile_grid_shape[0] = 3

Still no success though. I'm getting an error that 'screen' object has no attribute 'uv_editor'
I got it from here, but it doesn't work. I guess they changed it and didn't correct it here.

I also know of one other method with context override where you copy the context and do whatever you want in the new one, but the problem with that is that you can't delete the newly created context and when using it in a big batch it makes thousands of context copies and takes a lot of memory that you can't clear unless you restart Blender.
So does anyone have any idea how to do this thing?

Is a property of the UV editor space of the Image editor space.
Same deal as How to change View3DOverlay.show_stats?
The property is a member of the UV editor space. https://docs.blender.org/api/current/bpy.types.SpaceUVEditor.html#bpy.types.SpaceUVEditor.tile_grid_shape
following references will see that the UV editor is available from the Image editor
bpy.types.SpaceImageEditor.uv_editor

Test in python console.
>>> for i, a in enumerate(C.screen.areas):
...     i, a.type
...
(0, 'PROPERTIES')
(1, 'OUTLINER')
(2, 'IMAGE_EDITOR')
(3, 'VIEW_3D')
(4, 'CONSOLE')

>>> space = C.screen.areas[2].spaces.active
>>> space
bpy.data.screens['UV Editing']...SpaceImageEditor

>>> space.uv_editor
bpy.data.screens['UV Editing'].uv_editor
# Wrongly represents itself.

>>> type(space.uv_editor)
<class 'bpy.types.SpaceUVEditor'>

>>> space.uv_editor.tile_grid_shape[:]
(1, 1)

>>> space.uv_editor.tile_grid_shape = (2, 1)

Re error area.type is a string (see line above) and has no tile_grid_shape property.


Bake mesh not clickable I'm trying to make a fountain and I have finished the fluid baking...Now I want to bake the mesh it doesn't allow me to bake it.
I have to bake it in the domain

The reason for this is not resumable data. Click on the button near the cache . Hope that helps!


Problems with compositing and Shading settings There is a problem setting up the shadow of my CGI model that I want to add to the camera image on the compositing screen. I can’t intervene in the shadows.
In the tutorial I watched (https://youtu.be/hymtATx1QXw 23:35) I make the node settings in the Compositing tab, but the image I get does not change the shadows and the reflected image is different.

Not: I uploaded the HDRI image but there was no shadow so I put a point light. But I did not remove the HDRI image. If you say it may be related, I will throw the screenshot.

I fixed it by adjusting the settings of the screen and invert nodes.


Create circular object from a 2d mesh 1st of all i'm a beginner in blender or in modeling in general
so my apologizes if I use the wrong terms to explain my issue.
At some point I want to "transform" a side view 2d shape, in a circular object that rotate around an edge of it.
so having this 2d shape:

that I want transform to a 3d shape with rotation around the edge in white (that is in 0,0):

To "achieve" that result above, I tried using some modifiers:

Solidify to get some thickness (of 2m here)
Array of 180 item + Empty with 2degree rotation in Z
Weld to try to enhance this aweful result

but the result is still bretty bad in the end and the generated mesh is pretty bad too (I'll export it in .stl)
So at this point I don't know what is the proper technic to achieve this kind of "circular extrusion".
In addition I'm trying to use modifiers because I didn't finished the initial shape yet and I really like the non-disruptive way.
any help would be welcome
Thanks

Try a Screw Modifier. Just don't increase the "Screw" count (so it doesn't go "up"). You can increase the number of divisions from the modifier panel, and change the shape of the resulting object by transforming it in relation to it's origin (move it around in edit mode):


Remove doubles isn't removing overlapping vertices As you can see, I have vertices on top of vertices, I'm trying to delete them using delete doubles but it says there are 0. But they're clearly overlapping perfectly. I set my merge distance to 0 but they still wont delete. I'd rather not manually delete all of them so if you guys could point out what I've done wrong please help.

I didn't realize you needed to select vertices for remove doubles to have an effect. To remove doubles on the whole model, select everything with A first (you may need to press it twice if you have anything selected beforehand).


How do I hide an emitter plane while keeping it's emitted light visible in a cycles render? This is how you used to be able to do it in blender 2.79
https://www.youtube.com/watch?v=_lsRQQLFVEY

I can't find this option in 2.8

In the object settings, uncheck "Camera" under "Ray Visibility";

This;

Becomes this;

This setting removes the emitting object from view (while leaving it's light) regardless of whether you are looking through a camera or the normal viewport.


Boolean this made arch wtih a plane I'm trying to boolean this made arch wtih the plane, goal is to the remove the middle part of the wall inside Arch to make is open. Thx

You need to model the part you want removed as the "tool" for the boolean modifier.
In the image, if I Boolean Difference the arch from the plane, it creates a cutout of the arch in the plane as you can see on the left. If you only want the inside part of the arch to be removed from the plane you have to model that part as the tool for the boolean modifier, as on the right.


Why can't I create a new action? I am new to blender and am having lots of fun using it. I created a character of an online template and finished binding my armature. I was going to create a new walking action when the new action button was disabled. Can someone please help me.

Your Dope Sheet in Shape key editor mode. Switch it to Action Editor.


Shade Smooth looks weird I created a dice, the last step should be "Shade Smooth". After that, the surface looks weird. The problem is after render the same. Does anybody how to solve it?
Left one is before Shade Smooth, right one after it.

this is the standard way to create a hole inside a plane (you can do it manually or with few clicks with loopToops addon): as you can see, there are only quads and this will allow you to add subdivision modifier or shade smooth with not strange artifacts


how to turn off moving objects by holding RMB? I use for selecting RMB, but blender also has RMB for moving (hold and move mouse), but my computer is not superfast and my model is complicated enough to slow it down a little (over 800 000 verts.) and when I want to selcet a mesh, the slowed down computer automaticly thinks, that I hold it and starts to move the object. Is there a way how to turn off this function?

Go to User_Preferences->Input->Mouse->Tweak_Threshold and set it to higher value :


TIFF alpha channel glows on edges When I try to use an image that has an alpha channel, the image has glowing around the parts where there is transparency. Below are images to better explain my issue. Both are using the same image with exactly the same node setup and Cycles render engine.
In Blender 2.90.1 it looks like this:

and in Blender 2.79 it works as expected:

This is the image i'm using. It is a TIF file created in Photoshop

Is this a bug or has something changed in the way alpha is handled?
I haven't used 2.90.1 version for long as I only recently updated from 2.79
EDIT: After packing the TIFF file into the blend file, the glowing disappeared. Then after unpacking the image and adding it to a new image texture node, the  glowing appeared again.
Looks like Blender 2.90.1 treats external and packed files differently.

With image packaged into blend it works for me as expected. The issue appears when TIFF is unpacked and used linked from directory. Troy_s probably will be able to explain the issue, I don't have a knowledge in this area. I can just say how to avoid the issue here.

your TIFF doesn't use Transparency but channel "Alpha" (that is also why option "Save Transparency" is grey when you are saving your TIFF

to avoid the issue copy alpha channel and paste into Mask channel for "Background" layer.

Then when you save with "Layers", "Save Transparency" is available.

This TIFF is rendered fine in Blender.


How to batch rename bones and their corresponding vertex groups? If we have modeled a character or device or something that has many identical moving parts (arms, tentacles, etc.), and rigged one instance of such a part, how do we get all of the bones with the same names joined as a single armature, and also get all of the meshes joined with the vertex groups that correspond to those bones?

In the example above, the character has only six legs (the wrong number for an octopus, just to add to the poor guy's problems), but what about something with even more appendages, like a centipede? What about a spider robot with very complex leg rigs? In cases like these nobody wants to go renaming each bone by hand, and then renaming each vertex group by hand.

So, we need an add-on or a Python script for batch renaming. The only add-on I've found for batch renaming is too simplistic - just for renaming at the object level. And although I found and tried a script for renaming bones, I got an error when I ran it. I also found a script for renaming vertex groups, but I haven't found any scripts that handle the mesh and armature data together.

What is the most efficient way to accomplish this?

Usually an armature is the parent of the mesh that it deforms (from using ⎈ CtrlP->Automatic Weights), this means we can get the mesh deformed by the armature by looking at it's children property. We can then rename both the bone and vertex group to a new name that is unique among all armatures allowing a conflict free merge. Adding the rig name to the bone name so that "Bone" might become "Leg1_rig_Bone" seems like a good approach.

import bpy

for rig in bpy.context.selected_objects:
    if rig.type == 'ARMATURE':
        for mesh in rig.children:
            for vg in mesh.vertex_groups:
                new_name = rig.name + '_' + vg.name
                rig.pose.bones[vg.name].name = new_name
                vg.name = new_name


Linked scene in VSE doesn't run Python script I'm making a short movie in which one scene, I hide part of the mesh of a character using some python code in a Register .py file, like this:

bpy.data.objects['spider_eye.L'].modifiers['Mask.001'].show_viewport = 1

which hides the mesh in the animation file (anim.blend). I also have another blend file (vse.blend) where I linked the scene from the anim.blend to edit it but in the sequencer viewer of the VSE, the mesh is not hidden.

I'm guessing that when a scene is linked, the added code is not executed.

Is there a way around this?

Thanks for your help.

Make sure, in the User Preferences (Ctrl+Alt+U) you have Auto Run Python Scripts selected in the File Tab at the very bottom.


How do you refresh Object Mode after quitting Edit Mode When I switch back to Object Mode from Edit Mode, the displayed model still looks the same as it was before I changed the polygons (Texture, Rendered and Solid view, makes no difference):

Is there anything to force refresh? it works just fine when I edit with Sculpt Mode instead, but I needed to remove some vertex in this part.

Check if you have added Shape Keys to your model. This might have happened by accident. Shape keys allow you to define vertex location changes relative to the original model, and animate those location changes using a value slider. Kind of like recording a coordinate difference / offset. For character animation, this can be useful (search for corrective shape keys on this site).

When you add a new Key to a model in Blender, its influence parameter is set to 0.0 by default. That means, if you go back out to Object Mode, your model jumps back to its initial state. It's easier to show this in a short video:

As you can see, I'm adding the Basis Key (that's always the unaltered stage of the model) and a Key 1 to the model. I'm going to Edit Mode while Key 1 is still active, so I am defining a change within that key. When I tab back out to Object Mode, my changes disappear. But when I slide that Value Slider all the way to 1.0, my changes are back in place.

If this is your problem, Slide your Key 1 value to one, and then first create a new shape key from mix, and then remove all shape keys, while taking care that the new mixed key is the last one you delete:


How to subdivide concave face into quads I'm aware of bpy.ops.mesh.vert_connect_concave() and the result is similar to what I'm looking to implement. However, with bpy.ops.mesh.vert_connect_concave(), it adds edges to an already existing vertex.

This is an example of a selected concave face.

This is what I'm hoping to achieve. The "cuts" could go either vertically or horizontally.

I was thinking of going through every outside vertex and performing the concave test. If it passes, add an edge, or add new vertices and edges.

Is there an algorithm for this? The constraint is that the edges are always straight: vertical or horizontal. Think floor plans without any diagonals.

Edit: Fixed order of images

Edit: Wording

Edit: Would adding edges in all four directions to every vertex that has an interior angle greater than 180 be a better solution?

Download TinyCAD script from GitHub:
https://github.com/zeffii/mesh_tiny_cad

File > User Preferences > Add-ons > Install from file...
choose the zip file

Edit mode + Edge select > C
select an edge, and another one you'd like it to extend to.
Right-click to finalize selection.

W to bring up specials menu > TinyCAD > VTX | AUTO

I'm not having much luck with this script over here.
I'm not a pro at it, but I'm hoping it gets you in the right direction.

You might need to tweak it, but at least if gives something to start from.
Or file a bug-report on GitHub, if it's not doing what you need.

I've used a similar feature in drafting class, so I get what you're going for.
Hope it does better for you.


Is there a way to remove dublicate objects on top of each other in Object Mode? I have imported an fbx file of huge size with millions of verts. It seems something has gone wrong and unity file was converted into fbx with some errors.

There are around 5 dublicate objects on each object.

Is there any quick way to remove those dublicates without spending too much time on deleting objects manually?

If they have the same names they probably have a trailing .00x number behind them. So you could just pick them from the outliner and delete them.

alternatively select the ones you want to keep > ctrl + i to invert selection and delete.


Why is the wave texture not texturing these spheres? In this setup the plane, the cube, the uv and ico spheres, all these are assigned the same material.

The Rings mode of the Wave Texture node radiates from the object center in concentric shells. Because of that, the surfaces of your spheres are passing through a single shell, and therefore a single color. If you look at the edges of your images, where the distance from the center is a bit further, you can see that they are darkened:

To fix this, you can offset the location (or scale) with your mapping node:

Alternatively, if you wanted to make all the rings radiate from the same point, you could select an object in the bottom slot of the Texture Coordinate node (I chose the plane):

As a side note, the Icosphere looks pretty cool if it's scaled a bit differently:


How to create piles of snow on a mesh? For example on tree branches like this:

Image from Wikimedia commons

There is no doubt that the best result can be generated by using Particle or Physics system, which is a bit complicated to talk about in a few words. A quick-and-dirty way is shown as below:

Switch Transformation Orientation to Normal, try to find and select a single vertex which Z axis towards up (or nearly up). Press ShiftG1 to select nearly all possible upward vertices by tweaking a reasonable Threshold value, as shown in Figure 1 and 2.
ShiftD to duplicate the selection, then P1 to separate it as a new mesh. Now you can freely tweak it with a few modifiers to make a nice pile-looking snow cover, particularly with the Displace modifier. As shown in Figure 3.


Vertex position for linked object with armature I want to get the final position of a vertice with an armature. I know how to do it in a local object, but the problem is how get the final position if the mesh is linked in the scene( the typical character linked with proxy in a scene)

I can get the initial position with this code, but whithout the armature modifier.

import bpy

a = bpy.context.object
if a.type == 'ARMATURE':
    grpname = a.proxy_group.name

    grp = bpy.data.groups[grpname]
    for o in grp.objects:
        if o.type == 'MESH':
            print(o.name)
            data = o.data
            for v in data.vertices:
                print(v.co)
        print("===================\n")
else:
    print("No armature selected")

To get the final in local I have used:

  apply_modifiers = ['ARMATURE', 'LATTICE']
    for m in myobj.modifiers:
        if m.type not in apply_modifiers and m.show_viewport is True:
            m.show_viewport = False

    # Apply modifiers
    me = myobj.to_mesh(scene=context.scene, apply_modifiers=True, settings='PREVIEW')
    myvertices = me.vertices

After ask the question, I had an idea:

import bpy

a = bpy.context.object
if a.type == 'ARMATURE':
    grpname = a.proxy_group.name

    grp = bpy.data.groups[grpname]
    for o in grp.objects:
        if o.type == 'MESH':
            print(o.name)
            for m in o.modifiers:
                print(m.name)

            # Apply modifiers
            me = o.to_mesh(scene=bpy.context.scene, apply_modifiers=True, settings='PREVIEW')
            myvertices = me.vertices
            for v in myvertices:
                print(v.co)

            if me is not None:
                bpy.data.meshes.remove(me)

        print("===================\n")
else:
    print("No armature selected")

You can use the same code that I used in local mode.


create flat faced edge im relatively new to using blender and i was wondering if anyone could help me find the quickest way to create a flat face on an odd angle with more than 3 vertexes. Here is an example of what im looking to achieve. (This was done by putting a cube up to the corner and using Boolean to delete the corner) any help would be awesome :D

You can use the Mesh > Bisect operation for this.

Just look from the side angle you want to cut from, draw a line over your geometry with LClick+Drag, and release.

There are some settings in the Operator Panel. Enable Fill and Clear Outer to get the cut to produce a face like in the GIF above.


Bones moves weirdly after applying IK I'm trying to apply IK to leg bones. Leg bones are rotating correctly. After applying IK constrain to lower leg bone connected to copied foot bone, it starts acting weirdly. Moving that copied foot up rotates knee to the side for some reason. I expect the knee to be aim forward while I move leg up.

What am I doing wrong? Or am I expecting something that I shouldn't expect?

Blend file: https://drive.google.com/file/d/0B9zDr_Z5hiZAM3hvYnI4SjZpZUU/view?usp=sharing

Thanks for any help!

The IK solver will try to go toward a pre-existing bend: in your rig the upper leg bone is bending on the  left (of the mesh) more than on the front, so the IK solver follows that directions (left - left/front).
You can change this behaviour in many ways:

1) the simpler: in edit mode push the head of the leg bone backward and pull the knee joint  toward the front; also the foot bone can go backward. In this way the Ik solver will naturally go more toward the front.

2) The classic: create a new bone (I called it Pole Knee L), parent it with the IK foot controller, and in the IK constraint panel, set it as "pole target", fine tuning the "pole angle" parameter for correct behaviour; in this way the knee joint will always point in the direction of this new bone (which can be animated, for complete control).

3) Other ways: constraints that limit rotations, modifying IK bones stiffness, and others that maybe I don't know!

I suggest you also to turn off the "inherit rotation" option of your foot bone, and turn off the "deform" option if IK and pole controllers.


Extruding a circular shape from a non-circular object I need to extrude a circular shape from a surface that's basically just a grid of quads. What's the best practice to do this without screwing up the topology too much?

I basically want to have a circular face I can extrude, in order to have a cylinder like protuberance on the object, something like this:

Depending on your mesh, you will have to select a number of faces to use as a circular entrance to the hole. The density of your example image suggests to use 2x2 (4) faces.

Select the faces and remove them. X
Position the cursor at the center of the desired hole and set the pivo point to cursor mode.
Select the vertices and make them to sphere ⇧ Shift⎇ AltS > 1 > ⏎ Enter.
Smooth them with the loop tools space option.
Add a circle with 8 vertices and bridge the remaining geometry. You know have a perfectly circular piece of geometry which you can extrude inwards.

The resulting topology


Better way to join bezier curve to bezier (half) circle? Conceptually, I am trying to achieve what Merge can do with a mesh: select an end vertex from each of two bezier paths and merge them together with only one vertex as the result.

This is the only way I've come close to acceptable results, but there are still imperfections, so I'm wondering if more experienced modelers have techniques to share.

Add a Bezier Circle
Select all the vertices
Change the handle types to Free (in essence, lock in the vertex control point parameters)
Select two adjacent vertices, hit X, choosing to delete Segment (giving you a hemisphere)
Add a Bezier Curve
Position the curve so one vertex is near an end vertex in the hemisphere curve
Select the two vertices that you positioned close to one another
Press F to Make Segment

When I do that, no matter what my normals are doing, I get a loop as a segment between the two vertices.  To minimize this, before step 8 I have tried changing the handle type at the end of the bezier curve to be free and then scaled down to near zero its control point on the side towards the hemisphere, and doing the same to the corresponding control point on the vertex of the hemisphere that I'll be joining.  But I still get an additional segment (to be expected given the method, but not what I want).

This is in Blender 2.6, if that matters.

After step 8, click LMB once or twice to select the useless point, then X > Vertex to delete it.

Actually, it's recommended to enable Snapping so that the two vertex can be overlapped, that brings the new segment with zero length.

You can also use a nice addon called Curve Tools (by Mackraken). I recommend to use the modified version Curve Tools 2 (by Mackraken and guy lateur), which can handle this perfectly while keeping curvatures.

Added a short demo video (01:35).

Here is the lastest version, in case you cannot access Blendernation.com. (File > Download)


Morph between different facial expressions? I want to use Blender to make a dynamic character. I want to know if it is possible to make a number of keyframes for facial expressions and then have the ability (using python's game engine) to choose which face I want the current face to morph into?

Ok, so I have been trying to master Python scripting with Blender's Game Engine. I would like to make a basic game where you can tell the face, within the Python Console, what expression to do, running code from the Text Editor. Here is some code I wrote in the text editor after making two keyframes 'Basis' and 'Surprise' in Blender Render:

def Face(Expression):
if Expression == 'basis':
    C.object.data.shape_keys.key_blocks['Basis'].value=0.0 #I believe this should make the animation morph to the Basis as defined in my key frame
    print('basis')
elif Expression == 'surprise':
    C.boject.data.shape_keys.key_blocks['Surprise'].value=1.0 #Again this is defined in my key frame
    print('surprise')
else:
    print('invalide entry')

When I click Run Script it seems to compile with no errors. When I enter the Python Console and type "Face('basis')" I get the following error:

Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
NameError: name 'Face' is not defined

Firstly is the game engine capable of making a game where you can change character's facial expressions. Would it be better to manipulate bones in the face rather than morphing between key frames? And, how do I call the function I wrote in the text editor in the Python Console? I also want to know if I called the 'object.shape_key' from C properly from the python code?
Very detailed Q I know, thanks for the help guys!

There are at least two ways to create and animate facial expressions, not even involving python (although it's possibly to automate this):

Shape Keys - allows you to deform mesh vertices and blend multiple "states" together and also animate
Armature - a skeleton to control the mesh, with strong control over deformation using vertex weights, but also more complicated

I recommend to try out Shape Keys:

Start Blender and remove (X) the default cube
Add a Monkey (aka Suzanne)
Go to Object data tab in Properties Editor
Click the plus button + in the Shape Keys panel twice (will create Basis and Key 1)
Switch Suzanne into Edit Mode (Tab)
Deselect all (A) and pick some vertices, e.g. the right eyebrow
Enable Proportional Editing if you wish to deform nearby, non-selected vertices as well
Move the vertices up a bit (G)
Go back to Object Mode (Tab)
With Key 1 in the Shape Keys panel selected, move the Value slider to see the transition between the base shape and the keyed shape.
Use I over the slider or right-click and pick Insert Keyframe to animate the value and thus the facial expression transition!

You can create a Shape Key with Python like:

shapekey = bpy.context.object.shape_key_add(name="Key", from_mix=True)

See the API docs - Object.shape_key_add for details.

The value slider can be animated by inserting a keyframe, here's the most simple way:

# we stored the shape key reference above in the variable "shapekey",
# which should be equal to bpy.context.object.data.shape_keys.key_blocks['Key']
shapekey.value = 0.3 # set value
shapekey.keyframe_insert(data_path="value", frame=15) # now keyframe 0.3 at frame 15

See the API docs - keyframe_insert()

More on Shape Keys:http://wiki.blender.org/index.php/Doc:2.6/Manual/Animation/Techs/Shape/Shape_Keys

If you look into Armature pose animations, make sure to have a look at the Pose Library panel!

It's also worth to have a look at the NLA editor (non-linear animation). It allows you to blend multiple Actions together:http://wiki.blender.org/index.php/Doc:2.6/Manual/Animation/Editors/NLA


How to select creased edges? I've gone through my model and manually selected edges to be creased. I'd like a way to reselect these creased edges long after they have been deselected. Could anybody help me out with this?

In edge selection mode select a creased edge, go to select>select similar>crease and you should be fine


Edges not properly displayed in 3d view I worked on a model in large scale and then scaled down the model. Now I am not able to clearly see the edges in the model in 3d view. Is this a known Blender issue. Is there a way to increase the thickness of the edges that are displayed in the 3d view port?

Try to adjust in properties panel the start clip.Should solve the problem. Or you can try to turn your modifiers off in the viewport to sea the lines more clearly.


JPG decompressed and compressed again, will it affect colors and color space? I found easy to add a black frames to my photos with Blender. I just add some scaling and offset in VSE and render one image. I am wondering is that process affects colors or color space of my photo? Is my JPG decompressed and compressed again?

The color space is the same: sRGB, so expect no transformation there, but know that Jpeg is a compressed format, a lossy compression format designed to make file sizes small at the expense of quality. A terrible format if you are applying transformations.

Every time you decompress an image, change the geometry or color, and re-compress the image again you will get new compression artifacts. Do an image search for "macroblocking" and "compression artifacts" to understand the horrors of the JPEG format.


Access color channels independently of alpha with Cycles? Is there any way you can access  the colour channels of image textures without having the alpha subtracted from them? There is both an alpha and colour output from image texture nodes but colour output uses it for transparency in cycles but not in lookdev (Eevee). This creates a discrepancy between the lookdev output and cycles render. This has mainly occurred as an issue when working with game textures that are using the alpha channel as another texture map and the other maps in RGB channels are then disrupted as it's using that channel for their transparency. I've tried pulling the colour channels individually and recombining them to no avail is there any way I can pull out just the raw colour channels?

I'm not sure whether this is considered a bug. However the behavior in Eevee seemed to me to be correct response as no functionality is lost as there is already an alpha output that can be mixed back with the colour channels if/ when it's actually needed. Alternatively having more output options on the image node would fix this issue.

With the Image texture node selected in the node editor, enable the Options panel (N) and turn off the Use Alpha radio button. Use a separate RGB node if you want to use individual channels. If you need the texture with alpha too, then add another Texture Image node and use it with alpha this time.

I hope that helps.

Alex


A Disabled User in need of Suggestions/Help (UI Question) I have a minor case if Cerebral Palsy which affects my left hand therefore using some of the keyboard shortcuts are impossible for me to use.  I’m using Blender 2.8.

Just a few Examples of the problem keyboard shortcuts (in Windows)…

Ctrl+Alt+LMB for (Bridging Edgeloops)

Shift+Ctrl+ALT+C for (Set Origin)

I have tried making Macros but they are too limited.

I’m hoping someone has any suggestions,

You might want to look at programs like Stroke Plus. It allows you to add multi-key keyboard shortcuts to mouse gestures,without having to take up more shortcut keys on a already crowded keyboard.
Really almost anything you can do with a keyboard such as type in commands or strings like an email address. You can assign gestures globally or per-program.
See the video on the home page for a quick explanation.
I have used this for years to speed up programming.


Glitching normal map artifacts I'm getting strange artifacts in my normal map as you can see from the photos. Yes, I've checked all the normals and recalculated them several times. Yes, I have removed all doubles. Yes, All scale/transforms are reset. Yes, no other objects are overlapping. Yes, The object is large enough where it wont effect baking. Yes, I've tried baking both tangent and object space. I'm out of ideas, I am using Blender 2.81.

The ray distance has to be non-zero, increase it to avoid the problem.


Black drawings showing as white I'm in the Blender render mode, not Cycles. I created a texture with an alpha channel and drew on it with a black-coloured brush, enabled Z Transparency on the material it was applied to and enabled the Alpha influence in the Influences tab, only to find the black drawing is white (see below).

I'm not sure why it's doing this. Is it because of the material behind it also being black? I'd like to know how to fix this problem.

Okay I finally have it. All I had to do was enable the Colour field in the Influence tab via the texture section. It works fine now!


Camera: Focus Object shift Is it possible to adjust a camera's focus when DOF is locked to an object ?
As in: shift focus forward or back relative to dof.focus_object ?

You could try parenting an empty to your focus object, set with constraints to always point towards the camera, then have a second empty parented to the first, that moves along the local axis towards or away from the camera, and set your DoF focus to that empty instead. Then you can have the DoF moving along a line from your camera to the object you want while being able to control the distance.


Python controle Constrain to Image Bounds is it possible to controle True/False checkbox from "UV/Image Editor > UVs > Constrain to Image Bounds" via Python Console ?

Look in info area

In this case if we open an info window and toggle the setting in the image editor

We see the property is lock_bounds of the uv_editor settings of the image editor space.
Python console code to get there, in same screen. Beware: currently trying to auto complete an image editor  space from another (other than context) screen core dumps my 2.8 build

>>> for i, a in enumerate(C.screen.areas):
...     i, a.type
...
(0, 'PROPERTIES')
(1, 'CONSOLE')
(2, 'OUTLINER')
(3, 'VIEW_3D')
(4, 'IMAGE_EDITOR')
(5, 'INFO')

>>> a  = C.screen.areas[4]
>>> s = a.spaces.active
>>> s
bpy.data.screens['Scripting.001']...SpaceImageEditor

>>> s.uv_editor.lock_bounds = True
>>>

Although can set without, for the menu to show, mesh object needs a UV map and be in edit mode.


Pie menu and limited viewport shading options (show subset of an enum) So most code exmaples I find are using the option to list all shading options

pie.prop(context.space_data, "viewport_shade", expand=True)

But I would like to only show 3 and have the feeling that I have to create a new
class operator to execute the code like:

bpy.context.space_data.viewport_shade = 'SOLID'

Am right with that assumption?

nope, to display a subset of an enum you can use wm.context_set_enum

        f = pie.operator("wm.context_set_enum", icon='SOLID', text='Solid')
        f.data_path='space_data.viewport_shade'
        f.value = 'SOLID'

        f = pie.operator("wm.context_set_enum", icon='WIRE', text='Wires')
        f.data_path='space_data.viewport_shade'
        f.value = 'WIREFRAME'

You might use a loop to reuse some code:

        modes = [
            ["SOLID", "SOLID", "Solid"],
            ["WIRE", "WIREFRAME", "Wires"],
            ["BBOX", "BOUNDBOX", "Bounds"]
        ]

        for ICON, VALUE, TEXT in modes:
            f = pie.operator("wm.context_set_enum", icon=ICON, text=TEXT)
            f.data_path='space_data.viewport_shade'
            f.value = VALUE


(Blender Game Engine) How can I make scene/layer visible through a certain object without using python? I am needing a python-free way to make a layer or scene ONLY visible through a certain object. I want to make like a portal effect where you look through an object into another layer or scene. If anyone knows how to do this, please let me know! I would very much appreciate it!

General idea of making a portal: you have a camera that sees what the portal should show. Then the output of the camera is rendered to the other portal as a texture.

Without python this is not possible though.

So here's a python way to do it (who would have thought? ;) ):

First we create the portal:

You can use whatever mesh you want but a plane mesh is probably the best. Name it something fitting, e.g. "portal". Make sure that when the object isn't rotated (=> rotation of 0,0,0) the object's normal(s) is/are facing towards the -Y-axis.

Next create a new image in the UV/image editor. Make sure that the aspect ratio of the image is the same as the one of your camera. E.g. if your resolution is 1920*1080 the image's resolution could also be 1920*1080.

Then select the portal, create a material and make it shadeless. Head over to the texture tab and create a texture. Assign the created image to it and unwrap the portal (U in edit mode). Set the texture's source to Generated and its mapping coordinates to UV. If the portal's dimensions aren't the same as the image's you should also move the UVs to the image's center.

Last thing left for the portal is the logic. Add an Always Sensor and a Python Controller. Activate the sensor's true level triggering. Now the controller: Choose Module instead of Script and type portal.main into the text field. Add a new text data block in the text editor and paste in the portal script from below. Name it portal.py. Then add two string game properties. Name one camera and the other one image. The value of the second one is the name of the image you created. We'll fill the other one later.

Now we take care of the camera. So just add one. Again, choose a name that makes sense like "portalCam". You can put this name in the camera property we created moments ago.

Now the logic. Create a new script and paste the camera script in it. Name it something meaningful like portalCam.py. Add an Always Sensor and a Python Controller and activate true level triggering. Instead of choosing a module just choose the script that was just added. Create three string game properties, the first named camera, the second named portal and the third named reference. Put the name of your player's camera in the first property, the name of the portal in the second one.

The third property's value is the name of a reference object. It's the object the camera is referring to when calculating its position, so it's like another portal. The portal we created will look from the point of view of this reference object. You can use whatever you want, a plane (=> another portal) or just an empty would be fine. Add it and put its name in the reference property of the portal camera. All that is left to do is positioning and rotating it. The object's local Y-axis is the direction the camera will be looking in. To check the local transformation just hit ⎇ AltSpace and select local.

And now you're done! The portal shows the output of the camera which moves relative to the player camera's movement.

Here's an example .blend:

Scripts:

Portal Script:

from bge import logic, texture

scene = logic.getCurrentScene()

cont = logic.getCurrentController()
own = cont.owner
portalCam = scene.objects[own["camera"]]

matID = texture.materialID(own, "IM" + own["image"])
map_png = texture.Texture(own, matID)

source = texture.ImageRender(scene, portalCam)
source.background = (scene.world.backgroundColor[0]*255,scene.world.backgroundColor[1]*255,scene.world.backgroundColor[2]*255, 255)

map_png.source = source

def main():

    map_png.refresh(True)

Camera Script:

from bge import logic
from mathutils import Vector, Euler, Matrix
from math import pi

#getting all the objects
own = logic.getCurrentController().owner
scene = logic.getCurrentScene()
cam = scene.objects[own["camera"]]
portal = scene.objects[own["portal"]]
empty = scene.objects[own["reference"]]

#calculating the position of the portal camera
rotmat = empty.worldOrientation*portal.worldOrientation.inverted()*Matrix.Scale(-1, 3, portal.worldOrientation*Vector((1, 0, 0)))
diff = cam.worldPosition-portal.worldPosition
diff = rotmat*diff
own.worldPosition = empty.worldPosition+diff
own.worldOrientation = empty.worldOrientation
own.localOrientation = [own.localOrientation.to_euler()[0] + pi/2, own.localOrientation.to_euler()[1], own.localOrientation.to_euler()[2]]


Snapping faces: wrong orientation I'm a new Blender user. I have a shape which is a cube section (I made it with the boolean modifier and two planes). Then, I set its origin on the center of one face, which I want to "glue" to another plane. I tried to use the snap tool, with the settings "face" and "center", checking the "align rotation to target" option.
As you can see on my screen, the mesh does snap, but with the wrong normal. In the end, the faces are not parallel to each other. Can you please help me? I've been wandering the internet for literally more than an hour.
Thanks

Blender is snapping with the "negative Z axis" of the origin point.
Adjust you origin rotation and it will work.

Enable Transform Only Origin option and Face snapping
Snap the origin to a face - it'll inherit it's direction (Z+ axis)
Rotate the origin 180° along local Y axis (so it's Z-)

Snap origin and rotate it 180° along local Y axis


How should I link objects from external .blend if they have modifiers? I'm starting to learn how to do asset management for a project by linking from external blend files. I haven't figured out a good workflow for linking objectes that have modifiers on them. It's particularly ugly when the modifers reference other objects in the library (e.g., lattice) What is the standard workflow for dealing with linked objects that have modifiers relying on other objects in a lbrary?

Here is what I've tried so far: In lib.blend, here's an object with a lattice modifier:

Here's how I link it in scene.blend:

1: Link the teapot Ctrl+Alt+O

2: To be able to place it on a table in the scene, I make it a proxy object: Ctrl+Alt+P

3: Now the proxy object lost its modifiers, so I link the lattice object from lib.blend, and add a lattice modifier to my proxy teacup. (this is just an example - I've actually got quite a few modifiers on my asset)

4: Since I'm moving the teapot, I need to move the lattice object along with it (to keep the deformations sensible), so I make the lattice a proxy object.

This seems clunky. Is there a better way to manage assets from an external blend file?

Usually the approach is to put all the related objects into a group, and then link that group.


Is there a quick method to make a sawtooth structure? Is there a quick/easy way to make the following shape?

I was making the following shape, and the method I ended up using was loop-cutting a box, then extruding all the top edges up. This gave me all the vertices I needed, but there was still a lot of removing and adding of faces to do.

I also tried using the Rip Fill tool, but that made a mess of my geometry.

I was curious if there was a better way?

For repeated shapes, the obvious answer is “make one copy, then add an array modifier”. You can apply the modifier if you want to further edit the geometry, otherwise you can leave it in place.


Renaming an obj based on a Vertex Group script I have a model with parts named obj0, obj1 etc which I am creating vertex groups with the same name for. I'm joing them together to edo and then After editing the model I split by vertices. I'm trying to rename all the original parts their name based on their vertex group name now using a script to save time. The following is what I have so far.

I have this which works when there's just one vertex group in the obj, but after splitting by vertex it keeps the remaining ones in. How would I edit this code so that the obj is renamed from the VertexGroups.active_index selected instead of the at the top of the list?

Thank you.

Use the active vertex group

import bpy

for ob in context.selected_objects:
    avg = ob.vertex_groups.active
    if avg:
        ob.name = avg.name


Armature rigging seems fine in Edit mode, but messed up in Pose and Object mode I'm not sure what is causing this but have a feeling it is simple. My armature rig is fine in Edit mode, but changing to Object or Pose mode flicks and sticks the right leg to the left. Anyone know what may cause this?

Go into pose mode. Press "A" a couple times until your entire armature is selected. Press Alt+G, Alt+S, and Alt+R until the bones are back where they belong.


How to set fast the same customizations that i had in the previus versions of Blender? I have installed the new version of Blender 2.83, is very cool but now i have lost all customizations that i had in the 2.80 version. For exemple "Quick Favorites" or the layout. So there is a fast way to import/export all  customizations that i had in the previeus versions?

Just copy the preferences files to the new version.
Look for the userpref.blend of the old version and copy it to the folder of the new one.

In Linux is usually in /home/yourusername/.config/blender/version number/config.

For Windows it should be in \users\ your user name\AppData\Roaming\Blender Foundation\Blender\ version number \config.


Animation twitches/jumps between Keyframes I'm currently working on my first 3D animation and stumbled upon this:
Blender animates the movement between my keys, but here and there there is weird twitching between them.

It's like there are invisible keys that the body parts just jump to instead of smoothly animating.
My F-Curves are set to Bezier (even though I tried Linear without any changes) and I used the middle mouse button to go down in the timeline to see if there were any keys I missed.
I used the blender rigify addon for the armature.
Blender 2.91
The Project:

If you activate foot_ik bone "Toggle Pole" button will be shown in the
side bar. - tetii

That was it! After toggling I saw that there was something seriously wrong with my legs. I deleted the key-frames and redid them, now everything works fine.
Thanks.


Hide the UV layout while in Texture Paint Mode? Is there a way to hide the UV layout while in Texture Paint Mode?

I understand the logic behind being able to see the texture you're painting on (and its UV layout), but sometimes I want to look at a reference image while I paint on my texture image. Having a bunch of lines covering the reference image is distracting.

Here is a related question, but I want to do the opposite.

If the mesh object is selected in Object Mode it is still possible to view the reference image without the UV layout over it. But upon switching to Texture Paint Mode, the UV/Image Editor switches back to the texture image and even after re-selecting the reference image the UV layout lines remain.

Just uncheck this option in the view menu:


I used the compositor to add blur effects but they are not showing up in my final render image? I followed a blender tutorial and made the Earth. I have a sun in the background that I added some blur effects to in the compositor. When I rendered my image, the blur effects on the sun don't show up. How do I render the final image from the compositor? Are there settings that I am missing? Here is a screenshot of the composited image above the rendered image.

Make sure you are sending the final image to a Composite node. The Viewer node only displays in the backdrop of the node editor.


Moving a bone within weighted mesh? I have a skeleton rig and mesh configured in blender that I have imported from 3rd party application.  The rig and mesh are already working together correctly in blender.

I would like to adjust the position of some of the bones to align with animations from another 3rd party application.

Currently 1 or 2 bones cause the mesh to deform incorrectly due to differences in bone position between the animations and the armature for my skeletal mesh.

So the question, is it possible to move the position of the bone without the attached mesh being deformed during the move and maintain the existing weight painting for the new bone position?

So for example in my rig the neck bone is positioned more towards the back of the neck surface, but the neck bone in the animation is more centered, so when I apply the animation the head of my mesh is artificially leaning forward due to relocation of neck bone.

When I try to move any bone in my rig the attached mesh moves with it

Hopefully the makes some form of sense :oo

Thanks in advance

Yes! you can move the bones within Edit Mode. this should keep all of you weight settings as long as you've already parented the mesh to the armature.


How to select particular edges with a python script? How to select all the edges through the YZ plane with a python script ?

update

I know this script which do it for faces but I don't know the equivalent for edges :

import bpy, bmesh

me = bpy.context.object.data

bm = bmesh.new()
bm.from_mesh(me)

for face in bm.faces:

    center = face.calc_center_median()

    if center.x == 0:

        face.select_set(True)

bm.to_mesh(me)
bm.free()

Armed with the extra information consider:

import bpy, bmesh

me = bpy.context.object.data

bm = bmesh.new()
bm.from_mesh(me)

EPSILON = 1.0e-5

for vert in bm.verts:
    if -EPSILON <= vert.co.x <= EPSILON:
        vert.select = True

bm.to_mesh(me)
bm.free()

Some clarification perhaps:

EPSILON represents a value that is close to 0. If you've ever inspected coordinates closely in Blender you will find a cut off point maybe at around 6 or 7 digits after the decimal where you start to encounter artefacts in the representation of that float. Because 0 and 0.0000012312423 are not the same number you can't simply do a check for equality with 0, instead you might check is the x component within EPSILON tolerance.

Here I make the significant digit 5 places after the decimal point, from practical experience i've found this to be sufficient.

>>> 1.0e-5 == 0.00001
True

The above will select just the vertices, from that point selecting the edges shouldn't be too difficult. Here's a quick implementation

import bpy, bmesh

me = bpy.context.object.data

bm = bmesh.new()
bm.from_mesh(me)

EPSILON = 1.0e-5
for vert in bm.verts:
    if -EPSILON <= vert.co.x <= EPSILON:
        vert.select = True

for edge in bm.edges:
    if edge.verts[0].select and edge.verts[1].select:
        edge.select = True

bm.to_mesh(me)
bm.free()


Speech driven facial animation Is there any way to animate face and lip sync with audio input using machine learning algorithms in Blender ? I mean how can I controll the rigs and give them a value provided by python script for. The idea is to do a dynamic lip synchronization.
I appreciate any help ! thank you

This is a wide area, but I did have one thought about it myself:
The eSpeak speech synthesizer can output phoenomes instead of sound. You could make something to line up shape key keyframes based on this, although timing might be an issue. You might look into either the eSpeak Python api for synthesis timing check on the words, or even try the Descript project: they might provide synchronization data for the layman.


Material rendering black By that I mean things with a specific shader are rendering black, though the shader will render if I disconnect everything except ye olde diffuse, glossy, and mix shaders

For brevity, here's the blend.

Today, I rendered again just to reaffirm the problem, but the model did render for some reason. At this point the shader was the exact one in the blend file I linked. Again, still an exceedingly simple shader at this point.

But when I attempt to plug something into the material output's displacement (I wanted to try the same texture data used in the mix shader's fac input, if it matters), the model renders black again.

The shader's preview in the outliner panel shows up properly

Not sure exactly what you are asking.

I took a look at your blend file and the only thing missing was a light. I just added a sun lamp and everything seemed fine. I noticed you had some emission shaders on some layers and not on others. Also the emission shader you did have was very far away and not pointed in the correct direction. It was lighting up nothing.

Hope that helps.


What's the difference between Bias and Distance? I'm creating assets for Unity3D. Reading and searching on Internet, even here in Blender Stack Exchange, i understand that the best way to bake (in order to optimize and have still good quality) is using the Blender Render instead of Cycles Render.

For this reason my question is related to Bias and Distance

I baked a lot but i can't still understand what is the correct meaning of these 2 stats; i search from wiki to sites like this one
Baking normal map - distance and bias difference? but i can't focus the point (damn my mind ^^).

What does each of them help to?

I know the Bias from wiki "Bias towards further away from the object (in Blender units)" . .  . but this . . . What does it means?

What is their role in order to improve the quality of my bake?

Is the "Distance" similar to a Cage?

Thank you a lot for anyone will help me to understand this thing

Distance is the distance between the High poly object and the low poly object (in blender unit).

Note that the distance is only taken into account on the Z axis , and the low poly mesh must be directly under the high poly mesh.
if you do any of the above wrong, the result will be an empty baked image.

Setting the distance too low will make your details not appear on your final baked image since the rays will die halfway before they reach the low poly mesh.

The bias is only related to the high poly object, it controls how much of the geometry is preserved , anything after the bias is cut off.

The black lines are where the rays start being fired down to the low poly object, the rays start from lowest vertex of the high poly object.The rays' length is determined by the distance value.

The red line is the bias distance,it also starts from the lowest vertext of the high poly object, but is fired to the opposite direction(upward).

The details between the black line and the red line are preserved and will appear on the resulting baked image.

The details after the red line (greater than the bias, shown in blue) are lost , and will appear on the baked image as if that area was a flat surface.

Setting the bias value correctly is important when the high poly mesh has curved,round surfaces.

Please feel free to edit this answer and correct it.


How can I configure blender to import a custom mesh from the shift + a add mesh menu? It may be useful in sculpting and character design for example for the body parts (head, eyes ...)

An existing solution
There is the Asset Flinger Add-on which might be interesting to you.

(....) Free Blender Add-on for simple mesh importing via graphical menu. It's aimed at 3D modellers who constantly import pre-made 3D assets from their libraries for building their highly detailed creations.
The Add-on also includes a drag-and-drop thumbnail generator for .obj files for Windows and Linux (....)

Make your assets, save them as .obj and go through the instructions for making thumbnails. All instructions can be found on that link.


How can I get a volume shader to use a texture with camera projection UVs? In the linked blend file I have a box with a volume shader with a texture cut out coming from an image file.
https://drive.google.com/file/d/1LpxQXZRF66g3nVZw7lU8kgAVEVJY9Ant/view?usp=sharing
There are two examples in the shader network of the cube geo. One that work with the texture mapped through object space and another where the texture goes through a camera projection UVs. The later doesn't work.
How can I get the volume texture to work with the projection UVs?
Thanks!

So apparently Volumes shader don't support UV coordinates. So I generated the projection vector using this method:
Camera projection without generating UV's?


Rig has disconnected from mesh when editing animated action I have copied a walk cycle action from one rig to another - from a male to a female. When the timeline is scrubbed the new action works fine. But, when I try to edit the bone's positions at a particular keyframe, it's like the rig is disconnected from the mesh. The rig moves, but the female figure it's the parent of stays still.

Perhaps this has to do with the fact that I made these adjustments yesterday and got it working, but I hadn't created a fake user for the copied action and it wasn't saved. Now that I've worked a little more with pose libraries and actions (which I'm just learning), I tried to delete some extra ones of both, and somewhere in that process it created something problematic in the file. I got a warning on that animation this morning that it was corrupted and I should 'sanitize' it. I had to look that up here to realize that meant press the lifesaver icon to make the action suitable for use as a pose library.

It's a small file so I'm just going to attach it, as what the solution is may depend on exactly what I've done wrong here.

You have enabled Delay Refresh on the Armature.

From the manual:

  When enabled, the bone does not deform its children when manipulating the bone in pose mode.

To make the mesh deform at all times, uncheck Delay Refresh.


The armature does not move with the mesh Hy I am making a video game character and I'm on the animation part, specifically rigging. I am sure I did everything necessary and looked at similar questions to. As the title says the mesh does not move with the bones. Sorry, I'm used to 2D, but I REALLY want to get into 3D and know everything necessary to start except for rigging of course. The rigging part is hard and I don't know why.

your geometry is unsuitable for rigging. Imagine, that bones moving with vertexes. In your case is impossible bending mesh by bones correctly, because mesh have really bad topology for animation. And this is the reason why Blender can't assign vertexes to bones and give error message.

Normally you can use "Automatic weights" feature in Blender. Select mesh, press "SHIFT+LMB" select armature. After press "CTRL+P" assign mesh to bones. But this doesn't work in your case.

This is how mesh must look for use in animation:
..as you can see, it work

You can control, how armature move with vertex by "Weight paint". Every bone have vertex group with the same name. Here you can set how strong are vertexes controlled by which bone.

I hope this help you. Also you can find a dozens tutorials about this theme all over the internet.


Strange data while importing DEM and Contour files into blender via Blender GIS - addon I have been trying to import Digital elevation models as TIFFs, contour lines as shapefiles, and a few other things. but whenever i set the elevation based on attribute or import 'As DEM' i get long thin vertical data, seemingly projecting the whole dataset in the z plane like a tall thin rectangle. Has anyone had this occur, and if so how did you fix it? I am using all my data in WGS84.

I just have the same problem yesterday, if you want to fix it, you need to change the right coordinate (CRS) in QGIS or ArcGIS first. For reference coordinate you can find it in google as free, because each area or zone has different coordinate.
Then, after do that, when you try to import .shp in BlenderGIS you can see in the bottom right corner in Blender after import it, change elevation so from geometry to Field and select elev field same as contour table in your open atribute table in you GIS software. OK.
Or if you want the easier way, you can try to create contour from your DEM data to ArcGIS first:

Import DEM.TIF to ArcGIS
Create Contour from DEM.TIF
Create TIN from Contour, coordinate use Web Mecrator
Create TIN_LINE from TIN
Import TIN_LINE.shp to Blender

In Blender -> Click ur Contour -> GIS -> Mesh -> Delaunay


Scale model so distance between highest and lowest vertices are equal I have a bunch of models I made previously, and exported to obj's, all different sizes, I lose the original blend files to ransomware, but need to import those obj's into blender, and make them all the same size (ie, the distance between the topmost vertex and lowest must be equal for all the models, how can I set them all to, say, one unit?

Any help appreciated.

I would recommend using a script, see this answer https://blender.stackexchange.com/a/156501/15543

import bpy
for ob in bpy.context.selected_objects:
    if ob.dimensions.z:
        ob.dimensions *= 1 / ob.dimensions.z

will set all selected  with z dimension, to z dimension 1.

Note this is making the vertical (z direction) distance between top and bottom verts equal, and doesn't take into account x or y location at all.

  is there a way to do this without scripting?

Equiv of this per individual object in the UI


How to get Cycles viewport output in compositing I'm rendering with Cycles in the viewport (not with F12) and would like to get that viewport output as an input node into the Compositor.

How can this be done?

Well there is a way but it really is a cart before the horse thing. If you really need the image you can only get it by a screenshot, which will be limited to an 8 bit depth and the size of your viewport, obviously.

When it is saved you can then use a file node to import it into the node editor.
As I said this is a nuts way to do it but it can be done.

Don't do it though use F12.


Displace modifier on specified region of hollowed cylinder Noobie here
I have a hollowed cylinder (ie hole cut through top/bottom) and want to displace a small outer region of the cylinder with an image. The displace modifier tries to displace all verts of the entire object.

How does one displace specific verts with an image and not the entire object?

Tia

Use vertex groups. Select the vertices you want to displace, then go to "object data properties" in the properties tab, and create a vertex group. Assign your selected vertices to the group, then under the displacement modifier, choose your group in the box were it says "vertex group".


Cycles using only one of 3 GPUs I've been using 3 GTX 1080 cards for more than a year now, for Cycles rendering, but just recently, all of a sudden, Blender is only using one of them, ignoring the other 2 for rendering.

I can see all three in Blender User prefs. The system (Win 10) sees them, it's only just one, being used for rendering.

I've tried different versions of Blender. Even Nightlies. Same thing.

Any help and suggestions more than welcome.
Thank you.

Don't use SLI (Scalable Link Interface)

SLI works by linking two or more video cards together to produce a single output, which works to speed up the display in games.

Cycles works better if the load is split using each GPU independently.

Using the Nvidia Control panel you can disable the use of SLI.


I can't import a COLLADA (.DAE) file into my scene There's a COLLADA file that I've been trying to Import into my scene but it's not working right.
When I hit the "Import COLLADA" button after selecting it in the import screen nothing happens. It's not just my clipping distance either, the object doesn't exist in my outliner either and it's no where in my scene at all. It just isn't importing.
I opened the file in Notepad to see if something was fishy in there, but the only thing I saw that might be causing the problem is that this files is a COLLADA version 1.40 I'm not familiar enough with blender or COLLADA to know if blender still supports this version, but it's just an observation I've made.

I opened up the System Console and saw this error message:
Sax FWL Error: Texture with sid "Map__1-image" not found in effect with id "_3___Default-fx".

I've looked into the issue a bit and I think that the image is trying to communicate with a material and failing somehow. My only guess is that this file is out of date and the material it's referencing doesn't exist in blender (but I know very little about this stuff so I'm probably be wrong.)

I honestly don't even care about the material's or textures as long as I can import the model and have the Armature be functional. If I have to import it without the textures applied so be it (as long as the UV is still there and I can just slap them on later.)
So I guess my question is, how do I fix this problem and Import my COLLADA model?

Contains the COLLADA file and associated textures:
https://www.dropbox.com/sh/4wly62hjgjxduym/AADEkuOZ4XiRu5TuTfyyb1jsa?dl=0

I encountered the exact same issue, and the following steps fixed it for me. I'll be posting the solution for anyone still encountering this issue that comes across this post, like I have.

I originally found this method in this forum post.

Steps to fix:

Open the .dae file with a text editor. Any will do, but for large enough files, make sure it supports regex find/replace as to not make the fix tedious.
Remove the content of all <diffuse></diffuse> tags. Only delete their content, not the tags themselves.
Save the file as .dae

Example :

<diffuse>
    <color sid="diffuse">0.800000  0.800000 0.800000 1.000000</color>
</diffuse>

becomes

<diffuse>
</diffuse>

With regex :

You can achieve this by replacing <diffuse>[\s\S]+?</diffuse> with <diffuse></diffuse> (add backslashes before / if necessary).
However, if you have the option to make . include newline, the first regex just becomes <diffuse>.+?</diffuse>


Is it possible to take control of Blender with a standalone Python instance? I intend to make a framework for BGE using wxPython, being able to manage blend file libs,  datablocks of the blends, alternative ways to make logic and ease the project management in general. I need to use Blender to edit the blend files contents (add logic bricks, edit datablocks, etc), so at first I thought to call blender in background mode through command line and execute Python scripts generated by the framework to make the changes to the blends. However, that would imply to open blender (in background) and save the blend file for each operation, even the simplest ones (like renaming), or queue the changes and add a annoying 'Apply' button. So, I wonder if it's possible to 'take control' of Blender's Python using the framework's Python, so the user can see the changes by the framework in real-time while being able to do changes that the framework won't do (like modeling, texturing, animation, etc).
Is that possible? Thanks.

You'll have to build it yourself, but you can build Blender as a Python module. You can then do import bpy and use it as if you're inside Blender.


Colors/Lights drastically different in render (2.8 Eevee) Trying to get back into Blender after a bit of a hiatus. I am not sure what is going wrong. When I am in my rendered viewport the colors look perfect and then as soon as I go to render the animation/image the colors get blown out like crazy.

I have messed with color management settings (filmic, standard, none, etc) and they all look like garbage. If anyone has a suggestion that would be greatly appreciated.

Thanks!

Try disabling "Bloom" or adjust it's settings and see if you have the same issue.


Issue when Exporting Mesh to UnrealEd Hello friends this is my first post here.. I just started my own project after tons of procrastinating, and after maybe 2 horus of Blender tutorials, i made a model. It's a submarine, i know it looks like a bomb but it's just the basic version, and it looks somewhat fine on Blender (and it's not finished yet).

Now This is how the imported mesh looks on Unreal.

How it looks on UnrealEd Now the problem comes when importing it to UnrealEd, it seems like it smooths out the edges of the Mesh. There msut be a problem when exporting right?

It looks ok if i uncheck the Apply Modifiers box, but it only renders half the submarine (Considering Mirror is a Blender modifier) and if i leave it checked it'll end up looking like pic 2. Even when selecting faces (which was the recommended option in the tutorial)

tl;dr Mesh looks ugly on unreal what should i do?

Oh my. After a some search i've come up with the answers.

Followed This and This which are basically the same answer. Worked like a charm.


How to achieve this destruction effect? I would like to do something similar at this:

youtube: Minecraft Block Destruction with Realistic Physics
I have two questions:

Can I handle a simulation like that or bigger?
My PC is

CPU: i7-7700k 4.20GHz
GPU: 1080ti 11GB
Ram: 32GB ddr4

How can I set up a simulation like this?
I know this is a generic question, but even a starting point would be a great answer.

Thank you for your time.
PS: Sorry for my English. I'm not a native speaker.

For this purpose blender user usually use Rigid Body simulation. Here is a cookbook for a cube segmented into 10x10x10 (1000 parts). Yes it is process intensive and this is just one cube. The most calculation takes Constraints.

Create a Cube

Select a Cube
Assign Array Modifier > Count=10 > X=1
Assign Array Modifier > Count=10 > Y=1
Assign Array Modifier > Count=10 > Z=1

Search for operators:

Convert to Mesh
Separate by Loose Parts
Origin to Geometry
Move to Collection > New

Create a floor
Add a Plane and search for operators

Transform Scale
Apply Scale

Create a simulation
With Cubes selected, search for operators:

Active (Rigid Body)
Change collision shape > Box
Connect (Rigid Body)

With Plane selected, search for operators:

Passive (Rigid Body)
Change collision shape > Box

You can also try version of Blender with Fracture Modifier, that is much comfortable to work with, especially with constraints, but I didnt find grid cuts.


Spherical Displacement direction I am having problems getting displacement mapping to extrude in the correct direction on all sides of a sphere.  I have been following this tutorial: https://www.youtube.com/watch?v=n0r0UnaIK_Y

UPDATED

You need to use the Vector/Displacement node now - instead of feeding a value directly into the Displacement socket. This is due to how the Displacement socket functionality has changed at the more recent versions of Blender (it’s a vector now, rather than a scalar.

See here.


How to color vertices of a cube? I do some tests of 3D projection, I am using some references mesh like a cube. However, I need to colorize the vertices of a cube. Is it possible to do that?

You can use Vertex Paint

Select the cube and toggle Vertex Paint

Set a color from the Tools Panel on the left, then click a vertex to apply. Repeat for every vertex

INTERNAL RENDER

Check Vertex Color Paint in the Material Panel to render Vertex Colors

CYCLES RENDER

In Node Editor: Add > Input > Vertex Colors > select Vertex Color Layer...


Help with putting liquid in glass in blender I'm trying to make a beer in a glass in blender, and I am having an issue. I went to render it after I put the liquid in the glass to see how it looked, and the beer part (which is a separate object) is showing up in the bottom of the glass where it shouldn't. Can anyone help? By the way, I am very new to blender. If it helps, I was following the tutorial on blenderguru.com.
http://www.blenderguru.com/tutorials/make-beer-blender/

In your file the liquid object and the glass object both have the same material. If you give the glass object a separate material without any absorption, it works as expected.

With the glass selected, make a copy of the beer material by clicking the 2 icon:

Remove the absorption node (⌦ Delete):


combine targetless IK chain with copy rotation constraints I have setup a bone chain with a copy rotation constraint such that the entire chain bends when i rotate the root bone:

At the same time i have setup a targetless IK constraint on the chain tip which spans along the chain towards the root bone.

When the root bone is not rotated, then i can move the chain tip and all bones behave just right (as expected).

However as soon as i rotate the root bone a bit, then moving the chain tip results in odd behavior. This is because the IK move also changes the rotation of the Root bone. And since this rotation affects all other bones in the chain, i get a clash, and the chain begins to jump around when i move the tip.

I have enabled Offset for all rotation constraints, so that i can rotate each bone individually. But this seems to be not enough to solve this problem.

Actually i wonder if this can be solved at all.

What you are trying to do is to have FK control and IK control on the same bone chain.

As you stated there are dependency issues, and this cannot ever work.

What you need to do is to make 2 separate chains - FK and IK, and a 3rd deform chain that blends between them.

Another thing you can do is to have main IK chain for the general shape, and then FK chain that copies the main one and is there only for fine minor tweaks - but this will break the endpoint location.


Dump Scene object Information To console or String for debugging purposes A very simple question on how to dump bpy.context.scene information using python script to blender console or a string so I can use to debug.

I have tried to serialize the object using pickle and json dump with no success.
Serializing seems to not work here for some reason.

  Note to downvoters: Please atleast leave a constructive comment why you feel this question needs to be downvoted. If you dont know the answer move on.

I had the need to do something similar recently, and here is a very brief solution that I attempted, hopefully it can be helpful:

Create a script at the same location with your target .blend file named something like script.py:

import bpy
# Use bpy.context.scene.objects.keys() to get the name of objects

with open('output.txt', 'w+') as the_file:
    the_file.write(', '.join(bpy.context.scene.objects.keys()))

Execute blender in background for the target file and run the script: In command line, use blender -b filename.blend -P script.py to run blender in background and execute the script on the scene.

This script will dump all object names in the scene into a file named "output.txt".


sound_bake in command line script I'm making an audio visualizer which I want to render from the command line. Unfortunately the bpy.ops.graph.sound_bake() function seems only to work from the GUI.

I've found various tutorials, but they all use the gui to create the animation. They always require this fix

bpy.context.area.type = 'GRAPH_EDITOR'

to set the correct context for bpy.ops.graph.sound_bake() to work. This works for scripts run from the gui, but when a script is started from he command line bpy.context.area is undefined.

For materials I already found that instead of
bpy.ops.material.new()
I should use
mat = bpy.data.materials.new("")
to avoid problems with the context. I have not been able how to work out how to do something similar with sounds.

It seems in scripting, using bpy.ops.* can easily give problems with the context, as these function might check the mouse position for some reason, etc. and there would/should be alternative functions. I have no clue on how to find those alternatives. So far I found them by chance, but I have not been able to find an alternative for bpy.ops.graph.sound_bake()

How can I bake an mp3 to an fcurve and apply that curve to an object, in a script?

For Sound Drivers Addon I do a lot of sound baking, so I thought I'd check out how it would perform running in background mode (this has led to another q re running modal timer operators in bg mode). Anyhow using context override the following bakes in bg mode using command

blender -b ./Desktop/baketest.blend --python-text bake.py

using the following as a text block named bake.py.

import bpy
#from sound_drivers.utils import get_context_area
def get_context_area(context, context_dict, area_type='GRAPH_EDITOR',
                     context_screen=False):
    '''
    context : the current context
    context_dict : a context dictionary. Will update area, screen, scene,
                   area, region
    area_type: the type of area to search for
    context_screen: Boolean. If true only search in the context screen.
    '''
    if not context_screen:  # default
        screens = bpy.data.screens
    else:
        screens = [context.screen]
    for screen in screens:
        for area_index, area in screen.areas.items():
            if area.type == area_type:
                for region in area.regions:
                    if region.type == 'WINDOW':
                        context_dict["area"] = area
                        context_dict["screen"] = screen
                        context_dict["scene"] = context.scene
                        context_dict["window"] = context.window
                        context_dict["region"] = region
                        return area
    return None

c = bpy.context.copy()
get_context_area(bpy.context, c)
obj = bpy.data.objects["Cube"]
obj["y"] = 0.0
obj.keyframe_insert('["y"]', frame=1)

speaker = bpy.data.speakers["Speaker"]
bpy.ops.graph.sound_bake(c, filepath=speaker.sound.filepath)
bpy.ops.wm.save_mainfile()

Note for convenience sake I grabbed the filepath from a speaker's sound.  This successfully baked the sound file onto the "y" custom property of the Cube in bg mode.

Use something like How to pass command line arguments to a Blender Python script? to extend functionality,.

NB: Example of creating a simple sound visualiser using sound_drivers.


FCurve Noise modifier: set "Offset" value using Python First of all: excuse me for my terrible english.
Is there any way to set "Offset" value of "Noise" modifier in Graph Editor using Python?

Ok, I've found out this by myself.

bpy.data.actions['Compositing NodetreeAction'].fcurves[X].modifiers[Y].offset = Z


Object appears twice when linking it to a collection I am creating a bone, and then a collection with a specific name if it does not exist, with the following function:
def make_collection(collection_name):
    if collection_name in bpy.data.collections:
        return bpy.data.collections[collection_name]
    else:
        new_collection = bpy.data.collections.new(collection_name)
        bpy.context.scene.collection.children.link(new_collection)
        return new_collection

The collection is linked to the master collection so it's on the top of the hierarchy, and now i try link it to the collection.
I create the collection:
root = make_collection("bat")

and later on in the code, i create a bone (although is an empty since it's a standalone bone), and i try to link it like this:
bpy.ops.object.empty_add(type='CUBE')
bone = bpy.context.active_object
bone.name = data[i].name
#bpy.ops.collection.objects_add_active(collection=root)
root.objects.link(bone)

Even though it's called root, root is not the master collection, just to clarify.
The result is the following:

It's the same empty i created, that appears twice in both collections. Although an idea would be to just delete other collections, 2 will appear still, one in the master collection, and one in the collection i created.
Also it's the same item since, if i click one, both get selected at the same time, so there's only one empty in the scene, i just can choose where to click it from.
Now the problem is i'm doing this with several objects in a loop, so i  would be basically duplicating the object list twice, and that's pretty redundant.
If i don't use the root.objects.link code at all, the objects would just be on the master collection, but i want them to be on the collection i specifically created.
Is there any way to fix this? I'm not sure why it appears on both collections and i'm very confused. I'm fairly new with the blender API, so i'm not sure what i'm doing wrong.
Thanks for reading!

So I'm going to give two answers: the first for the question you actually asked regarding doubling linking objects, and the second for the question you wanted to ask, that being how do you create objects in a specific collection in the first place.
Given an object called 'bone' which was created in the current collection and a collection called 'root' you want to move 'bone' from the active collection to the 'root' collection:
# use unlink(bone)
root.objects.link(bone)
bpy.context.collection.objects.unlink(bone) # this is the active collection

The better way would be to create 'bone' in the 'root' collection in the first place. In the script below I do that by changing the active collection.
import bpy

def set_collection(collection_name):
    if collection_name in bpy.context.view_layer.layer_collection.children:
        root=bpy.context.view_layer.layer_collection.children[collection_name]
    else:
        coll=bpy.data.collections.new(collection_name)
        bpy.context.scene.collection.children.link(coll)
        root=bpy.context.view_layer.layer_collection.children[coll.name]

    bpy.context.view_layer.active_layer_collection=root
    return(root)

root = set_collection('Soear')
bpy.ops.object.empty_add(type='CUBE')

bone = bpy.context.active_object

Ref: Change active collection
Ref: https://devtalk.blender.org/t/set-active-collection/2409


Run script stored in text editor/blend file from CLI What is the correct way to run a script internally stored in the blend file from the CLI?

I'm trying to run a script I have in the text editor. I have it named "Import" in the text editor. The -P parameter seems to be made for externally stored scripts and doesn't work when I try to use it like this blender -b file.blend -P Import.

I would prefer to leave the script in the blend file. But if necessary I can move it out.

I've read that you can start a script when you load a blend file but that won't work for me. I am setting up a video render server where I will be importing video files into the VSE and generating proxy files from the "Import" script. The proxy render takes a long time so I am looking to offload that to the server. I will then be downloading the blend file and proxy files to another computer to do editing.

Run blender --help and look for any option with 'Python' in the name. You'll find that it's blender filename.blend --python-text Import.

Alternatively, name your script yourscript.py (so end it in .py), and you can enable the "Register" checkbox to automatically run the script whenever you load the blend file. This can be easier, depending on your needs.


Object appears smoothed after rendering but not in viewport I'm pretty new to blender and used it to model a castle and print it.
Now I want to extend the model by textures and render it, but even when I render
it with basic material i get some strange output.

Does somebody know my error? I already corrected the normals and they look fine.

you have a subdivision surface modifier (or multiresolution) set to render only, not visible in viewport but active when rendering.

Click the eye to see it, click the X to remove it.

As suggested by Chebhou, the subsurf modifier can also be different in viewport/render because of the subdivision levels number set for each.


How do I keep a cloth sim object inflated? I'm modelling a bed for a personal project and I wanted to make a duvet or puffy blanket for it, I've tried using cloth sim or Model Cloth (Used this video for example but mine doesnt seem to work https://www.youtube.com/watch?time_continue=34&v=qHEWsNYdGag&feature=emb_logo) and I cant seem to get the look I want. Any tips or ideas?

For 2.8+ versions use the cloth Pressure property under the Physics properties of the cloth object. Enable it and add a value that suits your particular object.
Make sure the geometry has enough subdivisions for an acceptable effect, and little enough that it get usable performance.