text:
what's the best way to render a ambient occlusion pass?
what's the best way to render a Ambient Occlusion pass without a backdrop so the background will be white instead of transparent?

In the Render properties tab under Film you could enable Transparent, which would give you a matte for the bg, then if you have the AO pass enabled as well then you can just invert the BG matte and Add that to the AO pass, with the output clamped. That would give you what you're describing. Though I'm not sure I fully understande the question.

how would you invert the BG matte

With an Invert Color node in the compositor.

To combine the transparent background to the ambient occlusion pass is to use the invert color to invert the Alpha pass make sure you click RGB and ALPHA boxes and then use the Alpha Over to combine the Alpha and the AO pass. I included a picture of the node tree


text:
transparent issue outline of the object is still showing up
I'm trying to have a smooth transparent fade but the outline of the object is still showing up.

Hello could you please pack your image and share your file?

here is the link to the file but I'm curious if it's because of the model I'm using   https://drive.google.com/file/d/1hkIW4rFDLU-gvk9XUXZVFZ2c_E9nmeb2/view?usp=sharing

These black areas are caused by overlapping faces, it is called Z fighting, your topology seems rather messy, a simple M > Merge by Distance doesn't seem to be enough to fix the problem, you'll probably need to rework the topology manually.

source: Stack Exchange

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

sort: votes


text:
Eevee Normal pass: remap negative values
Here's a result of Normal pass in Eevee:

Faces with normals in -1..0 range are rendered black. Is it possible to remap this range to 0..1 using Compositor? Here's the desired result made with a material:

I tried to render Normals pass in 32b .exr but it seems that there's no information about these normals in there.

Does it have to be in the compositor? In the shader, you could always use a Map Range node. or do it the oldschool way - (Normal Value + 1 / 2).

@ChristopherBennett I can do that in a shader (my second gif) but I want to be able to quickly render this: with a shader I'll need to override all the materials (and vanilla Eevee doesn't allow that), turn off all the effects like bloom/AO, then turn them back on...

Ahh, I see. Never mind then. Unfortunately I don't know how to do that in the compositor. I'll up-vote the question in the hopes that some user who is more knowledgeable in this area might happen by.

The image below gives a node set up that you could use in the compositor. It splits up the normal into its rgba values, takes the absolute value of each component (using the Math node with the "Absolute" setting), and then recombines them.

Hi Eliot, thank you for response! This works on a cube, but a sphere shows that mapping is made, I think, 0..-1..0..1, not -1..0..1: there's a border going through 0 https://i.imgur.com/akyRE3e.png

@SergeyKritskiy Thanks for pointing that out.  I fixed the answer and also realized that I didn't even need the second branch of nodes since I could just use the Absolute Value math node.

Ugh I tried to fix that myself and solution was so simple (well, also 'to learn nodes'..). Thank you!

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


text:
Aligning an instance using an angle between two edges with Geometry Nodes
I have some geometry edges and at each vertex that's linked to two edges I want an instance of an object and I want these instances to be oriented between the edges. On the left is an example of the desired result and on the right is where I'm stuck:

In theory I should get two adjusting vectors for each point, find their dot product and then arccos the result. In practice I guess something in my tree isn't doing that.
My GN tree:

and my scene:

If you convert your edge-only mesh to a poly-curve, the vertices have an order forced on them, and the  X orientation at the control-points bisects the angle between the edges, so that bit is done for you.
What's left is to determine whether the acute angle between the edge-directions entering and leaving each control-point is clockwise or anticlockwise, so we know which instances to flip.
This can be found by detecting  whether the cross-product of those vectors is 'up' or 'down' with respect to a given normal, by the right-hand rule. Here the given normal is (0,0,1):

The group also uses the Offset Point in Curve's  'Is Valid' output to filter out end-points. It can be used thus:

.. to give your oriented instances:

ooooh I didn't think of that, using a curve and Rotation attribute. Awesome — thank you for the solution and the file !


text:
Creating a new vert with bmesh resets previously created verts
I'm creating new vertices using bmesh at 3d cursor position but every time I add a new one, all the previously created vertices jump to their original positions (if they were moved). It's like I need to somehow update the bmesh, I'm doing bmesh.update_edit_mesh(ob.data) but this doesn't seem to help. Also I've noticed that if I manually switch to Object mode and back to Edit, verts keep their positions next time I run the script (switching modes with Python didn't help)
Here's what's happening:

And my code:
import bpy
import bmesh

def get_cursor_pos():
    for area in bpy.context.screen.areas:
        if area.type == 'VIEW_3D':
            ctx = bpy.context.copy();
            ctx['area'] = area
            return bpy.context.scene.cursor.location.copy()

def main():
  cursor = get_cursor_pos()
  ob = bpy.context.selected_objects[0]

  bm = bmesh.new()

  # convert the current mesh to a bmesh (must be in edit mode)
  bpy.ops.object.mode_set(mode='EDIT')
  bm.from_mesh(ob.data)
  bpy.ops.object.mode_set(mode='OBJECT')  # return to object mode

  bm.verts.new(cursor - ob.location)  # add a new vert

  # make the bmesh the object's mesh
  bm.to_mesh(ob.data)
  bm.free()
  ob.data.update() # ¯\_(ツ)_/¯

  bpy.ops.object.mode_set(mode='EDIT') #back to edit mode
  bmesh.update_edit_mesh(ob.data) # ¯\_(ツ)_/¯

main()

p.s. on a side note I also find weird that running the script selects all the verts I had selected when I had entered the Edit mode, I ownder if that's also part of the same problem

Add vert at cursor in edit mode
The cursor is in global coordinates. Set to local by multiplying by the objects world matrix inverse.
import bpy
import bmesh

context = bpy.context
scene = context.scene
ob = context.object
mwi = ob.matrix_world.inverted()
me = ob.data
bm = bmesh.from_edit_mesh(me)
bm.verts.new(mwi @ scene.cursor.location)
bmesh.update_edit_mesh(me)

even though my question wasn't about getting cursor coordinates (you can see on my gif that they're created in correct coordinates), your snippet helped me to fix my code by using bmesh.from_edit_mesh instead of bmesh.from_mesh. Thanks!

Try moving, rotating and scaling object then see if you get "correct coordinates"  With identity matrix world object coordinates == global coordinates and global cursor location difference with global object location (no parent?), otherwise it won't work as expected.

ah yes, I was only applying object location, not rotation or scale... thank you again


text:
How to turn up light bounces to infinity
I'm trying to make an infinity mirror in blender. I've managed to make a two way mirror by using the back facing geometry input to apply two different materials to either side of a face. Everything works OK but I only get 6 layers of bounce between the two mirrored layers before it stops.
How can I turn the number of bounces up to infinity so that the light pattern continues on indefinitely or until it fades to black?
Thanks. Here is an example rendering:

Try a really high number of bounces, like 100,000?

Would you add the result of the answer? Would be nice to see the effect.

Here is the final result (to fill the request above)

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


text:
Render is Completely Black
The problem that I am having, is that when I try and render my scene, everything turns out completely black. I press render, then it takes about 1 minute 30 seconds before it actually starts rendering, then it quickly renders a black screen. I have looked through many other posts about this, but none of the solutions are working for me. I'm a beginner, so I'm sure I am just missing something obvious, but help would be appreciated. Thank you.

Are you sure there is a light or light source in your scene?

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


text:
disable different snaps on zoom
When using the grid and snap-to, it uses various distances based on your zoom level. Is there a way to turn that off?
I want to snap to the zoom level I'm explicitly telling it to be at, not some arbitrary number because I happened to zoom out.

you can always move the object by entering a number while in translate mode (G). the incremental snapping is just 0.1, 0.01, etc, etc.

Grid snapping depends on the zoom level because orthographic grid depends on it. You can either snap without zooming in/out, or snap to geometry instead, or enable Metric or Imperial unit systems and look in the top left corner of the viewport to see what units are used at the moment. Then it'll be possible to keep track of zoom level. There isn't arbitrary number while snapping, it always snaps to one grid unit by default

To get zoom independent snapping you need to keep the displayed grid from subdividing. As described here (Grid: disable auto subdivision) to keep the grid from subdividing go to "View" -> "Properties" -> "Display" -> "Subdivisions" -> *set the value to 1*. To change the size of the snap, change the "Scale" value in the same section.


text:
Track cause of slow render
I've started using the branched path tracing and like the results, however I'm unable to figure out what the proper settings should be that result in a compromise between a faster render and good results.
Is there any way to track, on a given render, how long each type of sample is taking? (diffuse, glossy, transmission, AO, etc...) If I knew this information I could dial settings down until I find what seems to be a good compromise.
I feel like I'm using higher samples than necessary but every scene is different and will have different "optimal" settings and thus some way (other than trial and error) seems warranted.
Thanks!

Welcome to Blender.SE. There are render passes that can give you an idea of the amount of sampling for ecah type of BSDF. Did you already tried them? This doesn't fully address your question, but maybe could be a starting point.

Thanks for the reply. I hadn't thought of that and I just built a separate render layer for each type (disabling the combined layer), which allows me to watch how fast or slow they are in real-time, but Blender only reports the total render time in the upper left. I was hoping to get time for each layer so that I can see what's taking up the most time.

My ultimate goal would be to have a script that records current render settings, then sets everything to 0 and loops through each type of sample (setting it to 1) and then rendering the frame at a low resolution percentage and recording the time. Then it could simply output that info to the console and you'd be able to see what's taking up the most time and manually edit those settings.

So I figured out how to make it myself and folks can find the script here:
Code on pastebin
If you have a very simple scene then you might get some wonky results, as this calculates based on render duration and every single time you render a frame (even the same frame), you'll get different times. The best use for this is on a semi-complex scene so that the various samples (diffuse, transmission, etc.) really get to take effect and modify the total render time.


text:
Saving the deformations on an object after using soft body
Once I have used soft body physics to deform an object, can I save the deformations on the object once the animation is paused? I am applying soft body dynamics, playing the animation and then pausing it at the moment I have the deformations I want. I would then like to further edit the object and position it in its deformed state. Thank you for any help

Run the simulation to the desired frame and then apply the Soft Body modifier in the modifiers tab. This will 'freeze' the current state of the soft body into the now static mesh.


text:
Combining Curve modifier with Follow Path constraint
Is there a way to deform a mesh along the curve but also move the object along the curve?

if I add a Follow Path constraint with Follow Curve option enabled, my object doesn't deform;
if I add a Curve modifier, it deforms but I can't offset it;
if I add both constraint and modifier I can't make them to behave the way I want;

