New answers tagged

1 vote
Accepted

Activate addon not working

It turns out the blender field should be included in the bl_info dictionary. Otherwise, Blender will just ignore the script. the ...
BlenderEnthusiast's user avatar
1 vote

What is the simplest way to achieve viewport-like shading in python?

You can use the Workbench engine for that as it has simple to control lighting settings The Workbench engine does not use the lights of the scene. The lighting conditions that will be used can be set ...
taiyo's user avatar
  • 3,001
-1 votes

Delete all measurements with python

Warning, Potential AI generated content⚠️ This post is suspected to have been generated with the help of an artificial intelligence, chat bot, or other language model tools without proper attribution. ...
user2141040's user avatar
2 votes

How can I assign material colors to a color attribute?

Here's an example script. I'll assume you use V3.6+ Create a new color attribute Iterate over all materials and fetch their color Iterate over all polygons and fill out the correct colors into the ...
Gorgious's user avatar
  • 28.6k
1 vote

EXCEPTION_ACCESS_VIOLATION when running python in background mode and calling region_3d.update()

As @Iván found out in a similar post, there is a bug report which states that this is not considered a bug, quote: I don't consider this a bug. Calling an operator from background can be expected to ...
taiyo's user avatar
  • 3,001
0 votes

multiple template_preview flickering issue

I don't Have enough Reputation to leave a Comment, but I am experiencing the same issue and I believe this is a bug in Blender. I created a ticket here for anyone experiencing the same issue: Having ...
Diode II's user avatar
3 votes
Accepted

Why I need to run my script twice to get it to work?

The error does not pop up for the first time only, you can provoke it also when running the script multiple times. After running the script, move into the sphere (such that you are inside) and run the ...
taiyo's user avatar
  • 3,001
1 vote
Accepted

Get relative position to root

