New answers tagged python
0
votes
Add text information directly to the viewport for 5 sec
You can check if the operator is running and the handler has been added
...
1
vote
Accepted
AttributeError: 'NoneType' object has no attribute 'type'
This error is not coming from your script at all. It’s coming from the Power Sequencer addon, as stated in the source file location in the traceback. If your script is failing, it is either not ...
4
votes
Accepted
How to get not active object?
Selected objects are queried with bpy.context.selected_objects.
The active object is queried with bpy.context.active_object.
Thus you can query all selected, non active objects with something like <...
4
votes
Accepted
How can I run a function when opening Blender that requires context?
Add a Cube when registering Add-on
...
0
votes
How to recalculate pose bone rotations when armature bone rotation is changed?
I think i've fixed this. The pose bones rotation must be calculated like this:
...
3
votes
Accepted
How can I add a library override to a non-API custom property from a linked file with Python?
Change the value of non-api-defined library overridable custom property via Python
...
2
votes
Accepted
Addon works from Text Editor, but fails to enable from Add-ons preferences
When you run a script in a text editor, you can access bpy.data. in the register function at that time.
But in the add-on, when you open blender, the ...
3
votes
Accepted
How can I instantiate a Simulation Zone input / output node's socket via python?
You need to access state_items on the simulation output node:
...
2
votes
direction perpendicular to screen
You need to simply extrude in the direction of the camera, in geometry nodes it would look this way:
In Python the only tricky part is to calculate the position of the viewport camera:
...
1
vote
Python: Randomly selecting 1 object in a set
Notwithstanding the first part of your script which is irrelevant to your actual question, you can select a random item from a sequence with the standard random.choice function that comes with the ...
0
votes
Accepted
Props Dialog Width Issue
row.separator_spacer() makes it do that weird adjustment thing.
row.separator(factor=5.0) works good for what I needed.
...
3
votes
Correct way of using bpy.ops.import_mesh.stl bpy function?
Gorgious provided me with the solution in a comment beneath my question. The answer was to replace my function with a different operator, bpy.ops.wm.stl_import from ...
4
votes
bpy.app.timers.register is lagging Blender
After more research it appears that yes bpy.app.timers.register processes are running on the main Blender thread. So any data processing should be done outside the ...
3
votes
Accepted
KeyError: 'bpy_prop_collection[key]: key "View Layer" not found' when launching blender with external script
Notice that the error appears before it reads the blend file. That is because your command should specify the blend file first and then the python script argument like this:
...
2
votes
Is it possible to find the nodes connected to a node in python?
Hello from 2024.
Here's a non-recursive (as in the function doesn't call itself over and over. Nodes are retrieved recursively through a stack), customizeable variant. Works with the latest Blender (4....
1
vote
Accepted
How to get the path to an image that the user chooses
Run a function after user selects the filepath
...
1
vote
Accepted
create an object from scratch by using numpy
yes there is !
I've finally find a way to build all parts (even faces) with from_pydata!
more details here
...
1
vote
Accepted
Running modal seems to freeze if the mouse is not moving
Answered by comments: Without knowing too much about addon writing, it seems pretty evident to me from this function that it’s designed to run on some kind of GUI event (i.e. something happened with ...
2
votes
Accepted
Add text (label) to colored bar created using gpu module
Calculate text width and height using blf.dimensions
scale = 1.0
scale = 1.3
...
3
votes
Accepted
Control Blending Mode of the Color Mix node through the custom driver
You can use usual workflow: right-click a field and choose "Copy as a New Driver", and right-click another field and choose "Paste Driver". The value to be used is the index of the ...
0
votes
Python script to make all adjacent keyframes have constant interpolation
Here is a script I use in 3.6. Select all the objects and run it.
x is the interval between keyframes. Adjacent keyframes means x=1.
...
0
votes
Hard ops smart apply menu is missing
I just had to switch to Object Mode. Then the Operations > Smart Apply option is displayed.
2
votes
Accepted
Create big mathematical object directly from array data bypassing tolist
Finally,
this solution works for me:
...
3
votes
Accepted
Python code doesn't work on 'Collection'
I got it to work with @Gorgious comment. I just had to select the objects in the collection first and use the second line of code instead of the third:
...
1
vote
How to run custom script (via python) after use "delete object" or "rename object"
For my purposes, I'll use this for now:
...
1
vote
Get tags of appended asset browser object with python
It does not seem like it, per the Blender manual.
Append makes a full copy of the data into your blend-file, without keeping any reference to the original one. You can make further edits to your ...
1
vote
Accepted
0
votes
How to make rounded corners for 2d rectangle with a custom shader?
Though, this is not a custom shader, still might be useful to someone.
Calculating vertices is easy:
...
0
votes
Choose active tool in Python
In the Scripting workspace or in console you can run this:
import bpy
bpy.ops.wm.tool_set_by_id(name = <idname>, space_type="VIEW_3D")
Where ...
0
votes
TypeError: Element-wise multiplication: not supported between 'Matrix' and 'Vector'
If @ or * that doesn't solve it, make sure you have imported mathutils AFTER bpy in your python file.
thus:
import bpy
import mathutils
3
votes
Accepted
Automatic actions after starting addon?
Addons are first loaded in a restricted Context where no view_layer exists that's why you get thrown that error. Instead, you can execute your script within a ...
1
vote
Accepted
How do I get the output of the Join Strings node in python?
Right now only way to take string from geometry nodes evaluation process is to read name of geometry attributes. Exactly, with length limit.
1
vote
How to show to the user a progression in a script?
This is a complete example of updating a UI progress bar using multithreading :) by Blender 4.1
...
0
votes
How can I determine direction of flipped UVs?
So, after breaking down and doing it "manually" (flipping sections of UV islands) and being unable to avoid weird shading artifacts, I broke down and decided to completely redo the UV ...
2
votes
Trouble debugging this script (loop through non-manifold verts on one mesh and find index of closest edge on a different mesh) - any tips
Here is the corrected code for line 44:
location = v.co
This is because BMesh/BMVert does not use the location attribute. It uses co, which stands for coordinates.
1
vote
Extract code from Blender Shaders
What i was looking for was the input and output values for each node e.g.:
Node: Noise Texture.001
Type: TEX_NOISE
Input Vector is linked to Noise Texture.002
Input W has value 0.0
Input Scale has ...
0
votes
How to show only certain vertices in Geometry Nodes?
If you have identical geometry, you can transfer data from one to another using Sample nearest node:
Sample nearest finds nearest point at given geometry and returns index of this point, that you can ...
0
votes
How to show only certain vertices in Geometry Nodes?
Passing an array/string into Geometry Nodes is not possible, You should store data inside Attributes.
Here is an example how you can do this using Python:
...
0
votes
Top 50 recent answers are included
Related Tags
python × 13277scripting × 4815
add-on × 1202
game-engine × 665
animation × 646
interface × 627
mesh × 617
rendering × 481
objects × 442
operator × 429
properties × 421
materials × 392
node-editor × 382
bmesh × 312
modifiers × 279
transforms × 268
export × 261
vertices × 258
camera × 243
3d-view × 238
import × 233
drivers × 231
armature × 229
uv × 228
image × 223