Is it possible to achieve what I want without using Armature?
The only workaround I found so far is modifying my object pivot point + using Curve modifier, but this won't work for me: I want to have several linked objects along the curve.

Ah! Displace modifier before the Curve modifier with the same axis:


text:
two textures: painting on one of them while the other is still visible (2.8)
I have a model with two UVs and two textures: first set is a projected UV with paintover from Photoshop and second UV is a generated UV to paint on top. They're mixed using the Alpha of the second texture.
UVs:

Textures:

Result in Lookdev mode:

I want to be able to paint on the second texture while seeing the first one and sampling colors from both first and second. Is this possible?
At the moment when I switch to paint mode and make several light brush strokes my first texture looks very dark and brushstrokes look like they're opaque. When I switch back to Object mode everything looks like it should.

Have you tried to turn off overlays in LookDev mode?

OOOH. Why didn't I try this?? Without overlays it works as expected, thank you! I guess my next question will be how to sample colors from both textures, because by default it samples from the first one and if I turn on sample merged it also samples light...:/

When you press S to sample, look at the popup there to choose to sample from combined.


text:
Do not trim mesh endpoints with Geometry Nodes
I have a mesh, some edges share verts, all verts are connected. Empties on the image below show the verts that belong to only 1 edge — mesh "endpoints":

I separate the edges, convert the mesh to a curve, trim it — every segment gets trimmed. However I want to offset only the points that aren't the endpoints from the previous image. Here's the result I'm getting with the empties showing where the 4 mesh endpoints should've stayed:

Here's my node tree:

I can get curve end points with the Endpoint Selection node but converting to curves will split the mesh into several splines. I've also tried to capture the mesh endpoints with the Vertex Neighbours node before splitting the mesh to get the 1-edge verts but... I don't know what to do with them after, there's no selection I could plug them into that I can think of.
And the scene:
https://www.dropbox.com/s/zfim0903q9pugla/trim_without_endpoints.blend?dl=1

You could solve this as follows:

First determine the number of vertices per edge. You use this value as selection for Set Position.
You determine the position by calculating the direction vector of an edge and scaling it with the value of your choice.
The direction of the scaling is obtained by comparing the previously selected stand-alone point with the position of the points returned by the node Edge Vertices.

Of course, you can also turn this around by simply checking that the number of vertices equals $1$:

(Blender 3.1+)

Beautiful! The solution was to make your own version of the trim with more control. Thank you!


text:
Is there a way to hide the axis locking guide?
Whenever we axis lock transformations, the x/y/z guideline appears, and it's a bit intrusive for me when translating and snapping thin objects. Can it be hidden somehow?

No i don't think they can be hidden at the moment, though you can change their colors in the themes to something less intrusive, though they will remain visible still.

Oh, I see. That's disappointing. D': Thanks!

@Helixfate could you add a screenshot of what you mean?


text:
Normals shows up as single while they should be double
If I create a plane, subdivide it in halfs, grab the edge in the middle and pull it upwards and then inspect the normals, they show up like this:

Now, I do not see double normals at any vertex. Still, the rendered output suggests that the normals where the faces meat eachother are different:

Now, which normal is applied on each of those two faces? The average of the vertex normals?

This looks..normal. Pan around the shape and see if you get and really dark spots. A face's normal display color changes depending on the angle your looking at it.

The average normal of all vertices on a face is used for shading. If you want the vertex normal the shading would have to interpolate. Select "smooth" (shading) for the object in that case.

Auto smooth is required to display individual normals.


text:
ctrl+alt+0 moves geometry for me
When I press Ctrl+Alt+0, trying to move the camera to the current view I end up in a view like this:

and when I after some struggling comes back to controlling the 3d view again, I can see that my geometry has moved, far far away, into another galaxy.
What can I possibly have done to let this happen?

Please read the answer to this question, it should help. You have set an object as your camera.

Ctrl+Alt+0 moves the Active Camera to the current viewport position.
For this to work there have to both be a camera in the scene and the camera must be set as active object.
If some other random object is incorrectly set as active camera that object will be moved instead.
Either add a new camera to your scene and make it active, or make an existing one active for the scene by selecting the camera object and pressing Ctrl+0.
If you want to keep the current view you can then press again Ctrl+0 to return to the previous state and finally press Ctrl+Alt+0 to bring the now active camera to line up with the current view.

You had the object selected not the camera
Select the camera you want to apply and than do Ctrl + 0 again

Does not seem to matter actually.

sorry let me correct myself: You hit only CTRL + 0 => applying the camera function to the selected object

When I press Ctrl+0, its like I am pressing Ctrl+Alt+0.

Than you moved arround (while your camera is still applied to the object) .. than when you pressed CTR + ALT + 0 you moved the "active Camera" (saying the object instead of the camera) to the view position

What is "applying camera to object"?

I never had to select the camera before, the functionality has been to simple move the camera so it will see the object like I am currently doing.

I mean with that CTRL  + 0 sets any selected object as "active camera". So that any camera relative movement (like also the flight mode) will apllie to this object.
to fix now: Select the camera and press CTRL + 0. Than you can set the camera again to your view with CRTL + ALT + 0 as you expect

I am trying to select the camera, then when my mouse is hovering the 3d view, I hit Ctrl+0, but that will change the view to the camera, without moving it.

Now, ctrl+alt+0 works as expected, I did not even have to choose the camera, must be a bug.

yes but this is what should happen.
CTRL + 0 "makes" the selected Object the "active Camera".
CTRL+ ALT + 0 than will move any object that in this moment is marked as "active Camera" to fit the view you have. I'm sorry this sounds so confusing :D Just try it again playing with the CTRL + 0 and selecting different objects you will see what I mean

@derHugo Could you please rephrase your question and clarify what you mean? Please edit it and include all this information in the post.


text:
How to always have the local Z axis pointing upwards in the viewport?
I am editing an object, use local transform orientation.
Here it is

Why is not Z, the blue arrow pointing "screen upwards"?
That would make life so my easier!

As it's seen on the screenshot you probably rolled the viewport with everything there, see https://blender.stackexchange.com/questions/15049/how-to-roll-the-viewport. In this case Z could be pointing upwards but you will see like it doesn't. Generally it is useful to use Normal transform orientation or create a custom one and move along them.

World Transform and Local Transform exists for reasons.
You can reset/apply your object's transform to make your Local Z axis pointing upward.  But there is no way to lock Z axis to point upward.  What you can try is to move/rotate your object's mesh in Edit mode, in there, your rotation/move operations won't change the local axis's orientation.

Wow, that is depressing. The rotation contains information that I just dont want to change. I do not want to rotate the object in edit mode, because I do not want to rotate the object! Just to edit it with a locked axis.

I'm not sure if I actually understood your question correctly.  Were you asking about whether it's normal to have the 3Dview Grids and Z pointing at that direction as your image showed, or are you actually asking about the Local Z axis aligning with the world Z axis.  The world Z always points upward.  Unless you rotate your view in a weird way.

I need to edit my object having Z pointing upwards. Else, I feel very clumsy.

Define upward...  Z, always point upward IMHO, difference is one that is global, one is local.  Z is the upward/downward direction for local transformation.

I have written "screen upwards" in the question.

I'm amused I even got 4 upvotes then.  My answer is completely irrelevant to what you are asking after all.  Facepalm.


text:
Cannot lock to custom z-axis when extrude-scaling with custom orientation
I have a part of a mesh selected, using a custom orientation called "ventil".

Now, if I want to add some thickness to the cylinder, by extrusion scaling it with
ESShiftZZ
I will be able to lock out the Z axis of the normal orientation in the extrusion, but not the custom orientation "ventil", which I actually expected would be the orientation to use.
Why?
Extrusions seems to only use "Normal", but grabbing uses the custom orientation.
Is this a bug?
(I would create the tag "Orientations" to this question if I had 300 reputation)

I have already assumes this must be a bug and reported it in https://developer.blender.org/T52558

In the docs it suggests the (somewhat cumbersome) workflow of cancelling the default extrusion movement and then resuming as an ordinary transform, which is then able to use the custom orientation.
https://docs.blender.org/manual/en/dev/editors/3dview/object/editing/transform/control/orientations.html#workflow


text:
How to get hidden selected objects using Python?
Can I get a list of the selected objects from Outliner, not from the scene? I want to create a script that unhides the objects selected in the Outliner: the problem is that if I try to grab the objects using bpy.context.selected_objects the hidden objects aren't included.

It would seem to me that SpaceOutliner.filter_state might be relevant, though I'm getting console errors in b2.80 that "AttributeError: type object 'SpaceOutliner' has no attribute 'filter_state'", so I'm not sure if it works.

I think this is for filter queries, these ones :/

https://blenderartists.org/t/blender-2-8-python-hide-unhide-objects/1141228/2

That would affect all hidden objects though, not the ones selected.

I've been looking through the API and can't find anything relevant.
The Blender source code contains a ED_outliner_selected_objects_get() function in the ED_outliner.h library file. Would it be possible to make a C-based addon instead of Python that includes that library file and is able to use it?

Unfortunately I know nothing about C and C-based addons: sounds like an overkill for a simple unhide script :/

It definitely does, though I don't think there's much else you can do if it's not in the API.

Maybe devs will add this in the future. Thank you for you time!


text:
Buttons on a custom properties dialog
I made a simply addon for myself that shows a property editor dialog. I wonder if it's possible to add several buttons on it that'd change value for Index property?

I know I can add buttons for existing operators but what about buttons to use within the dialog itself?
Here's my dialog class:
class SetObjectIndex(bpy.types.Operator):
    bl_idname = "object.set_object_index_sk"
    bl_label = "Set Objects Index Pass"

    my_index = IntProperty(name="Index",
        min=0, max=99)

    def execute(self, context):
        objects = bpy.context.selected_objects
        for ob in objects:
            ob.pass_index = self.my_index
        return {'FINISHED'}

    def invoke(self, context, event):
        source = bpy.context.active_object
        current_index = source.pass_index

        self.my_index = current_index
        return context.window_manager.invoke_props_dialog(self)


text:
Installing Python dependencies on Mac
I'm using MacOS Catalina and I following this question to install scipy with my addon: How to write my add-on so that when installed it also installs dependencies (let's say: scipy or numpy-quaternion)?
Running this code downloads and installs the module so I can use it in Terminal:
>>> import scipy
>>> print(scipy.pi)
3.141592653589793

However Blender doesn't see the module:
Traceback (most recent call last):
  File "/Text", line 2, in <module>
ModuleNotFoundError: No module named 'scipy'
Error: Python script failed, check the message in the system console

