text:
GN: Setting modifier property via python does not update the 3D view
I copied full datapath for my property Vertices X as shown below and set it via python using bpy.data.objects["Cube"].modifiers["GeometryNodes"]["Socket_2"] = 5. The value will update when you hover over it but it does not update the 3D View evidenced in the GN tree socket value it's still 2 instead of 5. Why? I found this thread but no answer. Is this a bug?
I also tried context.view_layer.update() but that didn't help...

I noticed that when I manually toggle back and forth it works but if I do it with script it doesn't:
bpy.data.objects["Cube"].modifiers["GeometryNodes"]["Socket_2"] = 5
bpy.ops.object.mode_set_toggle()
bpy.ops.object.mode_set_toggle()

I also found this answer and tried this:
dg = bpy.context.evaluated_depsgraph_get()
dg.update()

But that also doesn't work. Is this maybe a bug I should log?

You can do the following:
import bpy

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

cube.modifiers["GeometryNodes"]["Socket_2"] = 2

cube.modifiers.update()

cube.update_tag()

About cube.modifiers.update() the Python console says

update() .. method:: update() Execute the properties update callback.
.. note::    This is called when assigning a property,    however in
rare cases it's useful to call explicitly.


text:
Python generated geonodes setup not behaving the same with the original geonode setup despite being identical
I have made a python script using this amazing addon Node2Python from the geometry nodes setup I made when I asked about this question. Shoutout to lemon thank you so much for your help! The geometry nodes to voxelize worked perfectly. At first when I generated the python script equivalent of the node setup and then executed it, you will see that the setup is exactly the same with the previous setup I have (The blend file is also available in the previous thread)

But when I apply this python generated setup, the colors output don't match anymore. I compared both the original GN version and the python generated GN version and I don't see any difference yet the output is not right. What's going on? I'm not sure if I reproduced a bug, can anyone confirm?

UPDATE: It looks like a bug as confirmed by lemon here
When you apply the modifier notice that there is an empty material added. This new empty material is added at the end in the original setup, hence not interfering with the setup. The python-generated node setup however inserts this empty material at index zero and thus disrupting the node setup by shifting all the material indices. So this is definitely a bug because of the inconsistent behavior despite identical GN setups.

Now the question is, does anyone know of a workaround to this?

I don't know the reason, but I ran the script again and... it works!

not totally. I've studied your files, tried with other models etc. And at the end, I've just regenerated the node tree using the script (and this time, it was ok).

Yes I've seen that also. Do you confirm that regenerating the node tree does the job (and repeatedly)?

Well.. I'm now unable to open "wtf" file again... Blender crashes each time...

thank you for helping me out! this is the code https://pastebin.com/tvWrhpBy

I think there is a bug somewhere (in gn)... If you apply the modifier using the original node tree, it adds a blank material but at the end so that this is not visible. But with the script this blank material is added at the begining... so it's visible... Why? For now I don't know. Just checked this is the same in 4.2.0. Most likely a bug in Blender. I will report that

FYI, https://projects.blender.org/blender/blender/issues/119258

