text:
How to get addon __name__ in another module into the same package or another subpackage?
I built some functions into python module functions.py, but in it if I try to get the __name__ I get something like __name __.functions
How do you get the name of the addon a pythonic way?
I add some details:
Example module functions.py
def open_user_pref(context, addon_name):

    preferences = context.preferences.addons[addon_name].preferences
    bpy.ops.screen.userpref_show('INVOKE_DEFAULT')
    bpy.context.preferences.active_section = 'ADDONS'
    bpy.ops.preferences.addon_expand(module=addon_name)
    bpy.ops.preferences.addon_show(module=addon_name)

Example call from __init__.py
from . import functions

functions.open_user_pref(bpy.context, __name__)

But if I want to avoid the input name, I should find the exact name of the addon.
So how can this be done?
def open_user_pref(contex):
    #addon_name = __name__.split(".")[0] ? This seems dangerous to me if this package becomes a subpackage

    preferences = context.preferences.addons[addon_name].preferences
    bpy.ops.screen.userpref_show('INVOKE_DEFAULT')
    bpy.context.preferences.active_section = 'ADDONS'
    bpy.ops.preferences.addon_expand(module=addon_name)
    bpy.ops.preferences.addon_show(module=addon_name)

Please add some details. An addon is imported as a module. The addons name (__name__) will be the same as folder or python file name (without py extension) in the addons folder. If functions.py  is a submodule of your addon, then it is not itself an addon.  If so and you are getting the package name of functions as eg myaddon.functions split on "." .