What I noticed is that if I try to run the install code again, I see this in the console:
Requirement already up-to-date: pip in /Applications/Blender.app/Contents/Resources/2.83/python/lib/python3.7/site-packages (20.1.1)
Requirement already satisfied: scipy in ./.local/lib/python3.7/site-packages (1.4.1)
Requirement already satisfied: numpy>=1.13.3 in /Applications/Blender.app/Contents/Resources/2.83/python/lib/python3.7/site-packages (from scipy) (1.17.0)

So scipy is located in ./.local and other modules are in Blender.app/Contents/. Does anyone know how can I fix this and use scipy in my addon?

Use bpy.app.binary_path_python to get the path to Blender's Python as shown here.

@RobertGützkow thank you for your reply. Unfortunately it's not: when I use your example to install a module I don't have (matplotlib you had there) it works, when I changed it to scipy I got the same warning as before: Requirement already satisfied + failed to import the module https://imgur.com/a/pbA4FC2

@RobertGützkow ok so I manually uninstalled scipy that I had before, reinstalled it from your addon and it works now, thank you! Do you have any idea what has happened? I checked and bpy.app.binary_path_python was the same path that I used in my script (str(py_exec)). Was it because something about using a wrong pip..?

You don't have to use the --user flag. There are some improvements planned that would allow this to work properly, but they are not implemented yet (see https://developer.blender.org/T71420)

You would have to add the modules to your sys.path if your using --user.

@RobertGützkow ah, interesting. thank you for the explanation!


text:
My blf-text appears in all 3d viewports after specific actions (ex selecting)
I noticed that the moment I select or deselect an object my blf text appears in all 3d viewports: is there something wrong with he way I use drawback handler?
Here's a gif with the issue:

Here's my simple modal:
import bpy
import blf

def draw_text(text, size, x, y, font_id, dpi, color=(1, 1, 1, 1)):
    blf.size(font_id, size, dpi)
    blf.color(0, *color)
    blf.position(font_id, x, y, 0)
    blf.draw(font_id, text)

def draw_callback_px(self, context):
    blf.enable(0, blf.SHADOW)
    blf.shadow_offset(0, 2, -2)
    blf.shadow(0, 3, 0, 0, 0, 1)

    draw_text(self.status, 30, 50, 115, 0, 72)
    draw_text('My Modal', 30, 50, 150, 0, 72)

class ModalOperator(bpy.types.Operator):
    """test"""
    bl_idname = "object.modal_operator"
    bl_label = "Simple Modal Operator"

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

        if event.type == 'MOUSEMOVE':
            pass

        elif event.type == 'LEFTMOUSE' and event.value == 'RELEASE':
            for ob in bpy.context.view_layer.objects:
                ob.select_set(False if ob.select_get() else True)
            self.status = 'Clicked'

            return {'RUNNING_MODAL'}

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

        return {'RUNNING_MODAL'}

    def invoke(self, context, event):
        self.status = 'Not Clicked'
        if context.space_data.type == 'VIEW_3D':
            self._draw_handler = bpy.types.SpaceView3D.draw_handler_add(draw_callback_px, (self, context), 'WINDOW', 'POST_PIXEL')

        context.window_manager.modal_handler_add(self)
        return {'RUNNING_MODAL'}

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

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

if __name__ == "__main__":
    register()

This is old (uses pre 2.8 bgl) but relevant https://blender.stackexchange.com/a/41329/15543  The draw call back is added to all spaces of that type. As seen in question once all viewports are updated.  Need someway to distinguish one from another. Example in Link looks at screen and area index.

@batFINGER thank you as always. I'm able to find my 'active' viewport but I don't understand how to draw handler only in it. I tried to limit draw_callback_px() to the index of the area but no luck..


text:
Rigid Body physics objects keep exploding
I have a remeshed Susanne with some fractures. Suzanne has a Passive Rigid Body with collisions shape set to Mesh. Fractures are set to Active, also with Mesh collisions shape.

Expected results would be for fractured objects to fall/slide using gravity, what I'm getting is an instant explosion of the fractures.

I've tried changing Rigid Body World scene settings (Split Impulse, Solver Iterations, Substeps), I've tried changing various Rigid Body settings (Friction,) and only getting more weird results. Tried scaling objects up ×10, the explosion was a bit smaller bit it introduced other issues like weird sliding, also this makes Suzanne ~20m in height which doesn't sound right. Anything else I could try?
Scene: https://www.dropbox.com/s/tgdmxavlnf2hbur/physics_explode.blend?dl=1

You could switch the pieces from Mesh to Convex, in the Scene panel > Rigid Body World > decrease the Substeps Per Frame down to 1, and it will work better but there may be a better way...

@moonboots thank you for the reply: yes I've tried that, unfortunately I believe this only slightly conceals the issue: the objects still explode, just in a different way. Plus fractures start to fall through the floor due to degraded Substep and because of the convex shape they start to push each other much stronger :(

i have no idea how you made the fractures...but i think they aren't all manifold and some faces are wrong. And of course i would change the margin of all parts to 0. [1]: https://i.sstatic.net/8A5x6.png