ok i see the extra material after apply at index 0 when python generated :( thank you for this information! i will try to find a workaround. i added a comment in the ticket, please can you read it. I think you can reopen if you rename the title differently because the referenced issue is complaining about an empty material added, but in our scenario we are not complaining about an empty material but rather about its inconsistent placement so we have no issue about the extra empty material. I created more specific one https://projects.blender.org/blender/blender/issues/119269

We can conclude that the addon somehow inverts the "join geometry" inputs, so that, if volume is first, we have the empty slot first. right? If having at least one mat slot is the way gn is for volume, your workaround works, but the bug is in the addon, I think.

Yes I verified now and there indeed is a bug in the addon that it interchanged the noodles to Join Geometry causing the empty material to get prepended instead of appended.

Digging a bit more, I've sent this new ticket: https://projects.blender.org/blender/blender/issues/119272 (so not sure this is the addon in itself...)

And I've warned NodeToPython about that: https://github.com/BrendanParmer/NodeToPython/issues/97

And (last) scurest pointed me to https://docs.blender.org/api/4.1/bpy.types.NodeLink.html#bpy.types.NodeLink.multi_input_sort_id but multi_input_sort_id will be available in 4.1

One possible workaround is to add +1 to the material index since blender consistently adds a hidden empty material to index 0. The development team claims it to be expected behavior in TICKET-119258 to add a hidden/secret Empty material.

Iliya Katushenock commented:
Volume have no material. Every time when new mesh is created from
scratch (not from other mesh) (but from volume without material), its
matrials list are empty. We can not have empty materials list on mesh
in geometry nodes, so empty material slot are added. This is expected behavior

So I guess this is the "proper" solution?

UPDATE:
The right solution is to swap the noodles going into the Join Geometry node so that the hidden empty material gets added to the end of the materials list, thus not interfering with the node setup.

will not always work. check Gordon's answer https://blender.stackexchange.com/a/314478/184387

source: Stack Exchange

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

sort: votes


text:
Beginning of Renders are Choppy | Cycles Render
When I render an animation, the first several frames are choppy and not smooth. This has been happening for a while and I'm not sure why it occurs -- it's only within the first 24 frames. This has occurred with both 2D and 3D animations.
I tried changing my fps and extending keyframe durations (both for 2D and 3D projects), yet the results remain the same.
The included .gif is a converted .avi rendered at 60 frames per second over 250 frames. It looks like the gif completely skipped over the choppy frames -- you'll notice it jumps.
Res: 1920 x 1920 | File Format: H.264 | Format: AVI | Codec: H.264
EDIT: I have tried reducing frame rate in addition to extending frames; I've also tried adding motion blur.
PROJECT FILE: https://drive.google.com/open?id=0B9m9vbrOjVXBTXpzdlVTM2IwZ3c

@cegaton if OP has the same problem as me it's irrelevant to the scene. As  for settings it's always present with H.264 encoding. It's gone after rendering animation to images.

@cegaton I'll provide later on .blend file and rendered animation file to inspect. And it's doesn't matter how much FPS you are rendering.

@cegaton I'm not using a curve, I set manual keyframes every 5 frames or so. The beginning of all renders are choppy. In my experience it's irrelevant to how the scene is set up, I experience the same issue.
I have two PCs, one at work and one at home. The one at home is optimized for animation, yet this still occurs.

@lukjach98 We need a .Blend file to troubleshoot. There can be several things wrong. It could be your render settings, your animation settings, your sequence settings, etc. etc.

@Einar I've uploaded the project file. Sorry about that. To be clear, I've changed the frame rate several times and it had no effect. I've just added motion blur and it looks slightly better.

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


text:
Subdividing a face with subdivided edges
When modeling, I sometimes run into the problem of trying to subdivide a face but can not do so because one or more of its edges are already subdivided.
For example, in this image, I can't subdivide the selected face because the other faces by it are already subdivided. When I try to subdivide the selected face, it just subdivides the edges instead.

I use the knife tool K to solve this problem.
LMB on one vertex, LMB on the opposite vertex, then press Enter.

Do this for each vertex that isn't connected, across the face.

The process is much faster than it sounds.  I'm hoping that someone will answer with a quick two step solution though.

You can fix this by dissolving the vertices
First delete the four subdivided edges

Then, in vertex mode, select all four of the "edge vertices" and press X then D to dissolve them.

finally select the four corners and press f to fill.

Now you can subdivide again!
Gif of the whole thing

UPDATE:
To fix the problem in your example it may take a few extra steps. It really isn't as hard as the eight steps may tell you

Select the face you wish to subdivide
Press Shift+D, then right click to cancel.
Next move the face, it is important you move the face precisely. For example I did Y then pressed 2
With that new duplicated face, dissolve all vertices except for the corner four.
Now, you can subdivide the face. In your example, it looks like you only want to do it once.
Now it is time to put the face back. Start by deleting the original one. Now move the plane back the exact opposite number you moved it forward. So, for me, that would be Y then -2
You need to now connect all vertices. There are a couple methods but here is my preferred method:
Go into wireframe mode by pressing Z. Since the vertices are in the same spot it will be difficult to select both, so press C to bring up the circular selection tool. Select two vertices right next to each other and press ALT+M, then A. Do this on the corners and edges. There you go! All subdivide.

NOTE:
I would, however, takes cegaton's advice in removing N-gons and triangles

This works but when I start doing more complex models edges can have multiple verticies and dissolving them would make a flat face. This can be a problem especially if multiple edges of a face are subdivides and dissolving all the verticies would make one huge flat face.

@playjoy can you give me an example? Because faces shouldn't have any more than four vertices

I added a better example; problems like this happen often, when I subdivide certain faces to make it easier to edit. In the image above, it would be difficult to dissolve the vertices as the model is curved and would mess up the mesh.

@playjoy updating answer...

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


text:
How to make a dynamic arrow from a vertex to another face center
I would like to make some arrows, each of whose shaft is a cubic bezier curve, beginning (tail) at a mesh vertex, and ending (head) at the center of a mesh face.
(The "center" of a face can be defined in any of several ways; e.g. centroid of vertices, or centroid of area; either of these is fine.)
The following picture shows three such arrows (tediously created by hand, not dynamic):

The arrow heads and tails should stay attached to the respective mesh features, as the meshes are translated/rotated/scaled and deformed (without structural changes).  The directions at the arrow heads and tails should always stay pointed in the directions of the respective mesh surface normals.
How can I create such arrows?

This reads like a job offer.

These other questions seem related to this one: https://blender.stackexchange.com/questions/13452/attaching-a-curve-by-its-endpoints-to-two-spheres https://blender.stackexchange.com/questions/38891/dynamic-way-to-connect-the-balls-with-rods  Specifically, it looks like the answer to those questions ("use a hook modifier") will address the subproblem of attaching the bezier curve's endpoints to two other movable objects.

Geometry Nodes should work, too. How do you define the face where the arrows should point to? The starting vertex could be defined by a vertex group.

You can do it with geometry nodes.
The nodes belong to the source object (from which the arrow originates).
Then it takes a target object (which the arrow points to)
The nodes take 4 user inputs:

Target object (the object which contains the target face)
Point index (the index of the point from which the arrow originates)
Face index (the index of the face the arrow points to)
Handle length (controls how early the arrow starts curving and also controls the diameter and size of the cone)

This is the main geometry node setup:

This is the Get_Directions node group:

This is the Create_Cone group:

I made the size of the cone and the diameter of the arrow dependent on Handle_Length.
File:

Alternative for versions that don't have "Align rotation to vector" node:
The Create_Cone group will be like this, where the change is only the part that connects to the rotation:

Alternative file:

Beautiful!  And full of great educational material for me to study.

One problem I notice: when I bring it up in blender 4.0.2 (which is the latest blender version available on my ubuntu linux distribution, at the moment), the cone is pointed in the direct opposite of the correct direction.  But it's correct in the 4.3.alpha which I built from source code.

@DonHatch, to solve the cone issue, just remove the multiplication by -1 that is connected to the Arrow_Direction output of the Get_Directions group. I'll leave the answer as is because it's tested and working for Blender 4.2.2 on Windows. If you consider the answer solves you question, please mark it as answered

@DonHatch, another thing to pay attention to: the face orientation of your objects. Since it's using the normal vector, if faces are inverted, the normals are also inverted. Also, the scales (scales must probably be applied to avoid distortions). And if you have a negative scale, that might cause the same problem.

I'd like to get something that works with 4.0 as well (and farther back, if feasible), so that I, and anyone I share blend files with, aren't forced to upgrade to a blender version that isn't universally available yet in order to view and work with my blend-files.  I'll try to see if I can figure out why it's not working on 4.0- that'll be a good way for me to get familiar with what you've done here.

@DonHatch, I told you above and updated the answer too. The solution is very simple.

Let us continue this discussion in chat.

Summary of chat: the solution didn't work in blender 4.0 because it uses a "Align rotation to vector" node which didn't exist yet.  The alternative solution works.

There's a problem: I need arrows to go from mesh object A to B to C and then back to A (as shown in my original mockup image). But when I try to hook that up using the solution given here, it fails with an error message to the terminal window, saying "Dependency cycle detected", and listing the names of the objects participating in the cycle.  Can this be avoided?  (I see one way to do it: make each arrow be an additional object, with geometry node group inputs referring to its "from" and "to" object; then there will be no cycles.)

Yeah... I think your solution would be the best in this case. Empty meshes being the arrows.

I added an answer showing a solution that supports cycles, based on your solution.

This is based on Daniel Möller's solution, improved so that cycles are supported.
E.g. you can have a cycle of arrows among objects A->B->C->A as shown in the original mockup picture, or an arrow from an object to itself.
The arrow is a separate object, so you can even have arrows between arrows, as shown here.

I constructed the graph in blender 4.3.alpha (built from source code from github).

Note that it contains both an Align Rotation to Vector node (the simplest way to do it in blender 4.2 and higher, but doesn't exist pre-4.2) and Daniel Möller's alternative implementation of that node, which I made into a node group Rotation to Vector: Z Axis (shim for pre 4.2).
Either one should work in 4.2+ (just switch the Transform's Rotation input from one to the other); I hooked it up to the latter, so that the solution will work in pre-4.2 as well (tested on 4.0).
Here is the shim node group, expanded (using Tab):

One non-obvious thing I noticed, in the shim node group: there is an Equal node, whose tolerance epsilon is displayed as 0.0000, which seems like it wouldn't work well.
But if you hover over the value or edit it, it becomes clear that it's actually 1e-5, which is a sensible value.
I don't know whether there's a way to make it display this important value better, but I changed the title of this node from Equal to Equals zero (within 1e-5) to try to call this out.

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


text:
How to write an undo-compatible python function to create a cube without using bpy.ops?
I'd like to make a blender python function that creates a mesh cube efficiently (i.e. without calling anything from bpy.ops),
using the technique described in this answer:
that is, copy an existing template object.
The caller of the function should not have to manage, or know about,
the template object; that should be a private implementation detail.
Here is my attempt:
import bpy
from mathutils import Vector

_template_cube = None
def PrimitiveCubeAddNotHorriblySlowly():
  global _template_cube
  if _template_cube is None:
    bpy.ops.mesh.primitive_cube_add()
    _template_cube = bpy.context.object  # the newly created cube
    _template_cube.name = "_template_cube"
    # Make template object invisible
    _template_cube.hide_set(True)

  new_cube = _template_cube.copy()
  new_cube.data = new_cube.data.copy()  # also duplicate mesh (remove for linked duplicate)

  # Change name and visibilty from those of the template.
  new_cube.name = "Cube"  # this may turn into "Cube.001" or etc., as usual
  new_cube.hide_set(False)

  bpy.context.scene.collection.objects.link(new_cube)

  # If this is used as a drop-in replacement for bpy.ops.curve.primitive_cube_add(),
  # then subsequent operations may assume the new object is the only selected one
  # and is active; so make it so.
  for o in bpy.context.selected_objects[:]:
    o.select_set(False)
  new_cube.select_set(True)
  bpy.context.view_layer.objects.active = new_cube
  # (that sets bpy.context.object and bpy.context.active_object,
  # both of which are read-only)

  return new_cube

# Use the function to make 1024 cubes...
for i in range(-48, 48, 3):
    for j in range(-48, 48, 3):
        another_cube = PrimitiveCubeAddNotHorriblySlowly()
        another_cube.location += Vector((i, j, 0))

bpy.context.view_layer.update() # don't place this in either of the above loops!

This works and is fast (.086s vs 12.39s for bpy.ops.mesh.primitive_cube_add(), i.e. 144x speedup, in this case; even more dramatic when there are more objects added, or in the scene already).
But there is a problem: if I run the calling code, then Undo and run it again, the template_cube.copy() fails with message:
ReferenceError: StructRNA of type Object has been removed

I understand why the failure happens: the function is trying to use the non-None _template_cube which is no longer valid after the Undo.
My question is: is there a way to rewrite this function in a way that is compatible with Undo?
One possible solution: put a try/except around the new_cube = _template_cube.copy(), and if a ReferenceError is caught, discard the template object.
But that seems kind of brutish; is there a cleaner / more standard way to maintain an Undo-friendly cache like this?
MCVE
Unfortunately, demonstrating the failure isn't trivial:
the failure does not happen if you just run the code above from the script editor, undo, and re-run it, since re-running the script gets a clean set of global variables each time.
So, to reproduce the failure, you have to do the action/undo/redo all without reloading the script. The following script sets that up, by making a custom ui button that does the action.  Follow the instructions at the top of the script.
This is the simplest reproducer I could think of.  If anyone has a simpler one, please let me know.
# MCVE for https://blender.stackexchange.com/questions/326410/how-to-write-an-undo-compatible-python-function-to-create-a-cube-without-using-b
# 1. Run this script in the blender script editor, or run blender as:
#          blender --python this_script.py
#      It creates a panel "My custom panel" in UI category "My custom category"
#      in the right sidebar of the 3D View.
# 2. Expand that panel, and click on the "Create 1024 cubes the fast way" button.
#      It should create 1024 cubes.
# 3. Undo; the cubes disappear.
# 4. Click the button again.  It fails with:
#      ReferenceError: StructRNA of type Object has been removed

import bpy
from mathutils import Vector
import sys
import time

_template_cube = None
def PrimitiveCubeAddNotHorriblySlowly():
  global _template_cube
  if _template_cube is None:
    print("  CREATING TEMPLATE CUBE")
    bpy.ops.mesh.primitive_cube_add()
    _template_cube = bpy.context.object  # the newly created cube
    _template_cube.name = "_template_cube"
    # Make template object invisible
    _template_cube.hide_set(True)

  new_cube = _template_cube.copy()
  new_cube.data = new_cube.data.copy()  # also duplicate mesh (remove for linked duplicate)

  # Change name and visibilty from those of the template.
  new_cube.name = "Cube"  # this may turn into "Cube.001" or etc., as usual
  new_cube.hide_set(False)

  bpy.context.scene.collection.objects.link(new_cube)

  # If this is used as a drop-in replacement for bpy.ops.curve.primitive_cube_add(),
  # then subsequent operations may assume the new object is the only selected one
  # and is active; so make it so.
  for o in bpy.context.selected_objects[:]:
    o.select_set(False)
  new_cube.select_set(True)
  bpy.context.view_layer.objects.active = new_cube
  # (that sets bpy.context.object and bpy.context.active_object,
  # both of which are read-only)

  return new_cube

# Create the operator to be run by the first button.
class MESH_OT_create_1024_cubes_the_slow_way(bpy.types.Operator):
  """Create 1024 cubes the slow way (using bpy.ops.mesh.primitive_cube_add())"""  # button tooltip
  bl_idname = "mesh.create_1024_cubes_the_slow_way"
  bl_label = "Create 1024 cubes the slow way"  # button label
  bl_options = {'REGISTER', 'UNDO'}
  def execute(self, context):
    self.report({'INFO'}, "creating 1024 cubes the slow way")  # unfortunately does not show up immediately in INFO area
    print("creating 1024 cubes the slow way")  # so we see something on terminal window immediately
    t0 = time.time()
    for i in range(-48, 48, 3):
      for j in range(-48, 48, 3):
        bpy.ops.mesh.primitive_cube_add()
        another_cube = bpy.context.object  # the newly created cube
        another_cube.location += Vector((i, j, 0))
    t1 = time.time()
    print(f"created 1024 cubes the slow way in {t1-t0:.6f}s")
    self.report({'INFO'}, f"created 1024 cubes the slow way in {t1-t0:.6f}s")
    return {'FINISHED'}

# Create the operator to be run by the second button.
class MESH_OT_create_1024_cubes_the_fast_way(bpy.types.Operator):
  """Create 1024 cubes the fast way (using PrimitiveCubeAddNotHorriblySlowly()).  Not undo friendly!"""  # button tooltip
  t0 = time.time()
  bl_idname = "mesh.create_1024_cubes_the_fast_way"
  bl_label = "Create 1024 cubes the fast way"  # button label
  bl_options = {'REGISTER', 'UNDO'}
  def execute(self, context):
    self.report({'INFO'}, "creating 1024 cubes the fast way")  # unfortunately does not show up immediately in INFO area
    print("creating 1024 cubes the fast way")  # so we see something on terminal window immediately
    t0 = time.time()
    for i in range(-48, 48, 3):
      for j in range(-48, 48, 3):
        another_cube = PrimitiveCubeAddNotHorriblySlowly()
        another_cube.location += Vector((i, j, 0))
    bpy.context.view_layer.update()  # don't place this in either of the above loops!
    t1 = time.time()
    print(f"created 1024 cubes the fast way in {t1-t0:.6f}s")
    self.report({'INFO'}, f"created 1024 cubes the fast way in {t1-t0:.6f}s")
    return {'FINISHED'}

# Create the panel with the two buttons.
class VIEW3D_PT_my_custom_panel(bpy.types.Panel):  # class naming convention 'CATEGORY_PT_name'
  # where to add the panel in the UI
  bl_space_type = "VIEW_3D"
  bl_region_type = "UI"

  # add labels
  bl_category = 'My custom category' # found in the right sidebar (instead of "Misc")
  bl_label = 'My custom panel'  # found at the top of of the Panel

  def draw(self, context):
    row = self.layout.row()
    row.operator("mesh.create_1024_cubes_the_slow_way")
    row = self.layout.row()
    row.operator("mesh.create_1024_cubes_the_fast_way")

bpy.utils.register_class(MESH_OT_create_1024_cubes_the_slow_way)
bpy.utils.register_class(MESH_OT_create_1024_cubes_the_fast_way)
bpy.utils.register_class(VIEW3D_PT_my_custom_panel)
```

Here's a way to avoid invalid pointer:
https://blender.stackexchange.com/questions/315994/reallocates-a-dead-pointer-object

@XY I'm finding all documentation and references to bpy.props.PointerProperty, including the one you pointed to, to be as clear as mud.  If you have an answer in mind, would it be possible for you to spell it out?  I'm guessing it's a 1- or 2-line replacement of something in my script.

I can't reproduce this on Blender 4.3β: run the script (cubes appear), ctrl+z (cubes disappear), run the script again (cubes appear again). Also, What I would do, is simply not store a reference on _template_cube between script executions, just on each execution of code set it it to bpy.data.object['some_unique_name']

@MarkusvonBroady ah I see, yes, if run from the script editor, it works properly, as you said, because re-running the script starts with a clean set of global variables.  The situation in which I run into the failure is when I have that calling code (which calls the function 1024 times) in the execute() method of a custom action run by a custom button in a custom panel.   Press the custom button, ctrl-z to undo, and press the button again; that's when it fails.     (I should probably edit the question to make this clear.)

@MarkusvonBroady If I understand correctly, you're suggesting the function PrimitiveCubeAddNotHorriblySlowly() should test for existence ofbpy.data.object['some_unique_name']; if it doesn't exist then create it, and if it does exist then reuse it?  Yes, I like that answer (better than the bpy.props.PointerProperty answer, in fact, since it seems simpler... it does clutter the objects set and is visible in the outliner, though, which I guess has advantages and disadvantages).  I had thought of this answer too and was going to write it up;  if you want to write it up then I'll accept it.

Added MCVE (it creates a button to do/redo the action without reloading the script, as I described above).

I think it won't appear in the outliner if it 's not added to any collection?

@MarkusvonBroady bpy.ops.mesh.primitive_cube_add() does add it to a collection, apparently.  I guess that could be avoided by creating the template using bpy.data.objects.new() instead of bpy.ops.mesh.primitive_cube_add(), as in XY's first script below, but that, too, would have advantages and disadvantages.  Or, I could remove it from the collection after the fact using 'bpy.context.scene.collection.objects.unlink(_template_cube)`, which does remove it from the outliner (and apparently hides it as well, thus removing the need for explicitly hiding the template and then unhiding the copies).

Argh, actually bpy.ops.mesh.primitive_cube_add() doesn't necessarily add it to bpy.context.scene.collection.objects, sometimes it adds it to some other collection(s?); at this moment I'm not sure how it decides.  So I'd have to figure out how to remove it from that other collection(s), and, if I still want to try to mimic bpy.ops.mesh.primitive_cube_add()'s behavior when making the copy (which is getting less and less appealing, TBH), I'd have to add the copy to that other collection(s).

Add a Cube to bpy.data.objects and assign to pointer proprety
import bpy

bpy.types.WindowManager.template_cube = bpy.props.PointerProperty(type=bpy.types.Object)

if bpy.context.window_manager.template_cube is None:

    verts = [
        (-1, -1, -1),
        (-1, +1, -1),
        (+1, +1, -1),
        (+1, -1, -1),
        (-1, -1, +1),
        (-1, +1, +1),
        (+1, +1, +1),
        (+1, -1, +1),
    ]

    edges = [[]]
    faces = [
        [0, 1, 2, 3],
        [0, 1, 5, 4],
        [1, 2, 6, 5],
        [2, 3, 7, 6],
        [0, 3, 7, 4],
        [4, 5, 6, 7],
    ]

    mesh = bpy.data.meshes.new(name="Cube Mesh")
    mesh.from_pydata(verts, edges, faces)
    cube = bpy.data.objects.new("Cube", mesh)
    bpy.context.window_manager.template_cube = cube

Change first 8 lines
import bpy
from mathutils import Vector

bpy.types.WindowManager.template_cube = bpy.props.PointerProperty(type=bpy.types.Object)
def PrimitiveCubeAddNotHorriblySlowly():
    if bpy.context.window_manager.template_cube is None:
        bpy.ops.mesh.primitive_cube_add()
        bpy.context.window_manager.template_cube = bpy.context.object
        _template_cube = bpy.context.object  # the newly created cube

Thanks fot the first "Add a Cube to bpy.data.objects and assign to pointer property""example:  from that, I can see how to rewrite PrimitiveCubeAddNotHorriblySlowly() using a bpy.props.PointerProperty instead of a python variable, so it will be undo-friendly, which answers my question.   It's not clear to me what the intent is of your second "Add 1000 cubes to the scene" example though-- it doesn't seem relevant to the question (which is: how to implement the encapsulated PrimitiveCubeAddNotHorriblySlowly() function, making it so the caller doesn't need to think about the template object).

Changing the first 8 lines should work, give it a try.

@X Y I don't understand what you're saying in your last comment.  I do apprecate your first example that shows how to use bpy.props.PointerProperty, which connects the dots so I could write a solution.  But, beyond that, I haven't been able to follow anything else you've said, in your answer or comment.

@X Y oh, sorry, I missed the fact that you edited your answer to show how my function should be rewritten!  Thanks.

@X Y your "Change first 8 lines" example code which you added works nicely. I'm still not sure what the purpose is of your final "Add 1000 cube to scene" code snippet is, though.  Maybe you could remove that?  (Or maybe replace it with the full file showing your fixed function and example of its use, which can be copy-pasted into the script editor-- that would be useful)

Just extra example, can be ignored.


text:
Put markers on mesh faces at weighted averages of face vertices
I'd like to use geometry nodes to put a marker on each face of a mesh.
Each marker should be placed at specified weighted average
of that face's vertices, and should stay at that weighted average as the mesh
is transformed and deformed without changing structure.
The desired weights have been precomputed and placed into
a per-face-corner attribute on the mesh.
How can I accomplish this?
I see there are some geometry node types that might be relevant: "Corners of Face", "Capture Attribute", but I haven't figured out how to string them together yet.
The script included below sets up a toy case: a cube,
with the per-face-corner weights in an attribute called "per_face_corner_weights".
These weights specify that all the markers should appear in the centers of the
faces, except for the one on the top face, which should be biased towards
one corner.
This script also puts a simple geometry nodes modifier on the cube,
which just puts a marker at each face center (ignoring the weights).
How can I position each marker using the per-face-corner weights, instead?

import bpy

# Create a cube with per-face-corner weights in a custom attribute.
verts = ((-1,-1,-1), (+1,-1,-1), (-1,+1,-1), (+1,+1,-1),
         (-1,-1,+1), (+1,-1,+1), (-1,+1,+1), (+1,+1,+1))
faces = ((0,2,3,1), (0,1,5,4), (1,3,7,5),
         (3,2,6,7), (2,0,4,6), (4,5,7,6))
per_face_corner_weights = (
  1/4, 1/4, 1/4, 1/4,  # uniform - put marker in center of face
  1/4, 1/4, 1/4, 1/4,  # uniform - put marker in center of face
  1/4, 1/4, 1/4, 1/4,  # uniform - put marker in center of face
  1/4, 1/4, 1/4, 1/4,  # uniform - put marker in center of face
  1/4, 1/4, 1/4, 1/4,  # uniform - put marker in center of face
  1/2, 1/6, 1/6, 1/6,  # bias this one towards one of this face's corners
)
mesh = bpy.data.meshes.new(name="CubeMesh")
mesh.from_pydata(vertices=verts, edges=[], faces=faces)
attr = mesh.attributes.new(name="per_face_corner_weights",
                           type="FLOAT",
                           domain="CORNER")
attr.data.foreach_set("value", per_face_corner_weights)
cube = bpy.data.objects.new(name="Cube", object_data=mesh)

# Link it to the active collection (whose icon is circled in the outliner),
# making it visible in 3D Views.
bpy.context.collection.objects.link(cube)

# And here is some code to put a simple geometry nodes modifier on the cube.
# This puts a marker (a sphere) in the center of each face, ignoring the weights,
# which is *almost* what we want.
# How do we position the markers using the weights, instead?

def PutMarkersOnFaces(mesh_object):
  # Create a geometry nodes modifier on the mesh object
  modifier = mesh_object.modifiers.new(name="AddFaceMarkersModifier", type="NODES")
  # Create the node group with group input and output nodes, and assign it
  # to the modifier (like bpy.ops.node.new_geometry_node_group_assign() does)
  node_group = bpy.data.node_groups.new(name="AddFaceMarkersNodeGroup", type="GeometryNodeTree")
  node_group.interface.new_socket(name="Geometry", in_out="INPUT", socket_type="NodeSocketGeometry")
  node_group.interface.new_socket(name="Geometry", in_out="OUTPUT", socket_type="NodeSocketGeometry")
  modifier.node_group = node_group
  nodes = node_group.nodes
  group_input_node = nodes.new(type="NodeGroupInput")
  group_output_node = nodes.new(type="NodeGroupOutput")
  # Add my nodes
  mesh_to_points_node = nodes.new(type="GeometryNodeMeshToPoints")
  mesh_to_points_node.mode = "FACES"  # change from "VERTICES"
  uv_sphere_node = nodes.new(type="GeometryNodeMeshUVSphere")
  uv_sphere_node.inputs['Radius'].default_value = 0.25  # change from 1
  instance_on_points_node = nodes.new(type="GeometryNodeInstanceOnPoints")
  join_geometry_node = nodes.new(type="GeometryNodeJoinGeometry")
  # Add connections between nodes
  links = node_group.links
  links.new(group_input_node.outputs['Geometry'], join_geometry_node.inputs['Geometry'])
  links.new(join_geometry_node.outputs['Geometry'], group_output_node.inputs['Geometry'])
  links.new(group_input_node.outputs['Geometry'], mesh_to_points_node.inputs['Mesh'])
  links.new(mesh_to_points_node.outputs['Points'], instance_on_points_node.inputs['Points'])
  links.new(uv_sphere_node.outputs['Mesh'], instance_on_points_node.inputs['Instance'])
  links.new(instance_on_points_node.outputs['Instances'], join_geometry_node.inputs['Geometry'])
  # Set node locations for the geometry nodes editor
  group_input_node.location.x = -500.0
  group_input_node.location.y = -25.0
  group_output_node.location.x = 160.0
  group_output_node.location.y = 0.0
  mesh_to_points_node.location.x = -320.0
  mesh_to_points_node.location.y = -80.0
  uv_sphere_node.location.x = -320.0
  uv_sphere_node.location.y = -265.0
  instance_on_points_node.location.x = -160.0
  instance_on_points_node.location.y = -80.0
  join_geometry_node.location.x = 0.0
  join_geometry_node.location.y = 0.0
  # Hide unconnected inputs on all nodes (like ctrl-h which toggles them in ui)
  for node in node_group.nodes:
    for input in node.inputs: input.hide = True  # gets rejected if connected; good
    for output in node.outputs: output.hide = True  # gets rejected if connected; good
  # Then unhide interesting unconnected inputs (ones we've set default values on)
  uv_sphere_node.inputs["Radius"].hide = False
  # Deselect all the nodes
  for node in node_group.nodes: node.select = False

PutMarkersOnFaces(cube)

# Make the cube selected and active (mainly so its geom nodes modifier
# will appear in the geometry nodes editor)
cube.select_set(True)
bpy.context.view_layer.objects.active = cube

I came up with something that works.
At this point this feels uncomfortably like dog science
("I have no idea what I'm doing").
I think the idea is sound: multiply together the position and weights attributes to get a product per-face-corner attribute; then use an "Accumulate Field" node to aggregate (sum) the result by face index, which turns the per-face-corner attribute into per-face attribute of marker positions, and then use "Mesh to Points" and "Instance on Points" with "UV Sphere" as the instance, to put sphere instances at the resulting per-face positions.
But honestly I don't understand the graph I created.  I think I'm probably taking advantage of some automagical conversions that I don't understand-- in particular, I'm combining positions and per_face_corner_weights, which are in two different domains, and that part of the graph seems pretty far away from anything that even knows what the domains are, so I'm really surprised it all works.  [EDIT: I understand this now; it has to do with the fact that the specification of the domain of evaluation flows from right to left in the graph.  Solution #3 calls this out and discusses it more, in the text and in the node graph labels.]

EDIT: Solution #2
Here's an alternative solution, a bit cleaner, I think.
The difference from the previous solution is the part that coerces the domain of the "Index" node to be face instead of face-corner, before feeding it into the "Group ID" input.  The previous solution accomplished that by using "Index"->"Capture Attribute (domain=Face)".  This solution uses "Index"->"Face of Corner" instead.  So this part no longer requires a geometry, resulting in fewer edges overall which means less stuff I don't understand, which seems like a good thing.

EDIT: Solution #3
This incorporates a suggestion by Markus von Broady in the comments: instead of using the "Accumulate Field" node, just multiply the vertex positions by the weights in the Face Corner domain, and then let the result be implicitly converted (by averaging) when evaluating in the Face domain, then correct the average to sum by multiplying by number of vertices per face.
Detail: The "Evaluate on domain (Face Corner)" node is necessary to force the multiplication to be done in the Face Corner domain, rather than the Face domain.  At first I thought that must be followed by a "Evaluate on domain (Face)" node to force conversion (averaging) into the Face domain, but it turns out that's not necessary, since the domain of evaluation of a field op is always what is mentioned to its right, never to its left.

You don't need "Accumulate Field". You can multiply each corner by the weight, and capture that. Then you can read captured attribute on the face domain - the interpolation will average all corners. Now multiply that by the number of corners ("Corners of face: Total") and you're good to go. Similar logic to here

@MarkusvonBroady Thank you!!  I will try that.

@MarkusvonBroady When you say "and capture that", do you mean using a "Capture Attribute" node?  Which means I would have to thread the Geometry through that? That seems like it might be a step backwards in a sense, no? I notice in the first picture in your linked answer, there are no Geometries in sight, which seems like a good thing-- looks like you are using an "Evaluate on Domain" node for roughly the same purpose?  I am trying that-- it doesn't work with a single "EoD (domain=Face)" for some reason, but it seems to work if I use two EoD's chained: domain=Face Corner, then domain=Face.

@MarkusvonBroady Here is a screenshot of the two-chained-"Evaluate on Domain"-nodes that seems to work.  Does this seem reasonable?  https://i.sstatic.net/0bmiYcIC.png (Also I'm using "Face Neighbors: Vertex Count" instead of your suggested "Corners of face: Total", looks like it's equivalent and maybe a bit easier to understand at a glance)

(oh, and I see from your example that there's a "Vector Math:Scale" that I can use where I have been using "Vector Math:Multiply"-- much nicer)

Hmm, actually it works if I just use a single "Evaluate on Domain (domain=Face Corners)", with no "Evaluate on Domain (domain=Face)".  That would be fewer nodes, but I don't think it would actually be simpler (neither conceptually nor in number of conversions and arithmetic operations at runtime), since that would unnecessarily make the Scale by number of face corners happen in the Face Corners domain instead of the Face domain (I think).

After more experimenting, I think I have come to the conclusion that the "EoD (domain=Face)" is a no-op and can be safely omitted; the "Scale" by face vertex count will be done in the Face domain regardless.  This because (I think) the domain of evaluation of a field op is always what is mentioned to its right (in this case the "Mesh to Points (mode=Faces)" node), never to its left (in this case the "EoD (domain=Face Corner)" node).  (My experiment was: replace the Scale node by a "vector scaled by min abs of itself" node chain, which gives different results depending on the domain)

@MarkusvonBroady ok here's my latest greatest solution, based on your suggestion: https://i.sstatic.net/HlbRbMpO.png  I'll write it into my answer, with credit to you, unless you see any further problems with it.

Very nice, that's about how I would solve it too.


text:
Which collection should I put new objects into?
I notice that, with factory-default settings, blender starts with two collections:

A top-level "Scene Collection", which apparently can't be renamed or deleted
A child collection "Collection", containing a Camera, Cube, and Light.
This child collection can be renamed or deleted.

Initially, bpy.context.scene.collection is set to the top-level "Scene Collection", whereas bpy.context.collection is set to the child "Collection"
(but changes if the user clicks on a different collection in the outliner;
in general it is the "active collection", i.e. the one whose icon has a transparent outline
around it in the outliner).
When I create a new object using bpy.data.objects.new() (lower level than bpy.ops), it seems I then need to add the new object to one of the existing collections, in order to make it visible.  Which collection?
The likely candidates seem to be:
bpy.context.scene.collection.objects.link(my_new_object)

or:
bpy.context.collection.objects.link(my_new_object)

Evidence in favor of bpy.context.scene.collection (the top-level collection called "Scene Collection"):

that's what it says in many examples, e.g. https://developer.blender.org/docs/release_notes/2.80/python_api/scene_and_object_api/#adding-objects
that's apparently where Import->glTF puts new objects.

Evidence in favor of bpy.context.collection (the active collection: the one named "Collection" initially):

that's apparently where the Add menu (and bpy.ops) puts new objects.

Is there a policy/guideline/rationale for deciding which collection to put new objects into?
To be clear, the cases I'm asking about are the cases in which I don't have any opinion about the overall structure of the scene (when I do have an opinion, of course I'll just put the new object where I want it to go).  E.g. the cases in question are when I'm writing an importer, or an addition to the Add -> Mesh menu, or some other utility function along the lines of either of those two (similar-seeming, to me) cases.  If I try to follow precedent, I seem to get two contradictory conclusions, thus my question.
Please note that this is not a duplicate of question Collection for New Object? (Version 2.8) , which asks only which collection the Add menu puts new objects into when using the UI.

Hello, IMO this is an opinion-based question because both propositions are valid, and depend on your end goal. You can even link your object to both collections. Or none, which will create an orphaned object but nonetheless a valid object. You may want to add more information about the broader picture and what you are trying to achieve here with this script ? BTW the question is exceptionally well formatted, I wanted to point it out.

@Gorgious Thanks.  In the cases for which I'm asking the question, I'm writing, say, an importer, or an addition to the "Add -> Mesh" menu, or something in-between-ish feeling, which is why I gave those two examples (with contradictory conclusions if I want to try to follow precedent... thus my question!).  I.e. my code creates object(s) to be used by other code (maybe in direct response to the user pressing a button or selecting a menu item, maybe less directly) but my code doesn't itself care about the overall structure of the scene.

@Gorgious I added a paragraph attempting to clarify the situations for which I'm asking the question.

I'm coming around to the conclusion that I have fallen victim to the "I have to put it in some collection, otherwise it won't be visible" fallacy.  No, I don't have to put it in any collection, because no, I don't have to make the object visible (and in fact I shouldn't, when, say, the code is at roughly the same low level of decision-making as bpy.data.objects.new()).    I'll write up an answer summarizing my current thoughts and conclusions.

I added an answer/proposal that resolves all the considerations I had been wondering about.

Tl;DR: if in doubt, Scene Collection.
I don't think it matters as much as you seem to think. Scene collection just serves as container for all objects and collections in the current scene. Any other collection is whatever the user wants.
You need to register your object in at either the scene's collection or a collection of that scene for it to appear in that particular scene (you could assign it to another scene this way, or to no scene at all and have it floating in your blend file for nothing).
So if you want your object in a particular collection, out it there. If not, default to the scene collection, or whatever you like.

Hi @Lauloque, yes certainly if I want an object to go in a particular collection I'll put it there, and I'll make new collections to hold the new items if it makes sense.    This would be the case if my intent is to construct a scene and I specifically want the structure of the scene to be a certain way.  But in the cases I'm not sure of (and why I'm asking the question), I don't have an opinion about the structure of the scene, I'm just trying to write clean modules/utilities, e.g. an importer or an addition to the Add menu, or something in-between-ish.

As long as you label it for what it is (e.g., "Add Object to Currently Selected Collection"), it should be fine. Even if it weren't explicitly stated, such a small detail probably wouldn't matter too much to the user.

I'm proposing this answer, after more thought and considering the comments and answer given so far.  These are the guidelines I'm now following.  I'd welcome any feedback, particularly if I got any facts wrong or missed any relevant information that should be considered.
TL;DR: Put the decision of what collection to use at the appropriate level of code, at which the choice either is obvious, or is an artistic decision of authorship of the scene structure, being made by that code.  If your code is at such a low level that it doesn't care, then don't put the new object in any collection.
Details and rationale:

If you're writing code that cares about where the new object goes, then of course put it there.  This would be the case if, say, your code is constructing a scene and is deciding the hierarchical structure of that scene.

Otherwise, if you're writing a function to be called more-or-less directly as a user action (e.g. an importer, or an addition to the Add -> Mesh menu), then follow the precedent of what bpy.ops.mesh.primitive_cube_add() and all the other bpy.ops functions called by those menu items do: add the new object to the active collection, i.e. bpy.context.collection.  This allows the user to have convenient control of where new objects go, by clicking the desired collection in the outliner to make it active (denoted by the transparent circle around the icon).

Note that the glTF importer does not follow the guideline stated in the previous paragraph: it apparently ignores the active collection, and instead puts new objects under the scene's top-level collection.  This may be due to it trying to satisfy a contradictory goal-- that is, to turn each of the things called "scenes" in the glTF file into the things called "scenes" in Blender.  At this point I'm not familiar enough with any other importers to know whether they are in a similar situation and/or have similar behavior.

If you're not in either of the above two cases, then you probably don't care where the object goes in the scene, if anywhere.  E.g. maybe you're writing a utility function that creates a new mesh object, to be used by other higher-level calling code.  In that case, don't put the new object in any collection-- let the calling code make the decision of where to put it, if anywhere.  This follows the precedent of bpy.data.objects.new() (which you are likely calling in your function).

Don't be tempted to helpfully add the new object to bpy.context.scene.collection, or anywhere else, just "because it's not visible until I do".  While it's true that code that calls bpy.data.objects.new() is prone to forgetting altogether to link the new object into any collection (resulting in questions on mailing lists and on this site), the "solution" of adding the object to an arbitrary collection actually creates a bigger problem than the one it solves: it makes it so that caller has to go out of its way to unlink the new object from that collection if it doesn't want that link.  This is one of several automagical side effects of the bpy.ops functions that make them painful to use by higher-level functions, making many experienced programmers prefer to avoid them.


text:
Transferring a texture 1 to 1
What i have is:

an exported .ply and .obj from MagicaVoxel
.obj has it's texture stored in this way
.ply is just a 1:1 mesh with all its textures stored in vertices

a cleaned up duplicate

What i want is to transfer the texture 1 to 1 from either mesh(.obj or .ply), but the problem i run into is that there is a pretty big margin of error when trying to bake in Blender
The mesh on the left is the cleaned up mesh with a 128x128 texture applied to it
The mesh on the right is the original in the form of .obj
When baked to a higher-res destination texture, the margin is smaller, but still noticeably there.
Baking from vertex colors using this setup yields a similar result with a similar kind of mismatch.

These are my baking settings.

I've tried changing pretty much everything, including baking with a cage, but still can't reach a 1 to 1 transfer. I can't imagine this being impossible to do so it must be something to do with how i approach it.
Any advice would be appreciated.
EDIT: Made some progress by using the "Snap to pixels" function when unwrapping the gun. It's fidgety and i ended up having to unwrap it a couple of times and manually moving it a bit to get the vertices snap to "correct" pixels. Basically fidget with it until you get lucky.

There's still a lot of warping going on, which is i think to do with the fact that it's a 128x128 texture and it's nowhere near being 1 to 1, but it's better.
I think.
EDIT 2: Cleaning up the UV helped a bit. I overlapped some islands and packed it a bit neater, which made for more space for individual islands and better alignment overall. Still not perfect, but with manual adjustment in blender and photoshop, you can get decent results relatively quickly.

2 days ago I thought I messed up one of my model's UV's because I saw a seem in Material Preview mode that I never noticed before. However, when I entered Render View, that seam was gone again. Material View is very imprecise. Your Blender image shows Material View. Please confirm the problem still exists when you render.

@hatinacat2000 Yeah, i'm aware of that issue and, unfortunately, it's not it.


text:
I am looking for some help on remeshing an imported STL
I have imported an STL and, as expected, the mesh is triangular. I am trying to understand the remesh function and not getting results I am after. I thought the remesh turned the mesh into quads?

Hello could you please share your file? https://blend-exchange.com/

Set the Remesh Mode to Block, then go into wireframe mode and then change the Octree Depth up til it looks like the mesh before.
Be careful though as it can slow down your computer (treat it like a Subdivision modifier). Then apply it and you should have quad geometry.


text:
[SOLVED]How to change mesh/model of an armature?
[SOLVED]I already have an rigged character in which there is already an animation associated in it, I want to change the mesh and to use another model on the armature. I am a beginner at don't know much about blender rigging, I am not getting any solution which would work for me.

You need to parent the new character object to the armature, make sure that the default character pose is aligned with the default armature pose

As moonboots said, Change armature to "rest" position. Then parent model to armature, and do weight painting to each bone.


text:
Model folds in on itself when i try and rotate it in edit mode?
Im trying to rotate my model 90 degrees to that the symmetrize function works correctly, but it ends up with bizzare results when i try and do so?
The same thing appears to be happenning with other objects like clothing as well, not just the body.

Give us more info, show modifiers tab, it looks like maybe mirror problem

Disable the Symmetry option on the top right:


text:
Bevel Or Smooth - Sliced Sphere

I am trying to re-create a car lens.
Have Sliced into a Sphere and 2 Cylinders to create the object - and want the sliced edges to blend as smoothly as possible without showing the creases.
As the round objects have multiple subdivides - it's messing up the smoothness of the circles.
If I create the shape with limited subdivides, it only creates a rough version of what is required, outcome-wise.
Have tried all the tools in the bag to no joy, as the shapes are so complex - any help is appreciated!

Hello could you please show different pictures of the object?

Attached "moonboots" - It's hard to explain with pictures, but to touch, there are no creases to feel (super smooth) - thanks

Maybe try this, create a UV sphere, remove a big part of it:

Cut this edge with the knife:

Remove some vertices:

Extrude and flatten:

Bevel this edge:

I think you are absolutely right @moonboots - I can't thank you enough for your time and advice...Gold Star!


text:
Is there any way to export in glb while keeping the NLA separation?
Is there any way to export in glb while keeping the NLA separation?
I am creating a model with multiple NLA animations on one part.
I am creating NLAs that are separated for each movement (image 1),
When I export the NLA in glb format and then import it back into Blender, the separation is removed and the model reverts to a series of NLAs. (Image 2)
I would like to know if there is any way to do this.
Translated with DeepL.com (free version)

It looks like the separate animations are still there, but embedded in what I assume are single keyframes, which should be relatively easy to clean up. Not a solution, but a potential workaround. Can you post a screenshot of the individual frames on the timelines? (Great avatar, by the way :)

thank you,Screenshots of the timeline have been added. Is this the correct one?
(Moomin is cute :))


text:
Transforming multiple objects to have equal dimensions
I created several planes scattered around the scene, but I created them individually.
I also extruded several planes to create an expanding curve, without realizing that I was scaling on two axes at the time (for each new plane).
I would have preferred to only scale the 'y' value, but I didn't notice my mistake in ortho view.
Is there a way to change all of their size values to be equal?  Let's say I want them all to be 1cm X 1cm, but they are all currently slightly different sizes. I don't want to change the position or rotation of any of them though.
Thanks for the help, I'm just getting started in the 3d world.

Just press the Alt key before clicking any of the value text boxes and inserting you values.
That will affect all selected objects instead of just the active one. It will also work for modifiers and most other properties.

Edit
If all your planes belong to the same object you have to separate them before controlling sizes directly, since absolute size control will only work in Object Mode, not Edit Mode.

Enter edit mode in your planes object
Select all with A
Separate all planes with P > Loose Parts
Now exit edit mode
Select all separated plane objects
Move their object center to the center of the geometry so their positions wont change when you change their scale, by pressing Shift + Ctrl + Alt + C > Origin to Geometry
Now you can change size

Don't forget to apply transforms afterwards with Ctrl + A > Scale

Thanks Duarte.  That does help with half of the problem.  It works great with the separate objects I created.  I can't get it to work with the multiple planes that I extruded though.  I've tried selecting faces and edges, but I can only get the dimensions in object view.  Then it just ends up scaling the entire object (all of the edges and faces) proportionally, instead of resizing everything to the same 'y' value.  I am willing to start from scratch, but I would just like to know if my problem is possible to solve in blender, for future reference.

@TinySharks The Alt key doesn't work for me, (ubuntu disabled as HUD still no joy).  You can also set the dimensions of your active object to (1,1,0)  right click and "Copy All to selected" to make all selected objects have the same dimensions.

@TinySharks You don't need to start over, you just have to separate the objects first. See my updated answer above on how to.

@Duarte, Thanks for the update.  The process makes complete sense, but I'm having issues with separating extruded planes.  I was able to use your method with complete success when using a subdivided cube, but not with extrusions, for some reason.  I even made a plane and extruded it twice, just to see if my original object was too complicated.  I couldn't separate by loose parts in that one either.  I can separate anything by selection just fine, it's separating by loose parts that isn't working with meshes created with extrusions.

Are you sure it's not working, there's not much that can go wrong. Separating by loose parts works on meshes composed of several separate chunks only. If your planes are somehow connected it wont work. Otherwise if you are still having trouble edit your question and a link to post your file so we can look at it. Afterwards be sure to poke my user name with @duarte-farrajota-ramos so I get a notification

Sure, once I figure out how to post a blender file.  I'll have to make a similar example, since I might still be under an NDA on the project, (It was a photography project, but I decided I'd like to 3d model it on my own).

Your mesh is composed one whole single chunk, obviously it can't really be separated by lose parts because there are none.

That doesn't look right.  I used Blender Stack Exchange.  Is there a different way users are sharing their .blend files?

@DuarteFarrajotaRamos, Ah, so I'm back at square one?  I think I understand why it became an issue with the way I way I started out in my project.  I will do a better job in my creation and try to figure out a solution to the issue in the future.  I wasn't terribly far along in my project, I was just hoping there was a quick fix.  Thanks for your help.  Your answers were definitely informative and useful.

Welcome, I'm sure you'll do better next time. File sharing is ok, you should always use that site around here, though you are supposed to always post links to files in your original question by editing it. I already did it for you here, since you may still not have enough reputation to do it.


text:
Why are particles are missing, when using Volume/Grid Emission?
I'm having an issue filling a cube with objects using a ParticleSystem.  It's as if a diagonal plane has cut through the cube and eliminated particles.  This doesn't happen to the front plane of particles though, which can make it difficult to tell that it's happened from that view.
I only added the UV Spheres to help visualize the problem.  They don't have any affect on the missing particles.

I've tried many setting, including, but not limited to;
Changing the particle size, Cube Scale, Resolution, etc...
I also tried double clicking Hexagonal Grid (I heard that will sometimes set things straight).
Thanks for any help.

could you please share your blend file

This issue should be fixed in the latest version of Blender (2.78b).

One way to solve this is to bevel each vertex of the cube very little. Tab into edit mode. A to select all vertices. Press Ctrl+V and select "Bevel". Then give it a very small amount of Bevel Offset (I used 0.001 here). Then Tab out of edit mode and it'll work.

Another simpler way to do it is to select all the faces and hit Ctrl+T to triangulate the faces.

Thanks @Kidus, I tried your method and it was a successful workaround for my problem.  I also tried a few other bevel offset amounts, with varying degrees of success.  I'll wait a bit before I give you an 'answered', just to see if anyone else can figure out why this happens.

Ok, I tried both methods @Kidus.  They will both fill the cube properly, with a few caveats.  When using the bevel method, the resolution must be an odd number, otherwise, the center row will be missing.  When using the triangulate method, the resolution must be 11.  Any other number leaves seemingly random rows out.

I have investigated this a bit further, and it appears to be a bug (which is still present in Blender 2.78c) :
Using an added Cube in combination with Particles > Volume > Grid results in missing particles.
Strangely, there is no issue when you use the original Cube "Cube", or a duplicate (Shift + d) of the original Cube. ??
So an appropriate "easy" solution, until this issue is resolved; would be to use the standard default cube when you use Particles > Volume > Grid
Particle > Volume > Grid bug
Blend file illustrating the issue
Note: (I moved your added cube: "Cube.001" to Layer 20, and the default cube "Cube" to Layer 1)


text:
How do I rotate a Multilayer EXR file in Blender's compositor?
It would seem that rotating an image is a trivial task, however I face this problem when working with Multilayer EXR format files in Blender.
But why?
I find it convenient to set my archvis scenes up as animations so I can change objects in different stills and render all camera angles at once as animation. I sometimes need landscape and portrait orientation images of the same interior and use a small script to quickly switch X and Y resolution dimensions and then rotate the camera when I am done framing so some frames render out rotated. It's then very convenient for me to do compositing on a sequence of images.
Recently I rendered a scene in a few batches and ended up with 1 8K panoramic image, 5 4K living room images in landscape orientation with one of them rotated and 5 images of stairs that are all portrait orientation all in a sequence and to my surprise when compositing I can do that with all the images at once as one sequence despite the difference in orientation and resolution and output them to files with File Output nodes to their correct resolution and orientation from that one sequence. So now I know, I can have different orientation in the same sequence which is amasing.
It would be even more amazing if I could always look at all the images rotated correctly while compositing instead of rotating only the output as I have done until now.
It would require me to rotate all the rendered Multilayer EXR files that need rotation in my sequence of files.
What I have tried
I have no problems connecting every output of a Multilayer EXR to File Output node with Python and also inserting any Compositor nodes to edit them automatically so any solution that works for one layer is convenient for me, however I cannot rotate the image in compositor as far because the image is cropped to original dimensions when rotated:

The question
Is it possible to rotate every layer of a Multilayer EXR and output it to an image with rotated dimensions as well with Blender's Compositor nodes, if it is - how?
My solution detailed in and answer below has issues with Cryptomatte. I am starting a bounty in hope to find a solution without those issues. I am starting to think of a solution with Python, but have no idea how it would be simple and easy to use from Blender...

Does this q/a help?

I think it does. Thank you!

I figured out a solution with some scaling and then rotating and fitting to render size, but this is so much better! Mask node's dimensions are animatable and I output render with File Output nodes anyway so this can be done while rendering! Thank you for finding this! Animating output dimensions problem was torturing me for years... :D

It took me too long at work to write my answer, didn't see you found a solution. Maybe you can still use it for something. I would have added a blend file as example but I didn't know how.

About cryptomattes
The issue is not due to the rotation but to the alpha over node:

which results in plain color image.
If you change the node group by this:

That allows to keep the image size from the mask, without considering it (multiplied by 0) but adds the rotated cryptomatte values.
A simple test case file:

It's great to get an answer that just works. Thank you. Seems to work with color mix nodes as well as long as alpha channel is mixed. I think it might be that Cryptomatte layers just use 4 channels. This is interesting, because Multilayer EXR format layers may have more than 4 channels(see https://www.openexr.com/documentation/TechnicalIntroduction.pdf) If cryptomatte layers had more than 4 channels this would not work. Anyway, seems to work for me.

Thanks for the information, @MartynasŽiemys.

This solution has issues - see the end of the answer.
As brockmann pointed out, there is a very similar question about rotating images I failed to find. It sort of explains that image dimensions in the compositor are inherited from the first node if it is mixed with something. Mask node without any mask selected works for setting the dimensions perfectly:

So to rotate a Multilayer EXR file one would need to rotate all the layers and with Python that inside a little addon creating a panel would look something like this:
bl_info = {
    "name": "Nodes",
    "author": "Martynas Žiemys",
    "version": (1, 0),
    "blender": (2, 80, 0),
    "location": "Compositor -> n panel -> Node Tools",
    "description": "",
    "warning": "",
    "doc_url": "",
    "category": "Compositor",
}

import bpy
from bpy.types import Panel, Operator
from mathutils import Vector
from math import radians

class OutputRotatedMultilayer(Operator):
    """Make multilayer EXR file output for all outputs of active image node rotated"""
    bl_idname = "node.multilayer_output_rotated"
    bl_label = "Multilayer Output Rotated"

    @classmethod
    def poll(cls, context):
        image_node_active = False
        if context.scene.node_tree.nodes.active is not None:
            image_node_active = (context.scene.node_tree.nodes.active.type in {"IMAGE","R_LAYERS"})
        return image_node_active

    def execute(self, context):
        if "RotateImage" not in bpy.data.node_groups:
            rotate = bpy.data.node_groups.new('RotateImage', 'CompositorNodeTree')
            rotate.inputs.new('NodeSocketColor','Image')
            rotate.outputs.new('NodeSocketColor','Image')
            out = rotate.nodes.new('NodeGroupOutput')
            out.location = (200,0)
            input = rotate.nodes.new('NodeGroupInput')
            input.location = (-400,0)
            mask = rotate.nodes.new('CompositorNodeMask')
            mask.location = (-200,200)
            mask.use_feather = 0
            mask.size_source = 'FIXED'
            mask.size_x = 3600
            mask.size_y = 2400
            mix = rotate.nodes.new('CompositorNodeAlphaOver')
            mix.location = (0,25)
            mix.hide = 1
            rot = rotate.nodes.new('CompositorNodeRotate')
            rot.location = (-200,-50)
            rot.filter_type = 'NEAREST'
            rot.inputs[1].default_value= radians(90)
            rotate.links.new(out.inputs[0], mix.outputs[0])
            rotate.links.new(rot.inputs[0], input.outputs[0])
            rotate.links.new(mix.inputs[1], mask.outputs[0])
            rotate.links.new(mix.inputs[2], rot.outputs[0])

        width = context.scene.node_tree.nodes.active.width
        active = context.scene.node_tree.nodes.active
        tree = context.scene.node_tree
        links = tree.links
        output = tree.nodes.new('CompositorNodeOutputFile')
        output.location = active.location + Vector((500,0))
        output.format.file_format = 'OPEN_EXR_MULTILAYER'
        output.format.color_depth = '32'
        output.format.color_mode = 'RGBA'
        output.format.compression = 15
        output.layer_slots.clear()
        for i,every_slot in enumerate(active.outputs):
            if active.type == "R_LAYERS":
                if every_slot.enabled:
                    output.layer_slots.new( name = every_slot.name )
                    g = tree.nodes.new('CompositorNodeGroup')
                    g.node_tree = bpy.data.node_groups["RotateImage"]
                    g.hide = 1
                    g.location = (-100,i*50)
                    links.new(active.outputs[i], g.inputs[0])
                    links.new(g.outputs[0], output.inputs[every_slot.name])
            else:
                output.layer_slots.new( name = every_slot.name )
                g = tree.nodes.new('CompositorNodeGroup')
                g.node_tree = bpy.data.node_groups["RotateImage"]
                g.hide = 1
                g.location = active.location + Vector((200,i*-33))
                links.new(active.outputs[i], g.inputs[0])
                links.new(g.outputs[0], output.inputs[every_slot.name])

        return {'FINISHED'}

class NODE_PT_node_tools(Panel):
    bl_space_type = 'NODE_EDITOR'
    bl_region_type = 'UI'
    bl_category = "Node Tools"
    bl_label = "Node Tools"

    @classmethod
    def poll(cls, context):
        space = context.space_data
        return space.type == 'NODE_EDITOR'

    def draw(self, context):
        layout = self.layout
        col = layout.column()
        col.operator("node.multilayer_output_rotated")

def register():
    bpy.utils.register_class(OutputRotatedMultilayer)
    bpy.utils.register_class(NODE_PT_node_tools)

def unregister():
    bpy.utils.unregister_class(OutputRotatedMultilayer)
    bpy.utils.unregister_class(NODE_PT_node_tools)

if __name__ == "__main__":
    register()

It turns out this does not work for Cryptomatte
The rotation process messes up precision of Cryptomatte values resulting in incorrect mask edges:

If so, please report a bug. Should be possible to rotate a few pixels (mattes).

Can that be a duplicate of https://blender.stackexchange.com/questions/143706/cryptomatte-doesnt-output-nice-clean-edges ???

@lemon I'll investigate pixel filter, thanks.

@MartynasŽiemys, Cryptomatte node, in matte part, the answer from aliasguru.

No, definitely not that, I use Cryptomatte as intended for a long time now and it works as good as it gets on the images that are just rendered without rotation. I still haven't tested the pixel filter settings from the other answer though and that sounds like something that might be related to the problem.

Since the Render Result doesn't take the dimensions or orientation of the EXR into account, the answer depends on what result you want to achieve. The simple way would be, if the EXR is for example 1920 x 1080, set the Render Dimensions to 1920 x 1920. This way the image will always fit and not be cropped either way. If you want to render at a different percentage like 50% maybe, you should place a Scale Node after the Rotate Node set to Render Size > Fit.
If you want to keep the aspect ratio of the rendered image at 16:9, then there are two possible ways to go:

The EXR should fill as much space as possible (1920 x 1080 at 0°, 608 x 1080 at 90°) or
the dimensions should stay the same (1080 x 608 at 0°, 608 x 1080 at 90°).

Either way you need the Scale Node described above with Render Size > Fit and a second Scale Node set to Relative > X = Y = 9/16 = 0.5625.
For the option 1 you have to disable the Relative node or set X = Y = 1 if the rotation is 0°. For 90° or -90° you have to enable it with X = Y = 0.5625.
For option 2 you just leave it enabled no matter if 0° or 90°, but as mentioned before in this case the EXR will not fill the image horizontally.
I've created a node setup with automatic disabling of the Relative node according to the Rotation value, see image. The idea is if you want to render a sequence and set keyframes for the rotation, you don't have to manually disable nodes. The aspect ratio of the Render Dimensions is calculated by drivers.

Thanks for the time put into this, but it seems you only described two problem cases. I want to take an image with some dimensions and keep them when rotated so full rotated image should have those exact dimensions only switched(exactly the same thing that we just call rotating an image in all other software). Making the image fit inside a bigger image is no good. These are large files and having extra black space is an issue. But I have a very good solution already based on the answer brockmann linked to explaining that dimensions are inherited from the first node mixed with anything.

Well, option 2 keeps the image dimensions the same vertical and horizontal - the scale depends on the scene size.
But it seems I didn't understand your question or I don't understand the proposed solution. The mask helps me to view the image uncropped in the Compositor, but I thought you wanted to render it out in a sequence or animation. When I render two images in a sequence, one at 0° and one at 90° with switched dimensions, the rotated one is still cropped and has empty space left and right.
If you worked out a different solution based on the tip you could give it as answer here for all.

Posted the solution I ended up with. Obviously, I will just output the render result rotated from now on, but ability to rotate Multilayer EXR is useful as well.

I guess one of the problems with rendering out switched orientation in a sequence is that the render output is always bound to the scene resolution and its scaling. Since an animation could not only be rendered as an image sequence but directly to a video file, switching dimensions and orientation is not possible because a video file wouldn't allow that.

It works when outputting with File Output nodes from the Compositor so I don't care about the regular render output. It's a pity actual render resolution cannot be changed during animation rendering.

You're right, I made a simple mistake. In the compositor I had the image connected to a Composite Output node as well, so rendering the animation saved two pictures, the one from the Composite Output and the File Output and I just saw the Composite.


text:
Shading with Float Vector Volumes
Houdini 18.5 has a volume Bake sop that computes the internal scattering of emission based on the density. This is used to minimize the render times because the volume bounces can now be set lower and internal scattering simulated by the generated volume.
My problem is that the generated volume is a Float Vector volume. I tried using it normally as an emission strength in the Principled volume but I think this does not work because it does not take the different intensities in the different vectors into account and just multiples them and takes a general intensity. But the scattered light has a direction hence the Float Vector.
Is there a way to shade this appropriately?
Here is an example volume
And some screenshots of the material:

Okay, I added some images of my problem

Hmm… try the light ray info node?

What node do you mean? Light Path? And what would you try with them?


text:
Semi-AutoTracking
I want to automatically detect features track 40 frames detect new features track 40 frames and so on.
I found this this addon but it does not work in 2.91.2 (I suppose my files are too heavy float EXR) so I wanted to build my own small script.
I found out how I could detect new features with python:
import bpy

C = bpy.context
ctx = C.copy()
for area in C.screen.areas:
    if area.type == 'CLIP_EDITOR':
        ctx['area'] = area

bpy.ops.clip.detect_features(ctx)

But I can`t track them forward for x frames. I found this script but it does not work:
for step in range(3) :
    currFrame = (step*20)+1
    frameNumber =bpy.data.scenes["Scene"].frame_current

    area.spaces[0].clip_user.frame_current = frameNumber
    bpy.ops.clip.detect_features(ctx)
    bpy.ops.clip.track_markers(ctx, backwards = False, sequence = False)

This auto tracker also does not work it tracks 9 to 20 frames and then just stops.
And is there a way to prevent Blender from completely stop responding while the script does its job? Some kind of multi-threading?


text:
How to properly render emissive and transparent materials (fire) for compositing
I am rendering a fire to a multilayer EXR and then composite it using the method described in this answer ontop of my footage.
One comment states that it is difficult to work with my EXR because I only have a beauty pass and my emissions and transparency aren't separated. I also get all sorts of wired effects compositing my exr when I try to pre divide/post multiply. But if I do not do that everything tourns with.

Here it gets blocky
Nothing I was just trying to bring the highlights of the fire a bit down but it messed the image up so I pressed premultiply / post divide and then it messed the rest up. I am wondering how blender outputs the exr is it already premultiplied or is it straight?
Reference files:
https://drive.google.com/drive/folders/1HatjWYAmmXHfEiaTNYChJYBK0PZVvMo7?usp=sharing

Proper alpha encoding, aka associated (premultiplied) is the only alpha encoding that a path tracer can generate, and is the only alpha encoding that works. By default, all path tracers will generate associated alpha encodings. It is literally impossible to model things like fires, flares, reflections, glows, etc. without it, as it is the only encoding that allows encoding of emissive yet unoccluding mixtures such as 0.0 3726.2 0.0 0.0 for example. A generic alpha over is how fire is composited.

As @troy_s stated in this case a normal alpha over should be used. In Resolve, this translates to a merge node with the Alpha Gain turned to 0.


text:
How do you export bones relative to parent?
I'm currently writing an exporter script. So far, I can export meshes just fine, but I've got some problems with exporting the armature.
According to the python api, there are three different types of bones:

editbones: Are used to create/modify the armature/skeleton and are only available in edit mode. See http://www.blender.org/documentation/blender_python_api_2_67_1/bpy.types.EditBone.html (which, obviously, aren't needed for exporting animation. I just list them for completeness.)
bones: Define the armature structure. See http://www.blender.org/documentation/blender_python_api_2_67_1/bpy.types.Bone.html
posebones: Are used for animation. The posebones are structured like the bones of the armature, but transformed according to the current frame of the active action/pose. See http://www.blender.org/documentation/blender_python_api_2_67_1/bpy.types.PoseBone.html

There's also this old (or rather: ancient) guide on how armatures work: http://www.blender.org/development/release-logs/blender-240/how-armatures-work , but I can't find a proper mapping between that document and the current api.
I know I can get the restpose of the armature by grabbing the bone.matrix_local, but this matrix is relative to the armature.
So...
How do you grab the bones matrices so that the transform is relative to the parent instead of relative to the armature?
I tried exporting the bones relative to their parent by multiplying the inverse of the parents matrix_local by the bones matrix_local, but that does seem to result in incorrect translation values.
This is how I currently grab the parent-relative matrices:
        #I'm interested in the rest pose here, so I iterate over the bones
        for bone in armature.data.bones:
            #make matrix of this bone relative
            boneMat = mathutils.Matrix.Identity(4)
            if bone.parent == None:
                boneMat = bone.matrix_local
            else:
                boneMat = bone.parent.matrix_local.inverted() * bone.matrix_local

            #decompose
            loc, quat, sca = boneMat.decompose()

By the way: I'm using blender 2.66.1 w/the included python

The code snippet you give seems to be correct if you want the transform from the head of the parent bone to the head of the child bone.
How is the translation incorrect? There are supposed to be two translations between these bones, one from the head of the parent to its tail, and (if the child is not connected to the parent) one from the tail of the parent to the head of the child.
In the 2.40 armatures guide, bone.matrix is bone_mat and bone.matrix_local is arm_mat. This is how they relate in python:
# parent head to tail, and parent tail to child head
bone_translation = Matrix.Translation(Vector((0, bone.parent.length, 0)) + bone.head)
# parent armature space matrix, translation, child bone rotation
bone.matrix_local == bone.parent.matrix_local * bone_translation * bone.matrix.to_4x4()

I'm planning on using the exported models in an openGL program. Somewhere between the export and displaying them on screen, something goes wrong. Now I can rule out the exporter as an error source. Thank you. Your explanation of the relation between matrix and matrix_local is really helpfull too. I wish this was explained better in the api docs.

To get real local-to-parent  position  and rotation of each bone I do this. Strange, but this works. Difference from OP is result quaternion must be inverted.
mat_local_to_parent = (
    bone.matrix_local if bone.parent is None else
    bone.parent.matrix_local.inverted() * bone.matrix_local
)
pos = mat_local_to_parent.to_translation()
quat = mat_local_to_parent.to_quaternion().inverted()


text:
Dissapearing shadows in Eevee
I'm having a problem with Eevee that's to do with shadows disappearing.
A number of people on the internet seem to be having similar problems, but i've failed to find the solution.
Basically, as you can see in the gif, as the camera zooms in, the shadows at the edge of the frame start to disappear.
The scene is being lit by an HDRI and one spot light.
I've tried adjusting just about every parameter that's to do with shadows in the render settings and in the lights settings. I've tried adjusting clipping as well. It seems as though Eevee just stops rendering objects once they disappear from of the frame thus removing the shadows as well.
GIF showing the problem
My settings:

Would really appreciate any input on this. Fixes, possible workarounds, anything.
Thank you.
SOLUTION: Enable Overscan under Film in the render settings.


text:
Eevee - Shader not appears in render image
I am learning blender by myself and now so confused.
This is my viewport for render test.

This is the render image. First of all, it is not same with the camera view.
Also, the shaders just look white.

What is the problem?

Could you please post your fix as an answer and mark this as accepted afterwards? That way others can find it more easily.

Hi. Please don't add "Solved" or "Fixed"  to your question or title. Instead we encourage you to post an answer below with a short description of the solution and what steps you took to reach it. Perhaps add a few images illustrating the workflow and final results. See How do I write a good answer?


text:
Apply rotation and translation to bones(Math)
https://stackoverflow.com/q/38541723/2495562
I posted the question on stackoverflow ealier before I realised here might be the right place to ask blender related questions.

I'm using blender 2.49 because the script was originally written for that version.
I'm trying to create animations using some transform data.
The original data contains a sequence of joints. Each joint has its own rotation and translation values, it may or may not have a parent joint. This sounds pretty much like bones in blender, right?
To set up the skeleton:
#pseudocode
for joint in joints:
    v = Vector(0,0,0)
    j=joint
    while j:
        v = j.rotation*v
        v = v + j.location
        j = j.parent
    joint.position = v

To process a certain frame:
#pseudocode
for joint in joints:
    v = Vector(0,0,0)
    j=joint
    while j:
        rot=j.rotation+j.curFrame.dRotation
        loc=j.location+j.curFrame.dLocation
        v = rot*v
        v = v + loc
        j = j.parent
    joint.position = v

To make things simple, I convert each joint into a small bone.
    for i in range(0, len(bones)):
        bone = Blender.Armature.Editbone()
        bone.head = Mathutils.Vector(0,0,0)
        bone.tail = Mathutils.Vector(0,1,0)
        bone.name = 'Bone.' + str(i)
        bone.parent = armature.bones['Bone.' + str(bones[i].parent)]
        armature.bones[bone.name] = bone

Then I move the bones to their desired locations, using the posebone trick to create the skeleton:
    pose=armObject.getPose()
    pose_bones=pose.bones
    #pose the bones
    for i in range(0, len(bones)):
        name = 'Bone.'+str(i)
        tran = transforms[i]
        pose.bones[name].quat = Mathutils.Euler(tran.rotX,tran.rotY,tran.rotZ).toQuat()
        pose.bones[name].loc = Mathutils.Vector(tran.locX, tran.locY, tran.locZ)
    pose.update()
    #update editbones
    armature.makeEditable()
    for i in range(0, len(bones)):
        name = 'Bone.'+str(i)
        armature.bones[name].matrix = pose.bones[name].poseMatrix
    armature.update()
    #reset pose
    for i in range(0, len(bones)):
        name = 'Bone.'+str(i)
        pose.bones[name].quat = Mathutils.Euler(0,0,0).toQuat()
        pose.bones[name].loc = Mathutils.Vector(0,0,0)
    pose.update()

So far so good. But when I apply the transform to a certain frame, the results are incorrect.
    for i in range(0, len(bones)):
        name = 'Bone.'+str(i)
        tran = frame.dTransforms[i]
        pose.bones[name].quat = Mathutils.Euler(tran.rotX,tran.rotY,tran.rotZ).toQuat()
        pose.bones[name].loc = Mathutils.Vector(tran.locX, tran.locY, tran.locZ)

By incorrect I mean the rotations seem correct, but the translations are all wrong. I guess it is because the transforms should be applied to the posebone's local space(the skeleton is correct because all transforms start from the center )? But how do I do that?

Well I solved the problem already. I realized the transforms are done in the bone's local space, so they need to be calculated with the editbone's matrix before applying to the posebone.
for i in range(0, len(bones)):
    name = 'Bone.'+str(i)
    tran = frame.dTransforms[i]
    pb = pose.bones[name]
    eb = armature.bones[name]
    m1 = eb.matrix['BONESPACE'].rotationPart()
    e1 = m1.toEuler()
    e = Mathutils.Euler(tran.rotX,tran.rotY,tran.rotZ)
    e2 = Mathutils.Euler(e1.x+e.x,e1.y+e.y,e1.z+e.z)
    m2 = e2.toMatrix()
    m = m2*(m1.copy().invert())
    pb.quat = m.toQuat()
    pb.loc = m1*Mathutils.Vector(tran.locX,tran.locY,tran.locZ)


text:
Blender Internal renderer question
How do I enable, for example, additive blending for a material? Do I need to use node? I am trying out to create a light ball.
I searched the internet but only found answers for cycles.
Edit:
The result should be like the first picture in this topic: How to get additive blending in cycles?

Using nodes would be only way to make additive blending for material.
Though If You're making a light ball in Blender Internal You don't need it. Just go to material, find Shading make Emit higher then 1, go to World, check Indirect Lighting switch Gather(right below Indirect Lighting) to Approximate and voila, You got ball, that emits light.

Thank you for answering. Can you tell me what do I need to do if I use node? I want to learn it just in case I need to other blending mode in the future.

Here is pretty nice tutorial on the topic of using material nodes in BI. For making light ball though I wouldn't use material nodes, cause it would be like painting with Your foot instead of Your hand - exercise in futility

Thank you. But if I understand it correctly, the material needs to blend with the background and object behind it in order to create the transparent effect. However from the video the material node only changes the material itself. :)

I guess You should be more specific on what You plan to do, cause you didn't mention anything about transparent effect earlier.

Oh, sorry. I mean additive blending like in this question(the ball showed in the first picture), but with blender internal render. http://blender.stackexchange.com/questions/5331/how-to-get-additive-blending-in-cycles

If You need the material to additively blend with the background and other objects, without using compositing, then I don't think there is a way to do that in BI. There is just not enough information that you could extract from the scene to use in material, no Z-depth node or anything similar.

Thank you again. I think I understand now. :) I don't mind using compositing, if it is the only way.


text:
Game Engine not run action in sensor "always" after sensor "keyboard"
I´m sorry for my English, I´m Brazilian. I need help, please.
I am creating a game (only to study and learning about BGE), it has two animations ocioso and pulando.
I can run these animations correctly on BGE, but I wanna continue running the animation with sensor Always after the animation with sensor Keyboard is finished.
Steps:

Press P, to start game.
The cat will look around itself (animation ocioso).
Press Spacebar (this call animation pulando).
When the animation pulando finishes, the animation ocioso does not
continue running. Why??

The download the .blend is at link below:

Thank´s for all.

Please use http://blend-exchange.giantcowfilms.com/ for file uploading instead next time. I don't think you file is publicly accessible. Please edit your question and provided a new link using the site above

fixed link...thank you...I´m newer in stackexchange...

Not much into the Game Engine myself, but see if this helps http://blenderartists.org/forum/archive/index.php/t-205271.html

This is a bug in the action actuator (since 2.62 - rework of the animation system). It looks like the override from Action.001 dues not get disabled.


text:
The rig is not parenting correctly
I have this model of V1 (From Ultra Kill). And I'm learning how to rig. I had followed a couple of tutorials but it has come to my attention the rig does not parent to the object properly. the mesh does not move correctly.
I have clicked the mesh > Clicked the armature > ctrl + p > With Automatic Weight
Could somebody please help?

Blender File

Hello please share your file

@moonboots added the file

You have overlapping vertices, apply the scale and rotation of your armature and object, select the whole mesh in Edit mode and Merge by Distance (M) with a Merge DIstance of 0.005 and parent With Automatic Weights.


text:
How does one round off the corners?
How does one round the corners to make it look like the cube has a frame?
Like a frame made out of tubes. In this case cylinders.

Give a Skin modifier to a cube, then a Subdivision Surface modifier, CtrlA to thicken the branches in Edit mode:

Or extrude a cube 3 times:

Give it a Subdivision Surface modifier (level 1 here):

Topology if you apply the modifier and clean a bit:


text:
Annoying issue with collisions on ThreeJS + RapierJS
I'm encountering an annoying issue when importing my Blender model into Three.js (with Rapier.js physics system).
I used the Array modifier in Blender to repeat several steps for my stairs, but when I import my model into my project, the colliders do not correspond to the shape of each step.
Instead, they encompass the entire object.
Here is a screenshot of the issue I'm currently experiencing :

How can I achieve a good collision system on Blender ? Because If I make my stairs step by step, it work but this is so annoying to process like that.. especially for very repetitive objects...
Thanks a lot ! :)

This doesn't seem to be a question about using Blender, but did you try applying the array modifier before exporting?

Hello John,
Thanks for your reply.
Yes, I applied the array modifier but I still have the same issue..

Anyone (including me) who doesn't use threeJS won't have a clue what a 'collider' is (or Rapier.JS for that matter)!

Can I just subdivise the steps of my array to get X similars objects in my hierarchy ?

If I create my stairs cube by cube, individual collisions work :
https://image.noelshack.com/fichiers/2024/11/5/1710506860-individual.png
But if I use array, the whole object is impacted by a global collision even outside the bounds of my steps..

You should be able to apply the modifier, go into Edit mode, then hit P > Separate by Loose Parts. Each step should then be a separate object when you go back into Object mode.

Bro, you are my day hero, IT PERFECTLY WORKS like that, thanks 1000X John Eason :-)

No problem. I'll add it as an answer later.

Create the steps from a cube using the Array modifier.

Apply the modifier by hovering over it and hitting CTRL-A. Then go into Edit mode, select All and hit P > Separate > By Loose Parts.

Back in Object mode, you'll see that each step is now a separate object:


text:
change modifiers values with a gizmo
I see a lot of potential in gizmos, yet there is very little info on it. For example, I want to modify the properties of the modifiers or geometry nodes of my object with a gizmo.
How to do this ?
What exactly do you mean by a "gizmo"?
When I think of gizmo, I first refer to gizmos objects.

But also to the gizmo in the python template like these.
in gizmo_simple.py :

in gizmo_custom_geometry.py :

But for me a gizmo is an interactive visual element which is not found in the outliner and only appears when an object is selected and which modifies some of the properties of this object when it is moved.
And I actually want to modify certain properties of geometry nodes using a gizmo.

What exactly do you mean by a "gizmo"? Please add more details so that we can help.

Geometry Nodes gizmos are planned by the devs. https://devtalk.blender.org/t/geometry-nodes-gizmos-feedback/32073 I don't think it will make its way into 4.2 but maybe 4.3 ?

In the meantime you can always put your geometry nodes in a Group and add inputs to the properties you want to change. They will then be easily available on the Modifiers panel of the Geometry Modifier.


text:
create a drive based on the name of the active layer
I saw this video. https://www.youtube.com/watch?v=e-lGco8mDiw&ab_channel=aVersionOfReality
It explains how to use a py script to retrieve the layer number to use that value in a driver or something. The problem is that I have to constantly Update Dependencies, sometimes several times, for it to work properly. When I save the file and reopen it, nothing works anymore. It doesn't matter how many times I Update Dependencies or relaunch the script.
Originally, I wanted to use this script on all my files. I thought I'd just have to convert it into an addon to be able to retrieve my layer number from any file. I've used chatgpt to convert it to an addon, but it doesn't work.
My questions:
How can I retrieve my layer number in a variable for use in a driver?
How can I do this for all my files?
How can I get a script to run automatically each time I reopen a file?
Thanks in advance
#Set layer name to start with a number then :, eg '1: Layer'
#Drive a value in a material node with expression: layer_number(depsgraph)
#The driven value will be the number at the beginning of the layer name
#Doesn't always update when switching layers, might have to Update Dependencies
#Muting/Unmuting the node will also cause an update
#Seems to always update on Render
#by aVersionOfReality.com, twitter@aversionreality

import bpy

def layer_number(depsgraph: bpy.types.Depsgraph):
    name = depsgraph.view_layer.name

    try:
        layer_no = int(name.split(':')[0])
    except:
        layer_no = 0

    #print ('name =', name, 'number =', layer_no)

    return layer_no

def register():
    bpy.app.driver_namespace['layer_number'] = layer_number

register()

What is a "layer number"?

You need to convert it to an addon use the load_post handler and use the @persistent decorator. see https://docs.blender.org/manual/en/latest/advanced/scripting/addon_tutorial.html https://docs.blender.org/api/current/bpy.app.handlers.html#bpy.app.handlers.load_post https://docs.blender.org/api/current/bpy.app.handlers.html#bpy.app.handlers.persistent

or you can directly type into the field #int(self.name.split(':')[0]). You do have to check "Use Self" in the driver settings though

It seems you are talking about view layers and retrieving a number from their names. You should state that clearly in your question so people don't need to read the code to know what you are talking about. The title should communicate what the question is about. It might also be agood idea to provide context and explain what you are trying to do with those numbers in a driver.

import bpy

def layer_number(scene):
    name = bpy.context.view_layer.name

    try:
        layer_no = int(name.split(':')[0])
    except:
        layer_no = 0

    print ('name =', name, 'number =', layer_no)

    return layer_no

def register():
    bpy.app.driver_namespace['layer_number'] = layer_number

register()

bpy.app.handlers.depsgraph_update_post.append(layer_number)

bpy.app.handlers.depsgraph_update_post.append(layer_number) allows you to run the code each time the layer_view name is modified. Whereas in the previous code this was not done automatically, which created a lot of problems.