Hi batFinger, I have added a trivial example. My concern (Because I'm impractical with this) is if the functions.py module became part of a subpackage

The inspect module.
This is somewhat a generic python question, tho As it happens I have an addon that automates a lot of settings to create and register addons based on a folder structure.  Wanted to keep it as simple as possible, and used the following to automate getting the importing module (addon) name.
Pretty sure this can be used  to suit your needs.
In root folder of "bat_tools" addon
bat_tools/__init__.py
from .types.app import BATApp

bl_info = {
    "name": "BAT Tools",
    "author": "batFINGER",
    "location": "Every Bloody Where",
    "description": "A Collection of BAT Tools",
    # "warning": "Still in Testing",
    "version": (0, 0, 1), "blender": (2, 80, 0),
    "support": "TESTING",
    "category": "Toolkit",
}

app = BATApp()

register, unregister =  app.register()

and a snippet from the class def in the submodule.  When the object is instanced set the name and package from the module which imported it. (Code from stackoverflow.com search Get __name__ of calling function's module in Python)
bat_tools/types/app.py .
class BATApp:
    @property
    def prefs(self):
        from bpy import context
        pref = context.preferences.addons.get(self.name)
        if pref:
            return getattr(pref.preferences, self.name, None)
        return None

    def __init__(self, **kwargs):
        # get the details of calling module

        import inspect
        frm = inspect.stack()[1]
        mod = inspect.getmodule(frm[0])
        # print(mod.__name__, mod.__package__, mod.__file__)
        self.name = mod.__name__
        self.package = mod.__package__
        path = Path(mod.__file__)

BTW see no issue with splitting the package as commented, (and illustrated in question) foo.bar.foo since an addon is a base module, follows a naming convention which  cannot be named "foo.bar" for example.

"BAT tools" made my day!

Really very interesting, I want to study this method of yours. But allow me a stupid question: Basically can I always get the name with __name __.split(".")[0]? or is it a bad idea?

If the base module is the same.  Above (inspect) "should" work across modules.


text:
How to Bend Object Coordinate Procedurally?
I'm trying to create a mapping that curves the line to keep it the same width. But I couldn't find anything on the entire internet.
I would like to understand what approach and how to do it. Furthermore, I think that the bending must be done according to a "Radius" of a hypothetical circle.
For now I have created something like this but it doesn't work as I hoped, as the line narrows, while I would like it to remain the same thickness once folded.
This is a view at the nodes that create the line:

This is my procedural attempt to bend the Line
As you can see, the line curves exactly where I'm interested, but with this bending, the line narrows when bent.

My idea is to choose the radius of curvature, and the degree of curvature. But I haven't found much help anywhere on the internet.
I hope to be more specific with this additional note:
My question is more oriented towards Vectors and how to bend them. Suppose I had inserted a dotted line (also an image texture), I would like to be able to bend the dotted line or the texture as well. Essentially Bend the vector coordinates without using UV mapping.
Bending 90 Degrees Example:
When I say I mean "Bend" I mean this, as you can see, the strip is only Folded in one point. (This example is done with 2 overlapping objects)

I think for this to work you need to account for the space bending in your "Less Than" threshold. Since space is bended it makes sense that the line is also bended and its width varies. And I would use an "Absolute" math node rather than a power of two which will make the computations harder

I just want start off saying I never used Blender in my life and I came here from Stack Overflow because the question sounded interesting. I'm not sure if this is possible in Blender, but have you thought about using a quadratic function? If you want it to be a straight line, you can set the x^2 parameter to 0, and slowly increase it to get a curve (like 0.00... slowly) and you can use the x parameter to orient it or just use it as 0. Again, I've never used Blender so this may all just be me rambling, but I'll be glad if it actually helps anyone.

Perhaps you could make use of a polar coordinate system - treat the u coordinate as the angle, and threat the v coordinate as the radial component. Both coordinates could have an offset, and the u coordinate might also have a scaling factor - these could serve to control the curvature. Then "convert back" to cartesian uv coordinates. Might need some tweaking/clamping

Duplicate of https://blender.stackexchange.com/questions/98736/convert-object-texture-coords-to-polar.

This question is similar to: Convert Object texture coords to Polar. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem.

You could look at how to implement the "Bend" modifier, then reverse it, because in a shader you're not taking a flat grid to bend it, you're sampling a position, and figure what coordinate would bend into this position. I explain the logic here: https://blender.stackexchange.com/a/278060/60486 so here's an example of the reversal: https://blender.stackexchange.com/a/320463/60486 the logic isn't exactly correct there...  And now copy-paste it to the shader: https://i.imgur.com/vanPfVE.png

@MarkusvonBroady Ok, I tried the shader, but it doesn't Bend, but rather produces a circular mapping, in which you can set the radius. However, this is not curving, it gives the illusion that it is, if you scale this mapping you will realize that it is a circle. Imagine having to bend the pipe in one place. The tube will be bent at that point, once the bending is finished, it will continue straight

@NoobCat in the "simple deform" modifier it's called "limits", and that too can be produced in a shader, I'd start doing it for the geonode modifier first, then reversing it.

@MarkusvonBroady If you think you have a solution that works I suggest you post an answer explaining how, unfortunately I can't understand what you are suggesting.

@Lutzi Please compare the 2 questions carefully, here I am asking how to "Bend" while the other question is focused on Polar Coordinates. Take a further look at Leander excellent answer and you'll understand why it's not a duplicate. Furthermore you reported it as "Duplicate" and in another comment you reported it as "Similar" This is neither duplicate nor similar. They are 2 different topics, which require different answers.

I did what was right at the time. Of course with additions I see the difference.

You can use the Vector Rotate node to rotate the texture coordinates.
I start by determining the angle and the rotating the coordinates to that angle. Now $x=0$ lies on that angle. Next, shift $x$ to your desired value using the subtract node.
By using the Clamp node on the angle, we can limit the effect and continue with undistorted coordinates after the bent segment.

Very interesting! I'm trying your setup and it looks very good. But I think there is a problem in "Radius" it doesn't set the radius, or am I wrong?

Radius indicates at what distance (radius) from the origin (which we rotate around) the uv coords x length remains the same and is not not stretched/squashed. With the UV grid you can see, that the points close to the origin appear distorted (squashed) and the points far from the origin appear distorted (stretched). With radius you can control which part is not stretched. When bending anything, the inner arc gets shorter and the outer arc gets longer.

Excellent, it can be combined so that it works in symbiosis. This setup seems to be the answer I'm looking for. Another question: Doesn't this setup of nodes bend in the other direction? I noticed that you can only do this towards the bottom -Y and it doesn't bend to +Y

To bend in the other direction, multiply the Y input (after the Separate XYZ node) with $-1$ and the input to the angle (of the Vector Rotate node) with $-1$ as well.

You could also rotate the coordinates by $180$ before and after the bend setup.

Sure, but i think the coordinates will be upside down with that method.

No, it wouldnt. ( But I should have said flip vertically before and after) :P

You are right! This configuration is really excellent as a starting point for creating a "Bender" node, it's the answer I was looking for

You can start with two circles, as you suggested:

With a 0.0 - 1.0 Slider version:

My idea is to bend the line as desired, this solution is useful for creating a curve, as shown in the example, my Group node has an input that must act as a bender

Interesting answer, but this does not bend a straight strip, but rather creates a curve at will, it cannot return to a straight line. My question is more oriented towards Vectors and how to fold them. Suppose I had inserted a dotted line (also a texture), I would like to be able to bend the dotted line too. So I'm dedicating myself to creating a procedural node dedicated to "Folding" vector coordinates

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
How to mapping Texture image in all Voronoii Cells?
I am trying to set up a mapping on each cell produced by the Voronoii Node. But I am running into a problem that I am unable to solve.
I would like each cell to make its mapping procedurally, but I am not sure how to achieve this.

Note:
In this example I would like to keep the Voronoii coordinates set to Object, as I would like to avoid any UV mapping setup.

Here is the example I get with this node configuration:

connect UV to voronoi, and set voronoi to 2D mode.

@MarkusvonBroady I added a note, as I would like to keep the coordinates on Object. It occurs to me that one could use the "Normal" Coordinates in combination with the Position output of the voronoii but I am not sure how to do it.

Why do you need "Object", that is sort of flawed and is what is causing your problems. If you use UV or take a "position/location" from a "geometry" node it would be waay easier.

you simply need to take 2 out of 3 coordinates, and decide which coordinates you take based on normal. At least for a cube.

@MarkusvonBroady You might think about proposing an illustrated answer, unfortunately for me the comment alone does not make me understand the configuration you have in mind.

I had an answer on this, but just can't find it :D It was about reproducing the "box" mode in image texture.

We can force some UV mappings procedurally
Face map
This solution considers every "direction change" in the faces as a seam. Using some math involving the global axes and the face normals, we can create their mapping.
Main nodes
Here we just connect your Voronoii setup with the said mapping for faces:

Face map non Z - This is a subgroup inside the "Face map" group
This maps every face, making their local Y be the projection of the given global Z onto the face (fails when face normal = global z)
The principle is simple:

Crossproduct from global Z to Normal gives us local X
Crossproduct from Normal to Local X gives us Local Y
Dot products of position by each local axis gives us the projected position onto these axes

Face mapping 2 (general) - this is shown in the main nodes
Because the crossproduct is zero when normal equals global Z, we need exceptional treatment for faces that are flat on XY.

Based on these questions:

How to map a texture to faces using geometry normals
Rotate texture per instance

Sphere map
For a sphere map, all we need to do is get the object coordinates (as long as its origin is at the center) and convert them to spherical coordinates remapped from 0 to 1 (where X is the horizontal angle -180  to +180 and Y is the vertical angle -90 to +90).

Shader nodes

File

WARNING
Everything below this line is experiments that I made before learning something important about what the "Object" texture coordinates mean.
They're not important for the answer, but may have some insights.
WARNING

Sphere map - using normals (requires shade smooth)
This is a simple map that takes the normals of the object and map these normals to coordinates similar to a UV sphere.
If the object is sphere-like, there will be some distortions, but it might be good enough. It also requires the object to be shade-smooth.

Advantages:

Uses only a shader

Disadvantages:

Requires shade smooth, otherwise it will pixelate to the face size
If there is a concavity, the texture will invert in the cavity, creating ugly distortions.
Shaders don't give you access to the geometry local coordinates, meaning that if you move or rotate the object, the texture will not follow (there will be movement between the texture and the object)

If you intend to rotate the object, you need to copy each rotation value of the sphere as a "driver" and paste each driver value to the rotation of the "Sphere Map" group. Unfortunately, if you have two objects, that will not work.

The node group
For a sphere of radius 1, its normals are equal to its coordinates.
All this node does is to transform these normals/coordinates into spherical coordinates and map the angles from 0 to 1, the same way a UV Sphere has its UV map.

Sphere map using position (requires geometry nodes)
To avoid the problems of moving textures, bad concavities, etc., we can use a "position" based mapping. But since shaders don't understand local geometry position (if it does, please teach me), I had to resort to geometry nodes.

Advantages:

Can deal with concavities
Does not require shade smooth
Can be improved to have a displaced center (don't know if it would be useful)
Object can be rotated and texture will follow

Disadvantages:

Requires that the shader be used on top of a geometry node group.
May show glitches on the poles of the sphere (can't decide the X value for the poles, any value will disrupt some of the surrounding faces) - Solution is to have small faces around the pole

The geometry nodes
Concepts:

Uses the position the same way the normals were used in the normal sphere map
To avoid a seam problem (vertices on the seam need to be both x = 0 and x = 1 simultaneously for the shader to work), we create two different X attributes

One attribute tells if a face is High X or Low X
For low X faces, we subtract 1 from X, but only if it's a high X
For high X faces, we add 1 to X, but only if it's a low X

The shader group
This gets the values for X and Y, join and scales.
But for X, it checks which of the two X attributes should be used based on whether it's a High X face or a Low X face

File

Interesting answer, do you think it is possible to make it so that it can be mapped on Meshes that are not a cube? Like a sphere? I just tried to use this material on a sphere, and as I suspected it does not give an acceptable result. Probably it is not possible to do it?

Yes, that's a universal "face-orientation-wise UV", but every direction change is a new UV island. For a sphere, use the standard UV mapping.

@NoobCat, check the updated answer

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Way to browse all type of files by operator button class in panel
I want to search a file on pc by pressing a button ,
The button will be drawn in the ui panel with:
class MYBROWSERBUTTON_OT_Seach(bpy.types.Operator):

    bl_idname = "my.browser"
    bl_label = "Search file"

    def execute(self,context):
        ###In this operator I would like to open a file search popup, and assign the path to file_finder(StringProperty)

        return{'FINISHED'}

class MAT_PT_Panel(bpy.types.Panel):
bl_label = "My Panel"
bl_idname = "My Idname"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"

def draw(self, context):
    row.operator("my.browser", text='Search file')

register string:
class MyProp(bpy.types.PropertyGroup):
    file_finder: StringProperty()

register property
Scene.my_setting= bpy.props.PointerProperty(type=MyProp)

I would like to have the full path name with file name, saved in the StringProperty ---> c:mydyr/my_folder_/my_file.###
I'd like to do it that way, but I don't know very well and I don't know if it's a correct way

Does this answer help?

@sambler is usefull, but this method give me only path folder , not path + file name


text:
How to trigger the 3D transformation widget with G, R or S
When I press G, R or S to move, rotate or scale an object, Blender starts transforming the object based on the current mouse pointer location. But I don't want to jump into the translation right away. Instead I want the 3D Widget to appear, and I want to use the handles in the 3D Widget to transform the object.
Is there any setting in blender to make it happen?
I am using Blender 2.8

Update:
Starting Blender 3 the setting 'Tool Keys' to 'Active Tool' will achieve the desired result.

I've found an even simpler solution from Julien Kasper.
Change the following setting, Edit > Preference > Keymap > 3d View > From Nevigate to Gizmos

Now pressing tab shows the following menu from from which I can the desired transformation gizmo.

Now you can switch transformation widget just by Tilde and a quick swipe which is much faster the moving cursor over to toolbox!

First, delete the existing G/R/S bindings by going to Preferences > Keymap > 3D View > 3D View (Global), and scroll down until you find them. Click the "x" button to remove them.

Next, create the new bindings by right click the widget tools in the side panel toolbar, and select "assign shortcut". Then type the key you want the new shortcut to be for that tool.

Unfortunately, you will need to do this seperately for each mode, such as edit/object/pose modes. And edit mode will need to be done for each object type, edit mode shortcuts for meshes are not the same as for curves or metaballs.
Finally, to make these changes apply to all scenes from now on, bring preferences up again and click "Save Preferences"

Thank you. Can you please tell me where can I find edit/pose mode? When I search  'G' key-binding in KeyMap, I find a large list of move actions assigned to G, none of which are edit/pose.

You only need to remove G/R/S once, it will remove it for everything. It’s just setting the new bindings for the widget that needs to be done per-mode

Sorry for this shameless plug, but try my addon. It's very simple and is probably the answer to your question, but it allows you to use the widgets instead of the active tools in a more intuitive way. Also, you don't have to mess with the keymap as much as you would with the active tools (ie setting the keymap for every possible mode). It works much better than the active tools and lets you change the selection mode or switch to the other active tools while the transform gizmo is still active. The bonus is that if you choose the select tool (not box select, lasso, or circle select, but the "Select" tool) the drag behavior is just like on the transform active tools. I'm trying to get the developers to see that this is a far superior way of working.
https://github.com/dpdpforlife/QWER


text:
IK control bone not rotating linked bone when behind it
I have an IK controller bone. It works quite well behind its rest position, moving and rotating both the linked bones. However, when I move the IK controller bone in front of the body, it only rotates the top bone, without modifying the bottom one.
Link to my .blend file is here.

The movements are limited by the IK settings for the lower leg bones. That is the IK settings not the IK Constraint settings. While in pose mode select the lower leg bone and you will find an Inverse Kinematics panel under bone properties.

There you have enabled a limit and set it to 0-90 degrees for the x-axis. While this does seem like a reasonable setting, it is causing the upper bone to take the rotation when the rotation of the lower leg could be negative.

Ah, I should have been more clear in my original question. What I need is for the bone to be able to be in the front yet still bend the leg accordingly. Is there a way I can do that? Other rigs of the same character allow it, but I see no differences in the way they are laid out.

I don't think it's common to enable the limits. To get control over the direction of the bend you place another bone out in front that is set as the pole target for the IK constraint. This also let's you move the knee from side to side while it is bent.

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Removing double edges (reverse edge split) in a script
I have a 2D model of a road that consists of separate rectangles whose ends are approximately lined up. Below an example of a situation where the road turns slightly.

There are thousands of rectangles, and that's a problem for later processing. I need to join ends of most of the roads such that they form a connected mesh, like so:

I can't simply perform a Remove Doubles on all the geometry, because this is done from a script, and the risk of joining vertices in a way that doesn't result in sensible geometry is too high. For example below only the bottom vertices of the edge have been joined. In intersections where roads overlap, completely unrelated roads might become connected in broken ways.

Thus what I need is an operation that joins each edge pair whose ends are sufficiently close to each other. Is there any way easier than writing that entirely by myself? If I were to write that myself, what would be the best strategy?
The end goal is to create a model that can be 3D printed nicely. I extrude the 2D roads, resulting in a tactile map that you get from Touch Mapper. Thousands of objects is a bit much for slicers, which basically need to first separate by loose parts, and then perform an union between every resulting object.
Below is an example of roads in a real-word city centre. Pedestrian roads (being edited in the screenshot) are extruded higher than other roads. I'd like to join eg. the edge whose vertices are hilighted.

Edit: final code
Below is my final code. Changes to Chebhou's answer are:

Speed up edge proximity searching with mathutils.kdtree.KDTree. Important with over a few thousand edges.
Merge all verts in one operation using bmesh.ops.weld_verts(). With 1000 verts to join, this shrinks execution time from several seconds to almost nothing.
Filter out weird edges, and precompute some values in filter_edges().
Don't merge edges in places where there more than 2 edges meet. This is a good heuristic that avoids all roads becoming a single object, which would not be desirable when 3D printing, because objects shouldn't intersect themselves.

Mesh is assumed to be in object mode initially.
def join_matching_edges(ob):
  lt = 0.1  # length difference + -
  dt = 0.1  # max distance
  at = 0.5  # max sin(angle)  (30°)

  bpy.context.scene.objects.active = ob
  bpy.ops.object.mode_set(mode = 'EDIT')
  bpy.ops.mesh.select_all(action='DESELECT')
  from math import sin
  bm = bmesh.from_edit_mesh( bpy.context.object.data )
  bm.edges.ensure_lookup_table()

  center   = lambda e : ( e.verts[0].co + e.verts[1].co ) / 2
  length   = lambda e : ( e.verts[0].co - e.verts[1].co ).length
  dist     = lambda v1, v2: (  v2 -  v1 ).length
  sinAngle = lambda e1, e2: abs(sin((e1.verts[1].co - e1.verts[0].co).angle(e2.verts[1].co - e2.verts[0].co)))

  def point_between_edge_neighbor_verts(e):
      # Return middle of the verts adjacent to the edge
      verts = []
      for v in e.verts:
          for linked_e in v.link_edges:
              verts.extend((vv for vv in linked_e.verts if vv != e.verts[0] and vv != e.verts[1]))
      if len(verts) != 2:
          #print("edge has non-2 adjacent verts: " + str(len(verts)))
          return None
      return ((verts[0].co[0] + verts[1].co[0]) / 2, \
              (verts[0].co[1] + verts[1].co[1]) / 2, \
              (verts[0].co[2] + verts[1].co[2]) / 2)

  class CEdge:
      def __init__(self, e, center, into_edge):
          self.e = e
          self.center = center(e)
          self.length = length(e)
          self.into_edge = into_edge
          self.welded = False

  def filter_edges(edges):
      out = []
      for e in edges:
          if len(e.link_faces) != 1:
              continue
          point_between_edges = point_between_edge_neighbor_verts(e)
          if not point_between_edges:
              continue
          vector_into_edge_face = center(e) - mathutils.Vector(point_between_edges)
          out.append(CEdge(e, center, vector_into_edge_face / vector_into_edge_face.length))
      return out
  candidate_edges = filter_edges(bm.edges)

  # Index edges into search tree
  kd = mathutils.kdtree.KDTree(len(candidate_edges))
  for i, ce in enumerate(candidate_edges):
      kd.insert(ce.center, i)
  kd.balance()

  to_weld = {}
  for i, ce in enumerate(candidate_edges[:-1]):
      if ce.welded:
          continue
      ce.welded = True
      lmin = ce.length - lt
      lmax = ce.length + lt
      matches = []
      for (_co, oe_index, _dist) in kd.find_range(ce.center, dt):
          oe = candidate_edges[oe_index]
          if not oe.welded and lmin < oe.length < lmax and sinAngle(ce.e, oe.e) < at:
              turn_angle = ce.into_edge.angle(-oe.into_edge)
              if turn_angle > math.pi * 0.6: # pi * 0.5 is 90%
                  #print("not merging edges (%s, %s) pointing to opposite directions, angle is %f" % (ce.e, oe.e, turn_angle))
                  continue
              matches.append(oe)
              oe.welded = True

      if len(matches) == 1:
          # Join nothing where >2 ways meet, else all roads in the scene may become joined and cross itself
          ev1, ev2 = ce.e.verts[:]
          oev1, oev2 = matches[0].e.verts[:]
          if dist(ev1.co, oev1.co) < dist(ev1.co, oev2.co) :
              if ev1 != oev1 : to_weld[ev1] = oev1
              if ev2 != oev2 : to_weld[ev2] = oev2
          else :
              if ev1 != oev2 : to_weld[ev1] = oev2
              if ev2 != oev1 : to_weld[ev2] = oev1

  print("%s: melding %d out of %d edges" % (ob.name, len(to_weld) / 2, len(bm.edges)))
  bmesh.ops.weld_verts(bm, targetmap = to_weld)
  bmesh.update_edit_mesh(bpy.context.object.data ,True)
  bpy.ops.object.mode_set(mode = 'OBJECT')

You could try select one of these edges and select others by direction from Select Similar operator (Shift+G). Adjusting Threshold in the operator settings, you could select only desired edges. Then remove doubles. This way won't really work if there're important edges similarly directed; probably you'll need to control visibility of the objects.

There will be all sorts of edges in there, but Select Similar could still be useful as part of the solution. Thanks.

This is modified version of TLousky answer in this script we use three factors to decide merging edges :

distance between their centers.
difference in length.
the angle between these edges.

you can drop any of them if it's not necessary in your scene, and this is the script :

import bpy, bmesh
from math import sin

bm = bmesh.from_edit_mesh( bpy.context.object.data )
bm.edges.ensure_lookup_table()

lt = 0.2 #length difference + -
dt = 0.2  #max distance
at = 0.16  #max sin(angle)  (30°)

center  = lambda e : ( e.verts[0].co + e.verts[1].co ) / 2
length  = lambda e : ( e.verts[0].co - e.verts[1].co ).length
dist    = lambda v1, v2: (  v2 -  v1 ).length
sinAngle   = lambda e1, e2: abs(sin((e1.verts[1].co - e1.verts[0].co).angle(e2.verts[1].co - e2.verts[0].co)))

i =-1
while i < len(bm.edges)-1:
    i +=1
    e = bm.edges[i]
    i = e.index
    l = length(e)
    lmin = l-lt
    lmax = l+lt
    c = center(e)
    for oe in  bm.edges[i+1:]:
        if  lmin < length(oe) < lmax  and dist( center(oe), c) < dt and sinAngle(e, oe)<at :
            ev1, ev2 = e.verts[:]
            oev1, oev2 = oe.verts[:]
            print( ev2, oev2 )
            if dist(ev1.co, oev1.co ) < dist(ev1.co, oev2.co ) :
                if ev1 != oev1 : bmesh.ops.pointmerge( bm, verts = [ ev1, oev1 ], merge_co = ev1.co )
                if ev2 != oev2 : bmesh.ops.pointmerge( bm, verts = [ ev2, oev2 ], merge_co = ev2.co )
            else :
                if ev1 != oev2 : bmesh.ops.pointmerge( bm, verts = [ ev1, oev2 ], merge_co = ev1.co )
                if ev2 != oev1 : bmesh.ops.pointmerge( bm, verts = [ ev2, oev1 ], merge_co = ev2.co )
            bm.edges.ensure_lookup_table()
            i=-1
            break

bmesh.update_edit_mesh(bpy.context.object.data ,True)

Works perfectly, after I added bm.edges.ensure_lookup_table() after bm's initialization. I added that into the answer's code. Thank you!

This script will delete edges that are closer to each other than the threshold specified edgeThreshold if both their vertices are closer than the vertThreshold.
I use two thresholds in order to avoid iterating over all the edges for each edge, and filtering faraway edges (will make a big difference if the mesh is large and has many edges).
It assumes your mesh is in edit mode.

import bpy, bmesh

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

mat           = bpy.context.object.matrix_world
vertThreshold = 0.3
edgeThreshold = 0.4

calcEdgeCenter = lambda e, mat: ( mat * e.verts[0].co + mat * e.verts[1].co ) / 2
dist           = lambda v1, v2, mat: ( mat * v2 - mat * v1 ).length

removedEdges = []
for i, e in enumerate( bm.edges ):
    if i in removedEdges: continue

    # Find current edge's center point
    curEdgeCenter = calcEdgeCenter( e, mat )

    # Find close edges (whose center is closer than the edgeThreshold)
    otherEdges = [
        oe for oe in bm.edges if oe.index != e.index and \
        oe.index not in removedEdges and \
        dist( curEdgeCenter, calcEdgeCenter( oe, mat ), mat ) < edgeThreshold
    ]

    eV1, eV2 = e.verts[:]

    for oe in otherEdges:
        oeIdx = oe.index
        oeV1, oeV2 = oe.verts[:]

        # An edge will be considered redundant if both its verts are closer to
        # the current edge's verts. In that case merge the edges' vertices
        if dist( eV1.co, oeV1.co, mat ) < vertThreshold and dist( eV2.co, oeV2.co, mat ) < vertThreshold:
            if eV1.index != oeV1.index:
                bmesh.ops.pointmerge( bm, verts = [ eV1, oeV1 ], merge_co = mat * eV1.co )
            if eV2.index != oeV2.index:
                bmesh.ops.pointmerge( bm, verts = [ eV2, oeV2 ], merge_co = mat * eV2.co )
            removedEdges += [ oeIdx, i ]
        elif dist( eV1.co, oeV2.co, mat ) < vertThreshold and dist( eV2.co, oeV1.co, mat ) < vertThreshold:
            if eV1.index != oeV2.index:
                bmesh.ops.pointmerge( bm, verts = [ eV1, oeV2 ], merge_co = mat * eV1.co )
            if eV2.index != oeV1.index:
                bmesh.ops.pointmerge( bm, verts = [ eV2, oeV1 ], merge_co = mat * eV2.co )
            removedEdges += [ oeIdx, i ]

If you read my question carefully, I mention that simply removing double verts isn't reliable enough. The geometry is unpredictable, and completely unrelated verts may happen to be arbitrary close to each other.

Missed that @SamuliKärkkäinen. Will update my answer to devise a better trick.

@SamuliKärkkäinen, updated my answer with a new script that should do the trick.

Outstanding answer! For me O(n*n) is too slow, but I'll see about speeding that up using KDTree.

To make the script work on my scene, I needed to remove "mat" from the "merge_co = mat * eVx.co"'s. After that things work with low thresholds, but when I increase the thresholds, I get every time a crash, or "BMesh data of type BMVert has been removed" on "if dist( eV1.co, oeV1.co, mat ) < vertThreshold and dist( eV2.co, oeV2.co, mat ) < vertThreshold:". In the beginning of the inner loop oe.is_valid is sometimes false, but skipping those oe's doesn't end crashing. I can't figure this out.

Hmm. Can you upload your blendfile? Might be tricky to debug otherwise...

I think a sufficient scene is one with two planes, such that the thresholds in the script are larger than the greatest distance between verts in the scene.

Let us continue this discussion in chat.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
How to find which materials use a missing texture?
Menu command File > External Data > Report Missing Files gives output such as:
Warning: Path '/foo/sometexture.jpg' not found

How do I discover which materials use that texture?
Or, is there a way to get a list of materials that have missing textures?
Update: I'm specifically interested in Cycles materials.

Also see: How do I find the users of a datablock using the Python API?

For blender internal materials that is easy. Enter the image name into the find field in the outliner header. Matches will be highlighted in green with material and objects easily visible for each.

For node based materials it is a bit more complicated. While the information can be found within the Datablocks view of the Outliner it is fairly well buried and not practical to find for a large project.
Currently the easiest way to search multiple cycles materials would be to use an addon called Online Material Library(cycles materials only - not blender internal node materials). This addon is currently still considered Beta. While not included with official release builds you should find it included with custom/svn builds from graphicall or can be downloaded from the above link and installed from the preferences addon panel.
Step 1 - activate the addon (or install from file and activate)

Step 2 - Show tools. This will now be available under materials properties.

Step 3 - Save All materials.

This saves all the cycles materials in the current blend file into the folder specified above the Save all materials button. The node information used for each material will be saved into it's own file. This leaves you with a folder full of text files that can easily be searched to find the image filename you are looking for.
While it doesn't appear to have been updated for a while blender-aid may also be another option.

The Online Material Library addon is very broken, and the Linux build on graphicall doesn't work on my Ubuntu 12.04. Nonetheless, this answer seems to explain the situation well, so I'm accepting it. Thanks.

It is now in "Community" and no longer in "Testing"

Hi, with blender 2.8 it's impossible to found unlinked images in the outliner, and know what object or material need it.

You can try this, it will detect image texture missing and tell you the name of the material where it is in the console window.
It only works at the node level, not inside groups
import bpy

print ("-Listing materials where the texture is missing----------------------------------------------")

missing_texture = "exact name of the missing texture without extension"

for mat in bpy.data.materials:
    try:
        nodes = mat.node_tree.nodes
        links = mat.node_tree.links

        for node in mat.node_tree.nodes:
            if node.name == "Image Texture":
                if missing_texture in node.image.name:
                    print (">>",missing_texture,"present in material :",mat.name)

    except:
        pass


text:
Bridge edge loops maintaining quad topology?
Blender's bridge edge loops feature does not produce quad topology in some situations it could. Say I want to bridge the selected edge loops:

"Bridge edge loops" produces something like this (Loop tool's Bridge feature isn't much better):

But I want this:

Is there any way to get that result automatically?
This situation comes up in modeling eg. when transitioning from narrower area to wider, even though in the pictures both top and bottom parts are drawn equally wide.

By default with current blenders tools? No. Manually ... Extrude two middle edges, Bridge and Tris to Quads (with Max Shape Angle set to 90).

If your question was solved, please be so kind and mark the answer that contributed to the solution as "Accepted Answer". This will make it easier for others to see which way leads to the solution, and the question will no longer appear as unsolved. Thank you! Here you can find more information: What should I do when someone answers my question?. If you still didn't get a solution to your question, please be kind enough to address it.

This answer is exactly what vklidu suggested (just to close the question):
No, it can't be done automatically, but it can be done manually:

Extrude the two middle edges (E)
Create a bridge between the top edge and the bottom edge with Bridge Edge Loop
Turn each two faces into a quad (ALT+J)


text:
Blender Grease pencils glow effect in any specific layer or region
Is there an option to limit the effects like BLUR and GLOW to a specific part of a compound scene (when multiple elements in one view)? whenever I tried applying that it applied to the whole scene. Is there any shader mask or such things?
I have discovered that the effects in different objects only work if the objects are present as separate "Greasepencil objects" like 2 stroke layers (which appears in the collection).

I think you will have to use different grease pencil objects. You can kind of hack your way to emulate glow or blur with specific layers and modifiers but I don't think it's designed to be used that way. It's very easy to make different objects share materials or layers though

Hello, yes I have already mentioned the solution as you stated in the question. Creating a grease pencil object isn't tuff, but when someone is doing animation it is hard to switch between grease pencil objects, so it will be more appreciable if a separate masking layer made available for the effects layer. *Please consider I am saying in context to 2d animation


text:
Weird black lines come up over final render
In the final render these weird black outlines show up. This happens in eevee and cycles, and I have no clue why.
This only popped up on this specific render.
For example, The black outlines on the snowman and the wall edges are not supposed to be there

Using blender 2.83

It looks like you have freestyle turned on. Freestyle is used to give outlines to things (primarily), however the lines do not show up in the viewport and are only visible in renders. You can turn it off by un-checking the box in the Render Properties panel:

Ah, thanks for that, worked perfectly


text:
How to make the outline of the cut clearer with Knife Project?
This is my result of knife project

and this one is when I saw some tutorial,

is it just about the setting of the view, or maybe there's a way to make the mesh clearer?

Please don't use all caps. Why typing in all-caps looks like you’re yelling

@susu thank susu

according to this answer you can set the vertex size but not the edge thickness: https://blender.stackexchange.com/questions/67519/is-it-possible-to-change-the-width-of-edges-in-edit-mode


text:
Mirror modifier. Instead of just moving the mirrored vertices it creates new vertex on each side
I have encountered a weird behavior when I try to move one or more vertex connected to mirrored ones. instead of just moving the mirrored ones it creates new vertex on each side connected to the old ones an example of the behavior I am encountering can be see in this picture.
This was a simple cube in which I tried to move an edge while the mirror modifier was active, is there any way I can prevent this behavior?

if you mirror, don't create vertices on the mirrored part, or don't move vertices on this part, to make sure that it doesn't happen, enable the mirror Clipping option, ti may be your problem?

Turn on Bisect, it will cut the model in the middle and mirror it instead of copying/reversing it.

i have tryied that it doesn't work

I should work. Please share a screenshot of your mesh without the modifier

i found out that if you cut in half the object and delete one half before mirroring this behavior does not occur. you need to cut to repeat the process for each axis of simmetry you want to use.


text:
help understanding purpose of downloaded textures
I downloaded a sonic model from sketchfab and added all the textures, then checked the other things that came with it, many where images that seemed to have something to do with the textures, but I'm not really sure what they're exactly supposed to do

Here's the link for the model: https://sketchfab.com/3d-models/sonic-hd-full-rigged-65cc641a3adf42468641cc208a858187

https://blender.stackexchange.com/questions/174401/how-do-i-use-texture-maps-in-cycles-nodes?noredirect=1&lq=1 and https://blender.stackexchange.com/questions/80695/how-to-apply-normal-gloss-occlusion-specularity-and-displacement-map-on-o and https://blender.stackexchange.com/questions/120623/how-to-apply-albedo-ambient-occlusion-normal-bump-maps-and-metalic-roughness-t/120627#120627


text:
Cycles. The object doesn't show the material I want, but other, how do I delete unwanted materials?
I modeled Plastic Plate in Blender, then added Clear Glass Material, also render in Cycles, but it doesn't show the glass material. See the result in the image below at the left-hand side. My question continue at the second or Image 2.
Image 1.

Here I render the object in Blender, everything was fine to me. Why it can't work in Cycles, or how to do make it to work?

Image 2.

Then in the image below; how to delete these materials. See Image 3.

Image 3.

Hello :). 1. Cycles materials work differently than Blender Internal, and there's a dedicated Glass shader 2. Click the 'minus' icon in the sidebar

And also, please split this post into two separate questions :). You'll get answers for both and it keeps the site nice and tidy :).

@Jachym Michal I hope I didn't misunderstand your direction; 1. I modeled the Object in Blender, then 2. I downloaded the Clear Glass from Here [link] (http://blendermada.com/materials/detail/79-clear-glass-material/) I later find out that it was for your Cycles.
Now, before I could use this Material, I must model the Object in Cycles?

You don't need to model it again :). Just switch to cycles and use a Glass BSDF Shader.

To remove materials from an object, click the minus icon
For glass in Cycles, simply use the Glass BSDF Shader

Oh yeah, I noticed that from the Surface; I used Diffuse BSDF but when I used your preference, it worked, but the Object is darker. So I would like to know the easy way to make it more bright, at least to look like realistic Plastic Material. Though it is called Glass, but it could work for Transparent Plastic right?

Sure, clear plastic is very similar to glass :). Please, post a new question about it. (To keep the site nice and tidy.)

just make sure no Object use your material you want to delete . Unset from all objects in your scene .
then go to file>Clean up > purge all
save your project
close and re-open .
Do it times to clear Scene completely .

I didn't know where to get Clean up as you directed. I actually have the same Materials in other projects, which I did not like to see them there. So, I want to get rid of them. And I wouldn't mind to start afresh to add new materials.

Do you use a library ? read this link : https://docs.blender.org/manual/en/dev/addons/materials/material_library.html

Now I have really understood how to Remove or Delete Materials from the material-box. To Shift+Click + x to Unlink data-block. Then I Click the -Minus button, and Saved, Close Blender and Reopen it, and it was gone.


text:
How to animate the disappearance of a mesh
I have this strip on my landscape that I want to make disappear from where the digger currently is, and then following the digger towards the end of the strip, to reveal the trench underneath.
What is a good way to do this? Can I animate an object that removes the ground strip? The camera is static in this scene so I could also imagine using a mask, or doing something in the video sequence editor.
*Cutting out my strip (knife project) messes up the connection with the rest of the landscape (they both have displacement maps). So I think I need to keep both images and animate a mask in the video sequence editor or something.

To get the cleanest result I suggest animated booleans. Since you have flat shading you wont get any shading artifacts, this is probably the textbook example for them. If you have some subsurf and displacement apply them or put the booleans after the displacement.
There will be 2 boolean objects.
- First one is static and will create the hole in the ground (highlighted). Put some edgeloops in the ground object around the trench so this boolean wont segment the whole thing.
- Second one can be just an animated cube and will intersect with first boolean object and the concrete wall inside trench. The bigger the intersection the more ground will be removed and more concrete wall will be shown.

I still have the problem here that the displaced mesh deforms when I cut my strip. I can't apply the displacement modifier, because the large area has a huge subsurf and displacement. I'll try to isolate it to the frame area and then apply them.

I see, but you should really get rid of subsurface because the model is so simple. Things get easy when you have only real geometry. And if there is only real geometry and the displacement is not animated it can be applied and gotten rid of. This would make your struggle so easier.

While it might not look like it, the displacement certainly there and the subsurf is needed. The displacement map is from a very accurate height map 0.1m resolution. It cause the ditches to be where they are. I agree that here it's not that necessary, but this is zoomed in from a larger scene, and if I remove it here you would see a weird discontinuity.

I think I managed to fix it. I cut out a context area around the frame, applied the subsurf and displacement there. It looks the same as the normal situation now. Now I'll try your method.

Thanks for all the help. Having never used boolean much, I'm now having a problem that the moving cube still appears. Illustrated here: http://imgur.com/bDuk629

Un-check the render icon for every object that you dont want to render in Outliner.)