@Chris I’ve decimated them (when they were manifold the result was the same). Changing margins didn’t change anything unfortunately:(


text:
How to set a value for FloatVectorProperty from a function?
I have two properties set in my Class:
o_color: FloatVectorProperty(name="Obj Color",subtype='COLOR',default=[0.0,0.0,0.0],set=set_o,update=set_o_color)
mode_o: EnumProperty(name="Mode", items=[("O1", "Randomize", ""),("O2", "Set", "")], default="O1",update=change_mode_o)

I want to set the color of o_color to a specific value when mode_o is switched to O2. In my head it was simple: when mode_o updates, I run the set function of o_color:
# update of EnumProperty
def change_mode_o(self, context):
    if self['mode_o'] == 1: # if switched to O2
        set_o(self, tuple(1, 0.5, 0)) # set o_color to (1, 0.5, 0)

# set of FloatVectorProperty
def set_o(self, value):
    self["o_color"] = value

in reality:

my color doesn't update. No errors, just nothing happens.
when I try to select color it only allows me to change Saturation. This seems to happen if FloatVectorProperty has set or get function passed:

What am I doing wrong?

Does it work if the color property is part of a panel? If so try add a def check(self, context): return True method to the operator.

Perhaps you need to copy those attribute and assign them separately? Since the code you did is actually changing the pointer of the List (And you gave him a tuple... not sure it can work)

@brockmann haven't tried as a panel (never made them, seems like a lot of things to change... so maybe later) but adding the check function didn't do anything

@HikariTW yes I've tried that, same result

different self problem? Can you open up the system console to see whether there is any error?

@HikariTW there were no errors. If I assign an int instead of a list, update of the FloatVectorProperty prints this integer

@brockmann tried to convert to a panel, they probably work somehow differently? none of my props were registered (getting rna_uiItemR: property not found: view3d.copy_paste_viewport_sk.o_color)

Is there any workaround to avoid using getter and setter? I don't feel you need to use them in your scenario. I mean: self["o_color"] = (.0,.5,1.0)?

@HikariTW this won't work until I manually change a color of o_color. Not sure exactly how it works, but o_color doesn't seem to exist in self until I change it at least ones

Yeah, you probably need to call redraw after that operation since no any event occur and panel won't notice the change. BTW did you just type: tuple(1, 0.5, 0) in your code? Did it work?

@HikariTW I did, it didn't :(

Oh if you didn't change them from default value, those value won't be exist since we don't need to store a duplicated default thing in system. See this post Blender Setter

oh! setting it via self.o_color in update function of EnumProperty worked! (self['o_color'] didn't)

Changed my mind, adding min and max seems required, although I would expect that changing the subtype should be enough to make it work. Added as example to HikariTW's answer.

Elaborate From brockmann comment and Blender API:
bpy.props.FloatVectorProperty(
min=sys.float_info.min,
max=sys.float_info.max,
soft_min=sys.float_info.min,
soft_max=sys.float_info.max)

min (float) – Hard minimum, trying to assign a value below will silently assign this minimum instead.
max (float) – Hard maximum, trying to assign a value above will silently assign this maximum instead.
soft_min (float) – Soft minimum (>= min), user won’t be able to drag the widget below this value in the UI.
soft_max (float) – Soft maximum (<= max), user won’t be able to drag the widget above this value in the UI.

You need to set min = 0.0 and max=1.0 (or soft min/max) for the color subtype property.
So it will look like this:
a_color : bpy.props.FloatVectorProperty(name='Color',subtype='COLOR_GAMMA',size=4,default=(0.5,0.5,0.9,1.0),min = 0.0, max = 1.0)

b_color : bpy.props.FloatVectorProperty(name='Color',subtype='COLOR',min = 0.0, max = 1.0)

It seems like color also support by light system. So the min max wasn't set by default, causing the silder getting a ridiculous range and break the panel

Operator based on this answer:
import bpy

class SimplePropConfirmOperator(bpy.types.Operator):
    """Really?"""
    bl_idname = "my_category.custom_confirm_dialog"
    bl_label = "Do you really want to do that?"
    bl_options = {'REGISTER', 'INTERNAL'}

    def update_func(self, context):
        #print("my test function", self)
        self.my_color = (0.5,0.5,0.9, 1.0) # Alpha

    my_enum : bpy.props.EnumProperty(
        items = (("RND", "Randomize", ""),("SET", "Set", "")),
        update = update_func)

    my_color : bpy.props.FloatVectorProperty(
        subtype='COLOR',
        min=0.0,
        max=1.0,
        size=4) # Alpha

    @classmethod
    def poll(cls, context):
        return True

    def execute(self, context):
        self.report({'INFO'}, "YES!")
        return {'FINISHED'}

    '''
    def check(self, context):
        return True
    '''

    def invoke(self, context, event):
        return context.window_manager.invoke_props_dialog(self)

    def draw(self, context):
        row = self.layout
        row.prop(self, "my_enum", text="Property A")
        if self.my_enum == "SET":
            row.prop(self, "my_color", text="Property B")

class OBJECT_PT_CustomPanel(bpy.types.Panel):
    bl_label = "My Panel"
    bl_idname = "OBJECT_PT_custom_panel"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_category = "Tools"
    bl_context = "objectmode"

    def draw(self, context):
        layout = self.layout
        layout.operator(SimplePropConfirmOperator.bl_idname)

def register():
    bpy.utils.register_class(OBJECT_PT_CustomPanel)
    bpy.utils.register_class(SimplePropConfirmOperator)

def unregister():
    bpy.utils.unregister_class(SimplePropConfirmOperator)
    bpy.utils.unregister_class(OBJECT_PT_CustomPanel)

if __name__ == "__main__":
    register()

could you try to add a set function to it? that'd just print values. To see if the colorpicker gets locked

@SergeyKritskiy Yeah, it's locked


text:
Getting a closest point to 3d cursor gives a wrong result
I'm trying to find a point on an edge closest to 3d cursor with .intersect_point_line() but I'm getting a wrong point as a result, here I create an Empty in the result coordinate.

What am I doing wrong? When I'm printing out the results the distances are correct but it looks like verts indices are wrong..? My code:
import bpy
import bmesh
import math
import mathutils

def main():
    ob = bpy.context.view_layer.objects.active
    if not bpy.context.view_layer.objects.active:
        return
    me = ob.data
    bm = bmesh.new()
    bm.from_mesh(me)

    cursor_pos= bpy.context.scene.cursor.location.copy()
    bm.faces.ensure_lookup_table()

    print("start")
    print("cursor_location: ", cursor_pos)

    dist = 1000000
    good_res = None

    for index, edge in enumerate(bm.faces[0].edges):
        res = mathutils.geometry.intersect_point_line(cursor_pos, edge.verts[0].co, edge.verts[1].co)
        if res[1] < dist:
            dist = res[1]
            good_res = res[0]

    bpy.ops.object.empty_add(type='PLAIN_AXES', align='WORLD', location=good_res, scale=(1, 1, 1))

main()

Global coords, and calculate the distance.
Firstly mesh coordinates are local and the scene cursor location is global. Either convert scene cursor to local
scene_cursor_local = ob.matrix_world.inverted() @ scene.cursor.location

and then the result back to global when adding the empty.
ob.matrix_world @ good_pos

This would require only 2 matrix multiplications.
or convert the mesh coordinates to global (have done this below)
bm.transform(ob.matrix_world)

since we are not writing back to the bmesh so it will not be reflected permanently.
What closest point on line does.
>>> geometry.intersect_point_line(
intersect_point_line(pt, line_p1, line_p2)
.. function:: intersect_point_line(pt, line_p1, line_p2)
Takes a point and a line and returns a tuple with the closest point on the line and its distance from the first point of the line as a percentage of the length of the line.
:arg pt: Point
:type pt: :class:`mathutils.Vector`
:arg line_p1: First point of the line
:type line_p1: :class:`mathutils.Vector`
:arg line_p1: Second point of the line
:type line_p1: :class:`mathutils.Vector`
:rtype: (:class:`mathutils.Vector`, float)

Test runs.
>>> geometry.intersect_point_line((0, 0, 1), (0, 0, 0), (0, 0, 2))
(Vector((0.0, 0.0, 1.0)), 0.5)

>>> geometry.intersect_point_line((0, 1, 1), (0, 0, 0), (0, 0, 2))
(Vector((0.0, 0.0, 1.0)), 0.5)

>>>

It finds returns the point on the line closest to the point, and what percentage this is from the start point, ie 0 is the start point, 1 the other end.  It does not go outside the line.
In example above notice both have the same result, whereas one is right in the middle of the line, the other is not.  Also evident in question image, result is least ratio from corner aka edge vert 0. Flipping the normals will change the vertex order will again shift that result, if it is 10% from corner (as is) will be 90% way with verts wound the other way.
Instead calculate the distance by subtracting the hit from the cursor location.
Test code:
Have changed up code to add empty at closes point of all edges, rather than only that of zeroth face.
import bpy
import bmesh
from mathutils.geometry import intersect_point_line as ipl

def main(scene, ob):
    me = ob.data
    bm = bmesh.new()
    bm.from_mesh(me)
    bm.transform(ob.matrix_world) # put in global coords
    cursor_pos = scene.cursor.location.copy()

    print("start")
    print("cursor_location: ", cursor_pos)

    dist = 1000000
    good_res = None

    for edge in bm.edges:
        hit, pc = ipl(cursor_pos, edge.verts[0].co, edge.verts[1].co)
        d = (cursor_pos - hit).length
        if d < dist:
            dist = d
            good_res = hit

    bpy.ops.object.empty_add(
        type='PLAIN_AXES',
        align='WORLD',
        location=good_res,
        )

main(bpy.context.scene, bpy.context.object)

Other constructs for min / max
Instead of the set a super high value as max and test during each iteration, there are other ways to find a minimum and maximum (numpy is extremely good at this)
Another is to make a list comprehension of all the hits and sort them.  The zeroth will be the closest, the last the furthest away.
    hits = sorted(
        [ipl(cursor_pos, edge.verts[0].co, edge.verts[1].co)[0]
        for edge in bm.edges],
        key = lambda p : (p - cursor_pos).length
        )

    bpy.ops.object.empty_add(
        type='PLAIN_AXES',
        align='WORLD',
        location=hits[0],
        )

Ahhh, I didn't read the function description properly! thank you so much (and thank you for sort example, I've been struggling with min-max)

Pleasure. Good question, you've had a go, demonstrated result and expected result.


text:
Unrotate a square polygon with Python: all 3 axes
I have a rotated square polygon. And I want to 'unrotate' it so that its normal axes would match world axes.

I'm able to unrotate it on the Z axis by using the face normal and rotation difference (I don't care about translation at this point):
quaternion = Vector((0,0,1)).rotation_difference(face_normal)
rotation = ( +quaternion ).to_matrix().inverted()
obj.matrix_world = rotation.to_4x4()

But for the love of god I can't figure out how to also add face  X and Y rotation to the mix.
Desired result:

Use the edges.
The bmesh module has some methods for faces to calculate the tangent vector of the face based on its edges. For example sake will use the tangent vector created from two longest non connected edges.
Using the face normal, the face tangent and the cross product of the two can create a rotation matrix from the three orthogonal vectors.
The axes are the columns of a matrix, so a rotation matrix with unit vector axes x, y, and z could be
Matrix((x, y, z)).transposed()

if you recall from linear algebra, the transpose of an orthogonal matrix is also its inverse.
Test script, aligns face zero based on the matrix created as above.
import bpy
import bmesh
from mathutils import Matrix, Quaternion

ob = bpy.context.object
me = ob.data
bm = bmesh.from_edit_mesh(me)
face = bm.faces[0]

n = face.normal
t = face.calc_tangent_edge_pair().normalized()
c = face.calc_center_median()

M = (
    Matrix.Translation(c) @
    Matrix((t.cross(n).normalized(), t, n)).to_4x4() @
    Matrix.Translation(-c)
    )

bmesh.ops.transform(
    bm,
    matrix=M,
    verts=bm.verts,
    )
bmesh.update_edit_mesh(me)

Thank you! Great answer as always


text:
Close a popup with an OP call
I have a invoke_props_dialog popup that shows a list of modifiers. It has a OK button that calls execute() and closes it:

I want to have a similar popup with two buttons, that'd do different stuff but still close the popup. So it's like having two executes:

So I changed popup type to invoke_popup and added two buttons as operators (screenshot above), however I can't figure out how to close the popup after I press a button. I know that with invoke_popup I can simply click anywhere outide the popup area to close it however I wonder if it's possible to imidiately close it with a single click.
Here's my code:
import bpy
from bpy.props import (
    BoolVectorProperty,
)

class TestOpA(bpy.types.Operator):
  bl_idname = "object.test_op_a"
  bl_label = "My Button A"

  def execute(self, context):
    print('executed A')
    return {'FINISHED'}

class TestOpB(bpy.types.Operator):
  bl_idname = "object.test_op_b"
  bl_label = "My Button B"

  def execute(self, context):
    print('executed B')
    return {'FINISHED'}

class TestMainOp(bpy.types.Operator):
    """"""
    bl_idname = "object.test_main_op"
    bl_label = "Test Popup"
    bl_options = {'REGISTER', 'UNDO'}

    selection: BoolVectorProperty(
        size=2,
        options={'SKIP_SAVE'}
    )

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

        layout.prop(self, 'selection', index=0, text='Prop Name 1',toggle=True)
        layout.prop(self, 'selection', index=1, text='Prop Name 2',toggle=True)

        column = layout.column()
        r = column.split(factor=0.5)
        o1 = r.operator("object.test_op_a")
        r.operator("object.test_op_b")

    def invoke(self, context, event):
        wm = context.window_manager
        wm.invoke_popup(self)
        return {'RUNNING_MODAL'}

    def execute(self, context):
        return {'FINISHED'}

def register():
    bpy.utils.register_class(TestMainOp)
    bpy.utils.register_class(TestOpA)
    bpy.utils.register_class(TestOpB)

def unregister():
    bpy.utils.unregister_class(TestMainOp)
    bpy.utils.unregister_class(TestOpA)
    bpy.utils.unregister_class(TestOpB)

if __name__ == "__main__":
    register()

One way to solve it would be by moving the cursor out of the panel temporarily, like so:
def close_panel(event):
    x, y = event.mouse_x, event.mouse_y
    bpy.context.window.cursor_warp(10, 10)

    move_back = lambda: bpy.context.window.cursor_warp(x, y)
    bpy.app.timers.register(move_back, first_interval=0.001)

How this works is: first, we grab the X and Y values of the current mouse position, because in the next line the event is updated, and we lose the original coordinates.
Next, we move the cursor way over to the bottom left corner of the screen (not 0, 0 though because that doesn't close the panel for some reason).
Then, we prepare a function which moves the cursor back to where it was originally.
And finally, we use bpy.app.timers to delay starting our function by 1 millisecond, to give Blender time to realize the cursor is no longer on the panel, and close it.

This function apparently fails in Blender 2.90 Alpha, because bpy.context.window, doesn't exist there, so if you can't just tell people to update Blender to the stable Blender 2.90.1 release, you'll have to pass context.window from your operator to the function and use that for cursor warp. I'd just tell people to update though.

Worked on 2.83 and 2.90, thank you!


text:
Extruding imported svg does only translate curve
I created a svg in inkscape.

and imported it in blender.

Edit mode, with the display of handles turned off looks like

Selecting the curve by selecting one vertex and and pressing ctrl-L and pressing E to extrude it, restricting it by pressing Z does only result in translation.
I expected the mesh to become like a strip/band/wall.

The extrude curve menu that comes up shows some alternatives

...but changing to something else than translation here does not result in anything.
Why not?

Blender does not support this on curves (as far as I know). You can extrude curves only if created from 'add/surface/' and choose a curve (not from 'add/curve')

That is not how you extrude curves in Blender, use the Extrude property in the Properties Window > Object Data > Geometry > Extrude

Go to the object mode, press ALT+C and transform the curve into the mesh. Go to the edit mode and then extrude it along z-axis.


text:
How do I set an objects position relative its parent?
Does blender support parent relative coordinates?
How do I set an objects position relative its parent?
I am setting the coordinates of the ship (being a child of the bottle) to 0 0 0. Trying to change transform orientation of the 3d view gives no change, the ship goes to origin in any case.

You want the ship to stay in a bottle?

I want to view/set the ships coordinates relative the bottle.

You can use Alt+O to setup 0,0,0 coordinates at parent location.

The operator is called Clear Origin, for 2.8+ you can access it from the 3D View header menu under Object > Clear > Origin.

Which software did you use to create that presentation?

@AndersLindén it's byzanz with custom script from here. Keypad is KeyMon

What about rotation?

What's this called? It would be nice to have a name for the "alt O" procedure so I can find it in menus.

@foobarbecue Clear origin

This does not work for me in 2.79 or 2.8. Clear Origin works exactly the same way as Parent Without Inverse: it snaps the location of the child to the center of the parent. That is not what I want, nor presumably, what the OP wants, since it was initially stated that "the ship goes to origin in any case", indicating that such snapping to the parent is NOT desired behavior. This answer was marked as accepted. Does this mean it worked for the OP? Alt-o in 2.79 snaps the child to center of the parent. Object > Clear > Orgin in 2.83 snaps the child to the center of the parent. What am I missing?


text:
Undo grease pencil stroke in sculpt mode
How do I undo a grease pencil stroke caused by
D+LMB drag
in sculpt mode?
It seems like
Ctrl+Z (undo)
and
Ctrl+Shift+Z (redo)
will only affect the sculpting.

Yes, on Blender 2.79 Grease pencil "DRAW" is more like an annotation. (Obviously you can extend it to some animation functions). But yes, If you´re on the UV editor for example, and then D+Mouse drag, when you finish, you will not be able to "undo" the action. Just END the drawing, because you´re in a supra-mode.
Supra-modes are direct override over the system in which -once you start a session with the tool- you can´t "undo" or "change tools" until you end it.
Other tools that work in the supra-mode are "C"ircle select. Once you enter into a circle select session you cannot undo. If you CTRL+Z, session ends. But you don´t undo. Then you CTRL+Z again, and Blender will take you back to the START of the "C" supra mode session select.
I work on 2.79.7B (Daily verision) and NOW you can DRAW (D) and then CTRL+Z.
Check the version you have.
Thank you if you vote me up for answer.
BFCT_Schiller

I don't know a short cut, so I usually just delete the active grease pencil layer in the N panel. You are right, the undo system is only focused on the sculpt. Perhaps things will be different after the new grease pencil system has been used awhile in 2.8.

When I meant the "version", I meant it for Blender 2.79b (Daily version), not regular one. To access, click on Blender 2.8 download, an most downward the page, you´ll see Blender 2.79.7 daily release. Get that one. There you can do UNDO after stroke in grease pencil.


text:
Edge selection does not result in highlighted edge for one object in scene
I have an object in my scene where selecting an edge does not display the edge with a different color.

Why?
Here is an object, in the same scene, where edge selection highlights as expected.

When I had removed doubles, I got the selection highlighting back.
Now, why would that change anything?

Most likely the reason was that there were double vertices composing several versions of that edge. With that, Blender couldn't display selected edge as highlighted because there were some more edges in front of it. Anyway the first thing to check is to remove doubles.

Talking about doubles, I wish there was a way to select for instance a vertex and delete it together with all its doubles with one keypress.

You can press Ctrl+L while vertex is selected and the geometry linked to that vertex will be selected as well.

Thats seems like a promising answer, thanks!


text:
Rendered image shows visible "line strokes" artefacts
If I just render the default cube it will look like this:

It is rendered with color depth 16. I can see there are artefacts consisting of visible "line strokes" on some of the cube faces.
The bands seems to not go darker and darker, but alternates between light and dark, or is my eye fooled?
Why?
Edit
Here comes a gradient created by gimp without banding, using the same computer:

This is due to banding. If you are viewing that 16bit image on 10 or 12bit display, you shouldn't see any banding. But on 8bit display the banding is still there and you get rid of it by dithering. Basically just add noise to the image.

I view the image on a modern display.

@AndersLindén What is your display/monitor? Most modern monitors are in 8 bit.

It's not really if it is modern or not, but how much expensive it was. 10 or 12 bit displays are special and very expensive and you also need a workstation grade gpu like quadro or firepro to run them.

So the image above with the cube looks different using different displays?

Then the artefacts would not grow when I am scaling it :)

I guess the viewer is broken... Do you see banding on the right: https://i.sstatic.net/wg6cM.png?

@poor No, the right image looks ok. The viewer is broken should mean that blender is broken. Or do you use something else than the default setup?

After some research, I can say the viewer isn't broken. The viewer is just not displaying the image in that way I would expect in 2017 @AndersLindén. It seems to be an opengl precision issue, probably to avoid conflicts with older graphic cards or due the lack of interest implementing this properly, not sure... However, nowadys it's possible to display the image without the banding and without manually adjusting a dithering value so hopefully a developer will fix this in the near future.

Also I noticed that in most cases a dithering value of 0.85 is enough to get a clean image, but then this "generated noise" is baked into the image when saving as jpg or similar, which isn't really useful in most cases. So leaving the dithering value at 0.0, rendering as exr and adding real film grain at the end of the process is the way to go (IMO).

The artifact is called color banding and is a common occurence in computer graphics. (Most) computer monitors only have a range of 8 bit per channel. The human eye can differentiate a much greater resolution of light values, especially in dark tones.
See this less specific, but informative article.
Hence, color banding is especially visible in dark gradients. An image with a depth of 12 bit or more viewed on the according viewing device would have practically no visible banding.
Although a bit depth of 16 and higher are today's standard in computer graphics such as 32-bit floating points, which have no banding in theory (most) monitors remain in 8-bit color mode.
Most image related software "solves" this issue by adding noise to the image. This process is called dithering.
Different software manage this in different ways.

The gradient tool in Photoshop has a dither option.

Nuke dithers gradients dynamically in the output viewer.

Blender has a dither slider, this allows the user to control the dithering amount manually.

By default, Blender's dither value is at $0$. That's why you can see the color banding even if the image is rendering in 32-bit floating points. Blender will always render images in 32-bit floating point color depth. Only when you save the image, will Blender convert it to the selected bit depth of the output format.
The image you displayed has dithering already applied. When increasing the contrast we can see the noise, which GIMP added to the gradient.

If we increase the dither property in Blender to $1$ and render the default group, there will be no visible banding artifacts.

Otherwise banding will show (dither value of $0$).

Increasing the contrast afterwards can reveal the dithering noise. (Left, dither at 1; right: dither at 0)

When should I not use dithering?
Do not save images with applied dithering when you plan on processing them further. Save them with a high bit depth (16-bit or more). Postproduction applications can then do color operations correctly and dither the image at the last step if necessary.
Example: A color correction with applied dithering noise would change the amount of noise in some parts of the image thus resulting in uneven dither, which could possibly be visible.
When should I use dithering?
Use dithering in the final step of production, where the product is created which has the chance to be viewed on an 8 bit display. (In other words all final image material.)
Additional Note
Digital movie format (obviously not DCP packages) don't support bit depths higher than 8.

Great answer, but I even can see the banding on my dreamcolor monitor... I guess the viewer is broken: https://i.sstatic.net/wg6cM.png (same image on both sides)

@Poor The dreamcolor is in AdobeRGB (10bit), the human eye should be able to recognize banding. Further, your image doesn't proove anything as it is in 8bit and [nuke added noise]8http://imgur.com/a/nE1sh). If a saved 16-bit gradient appears differently than an 8bit version in your image viewer and Blender show it same way as saved as the 8bit image the viewer must be not correct. I have no means of confirming this.

Thanks for pointing out that gimp actually dithered the output in such an informative way!

@Duarte Thanks for the edits. I admire and appreciate the effort you put into maintaining this site!

Welcome, it is users like you posting good answers that make this worth it. Keep up the great work.


text:
Sending data from scripts to Python Console
I wonder if it's possible to send commands/data from scripts (ex from Text editor) to Blender Python Console? I've enabled a Math Vis Console: it draws provided Vector/Line/Etc data in 3d viewport and it'd being a great help, however it requires data to be typed in Python Console. So for example if I want to display an ob.location I have to

print(ob.location) in my script first
then copy string from System Console: <Vector (-1.4095, -0.1780, 1.7132)>
reformat it as a 'proper' Vector: Vector((-1.4095, -0.1780, 1.7132))
paste this along with a variable name (loc) to Python Console: loc = Vector((-1.4095, -0.1780, 1.7132)):

I wonder if there's a faster way of doing that?

You can paste data onto bpy, not sure how advisable it is, but its a technique that works:
In a script:
import bpy

bpy.sergey = (1,2,3)

And then on the console:
>>> bpy.sergey
(1, 2, 3)

Woah! This works, thank you!

Not sure about the method above, tried it in 3.6.4 and it gave me no results.
What works for me is the code below that writes to the current window console directly.
def get_current_console():
    import console_python
    for window in bpy.context.window_manager.windows:
        for area in window.screen.areas:
            if area.type == 'CONSOLE':
                for region in area.regions:
                    if region.type == 'WINDOW':
                        console = console_python.get_console(hash(region))
                        if console:
                            return console[0]

console = get_current_console()
console.locals['location'] = bpy.data.objects['Cube'].location


text:
How to update 2d-shader coordinates when camera moves
I'm drawing some lines using a 2D_UNIFORM_COLOR shader based on object location. When I rotate my view, the lines update only when the rotation is done: I thought that I can just put a function that updates my coordinates in modal() but this didn't work. So I wonder if there's a way to update the regions while the view is rotated?

P.S. I realise that a 3d shader would work better for drawing axes, but axes here is just an example
My code:
import bpy
from mathutils import Vector
import bgl
import gpu
from gpu_extras.batch import batch_for_shader
from bpy_extras.view3d_utils import location_3d_to_region_2d

def draw_callback_px(self, context):

    # do I really have to create a separate shader for each line? Ugh

    shader_X = gpu.shader.from_builtin('2D_UNIFORM_COLOR')
    shader_Y = gpu.shader.from_builtin('2D_UNIFORM_COLOR')
    shader_Z = gpu.shader.from_builtin('2D_UNIFORM_COLOR')
    bgl.glEnable(bgl.GL_BLEND)
    bgl.glLineWidth(2)

    v_x = (self.axes[0] - self.ob_location).normalized()
    v_y = (self.axes[1] - self.ob_location).normalized()
    v_z = (self.axes[2] - self.ob_location).normalized()
    batch_X = batch_for_shader(shader_X, 'LINE_STRIP', {"pos": [self.ob_location, self.ob_location + v_x*100]})
    batch_Y = batch_for_shader(shader_Y, 'LINE_STRIP', {"pos": [self.ob_location, self.ob_location + v_y*100]})
    batch_Z = batch_for_shader(shader_Z, 'LINE_STRIP', {"pos": [self.ob_location, self.ob_location + v_z*100]})

    shader_X.bind()
    shader_X.uniform_float("color", (1, 0, 0, 0.2))
    batch_X.draw(shader_X)

    shader_Y.bind()
    shader_Y.uniform_float("color", (0, 1, 0, 0.2))
    batch_Y.draw(shader_Y)

    shader_Z.bind()
    shader_Z.uniform_float("color", (0, 0, 1, 0.2))
    batch_Z.draw(shader_Z)

    # restore opengl defaults
    bgl.glLineWidth(1)
    bgl.glDisable(bgl.GL_BLEND)

class ModalOperator(bpy.types.Operator):
    """Move an object with the mouse, example"""
    bl_idname = "object.modal_operator_test"
    bl_label = "Simple Modal Operator Test"

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

        self.update_region(context, event)

        # Navigation
        if event.type in {'MIDDLEMOUSE', 'WHEELUPMOUSE', 'WHEELDOWNMOUSE'} or event.alt:
            return {'PASS_THROUGH'}

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

        return {'RUNNING_MODAL'}

    def invoke(self, context, event):
        self.ob = bpy.context.view_layer.objects.active
        if not self.ob:
            return {'CANCELLED'}
        self.update_region(context, event)

        args = (self, context)
        self._handle = bpy.types.SpaceView3D.draw_handler_add(draw_callback_px, args, 'WINDOW', 'POST_PIXEL')

        context.window_manager.modal_handler_add(self)
        return {'RUNNING_MODAL'}

    def update_region(self, context, event):
        self.region = context.region
        self.rv3d = context.space_data.region_3d
        self.ob_location = location_3d_to_region_2d(self.region, self.rv3d, self.ob.location, default=None)
        self.axes = [location_3d_to_region_2d(self.region, self.rv3d, self.ob.location + Vector((1,0,0)), default=None),
                     location_3d_to_region_2d(self.region, self.rv3d, self.ob.location + Vector((0,1,0)), default=None),
                     location_3d_to_region_2d(self.region, self.rv3d, self.ob.location + Vector((0,0,1)), default=None)]

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

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

if __name__ == "__main__":
    register()

Edit: as I wrote all that is below, I just realized the question was explicitly about 2D shader...
You just missed to call
self.update_region(context, None)

from inside the callback, which is itself called at each drawing.
Though, as it is the calculation is not correct. You should use object world matrix (see the previous answer).

Previous answer (I don't delete it as that could be useful):
As you want to move during the operator, you are in 3d, use:
gpu.shader.from_builtin('3D_UNIFORM_COLOR')

instead of:
gpu.shader.from_builtin('2D_UNIFORM_COLOR')

Also, in this case, use POST_VIEW, as indicated in the documentation.

draw_type (str) – Usually POST_PIXEL for 2D drawing and POST_VIEW for
3D drawing. In some cases PRE_VIEW can be used. BACKDROP can be used
for backdrops in the node editor.

self._handle = bpy.types.SpaceView3D.draw_handler_add(draw_callback_px, args, 'WINDOW', 'POST_VIEW')

One shader is needed.
You can start from object axis and convert them in world space:
def draw_callback_px(self, context):

    obj = context.active_object
    mat = obj.matrix_world

    shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
    shader.bind()

    bgl.glEnable(bgl.GL_BLEND)
    bgl.glLineWidth(2)

    origin = mat @ Vector((0, 0, 0)) #Convert coordinates in world space
    x = mat @ Vector((2,0,0))
    y = mat @ Vector((0,2,0))
    z = mat @ Vector((0,0,2))
    batch_X = batch_for_shader(shader, 'LINES', {"pos": [origin, x]}, indices = ((0, 1),) )
    batch_Y = batch_for_shader(shader, 'LINES', {"pos": [origin, y]}, indices = ((0, 1),) )
    batch_Z = batch_for_shader(shader, 'LINES', {"pos": [origin, z]}, indices = ((0, 1),) )

    shader.uniform_float("color", (1, 0, 0, 0.2))
    batch_X.draw(shader)

    shader.uniform_float("color", (0, 1, 0, 0.2))
    batch_Y.draw(shader)

    shader.uniform_float("color", (0, 0, 1, 0.2))
    batch_Z.draw(shader)

    # restore opengl defaults
    bgl.glLineWidth(1)
    bgl.glDisable(bgl.GL_BLEND)

Why POST_VIEW?

@brockmann, just edited about that. I don't know why, but it is in the docs...

Cool! Thanks @lemon.

@brockmann... fyi (if needed), the issue was simply... see edited answer... : ))