This: obj.pose.bones['Bone'].head gets bone position in object space (relative to object's root)
Crantisz's user avatar
  • 33.2k
3 votes
Accepted

Using python to set inputs on geometry nodes

I think you want to set values for modifier inputs and not the inputs of the node group. (for tooltips like that enable Python Tooltips in the Preferences, Interface tab, Display panel) So that would ...
Martynas Žiemys's user avatar
0 votes
Accepted

Addon doesn't work after restarting blender 3.3.1

The problem is that bpy.app.handlers.render_complete.append(render_complete_handler) will not persist, even when you create a new file. To remedy this issue, you ...
Harry McKenzie's user avatar
2 votes

Uv coordinates values seem to be placed on the wrong vertices

I have made the following experiment of changing the vertex indices of the plane, and you will notice that there is no obvious pattern to determine which vertex is used to map to which UV coordinate. ...
Harry McKenzie's user avatar
-1 votes

Using python to set inputs on geometry nodes

nodeGroup.inputs[3] this will give you the Input object which has multiple properties. Try to print it to explore more. Or try it in blender python console. What ...
Reigen's user avatar
  • 865
0 votes

Add custom property to panel

First, assign "foobar" to an object: obj["foobar"] = 3 then in a panel draw() function: ...
Willy Wonka's user avatar
2 votes

How can I convert a complex point cloud to mesh?

Use geometry nodes, I know that blender 4.0 comes with a points to curves node, from there you can convert those points to mesh, alternatively you can convert the points to volume and convert to mesh ...
Sooroojdeen's user avatar
0 votes

Inconsistent ORM Texture Atlas Automatic Baking Results in Blender ( 3.3.1 LTS)

"Gamma correction" is not a thing. This term is a symptom of someone not understanding what is going on with color management. "Incorrect gamma" most likely means it's a color ...
Martynas Žiemys's user avatar
1 vote

Scripting for loop adding attribute incorrectly

Thanks to @Ratt for the solution: Adding the following line of code to the for loop solved the issue: ...
aidan Barry's user avatar
0 votes

Rendering on GPU cluster

Blender can't saturate alone a beefy GPU, let alone 4. Try using only one GPU at a time. BTW I work with synthetic datasets (basically render as a map reduce process) and we use an approach kind of ...
Lucas Eduardo's user avatar
0 votes

How to close a popup dialog with a custom Close button using python?

here is a link to a similar question/original answer using just a popup instead of a dialog popup. it is still a workaround since I, and as it looks like others also have not found the proper way to ...
Ēriks Rasolovs's user avatar
0 votes

How to apply transformations to an object using the world matrix?

I hope it is not too late, but as far as I remember, matrix multiplication in python requires '@' instead of '*'. For me, this worked instantly
Alex's user avatar
  • 11
1 vote

Should I delete/comment all the asserts in my code when my addon is finished?

A different solution: turn it into a debug feature in your addon. In my addon convertRotationMode, I started development using prints everywhere to monitor how things went, and even though it ...
L0Lock's user avatar
  • 13.6k
6 votes
Accepted

Should I delete/comment all the asserts in my code when my addon is finished?

Assertions are a feature specifically designed to allow to easily disable the checks in the production code. You can do so by compiling your Python code to a .pyc ...
Markus von Broady's user avatar
1 vote
Accepted

Get the updated Index of a Face as if it had been separated from the main mesh with a group of other faces

Here is another script which relies more on Blender's built-in methods to retrieve the values. This version has the advantage to still run very fast with bigger meshes. For an object with 100000 faces ...
taiyo's user avatar
  • 3,001
0 votes

How to access Motion Paths found under Object properties through the script?

It seems your ultimate goal can be achieved with two drivers: First a simple driver to move the object along $x$ axis (though this could easily be achieved by 2 keyframes and a linear interpolation): ...
Markus von Broady's user avatar
3 votes

Get the updated Index of a Face as if it had been separated from the main mesh with a group of other faces

I checked with @markus-von-broady idea how the indexes are organized and it looks like he was right. My script attempt gets a face index as input. The vertices of this face are put into a list and it ...
Erdorano's user avatar
1 vote

Activate addon not working

If you execute the code you provided from the text editor, you get the error: ...
L0Lock's user avatar
  • 13.6k
1 vote

Channel or email to report a security bug?

Bur reports generally go to the official bug tracker, however as stated in the report page, security vulnerabilities should be reported privately. See the Blender Wiki about Security Vulnerabilities ...
Duarte Farrajota Ramos's user avatar
1 vote
Accepted

How to make an int array/list property?

CollectionProperty is what you need. First define your integer property class like so: ...
user3768771's user avatar
1 vote
Accepted

Python: Add Shape Key As Driver for Other Shape Key By String Reference

I had to rely on an existing answer, but modify it as the formatting wasn't working for me. ...
Josh G's user avatar
  • 76
0 votes
Accepted

How can I update the animation line of bone's transformation in UPBGE with python code?

X, Y, and Z location to set cube1.location = (0.0, 0.0, 0.0) Set the keyframe with that location, and which frame. cube1.keyframe_insert(data_path="location", frame=1) For example repeat ...
blendpro's user avatar
  • 101
0 votes

RNA warning on EnumProperty

No matter what the length of the dynamic list, This error occurs, when the index is not found in the list Example - ...
Mohit Saini's user avatar
2 votes
Accepted

Trying to use python API to output depth and normal images -- but no files are outputted

If you check your generated compositor setup, after moving nodes around, you'll see this: The normal and depth output nodes are not connected to the Render Layers ...
taiyo's user avatar
  • 3,001
1 vote
Accepted

Way to return all nodes in a Material

You could just make it a list: import bpy nodes = bpy.data.materials['Material'].node_tree.nodes print(list(nodes)) This would also work: ...
Martynas Žiemys's user avatar
0 votes

Way to return all nodes in a Material

The post you linked has a functional solution, but it isn't doing what you ask here. ...
L0Lock's user avatar
  • 13.6k
1 vote
Accepted

Python: How to merge objects in a grid with the objects in another grid

You could write some double loop starting from a corner and check which object falls into the current segment in space, but there is a shorter way by snapping the object's locations to the grid layout....
taiyo's user avatar
  • 3,001
2 votes

How to replace all material nodetrees on selected objects for random colors?

Try this script for your first problem: ...
taiyo's user avatar
  • 3,001
1 vote
Accepted

Python: Rename Armature's "root"

The green name is the name of the Armature, while the orange name is actually an object that represents the armature's transform. Since the Armature is thus named 'root', this is how you rename it: <...
Josh G's user avatar
  • 76
1 vote
Accepted

How to specify specific x and y FOV angles for a camera in Blender 3.6

Setting angle_x and angle_y directly to create a square camera does not work as you have experienced. Quoting you (emphasis mine)...
taiyo's user avatar
  • 3,001
0 votes

Is it possible to make my script toggle the console on?

improved solution: ...
The_Masked_Man 15's user avatar
0 votes

My UIList does not scroll down in version 3.3.6

In the col.template_list, I set the list_id parameter to "". In order for the scrollbar to work correctly, I needed to assign name to the list.
SJK's user avatar
  • 117
3 votes
Accepted

Expression for Additive Transform Noise

I don't know if there is a way to cache variables within a driver natively, but if not you can add a custom function to the driver namespace which handles that. Run this script to install the function ...
taiyo's user avatar
  • 3,001
3 votes
Accepted

Check if a Blender class has a property?

You can use this little function: ...
taiyo's user avatar
  • 3,001
4 votes
Accepted

Blender Python: How to test for "selectable" objects in viewport?

I've found a solution for my situation: ...
Christoph Werner's user avatar
3 votes

Blender Python: How to test for "selectable" objects in viewport?

You can query the Object Types Visibility dialog, for example for the MESH type: ...
taiyo's user avatar
  • 3,001
4 votes

Blender Python: How to test for "selectable" objects in viewport?

You can use the property hide_select to set an object's selectability: ...
Harry McKenzie's user avatar
1 vote
Accepted

How to get camera view bounds on 2D plane, not Viewport limits

Try this revised version of your script, have a look at the comments: ...
taiyo's user avatar
  • 3,001
3 votes
Accepted

msgbus for collection selection in outliner

The msgbus is quite limited, I don't think there is a solution using that, but you can use the depsgraph_update_post application ...
Harry McKenzie's user avatar
3 votes
Accepted

Proper GPUOffScreen projection matrix from viewport

You need to replace: ...
taiyo's user avatar
  • 3,001
1 vote

New camera angle is not rendered after set rotation_euler

As @Jag JB has mentioned, you have keyframes on the camera as you can see with the brownish color. It turns orange color temporarily when you change the value manually or change it via script, but it ...
Harry McKenzie's user avatar
0 votes
Accepted

How to calculate camera y-shift value to compensate when removing vertical perspective distortion

Using elements from @tetii's suggestion, this is what I ended up with that appears to work for my use case: ...
hz3d's user avatar
  • 41
0 votes

How to calculate camera y-shift value to compensate when removing vertical perspective distortion

This can be solved by using the following two things: There is a function that converts 3D coordinate values to coordinates on the camera's image plane. The camera coordinates are normalized by the ...
tetii's user avatar
  • 1,599

Top 50 recent answers are included