The Cube is unchecked (camera icon). Did I do something wrong with the modifier? When I click either the strip of ground or the cube they both are selected. See image bottom pane.

When I try a test with a normal cube I made and a simple strip from a cube, it does work fine. Maybe it's something with the mesh, weird and frustrating...

And now the strip doesn't connect to the landscape anymore. Couldn't I just use the before and after image and apply a sliding mask or something. Don't know how though.

I think you are doing it wrong, all booleans should have thickness (volume) and normals pointing out. Check this example, I also put there subsurf and displace: http://www.pasteall.org/blend/33201 I will edit the answer to make it more detailed

It was the normals. I flipped them and now it's fine. Thanks!

You could try a reversed Build Modifier starting with a cube which has been duplicated by an applied Array Modifier.

Result:

You could also use hide planes by the Build Modifier to uncover the trench.

The problem there is that my strip of land already has a displacement modifier shared with the rest of the landscape, otherwise it doesn't fit in. Could I cut it up in blocks and then do this?
*Nevermind, the displacement is already messed up on the cut, as it doesn't connect well with the rest now. I think I need to do something with a mask in the video sequence editor, not quite sure what yet.


text:
Particle system removes my particles when I render
I'm using a hair particle system to make a forest with the density determined by a separate UV mapped texture. When I set it up it looks correct:

But when I render it seems to remove most the particles and only leaves some blocks behind. I have no idea how to fix this:

Here is the blend file: https://mega.co.nz/#!8E5VkDaJ!PsExHPP7LQNxk8Ry7xco9B3iO1xKrDhELS6wEszjM_Q

No child particles. Don't know what details I could give, so here is the blend file: https://mega.co.nz/#!8E5VkDaJ!PsExHPP7LQNxk8Ry7xco9B3iO1xKrDhELS6wEszjM_Q

Have you tried use modifier stack?

This seems a bug report.  The viewport render looks fine and then as soon as I do a Camera render; the Viewport render breaks and now starts doing the same thing as the camera render.  When I reload the scene, the Viewport render is fine again until I do a camera render->  then both are broken again.

The subsurf modifier is closely related the erratic behavior.  Not sure why though.  Try enabling and disabling it.  Also try changing the viewport subsurf levels.  They all change the layout of the trees.

Yeah it's weird. Luckily the answer by TheAdamGaskins provides a superior work around.

Just quick side note, I'm a huge fan of this style of art. You've done a really good job on this, and I've enjoyed looking around your .blend and learning a little bit about how you did it :)
You can tell something is immediately not right if you jiggle the Display percentage, under particle settings, a little. It will cause a lot of trees to disappear like when you perform a render.