Thank you for the answer! Yes, I knew how to make it work for 3d shader so I was looking for a solution for 2d shader. Putting my region_update to draw callback fixed the issue I had, thank you!


text:
Problem finding a face center of a mirrored object using a ray_cast
I want to find a face center of a face I'm clicking on using the .ray_cast method. Since this method returns a face index, I thought I'll just use it to get the center coordinate from obj.data.polygons[face_index].center.
However when I have an object with a Mirror modifier with a Bisect option turned on, .ray_cast returns a face index of the original, not mirrored face even though I'm iterating on evaluated depsgraph. Here in this gif the printed face index is the same for both faces of the Mirror w/ Bisect object while two other objects return different proper values:

can I somehow get the correct face index?
maybe there's a different way of getting a face center coordinate that'd work on this object?

Here's a slightly modified version of the default Blender raycast template that prints out a face index.

So, I used scene ray cast instead. It worked faster than ray casting through objects and was returning correct normals/faces.


text:
How can you split an edge in 3 or more edges?
Is there a way to split an edge into more than 2 equal edges? Same for faces I was using another program that had this option and it was quite handy.
Thank you for your time.

W > Subdivide > Adjust number of cuts

First of all, go to Edit Mode and select the edge you want to split, then click the Subdivide button (step 1 in the picture below) and adjust the number of cuts in the panel that appears below (step 2). Also make sure you don't do anything else before adjusting the number of cuts, or the panel will disappear because Blender doesn't store that kind of information in its history, so even if you do Ctrl+Z the edge will return as it was before subdividing but the panel will not reappear and you'll have to do the procedure again.

