New answers tagged python
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 ...
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 ...
-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.
...
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 ...
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 ...
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 ...
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 ...
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)
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 ...
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 ...
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. ...
-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 ...
0
votes
Add custom property to panel
First, assign "foobar" to an object:
obj["foobar"] = 3
then in a panel draw() function:
...
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 ...
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 ...
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:
...
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 ...
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 ...
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
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 ...
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 ...
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 ...
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):
...
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 ...
1
vote
Activate addon not working
If you execute the code you provided from the text editor, you get the error:
...
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
...
1
vote
Accepted
How to make an int array/list property?
CollectionProperty is what you need. First define your integer property class like so:
...
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.
...
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 ...
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 -
...
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 ...
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:
...
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.
...
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....
2
votes
How to replace all material nodetrees on selected objects for random colors?
Try this script for your first problem:
...
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:
<...
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)...
0
votes
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.
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 ...
3
votes
Accepted
4
votes
Accepted
Blender Python: How to test for "selectable" objects in viewport?
I've found a solution for my situation:
...
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:
...
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:
...
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:
...
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 ...
3
votes
Accepted
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 ...
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:
...
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 ...
Top 50 recent answers are included
Related Tags
python × 12627scripting × 4614
add-on × 1129
game-engine × 659
animation × 611
mesh × 608
interface × 587
rendering × 465
objects × 419
properties × 397
operator × 385
materials × 374
node-editor × 373
bmesh × 297
modifiers × 257
transforms × 257
export × 249
vertices × 240
camera × 229
armature × 225
uv × 222
3d-view × 218
drivers × 218
import × 217
bones × 213