Blender seems to be a little confused, and this might be a bug.
Anyway, the underlying issue is that you're using a texture to change the density. If this is your emitter:

This is your mask texture:

Then when applied, it simply deletes the trees outside the mask:

And that's how texture density masks work. You can prove this by setting the particle count to a small number like 10. If you count up all the trees you see, it will definitely be less than 10, if there are any at all.
But what you want is for it to constrain all the trees to your mask. The way to do that is with vertex groups.
Step 1: Remove the texture mask.
Under particle settings, click here:

Scroll down, set Density to 0 and uncheck it:

At this point, you should see all 40,000 trees. You may want to go ahead and lessen the emitter amount, because your computer will probably be running slow. Also, be sure to check Use Modifier Stack.

Step 2: Create the vertex group
Now one way to create the vertex group would be to use weight painting, but that can be a pain, and you already have a texture you want to use, so we'll convert that texture into a vertex group.
First, create a new vertex group, and call it something you'll be able to remember.

Go to your particle settings, and assign the new vertex group to density.

Nothing should happen just yet. Almost there. Add a new Vertex Weight Edit modifier:

Use these magic settings:

And Voila!

Click for full size
Note: I turned down the emitter count to about 3,000 in the photo to decrease render times.

It seems a bit complex but it's nice and clear answer!

@TARDISMaker It's not as complicated as it looks, I promise :) Blender is just confusing sometimes. For example, it doesn't make sense that the vertex group density works different from the texture density. They're called the same thing, so you would think they would work the same way.

Thank you so much! This technique will also be handy for my future particle systems. I always used that density thing and did indeed notice I needed way more particles than should be necessary. Also thanks for the compliment on the style!

You said you liked the style, here you can see the resulting animation: https://www.youtube.com/watch?v=Ti724qA5XEQ
I would have liked to do more, but it was a real rush job as I only had three days. Can make some last small adjustments on monday, but that's it. It's for an item which explains the use of air cushions to reduce earthquake effects. Thanks again for the help.

Sorry forgot to mark the question as answered. Thanks again.


text:
How can I make a holographic material in cycles?
I'm talking about those holographic designs you sometimes see on stickers and foil, not free floating holograms. Examples here.
I also want this to change colors as real ones do when you rotate them.
I came across this video that shows it's possible, but it doesn't list a method.
It's similar to iridescence, but not the same. I don't see a clear path from the linked iridescence example to what I want.

That's close, but I wouldn't know hot to get from that to what you see on those stickers

I appeal to not close this question as this requires the separate solution. Hologram material behave slighty different from the iridescence material in my opinion.

@Gonzou holographic material is exactly iridescence material, just that each shape has different angle of iridescence.

I'm sorely disappointed in StackExchange (modding), as I don't see a clear path from iridescence to what I want. It's like marking a question duplicate because it uses the extrude function which has been covered elsewhere.

@David Can you explain how it is different from iridescence? As someone who voted for this to be a duplicate I don't personally understand the difference. But if you can explain how it is different, then both myself and others would be more likely to be convinced the question needs to be re-opened.

I'm not an expert so I can't comment too much on the physics. Luckily I found people on Blender Artists working on it. As you can see the technique is much more complex than show in the linked duplicate.
http://blenderartists.org/forum/showthread.php?340095-A-complex-approach-Iridescence-in-cycles/page3

@cybrbeast That link described specifically irridescence as far as I can see - but you're saying that "holograms" are different to that. Please edit your quest to be more specific about what it is you require. I realise that this is an old question but without more specific information it will never be answered.


text:
How to reload icon in ui preview dynamic
I will try to explain myself as best as possible, in this preset you can get the preview using this function,
the problem is that if I change a png file in the selected directory but keep the same name the function will not update the image since it has already been loaded, I would like to understand how to delete this icon image out of the function, I can do it anywhere is not a problem I do not need to be in the function
def enum_previews_from_directory_items(self, context):
    """EnumProperty callback"""
    enum_items = []

    if context is None:
        return enum_items

    wm = context.window_manager
    directory = wm.my_previews_dir

    # Get the preview collection (defined in register func).
    pcoll = preview_collections["main"]

    if directory == pcoll.my_previews_dir:
        return pcoll.my_previews

    print("Scanning directory: %s" % directory)

    if directory and os.path.exists(directory):
        # Scan the directory for png files
        image_paths = []
        for fn in os.listdir(directory):
            if fn.lower().endswith(".png"):
                image_paths.append(fn)

        for i, name in enumerate(image_paths):
            # generates a thumbnail preview for a file.
            filepath = os.path.join(directory, name)
            icon = pcoll.get(name)
            if not icon:
                #################################################
                ##problem if i try to reload avoiding the if  condition, get error because is has
                #already been uploaded
                thumb = pcoll.load(name, filepath, 'IMAGE')
                ##i need to delete 1 item by name so that the image can be loaded
                ###########################################
            else:
                thumb = pcoll[name]
            enum_items.append((name, name, "", thumb.icon_id, i))

    pcoll.my_previews = enum_items
    pcoll.my_previews_dir = directory

    return pcoll.my_previews

I don't need to delete in this function , i can delete from my operator button
I try to delete from bpy.utils.previews.remove(preview_collections["main"].pcoll) but i don't know if is a right way.
Edit:
Failing to find an answer this script inside an operator, it works but deletes all the previews and then regenerates them, I have not yet understood how to delete only 1 icon..
class Myoperator(bpy.types.Operator):

    def execute(self,context):

        bpy.utils.previews.remove(pcoll)
        pcoll = bpy.utils.previews.new()
        pcoll.my_previews_dir = ""
        pcoll.my_previews = ()

        return{'FINISHED'}

I think this script works for me, even if I have to say that it would be better to delete only the icon in question to avoid having to reload all the icons, I would just need to reload only the icon changed from this preview collection, for now I'll do well, if anyone has any better ideas (or correction) I would be happy


text:
Alternative to: normals_make_consistent ops (is too slow)
I try to make bmesh method but not have idea about in the apy not find that method, i need to adjust faces orientation for object selected, but my script is too slow...
I try :
selected =  bpy.context.selected_objects

for o in selected:

    if o.type == 'MESH':

        bpy.ops.object.mode_set(mode='EDIT')
        bpy.ops.mesh.select_all(action='SELECT')
        bpy.ops.mesh.normals_make_consistent(inside=True)
        bpy.ops.mesh.select_all(action='DESELECT')
        bpy.ops.object.mode_set(mode='OBJECT')

Edit 2:
    meshes = set(o.data for o in context.selected_objects if o.type == 'MESH')
    bm = bmesh.new()

    for m in meshes:
        bm.from_mesh(m)
        bmesh.ops.recalc_face_normals(bm,faces = bm.faces)
        bm.to_mesh(m)
        m.update()
        bm.clear()
    bm.free()

From Api blender , this method adjust orientation inside, but not find api to orient outside
Edit 3:
i find a bmesh ops
bmesh.ops.reverse_faces(bm,faces = (bm.faces), flip_multires = True)

now i control that in an if statement after the recalc_face_normals

Show your bmesh code, please. Others can then improve it, even if it isn't working

@Leander Ty , but no have idea about bmesh Api, because i know other function in bmesh no idea about  to normals_make_consistent in bmesh method


text:
Render Animation with layers
I'm trying to render an animation using version 2.90.1, but my PC has no chance rendering it all at once, cant even get past the first frame without vram used up.
I tried doing it with layers and I managed to render an image without it failing, but I'm wondering how I can render it as an animation/video file, as I cant find the FFmpeg in the file output settings.
Also I'm using dynamic sky for lighting and clouds etc, but can find a way to put the dynamic sky world settings into a layer/collection for it to render. And if so, does the lighting from the world settings affect the other layers?

Try compositing, maybe?