First thing that came to mind was ctrl-B and then roll up with the middle mouse button.

Note that Ctrl+B won't do anything with an edge (Ctrl+Shift+B as well because there won't be anywhere to move beveled vertices)


text:
Sculpting problems, not enough faces?
I've just started trying out the sculpting tools in blender. I first followed this sculpting basics tutorial: https://www.youtube.com/watch?v=uVpwivEl_6o
and am now trying to sculpt a leaf shape.
I started out with a bezier curve for the leaf outline, which I then converted to a mesh, then extruded to give it a bit of depth and then cut out some holes, this got me an object which looks like this:

Now the problem is that when I try to follow the tutorial and use the multiresolution modifier, I get something which looks like this:

Or if I try to directly use one of the sculpting tools on the leaf objects, for example to make a crease down the middle, it looks like this:

Obviously this isn't what I'm going for at all.
Now I'm thinking it might be that the faces on the top side of the leaf might be too few / not at all in the shape that I want to modify, my question is, how do I change that? Shouldn't the multiresolution modifier add more faces?
Or should I have created the basic shape in a different way?
Any help is appreciated!

The linked tutorial is not suitable for what you are going for. The two major problems with your mesh are 1) that it is not going to be evenly subdivided by the modifier and 2) that it has ngons instead of quads. You might achieve a better result when using dynamic topology. Search for tutorials with "dyntopo" or "dynamic topology" instead.


text:
Modify a softbody during animation
I am hoping to grow a branching shape while softbody animation is underway.
I am using a bmesh to update the object's mesh as the branching shape grows.
However once the softbody animation is underway, the pointcache seems to rely on a stored version of the mesh.
If say I elongate the mesh, the pointcache continues to behave as if the mesh was as it was when the animation started.
If I hack the point cache (on disk) and move vertices in the pointcache to where they should be if they matched the mesh, they spring back to the unelongated shape (but distorted by the softbody).
After each frame, after I have modified the mesh, and the pointcache, I am running
bpy.ops.screen.animation_cancel(restore_frame=False)
 bpy.ops.screen.animation_play()
in an effort to get the pointcache to look back to the edited mesh, but to no avail.
If I stop the animation and go to edit mode, the elongated shape of the mesh is evident, but with no distortion from the softbody.
I gather there must be a data structure in memory representing the edges of the mesh (as it was when the animation started) as springs.  Will I need to force regeneration of this data structure somehow?  Or maybe directly edit it?  Where can I find it?
Apart from elongation, I want to extrude parts of the mesh gradually as the animation progresses, and branch the structure.

After quite a bit of research I found out that:
The physics engine creates the springs (representing edges and if 'Stiff Quads' is set the diagonals of each quad) only once on starting a render animation.  The springs are stored in memory somewhere but there doesn't seem to be any way to modify them or reload them during a render animation.  So they can't be changed during a render.  However, if I render little bits (frames 1 to 2, then 2 to 3 etc), the springs are re-loaded at the start of each mini-animation.
But of course without any other intervention the springs are loaded from the un-animated mesh, so the physics is cancelled out at each step.  UNLESS, I discovered, the softbody cache, stored on disk, is copied before the end of a 'mini' animation (see bpy.app.handlers.frame_change_post), and restored just after the start of the next 'mini' animation (see bpy.app.handlers.frame_change_pre).
And where changes are made to the mesh, they need to be made between 'mini' animations, and corresponding changes to the softbody cache need to be made.  It is critical that the same number of vertices are in the mesh and the cache and that they are in the same order.
With help from http://blender.stackexchange.com/questions/15577/how-to-extract-convert-data-from-blender-cache-files-bphys-into-a-human-readabl I created a utility to read and unpack the disk cache, allow modifications then write the modified cache back to the same location.
Unfortunately this procedure means that each frame is rendered twice (e.g. frame 2 is rendered during the animation of frames 1-2 and during the animation of frames 2-3) but there seems no way around this.  It would be wonderful to be able to suppress rendering of the last frame in the range, but I haven't seen a way to do that.  Animating from frame 1 to 1 and then 2 to 2 etc would obviously only render each frame once, however there is no room for the physics engine to work.
If I was simply looking at animation in the 3D window (not rendering), I found that toggling the edit mode in the frame_change_post handler was sufficient to get the physics engine to re-load the springs.  Toggling edit mode during a render animation just generates an error, so the more complicated 'mini' animation approach needs to be used.
I am using Blender 2.79b on Windows 10.