It is not recommended to render a video file (FFmpeg) directly, because if Blender crashes, you have a damaged file and have to start over. It is better to output single frames (png (lossless) or jpeg (loss of detail, but smaller file size) as animation and then use Blender's video workspace to create the video from the frames. If it crashes, it can continue where it crashed.

Render each frame and layer separately as an image sequence in EXR format.  Then composite them together in the compositor. Once you render those frames then encode as video.


text:
UV mapped texture being distorted by extruding and rotating
I'm trying to make a castle tower with this rounded stick-out part on the side. I'm trying to add this brick texture image but it's warping at the part where I extruded and rotated.  I've tried Smart UV Unwrapping and other stuff but it never works properly. Any help would be appreciated.


text:
How to fix sharp edge in 3d mesh object

I'm just trying to add numbers on to a basic shape. Most of my numbers turned out fine except my #3 which has this sharp edge on the right side. Is this a basic fix? I'd really like some help to know how to fix in the future.
Much thanks!

hello, please share your object: https://blend-exchange.giantcowfilms.com/

Is this is a project I intend to sell, do I still keep it's rights if I place it?

if you share something there's always the risk that someone steals it, so only share the bare minimum, if you can't, show more pictures so that we try to understand, for example show pictures of your topology

Sounds good, I uploaded just the number i'm having a problem with does this text help?

so I guess you've just converted a curve to mesh? There must have been an extra vertex in the curve and it has created this protrusion, switch to X ray mode with alt Z, go in ortho top view with 5 and 7, select this part with the lasso, delete with X, then select the missing face with edge loop select and fill with F


text:
Video file is much shorter than the number of frames set for the output
When I render animation, it renders all 3000 frames (avi jpg) but, the resulting video file is much shorter than the 3000 frame render. I believe that it is only creating a video file that is  about the first 1200 frames (it is stopping at a point that I had a previous render going to) event though I am rendering 3000 frames.
Why in the world would it render all of the frames in the timeline but only provide a video with less than half of the rendered frames?

Please make the title for your questions more specific and not a vague or general one.

Do you have any strips in the sequencer? https://blender.stackexchange.com/questions/5285/blender-is-rendering-an-older-version-my-project

I unchecked sequencer in the post processing section and still have the same result.

might sound stupid to ask but, did you run out of space on the hard drive?

No, I have over 1.5 tb left. I got it to work with an ffmpeg video rather than avi jpeg but, it still  was more of a work around than a solution.


text:
After rendering with OpenGL it's always rendering with OpenGL with v2.69
Just once switched to OpenGL rendering, but after that changing to Blender Render or Cycles really doesn't help. Even after quitting Blender and then re-starting it and reopening the scene, it's still rendering with OpenGL.
What could possibly go wrong?
Here's my file https://copy.com/MQ4RHuAYVvum

How are you rendering (what are you pressing)?

I'm rendering an animation. But tried to press F12 or the big Render active scene button.

Hm.. Normally those always trigger a render with cycles or whatever, I don't think it's possible to set those to render with openGL without using python or something.. Is it possible you could upload your .blend?

Here's my file - https://copy.com/MQ4RHuAYVvum

Ah, you must have rendered it to a VSE sequence.. Idk how I didn't think of it before.


text:
Which measuring is the correct one?
Just noticed that the Measure tool on the left and the Measurement of Edge Lengths under Overlays give different results, here - 3.65 and 3.76791.
EDIT - something is completely wrong there, just look at the vertical measurement which shows 31.6131 :-O
I'm using v3.4.1 on Linux.
Is that expected?

Does the object have unapplied scale?  Scale should be 1,1,1 you can Ctrl+A and apply scale if needed.

@AllenSimpson awww yes, thanks a lot! Going to read more about it, forgot to mention I'm still a beginner. Please add the answer below.

The measure tool measures world space, where these measurements are taking the object's Scale into account.  You can apply the object's scale to reset it.
In Object Mode with the object selected, press Ctrl + A for the apply menu and select Scale.


text:
Blender won't import my custom module, ImportError: No module named mymodule
My addon is in /home/usr/.config/blender/2.68/scripts/addons/foldername, has an __init__.py and cannot somehow import parts, that exist in the same folder. It says,
no module named mymodule but from text editor it runs and work properly
What could be wrong here?

it solved: import sys sys.path.append('/home/$USER/.config/blender/2.68/scripts/addons/$FOLDER') or installetion with zip from BUP

Place an __init__.py file inside a folder to make it recognized as a Python module.

@Adhi, it is in. The last thing i found, it says, that it whants not id-parameter in registration, but rna... I don't know what he needs exactly

I forgot to say, we write custon nodes addon

You can place your module into the folder blender_directory/2.68/scripts/modules/ (so Blender can found it automatically), while your addon can stay in the scripts/addons/foldername folder with its __init__.py (and not __index__.py, by the way).
Or, you can go to User Preferences, tab File, and specify a custom extra folder for scripts, in the scripts input.
Note that this custom folder must contain 3 sub-directories : addons, modules, and startup.

In this example, your addon will of course be placed in :
/home/user/scripts/blender/addons/yourAddon/,
and the module(s) you want to import will be into :
/home/user/scripts/blender/modules/.
This way, no need to use sys.path.append()!

thanks you much but index is html tradition. here all scripts init

Mostly this is a Python question, but it can be helpful to see working examples. Just like topology isn't strictly a Blender specific topic yet we still cover it sometimes. This reimport / and local imports topic is not necessarily obvious in a Blender add-on context.
If you have a folder called 'SomeAddon' and it contains the following files.
SomeAddon
Ͱ __init__.py
Ͱ resources.py

And you want to import a few functions from resources.py into __init__.py, then you do
from .resources import (function1, function2, function3)

This will work once, but when you go to reload python F8 - as you will most likely do a lot during development - the changes you make to the functions (function1, function2, function3) will not be pulled in - globals() will still contain the cached versions of the old functions.
You can control what your add-on does during the reload event (triggered by F8). Most add-ons have some form of explicit reload of their modules. What tends to work is this (or something similar):
if 'resources' in globals():
    importlib.reload(resources)

from .resources import (function1, function2, function3)

The first time you enable the add-on, resources is hoisted into the globals for this module (your add-on). When you hit F8 resources is already present and to update it you need to use importlib's reload function.

You dont need all this. Just import from __init__.py like this:
from . mymodule import *

Or from a subfolder
from . subdir.mymodule import *

Please elaborate on "You dont need all this."  Recommend reading https://medium.com/@s16h/importing-star-in-python-88fe9e8bd4d2


text:
Convert from Blender rotations to Right Handed Y-Up rotations (Maya, Houdini, ...)
Question:
My question is, how can I convert a Blender Z-Up RH rotation to Y-Up RH (Maya, Houdini, etc.) rotation?
(I believe Blender uses a Right-Handed Z-Up orientation... correct me if wrong)
Details:
Position seems pretty basic. I am simply getting the position column of the world matrix like so:
posX = lightObj.matrix_world[0][3]
posY = lightObj.matrix_world[2][3]
posZ = lightObj.matrix_world[1][3]

(swizzling Z and Y)
Rotations on the other hand seem to need more than a simple swizzle. I have figured out how to get the Blender world space rotation in XYZ by doing this:
lightObj.matrix_world.to_euler('XYZ')

Now if only I knew what to do with it... I have searched for conversion formulas online and come up with several incomplete/incorrect implementations.

Related: Is it possible to make Blender a Y-up world?

I'm not sure if it's correct, but in the past I've gotten correct-looking results by swizzling X > Z, Y > X, Z > Y.

I think swizzling works in some cases but not all, as in the swizzle is different in different quadrants or something. From what I gather I might need to build a matrix to convert coordinate systems, or make use of quaternions...

Just rotate all your objects by -90° around the x-axis. The rotation matrix will do the zwizzle for you. Just make sure you are rotating the objects relative to the world center, not relative to the object center. Then the relative positions of different objects will also be transformed correctly.

maddin45, I am not able to get this to work. I am getting a x = -90 rotation matrix, multiplying to the matrix_world of the object, then getting euler from there and results are pretty different. Can you tell me what I am doing wrong with this method?

The obj export addon uses bpy_extras.io_utils.axis_conversion

sambler, it looks like that returns the same matrix I have been trying to get to work which is supposed to transform from one coordinate system to the other. newMat = orientMat * obj.matrix_world.to_3x3() I think it must be the newMat.to_euler('XYZ') that is messing me up. All I can figure is that to_euler() might still assume things are in Z up... or I am doing something else wrong. Again an example of a working implementation would be ideal.

I don't think to_euler() takes orientation into account after all.

but blender is right handed

Finally got it! There were a few problems with my earlier attempts. The one that was throwing me off the most was incorrect position (because the rotations never looked consistently right with a wrong position)
It turns out I had the position wrong because the +Y in Blender is actually -Z in a Y-Up RH coordinate system. Or in other words when converting the code is:
posX = lightObj.matrix_world[0][3]
posY = lightObj.matrix_world[2][3]
posZ = -lightObj.matrix_world[1][3] # note the negative

(swizzle YZ and negate Z)
Another problem I encountered... It turns out there is a special case when exporting lights, which I didn't realize earlier. In Blender, the cone of a spotlight with zero rotations aims straight down, where in Maya, Houdini, and my game engine, spotlights face down the -Z. (If blender were to match this it would aim down the +Y)
So with these in mind, I came to this for rotations:
# for objects
obj = bpy.data.objects['objName']
mm = bpy_extras.io_utils.axis_conversion(from_forward='Y', from_up='Z', to_forward='-Z', to_up='Y')
om = obj.matrix_world.to_3x3()
t = mm * om
v = t.to_euler('XYZ')
print('pos:(%s, %s, %s)' % (obj.matrix_world.translation.x, obj.matrix_world.translation.z, -obj.matrix_world.translation.y))
print('rot:(%s, %s, %s)' % (degrees(v.x) + 90.0, degrees(v.y), degrees(v.z)))
# not totally sure why we need the +90 in X, but assume it has something to do with compensating for the axis_conversion

# for spot lights (they face straight down in Blender)
obj = bpy.data.objects['spotLightName']
mm = bpy_extras.io_utils.axis_conversion(from_forward='Y', from_up='Z', to_forward='-Z', to_up='Y')
om = obj.matrix_world.to_3x3()
t = mm * om
v = t.to_euler('XZY') # not sure why this needs to be XZY for spot lights and XYZ for objects
print('pos:(%s, %s, %s)' % (obj.matrix_world.translation.x, obj.matrix_world.translation.z, -obj.matrix_world.translation.y))
print('rot:(%s, %s, %s)' % (degrees(v.x), degrees(v.y), degrees(v.z)))
# note: there is no need for the axis_conversion rotation compensation due to the spotlight facing down already

As you can see in the comments, there are still things I am not clear on and not sure I am doing right, so please feel free to comment/correct me where wrong.
I have a feeling something might be off with my rotation order stuff, but I don't know what it should be. All I know intuitively is that it makes sense to use XZY since that is what I am swizzling to, that should match the post-swizzled rotation order so it is XYZ in both systems right?


text:
Does Blender keep a log when it's rendering?
Does Blender keep a log when it's rendering? Specifically, does it track when the render started, how long each frame took, etc.? I'm super curious about this information.

I don't think it does, but it should be relatively simple to implement as an addon

Blender has System Console with text.  Show with Menu ... Window Toggle System Console.  Frame rendering info of some sort is there.  Frame by frame rendering produces timestamps with can be subtracted for time duration.  These comments are meant as an interim measure.   Blender has frame events which are script accessible.

The console doesn't seem to have anything relevant, I don't think

With a frame change handler script you might consider subtracting the time of first frame render from the time of last frame render and print text to console.    Have you written a script before?  A relevant search term here might be .... frame_change.append  ............ If time permits I will post one here.  If you subtract the relevant file creation times from your operating system you might get a useful duration.

Time: 00:00.12 (Saving: 00:00.02) .....  is an example from the Blender Console.  So perhaps not the most appetizing approach to sum the time values.

The rendertime is saved in each rendered image's meta data. You can also write quite a bit of information directly onto the image via the stamp option

Here's a quick script you can use to output some simple frame times:
import bpy
from bpy.app import handlers
from datetime import datetime

def render_init_handler(dummy):

    global LASTFRAME
    global STARTTIME

    STARTTIME = datetime.now()
    LASTFRAME = datetime.now()

def render_post_handler(dummy):

    global LASTFRAME
    global STARTTIME

    ELAPSEDTIME = datetime.now() - STARTTIME
    FRAMELENGTH = datetime.now() - LASTFRAME
    frameNum = bpy.context.scene.frame_current
    blendName = bpy.path.basename(bpy.context.blend_data.filepath)[:-6]

    f = open(bpy.path.abspath("//") + blendName + '-renderlog.txt','a')
    f.write("Frame %d - Length: %s - Elapsed: %s\n" % (frameNum,FRAMELENGTH, ELAPSEDTIME))
    f.close()

    LASTFRAME = datetime.now()

handlers.render_init.append(render_init_handler)
handlers.render_post.append(render_post_handler)

You should generate a text file that looks like this inside:
Frame 1 - Length: 0:00:00.139432 - Elapsed: 0:00:00.139441
Frame 2 - Length: 0:00:00.232712 - Elapsed: 0:00:00.372586
Frame 3 - Length: 0:00:00.257580 - Elapsed: 0:00:00.630437
Frame 4 - Length: 0:00:00.265303 - Elapsed: 0:00:00.895999
Frame 5 - Length: 0:00:00.259570 - Elapsed: 0:00:01.155840
Frame 6 - Length: 0:00:00.266500 - Elapsed: 0:00:01.422597
Frame 7 - Length: 0:00:00.260504 - Elapsed: 0:00:01.683389
Frame 8 - Length: 0:00:00.259319 - Elapsed: 0:00:01.942971
Frame 9 - Length: 0:00:00.258627 - Elapsed: 0:00:02.201868
Frame 10 - Length: 0:00:00.260319 - Elapsed: 0:00:02.462535
Frame 11 - Length: 0:00:00.257915 - Elapsed: 0:00:02.720720
Frame 12 - Length: 0:00:00.261301 - Elapsed: 0:00:02.982309
Frame 13 - Length: 0:00:00.262327 - Elapsed: 0:00:03.244906


text:
Way for save or store by StringProperty (Preset) all the class PropertyGroup
I'm writing a script, now I'd like to understand how these properties can be saved, the properties are stored in a class PropPerSet(bpy.types.PropertyGroup), I put a StringProperty as input to give a name to the preset, 1 button operator for save 1 button operator to delete current preset, and an EnumProperty for a list of options, the class is based on Scene.scene_check_set = bpy.props.PointerProperty (type = PropPerSet), it is possible to save in a text file, or better other solutions ?
Edit 1:
This is my idea input is StringProperty, dropdown menu is only example i put manually in enum "My preset 1":

You may add another two operators to save and load those properties as dict by encoded to JSON format files, which is more flexible when you want to exchange in other program and read it directly from text.

@Hikariztw, ty know any way to find an example for store and save my Scene.scene_check_set = bpy.props.PointerProperty (type = PropPerSet)?

Related. https://blender.stackexchange.com/questions/134613/can-python-operator-presets-be-shared-between-operators/134620#134620  define scene in preset defines scene = bpy.context.scene and scene.scene_check_set.foo etc in values.

@batFINGER, ty
the concept is not very clear to me, for example, after setting the parameters in the UI panel I would like to save these parameters in a file or somewhere else, I would like these presets to be recalled via (I think) a drop down list, for now I have created an EnumPropery ... but I don't think it's the right way, the example you indicated is what I need? I have to put name in preset for example 'My preset 1" "My Preset 2" by Stringproperty


text:
Copy vertex groups from old object to new object(2.8)
I have to modify new orientation and for this i think to make a copy from old object to new object, but not undertand if is possible to copy vertex grup from old object/ mesh to new object/ mesh :
 old_obj = bpy.data.objects['My old obj name']

 mesh = bpy.data.meshes.new('My new obj name')
 new_obj = bpy.data.objects.new('My new obj name', mesh)
 new_obj.data = old_obj.data.copy()

Do you need to use python? Under the +- buttons next to the shape key list is a menu that has Transfer shape key that will copy the active shapekey from a selected object to the active object.

@Sambler, sorry i need a script in python


text:
Is there a way to memorize properties that refer to the project and not to the scene?
I have properties pi like bpy.props.PointerProperty, this is very useful to me, I often use them to refer to the scene in use, but I'm having to create new scenes and all references to other scenes when I add a new scene return to the default value (rightly) I was wondering if there was a way to avoid having to create a function that copies these values (since they are many) The current example is the one I have, that is properties that refer to bpy.context.scene:
class MySceneProperty(bpy.types.PropertyGroup):

    my_bool: BoolProperty(default=false)
    my_int: IntProperty(default=0)
    my_float: FloatProperty(default=0.0)

def register():

    bpy.types.Scene.scene_prop = bpy.props.PointerProperty(type=MySceneProperty)

This is usually very convenient, but currently I am dealing with the creation of new scenes and it creates the problem that these values return to the default state, there is something above bpy.types.Scene?
Edit:
I was trying to copy the properties from one scene to another but I realize I can't, this should happen when bpy.data.scenes.new is created


text:
How to exit with keys like "ESC" or "CANC" from for loop?
I was wondering if there was a simple way to get out of a "for loop" in case it gets too long. I was thinking in a keyboard type input as the interface during this cycle is completely freezed.
Currently I have this cycle inside a function called by an operator.
Example
class MyOperator(bpy.types.Operator):
   """call my function"""
    bl_idname = "call.function"
    bl_label = "My Ops"
    def execute(self,context):

        myfunction(self,context)

        return{'FINISHED'}

def myfunction(self,context)
    for many in context.scene:
        many.###blah blah blah
        ###I would like to use the 'Esc' button to exit this cycle

Depends on how you enter in the for-loop. In your case, it will be difficult to make it stop since the keyboard event is not given concurrently in your loop. The loop won't catch any new event unless you use some async method.

@Hikariztw Hi, thanks for the time dedicated to me, I'd like to know something about it, I grope in the dark and I don't know what kind of research to do to find the solution

I don't really do that before but usually the key input is deal in def modal(self, context, event):. This block catch all user event which can be determined whether the function should stop or not.

But as I said, I am aware that the for-loop couldn't get other information in the same time since it is one-thread program. Those event should go after the for loop. So check asyncio and concurrency and parallelism for details.

I admit I don't understand much, but I have a problem, the modal operator I saw that happens inside a class, the problem is that the function with inside the "for loop" is callable by some operators , so I really don't know how to organize it

As you might know, Blender comes with python templates as part of the Text Editor. Have a look into Python > Templates > Operator Modal - In this template ESC is already pre-defined and ready to go @Pastrokkio

@Hikariztw think I think your first comment is correct, I just tested the modal method, but it doesn't detect any input, I tried a while method, until the cycle ends the blender interface is completely freezed


text:
How to make node group of an existing material into a new group? (in python)
This is what I would like:

I'm looking for an alternative to bpy.ops.node.group_make()
Because it seems like a bad approach.
I simply want to group a new group nodes of an already existing material, without having to recreate anything, after which I would add the inputs and outputs (the latter does not seem to me a difficult passage)
But the problem is that I can't find answers anywhere, I probably try badly, but basically I just want to move my nodes within a group, just like it does bpy.ops.node.group_make()This, however, has problems in the context area so I discarded it regardless
Edit: I want to clarify that this must happen in the context 3D_view the context nodes editor is not necessarily open
Edit 2: I was also thinking if it is possible to easily copy the nodes and their links / parameters without necessarily having to write an exaggeratedly long script, to then insert them in the group node

Just for clarification, you would be fine with using bpy.ops.node.group_make() if the issue of passing the correct context would be solved?

@rjg Hi, thanks for your interest. Only if it is the only possibility without an alternative, I find it quite frustrating to have to do a loop that checks all the links of the nodes and then having to reconnect them within the group. Basically, I think that's what bpy.ops does, but I'm not sure because I have little experience with groups

The operator does exactly what happens when you select nodes and then use Add > Group > Make Group or CTRL + G to create a new group based on the selected nodes. Is that the behavior you want or something else?

@rjg Basically yes, but there are context problems, as I need it to work also with the closed nodes editor. This is very important.Currently if I run this bpy.ops.node.group_make ()
I get (rightly) this error: RuntimeError: Operator bpy.ops.node.group_make.poll () failed, context is incorrect. I need this to work from the "UI" panel in the 3DView via a button

You could change one of the areas to the node editor and switch back afterwards, but this is not a nice solution. How do you know which nodes should be grouped, since the node editor isn't open so presumably the user didn't select them?

@rjg The nodes are easily available by : for n in C.object.active_material.node_tree.nodes:
from here you can also make selected or not with n.select = True     It is not important to see the nodes, the nodes are already defined, so they will be converted into a group

I'm was already aware of that, what I'm interested in is understanding your use case. When and why would you want to group nodes? Which nodes do you want to group? Surely you don't want to create a group from all nodes in the material, material output node included. So where does that selection come from?

This must group all the nodes present through a function. Obviously the output node remains outside and probably also the mapping and coordinates node. It is simply a question of enclosing the nodes in a group, which I can then manage separately, but the point that interests me is how to group, here there are missing commands in blender "Low level" api that prevent simple grouping (Nothing more), bpy.ops would be convenient (but not very good),  I see that there are indeed problems with the context.

The issue with switching the area is that the ids aren't properly updated and edit_tree isn't set before calling the operator. You could set it manually, however the ids aren't updated until the WM_main is executed where wm_event_do_notifiers is called which further down the stack results in a call to node_area_refresh() and snode_set_context() and ED_node_tree_start() (space_node.c). This is the reason why it works when you run the script a second time.

@RobertGützkow Thank you very much for the accuracy of the information, and the time you're dedicating to this, I'm really frustrated by this, I don't understand how to get around this, this seems to be a lack of API, I really don't know if to report this and how

I have one method May be this is what you wan't this may work for you
if you do not wan't to use bpy.ops. .... then you have to create a node group
import bpy

for mat in bpy.data.materials:
    if "Material" in mat.name:
        nodes = mat.node_tree.nodes
        for node in nodes:
            if node.type != 'OUTPUT_MATERIAL':  # skip the material output node as we'll need it later
                nodes.remove(node)
group = bpy.data.node_groups.new(type="ShaderNodeTree", name="Test Group")

#Creating Group Input
group.inputs.new("NodeSocketShader", "Input1")
group.inputs.new("NodeSocketShader", "Input2")
input_node = group.nodes.new("NodeGroupInput")
input_node.location = (0, 0)

#Setting Default Values For Node Sockets

group.inputs[0].default_value = (1.000)
group.inputs[1].default_value = (2.000)

#Creating Group Output
group.outputs.new("NodeSocketShader", "Output1")
group.outputs.new("NodeSocketShader", "Output2")
output_node = group.nodes.new("NodeGroupOutput")
output_node.location = (500, 0)

# Creating Principled bsdf Node
#You can create any node here which you think are required to be in the group as these will be created automatically in a group

Principled_Bsdf_node = group.nodes.new('ShaderNodeBsdfPrincipled')
Principled_Bsdf_node.location = (100, 0)

#creating links between nodes in group
group.links.new(input_node.outputs["Input1"], Principled_Bsdf_node.inputs[0])
group.links.new(Principled_Bsdf_node.outputs["BSDF"], output_node.inputs[0])

# Putting Node Group to the node editor
tree = bpy.context.object.active_material.node_tree
group_node = tree.nodes.new("ShaderNodeGroup")
group_node.node_tree = group
group_node.location = (-40,0)

#connections bewteen node group to output

ShaderNodeOutputMaterial_node = tree.nodes["Material Output"]
links = tree.links
link = links.new(group_node.outputs[0], ShaderNodeOutputMaterial_node.inputs[1])

Thank you for the answer, but this method does not group, this creates a new group but does not contain the existing ones, it seems to me very far from bpy.ops.node.group_make (), the problem is how to group existing nodes. This method you indicated requires the creation of new nodes which is good if you want to build a set of nodes from "0" but not useful for grouping existing nodes


text:
After moving bones and inserting keyframes, the animation doesn't work
I'm animating something right now and when I go into pose mode, and move the bones and inserted a keyframe and i go back to the first frame and play the animation, nothing happens, anyone got any ideas?

In the Timeline > Keying menu, have you chosen a transform in the Active Keying Set menu? Or is one of the Dope Sheet track locked? Maybe share your file (the armature only): https://blend-exchange.giantcowfilms.com/

The way you describe it sounds like you only have one keyframe. You need at least 2 for a bone to do anything.


text:
How to take away the wrinkles on the tentacles?
so I have just started on blender 3D modelling and have a question regarding it. Now, I'm planning to create a 3D Octopus, and I'm stuck at the tentacle's suckers. After I shade smooth the tentacles, the tentacles appear to have wrinkles, how do I solve that?

I tried Knife tool too.

please edit your question and show an image of the object in edit mode  in a way that shows the topology. Most likely you are dealing with n-gons and non planar geometry. Did you use booleans?

related: https://blender.stackexchange.com/questions/49639/how-to-smooth-an-arrayed-object-so-the-breaks-between-objects-are-less-obvious/49651#49651

As supected: n-gons (polygons with more than 4 vertices) creating non planar faces.. Start over and try to keep quad topology. https://topology-guides.tumblr.com/page/3

I don't think you need to start over, add a loop cut (CTRL R) between the suckers. If the problem persists, make quads from the 1. vertex that pokes into one of your ngons and the middle loop. Or add a multires and see if you can just use the smooth brush to avoid the ugly normals.

As it has been said, your topology is bad, the stretched triangles create these artifacts. To fix this, use the knife (K to activate, Z to cut through) to create new edge loops, and join (J) the vertices like that, and it should work:


text:
Error EXCEPTION ACCESS VIOLATION. Blender is crashing at startup, even though it's the latest version
Blender is crashing at startup,  even though it's the latest version.
One of the solutions worked temporarily and then the problem came back. I tried to add something to Environmental Variables which actually worked just for a bit then on the next try to open Blender it crashed again. My video card is updated plus I tried running Blender through CMD and I tried running it as administrator. All FAILED.
The error on CMD shows is as follows:
Error EXCEPTION ACCESS VIOLATION
...

Try using the zip version, not the install one.

So I uninstall this one n then I download the zip version from the official site?

I tried it it didn't work


text:
Set Camera Depth of Field so that the character is not blurry, but the scene behind it is
I set a scene in evee and I really like the effect of the Camera Depth of field. In this scene I have a character right in foreground. The effect of the camera blurs it way too much. Is there something I can do to maintain the effect on the scene but not on the character?
Thanks!

Maybe render just the bakground with one camera settings, then just character with other settings and then join two renders in Gimp.

Depth of field is the area in which elements are acceptably in focus. Objects closer of further away from that area will be progressively blurry.

Image from https://expertphotography.com/understanding-depth-of-field-photography/
By changing the focus and the $f$ stop (iris) on the camera, you can determine where objects are in focus and when they are not. The wider (lower value) on the $f$ stop, focus will be more critical. As you close (higher value) the iris to a higher $f$ stop more of the scene (in front and behind the object) will be in focus, or less blurry.
Here's an example from wikipedia:

Play with the values for focus and $f$ stop, until you find the point where you get the results you are after.

In the camera menu under depth of field, you can set the focus object to the character in order to keep the character in focus. Note that it will focus on the origin of the character object (the small orange dot that appears when you select the object in object mode). If the dot is not centered on the object, you can center it by clicking Object > Set Origin > Origin to Center of Mass (Volume).
You can also manually change the focus distance under the depth of field menu. When changing the focus distance, changing the F-Stop might also be needed to get the same amount of bokeh for the background as before.


text:
Texture brightness problem in Cycles
Currently using 2.83 (supposedly latest version).
When I add an image as plane (leaves for my tree), its colour is very pale/bright. This looks alright in Eevee but looks horrible in most other render options (such as Cycles) that I have available. (BTW, if I export my tree model to UE4, which version will be used? The Eevee or Cycles one?) Can someone please help? Will provide whatever information is necessary to have this problem solved.

it might be the Render > Color Management? or the lighting?

How bright things are depends on the intensity of the lights and environment.

I did search in the Color Management and tried different stuff, but didnt notice any improvement. Anything a bit more specific?
@susu But why is it normal in Eevee and this bright in Cycles? It is the same light with the same intensity....

could you please pack the image and share your file? The renders will be different in Eevee and Cycles, so Cycles may need some adjusments

Couldn't find an option to upload directly here, so used a fileshare site:
https://gofile.io/d/obZDgy
Advice is appreciated.


text:
Image as plane layering problem
I've got this problem with layered planes where planes behind are showing through the top ones.
Tried spacing them further apart but that didn't fix the problem since I plan to make a lot of these for foliage so I can't do that. When spaced really far apart, the problem does not happen, but this is not viable in my use case.
Made a video to illustrate the problem so please take a look at the link below.
https://youtu.be/LGGhv192yzo

I am using Eevee yes.

https://blender.stackexchange.com/questions/160389/pngs-in-distance-appear-to-overlap-foreground-pngs-when-viewed-at-different-angl

https://blender.stackexchange.com/questions/143525/eyes-wont-show-correctly-overlapping-transparency-issue/144813#144813

https://blender.stackexchange.com/questions/182646/odd-transparency-or-normal-issues/182651#182651

Swapping blendmode from alpha blend to alpha clip fixed it so I will keep this in mind in the future, thank you.

Please write an answer in the answers section. Other users with the same issue can learn from your experience


text:
Need advice to cleanup and rectify shading issues caused by boolean

Need advice. I used union boolean to make this object, now need help to cleanup and rectify shading issues. Thank you

I guess you'll have to do it manually, but you should simplify your mesh a bit, you don't need so many edge loops


text:
How to create a flare lighting up the background

Hello! I am a Blender 2.8 beginner. I want that little sphere at the back to act like a Sun and light up some of the background, kind of like this:

But I have no idea how to achieve that. Can somebody please help me?
Also, any other advice or criticism is welcome.
Thank you

If your sphere has an emission material, go to the render settings tab (the one that looks like a little camera), and enable "Bloom". You may have to increase the emission strength to make it "glow" the way you want.

It worked. Thank you @ChristopherBennett

Firstly, that sphere is not lighting up the background. The background appears to be an HDRI and the HDRI lights the scene, the scene does not light the HDRI. The effect that you want is glow (aka bloom).
If you are in Eevee then you can give that sphere an emission shader and turn on bloom. and that is the only step. If it does not appear change the emission value or change the values of the bloom.
If you are in Cycles there are two options (probably more, but these are what I know).
First way is to give it an emission shader set to any ammount and set the render passes to include Emission. Then in the compositor use a gleam node set to something like fog glow.
The second way is to render it twice (this is the slow method unless you have a good computer or little geometry). Render it once in Cycles for the high quality render and again in Eevee (at the same resolution and settings except maybe samples which can be turned down). In Eevee set the render passes to include bloom. In the compositor combine the Eevee bloom pass with the cycles render with a MixRGB node set to screen or add.

It worked. Thank you so much


text:
Boolean issues with subdivision surface
I have a problem with the Boolean and subsurface division: it created shading issues.
Herewith I attach the image with my modifiers.
Need help to solve this problem
]1

The problem with Boolean operations is that they create quite the mess in your topology. This messy topology results in shading artifacts. Because subsurf results in so much geometry, it makes this mess nearly impossible to fix.
Put your current mesh in an archive somewhere in case you mess something up. Duplicate it and work on the duplicate.
Now, select the duplicate, apply all boolean modifiers but not the subsurf modifier. This will make the topology easier to handle. Go into Edit Mode and try to fix the topology.
After doing that, there's one problem. Your Booleans are going to be subsurfed as well. To avoid that, there's two options:

Select all the edges of your booleans and set their edge crease to 1. The edge creases tell the subsurf modifier not to smooth those edges.

Add supporting geometry to your booleans so they don't get smoothed as much.

If both of those don't work, try turning on Auto Smooth and adjust the angle. This cuts off the smoothing on corners at an angle greater than the Auto Smooth angle.

Your mesh should now not have the shading problems you had before.