text:
How to convert a text/curve to mesh with given maximum face size?
I have a text object, which I am converting to a mesh; later I want to apply a shrinkwrap modifier to project the mesh-text onto a curved surface, so I would like to avoid very large faces (e.g. when converting letters like I or L, with long straight edges).
I am subdividing the resulting mesh to work around this, but this creates lots of unnecessary faces (as it is subdividing the small faces as well)
Is there an adaptive-subdividing tool which I can use to subdivide faces that are larger than a given threshold?

Try a remesh modifier with an octree depth of about 7. Uncheck "remove disconnected peices".

Make sure you have converted to mesh first.  This only works if the mesh has some substance to it (solidify modifier, or edit mode, select all, extrude).
Apply modifier to see results in edit mode, or check "display modifier in edit mode".


text:
Realtime hologram pyramid
I'd like to make a hologram pyramid project and I'd like it to work in realtime using blender game engine. I need help to set up the 3 cameras to work simultaniously, can anybody help me?

Why do you need 3 cameras?


text:
update callback for CollectionProperty item, propagate to other collection items
I'm wondering what the best way is to handle this case:
I want a change of one Propertygroup in a Collectionproperty, to affect the others inside that CollectionProperty. Say if an EnumProperty in the Propertygroup is set to a specific option, all other members of that collection should have their enum be set back to default. Essentially only one member of the collection is allowed to have this option.
import bpy
from bpy.types import Operator, PropertyGroup, UIList
from bpy.props import IntProperty, EnumProperty, CollectionProperty, PointerProperty

class NodesPanel(bpy.types.Panel):
    bl_label = "Nodes Panel"
    bl_idname = "OBJECT_PT_nodes"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"

    def draw(self, context):
        layout = self.layout
        col = layout.column()
        col.operator("object.addcustomnode")
        col.template_list(
                "Nodes_UL_List", "",
                context.object.nodes_list, "collection", context.object.nodes_list, "list_index")

class OBJECT_OT_addnode(Operator):
    bl_idname = "object.addcustomnode"
    bl_label = "Add Node"

    def execute(self,context):
        obj = context.object
        obj.nodes_list.collection.add()
        return {'FINISHED'}

class NodeProp(PropertyGroup):
    type : EnumProperty(
        items=(
            ('CHILD', "Child", ""),
            ('PARENT', "Parent", ""),
        )
    )
    val : IntProperty()

class NodesList(PropertyGroup):
    collection : CollectionProperty(
        name = "Nodes",
        type = NodeProp)
    list_index : IntProperty()

class Nodes_UL_List(UIList):
    def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
        if self.layout_type in {'DEFAULT', 'COMPACT'}:
            layout.prop(item, "type", text="Type")
        elif self.layout_type in {'GRID'}:
            layout.alignment = 'CENTER'
            layout.prop(item, "type", text="Type")

classes = (
        OBJECT_OT_addnode,
        NodeProp,
        Nodes_UL_List,
        NodesList,
        NodesPanel
        )

def register():
    for cls in classes:
        bpy.utils.register_class(cls)
    bpy.types.Object.nodes_list = PointerProperty(type= NodesList)
if __name__ == "__main__":
    register()

teh above example is a simplified representation. I would want there to be only one Node per object that can ever be set to "Parent", it should force all others back to child.
I've read about callbacks on adding to the collection but this goes deeper.
I'm assuming I could do something contrived with set, get or update functions on the enumproperty, and in one of those functions derive the selected object from context to find the collectionproperty, iterate over it to fix the others. That seems a bit roundabout, so perhaps I'm missing something?

you can get the collection the item is from with self.id_data.nodes_list.collection in the callback

Thanks Gorgious, You've got my back again! To confirm: you're talking about 'self' in the context of a callback in NodeProp (like set or get)? Where id_data points back to the original object the whole collection is on ?

yup, see https://docs.blender.org/api/current/bpy.types.bpy_struct.html#bpy.types.bpy_struct.id_data and https://docs.blender.org/api/current/bpy.props.html#bpy.props.PointerProperty I suggest you use the update callback, its less overhead in that case imo, and also be careful not to cause an infinite recursion by filtering out self in the collection items

You could do something like this in your property group definition :
def update_node_prop(self, context):
    obj = self.id_data
    nodes_list = obj.nodes_list
    collection = nodes_list.collection
    for node_prop in collection:
        if node_prop == self:
            continue
        if self.type == "PARENT":
            node_prop.type = "CHILD"

class NodeProp(PropertyGroup):
    type : EnumProperty(
        items=(
            ('CHILD', "Child", ""),
            ('PARENT', "Parent", ""),
        ),
        update=update_node_prop,
    )
    val : IntProperty()


text:
Confused by UV Layers - why are they needed if an object can have UV's without them?
I'm trying to come to grips with UV concepts in Blender, as someone coming from Autodesk products where there's the concept of UV-channels.
For now I'm assuming UV layers are like channels, meaning you can have different UV layouts on the same object coexist.
What I find very confusing, is that an object can have UV's, without having an explicit UV-Layer (an entry in the Mesh / UV Maps properties rollout). A new cube does come with a UV layer, but deleting is has no effect on it's UV's. Meshes created in Python with bmesh have UV's, without having a UV Layer.
Without this UV Layer I can't start editing from these existing UV's. Annoyingly, Blender seems to default to using these un-editable non-Layer UV's for all textures, meaning I have to take extra steps to explicitly use this UV layer for each texture. Compared to UV-channels in Max or Maya this seems so limited: you can always edit, clear or copy any channel in those apps. The default channel 0 is always used first by a material. I guess Blender is doing it different, to safeguard an object from ever having no UV's at all?
(additionally, I'd love to know if there is at least a way to edit or set this hidden, non-layer UV through python code with bmesh, or is it always locked..?)

A new cube does come with a UV layer, but deleting is has no effect on it's UV's This is not true, could you elaborate on why you think it is ?

"an object can have UV's, without having an explicit UV-Layer (an entry in the Mesh / UV Maps properties rollout)" How? Could you show where these "UV layer" are?

I was going to ask the same as @Gorgious - when I delete the default UV map of the default cube, it certainly has an effect on the UVs, and textures mapped to the default UV map will not show correct anymore. And the UV layout is not saved somewhere in the background either, because simply adding a new UV map with the "Plus" button does not bring the old layout back. And I don't know about UVs from bmesh, but if you for example create custom UV coordinates by storing data in an attribute in Geometry Nodes you might not have a UV map either, but the coordinates in an attribute...

Hey, digging deeper it seems I am getting confused by the "Checker Texture". Apparently this isn't a true texture, as it looks like it can map to an object even if it has no UV's. I expected a "texture" to behave like a texture, not as a sort of semi-procedural...

...well, when you talk about procedural, non-image textures, by default without plugging anything into the Vector input they use Generated coordinates, not UVs. Only the Image Texture node uses a UV map by default - but also has a problem if none is present...

Right, I see. Look more closely, it seems like Checker Texture does an internal, non-uniform box UV projection.
Very much not a texture by my definition then, but I can live with that!

Yes it seems your confusion stems from having a biased definition of what a texture is :) A texture is a N (1, 2 ,3, ...) Dimensional image projected on a 3D surface, its definition is not directly tied to UVs. UVs are a means to project the texture on a surface, but the projection can be pretty much anything you can think of, procedural, box mapping, sphere mapping, etc. See Texture Application

@Xoliul The Checker Texture does not use an "internal non-uniform box UV projection". It uses Generated coordinates which are normalized to going from 0 to 1 on each local axis. And other than image textures which are always 2-dimensional, procedural textures can be 1-, 2-, 3- and some even 4-dimensional. Maybe your definition of texture is limited to 2D bitmap images. A UV layout is always 2-dimensional, but the Checker Texture actually uses 3 dimensions.

Ah but that's an age-old CG discussion ;) I had to look on Wikipedia a bit, but even there it also does suggest that "procedural textures" do get passed along as 2D files before they get mapped onto a 3D surface: https://en.wikipedia.org/wiki/Texture_mapping
We can discuss it all day long, I guess it's just part of Blender doing things a tad different.

Your assumptions are wrong. UVs actually work pretty much the same in Blender as in most other 3d packages. If you delete a UV layer of an object it is gone and can no longer be used or edited. You can use other types of texture coordinates if there are no UVs on an object:

See the manual for more about them. Most procedural textures use Generated texture coordinates by default, because unlike UVs those are 3D coordinates.
You can actually see part of the coordinates as color(limited to ranges from 0 to wherever they are cut off by color management) if you just connect them to the Material Output

UV layers in Blender are what UV Channels are in Max, that's just a different name. You can even import and export them between Blender and other software.

Thanks! Seems like my confusion came from Checker Texture using a form of generated coordinates over explicit UV's.

@Xoliul Your confusion might come from thinking the generated coordinates the Checker Texture uses (which are the same generated coordinates all other procedural textures use) would have anything to do with any UV coordinates. But they haven't. It might only be that using some UV map layout results in the same or similar visual appearance as generated textures.

Yep. That is actually very useful when you work with procedural textures in Blender, because you can then manipulate a linear 3d coordinate system with math to deform procedural textures in 3d space in various ways.

Yes! Conclusion for me is: Other 3D applications most often clearly mean a 2D, bitmap file that exists in memory as such when they label something as "texture" (as is the case with the Checker in 3DS Max). In Blender this is not the case, and parametrically calculated and applied patterns are also labeled as textures. Only Blender's "Image Texture" would fit the definition I had in mind.

That's not really true. 3D textures exist in a lot of other software. They are a lot less commonly used just because of how widely used bitmap textures are. Volume or 3d textures is definitely a thing in most 3d packages. I am not extremely familiar with 3ds Max, but I would be surprised if that doesn't exist in it. I know for a fact, that Maya certainly has procedural 3d textures.

https://help.autodesk.com/view/3DSMAX/2024/ENU/?guid=GUID-0F4CC48B-8245-46C8-995D-43403C583EA3 You can clearly see that the term "texture" or "map" does not actually imply it being 2D. That's the confusion. Nothing to do with Blender being different in this case.


text:
Parametric primitives through python script
I'm trying to get into blender Scripting and am having a hard time finding examples or info on how one would create something like 3DS Max's Scripted Primitive; parametric objects that can be modified at any time after creation, not only until you perform another action, like standard blender object.
Main thing is I want to generate geonetry through code, not with blend shapes or by simply moving components around, and I want to be able to go back at any time and adjust this geometry.
Ideally there's an example script out there that does something similar, I'm experienced enough with Python to figure it out, it's just documentation is very lacking and I find info on google that is over 10 years old!

Welcome to Blender.SE. "Archimesh" add-on has this functionality and it's quite up-to date. You can start by looking its code.

Am I missing something? When I create an Archimesh cabinet, I can only modify the parameters right after it's created. Once I do anything else, it becomes unchangeable, just a collection of meshes with no more params.

Can you please add a link, or a short precise to describe  a 3ds max scripted primitive. Scripted SimpleObject plugin???  to get latest search results:  How to filter google search results by date

For the cabinet there is no option yet, but if you try with the door, the wall or the windows, you'll have objects driven by parameters (bottom of the properties panel).

I don't know if you're still searching for this but I found something that may be what you're looking for. It's an Add-On called "Wonder Mesh". The Add-On allows you to generate and edit the parameters of its available primitives. That being said, the author states that you need to convert the object to a "regular mesh" if you want to modify the primitive. It overwrites modifications to the Object Data that were made in Edit Mode.
Here is a direct link to the Add-On:
https://blendermarket.com/products/wonder-mesh
(You can purchase it here or go to the bottom of the page for the GitHub link)
Here is a video on the most recent version for Blender v2.8:
https://www.youtube.com/watch?v=zUFWcGAoDPw
Here is a video on a older version (in case it's useful):
https://www.youtube.com/watch?v=WCnwnwuDbfk

Hello and welcome, thanks for the answer. You should probably post links to where one can directly get said addon.

Thanks for letting me know. The links that I posted are to videos from the author of the add-on and the videos include the links to the download in the descriptions of them. I'll update my post and include the most recent link though.


text:
Draw 2D Shapes to bitmap using python GPU module
I want to create some dynamic helper bitmaps for my addon. I'me struggling a lot with just getting stuff drawn to bitmap using gpu module. I can get it working with numpy and directly manipulating the pixel arrays but that's not efficient at all, so i'd much rather get it working using gpu.
The following code only ever saves a pitch black image, I could really use some help to figure out my mistake, there's very little info about this...
import bpy
import gpu
from gpu_extras.batch import batch_for_shader
import numpy as np
import os

class SimpleDrawTestOperator(bpy.types.Operator):
    bl_idname = "object.simple_draw_test"
    bl_label = "Simple Draw Test"

    def execute(self, context):
        width, height = 512, 512  # Image dimensions
        background_color = (1.0, 0.0, 0.0, 1.0)  # Red background for visibility

        # Create an offscreen buffer for rendering
        offscreen = gpu.types.GPUOffScreen(width, height)

        # Bind the offscreen buffer for rendering
        with offscreen.bind():
            # Set the viewport to match the offscreen buffer size
            gpu.state.viewport_set(0, 0, width, height)

            # Clear the screen by drawing a full-screen quad with the background color
            self.clear_color_quad(background_color)

            # Save the rendered image to a file
            self.save_image(context, offscreen)

        offscreen.free()

        return {'FINISHED'}

    def clear_color_quad(self, color):
        # Shader and quad setup
        shader = gpu.shader.from_builtin('UNIFORM_COLOR')
        shader.bind()
        shader.uniform_float("color", color)

        # Define the vertices of a full-screen quad
        vertices = np.array([
            (-1.0, -1.0),  # Bottom left
            (1.0, -1.0),   # Bottom right
            (1.0, 1.0),    # Top right
            (-1.0, 1.0)    # Top left
        ], dtype=np.float32)

        # Batch to draw the quad
        batch = batch_for_shader(shader, 'TRI_FAN', {"pos": vertices})
        batch.draw(shader)

    def save_image(self, context, offscreen):
        # Read the pixels from the offscreen buffer
        buffer = gpu.state.active_framebuffer_get().read_color(0, 0, offscreen.width, offscreen.height, 4, 0, 'FLOAT')

        # Convert the buffer to a flattened list
        buffer = np.array(buffer).flatten()

        # Create an image and assign pixel values
        image = bpy.data.images.new("Rendered Image", width=offscreen.width, height=offscreen.height)
        image.pixels = buffer.tolist()

        # Get the file path to save the image
        if bpy.data.filepath:
            output_dir = os.path.dirname(bpy.data.filepath)
        else:
            output_dir = os.path.join(os.path.expanduser("~"), "Desktop")

        image_path = os.path.join(output_dir, "simple_test_output.png")

        # Save the image
        image.filepath_raw = image_path
        image.file_format = 'PNG'
        image.save()

        self.report({'INFO'}, f"Image saved to {image_path}")

# Register the operator
def register():
    bpy.utils.register_class(SimpleDrawTestOperator)

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

if __name__ == "__main__":
    register()
    bpy.ops.object.simple_draw_test()

It doesn't need to save to disk, but before i get to showing a dynamic bitmap in UI, I at least want to get the drawing to work somehow...


text:
Remove the smooth animation in Blender
Is there a way to disable smooth transition on key-frame animation in Blender?
Lets say I have a character modeled in Blender and now wish to animate it.
I want this character to have really bizarre spazz-like animation that doesn't seem realistic.
So I'd like this characters arm to 'teleport' between frames. From up to down and so on. Right now, the key-frame system forces the hand to transport visibly to the location.
This also would open doors for animated textures as changing image on object using AnimAll add-on.

You may try to set the interpolation type of the curves to Constant.

If you're looking for a manequin, bizzare looking movement try the Bounce effect.

Here's this dynamic effect applied to the head and a right hand of the model.

I also encourage you to test some other available types of interpolations, for the different (sometimes really amazing) movement types. Maybe one of them'll fit your needs.


text:
Cloth not rendering
I am working on a scene with a cloth modifier. When in preview mode, it shows the cloth the way I want it but when I render it, the texture is completely deformed and the cloth modifier does not appear to be applied in the render. I checked in the physics tab, but the little camera button is checked, same as in the outliner. How do I apply the cloth modifier correctly in the final render?

Solved. I had a cloth modifier, subdivision modifier and solidify modifier applied to the towel. The cloth should be the first in the list of modifiers, not the last. Speeds up calculation of cloth physics a lot as well.

This happens mainly when you put the Subdivision Modifier in the
Modifiers tab as default or not the same as your viewport subdivisions.
If that's the reason just put the render subdivision amount same as your viewport subdivision amount.


text:
Blender suddenly very slow
I was working on a simple project with a single model, a backdrop and lamps, and suddenly, Blender became really, really slow. I tried starting a new project, restarting the computer, even reinstalling Blender, but nothing seems to help. What could have happened and what can I do to resolve it?

I’m not sure but you may be having the same problem I and several other people have run up against in the last few days. I just uploaded my post Blender running at a crawl after NVidia update. Look it over and go to the Blender URL listed for more info. Sorry this is not a fix, but I have some tickets out and will update when I get some answers.

@Marijn Tulp,  Steve King has posted his solution here: http://blender.stackexchange.com/questions/73818/blender-running-at-a-crawl-after-nvidia-update ....

I am doing a Udemy Blender training and there they advised to do a forced update of display drivers. This appeared to be the cause of my problem, because since I rolled back the driver update, it works perfectly again.

I recently ran into the same problem.  I found this similar one Blender 2.78 with Windows 10 lags when interacting with the UI, which seems to indicate a problem with Windows 10, which I was running. But I found that the solution was to right click on the blender shortcut>Run with Graphics Processor>Integrated Graphics.  Mine immediately went back to running fast when I did this.


text:
Rig not aligned with the model
I created a character model and fully rigged it. I used the mirror modifier during modeling and the rig is (when in edit mode) exactly the same on both left and right. However, when I go to pose mode, the left hand is still rigged correctly, but the in the right hand, the rigs of the fingers are not aligned with the fingers anymore (see the image). Moving these bones cause the fingers to deform.
How can I fix this without having to re-rig the entire model?

[SOLVED] I fixed it. How it happened is unclear to me, but changes in Edit mode of the rig did not affect the model.

Changing the rig in edit mode shouldn't affect the model. That's expected behavior.


text:
Mesh becomes extremely wrinkled around the hips and shoulders
I have been trying to fully model, rig, and animate my own character with Blender.  So far, it's been going great.  However, I have come across an issue that has impeded my progress.  Whenever I lift up a leg or arm, it looks okay until I put on a multiresolution modifier.  My mesh becomes extremely wrinkled, and looks terrible.  My gut tells me that it's in my weight paint, although after repeated weight paint combinations, it has resulted in no solution.  Any help is appreciated!

Upload your modifier stack. Make sure the multires modifier is after the armature modifier.

Could you upload your .blend file on http://blend-exchange.giantcowfilms.com/ to be able to help you?

Moving the multires modifier below the armature modifier solved the issue.  :)


text:
Handle when material is dragged and dropped onto object
I need to handle some special steps for my material system, when a material is assigned.
I've followed this tip so far, and it works well if assigning through the properties UI. It does not work when dragging and dropping a material from the Asset browser, which i'd love to handle as well. Seems Blender has been dragging their feet to support this for 10 years, and I suspect my only chance to get this to work, is through a depsgraph update post handler?

Just some info for those ever looking:
-Track changes from depsgraph_update_post.
-Keep a global dict of obj - material pairs for the previous state
-if a change happens in an update, you have a list of changed objects
-because it's tricky to run code in the handler, I had to make an operator on a very short timer that forces context to window, and makes changes.
(ChatGPT was very helpful in figuring this out btw.. credit where it's due)


text:
How are appended assets from the Asset Browser handled, can i replicate this in python?
The Asset Browser does something special that I can't quite grasp:
If you drag a material from a library into the scene, on an object, it loads and appends it. If I modify this material (name, properties), and then try to drag that same, original material again from the Asset Browser, it does not create a new copy, but rather reuses and applies my modified version that is in the scene. I haven't tested it for non-material assets.
How does the Asset Browser check this? It's not name-based, it's not based on data comparing... Does it do some kind of uuid check, does the data block in Blender keep references to the library asset?
I'd love to replicate this behaviour when loading assets through code with Python!

Hello. You might want to read https://devtalk.blender.org/t/asset-linking-proposal/34127 which tackles this very subject and proposes alternatives. TLDR : it's not reliable and I don't think you can replicate the exact same behaviour in python.

Thanks, it makes sense, I had a feeling a lot on the asset browser is a special case, and not accessible through Python.