Skip to main content

New answers tagged

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 ...
X Y's user avatar
  • 6,213
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 ...
TheLabCat's user avatar
  • 6,731
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 <...
Gorgious's user avatar
  • 31.6k
4 votes
Accepted

How can I run a function when opening Blender that requires context?

Add a Cube when registering Add-on ...
X Y's user avatar
  • 6,213
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: ...
taptaptaptap's user avatar
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 ...
X Y's user avatar
  • 6,213
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 ...
X Y's user avatar
  • 6,213
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: ...
Markus von Broady's user avatar
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: ...
Markus von Broady's user avatar
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 ...
Gorgious's user avatar
  • 31.6k
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. ...
Lukas Sneyd's user avatar
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 ...
Syl's user avatar
  • 51
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 ...
David B's user avatar
  • 423
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: ...
Harry McKenzie's user avatar
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....
Mr.Kleiner's user avatar
1 vote
Accepted

How to get the path to an image that the user chooses

Run a function after user selects the filepath ...
X Y's user avatar
  • 6,213
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 ...
Certes's user avatar
  • 61
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 ...
TheLabCat's user avatar
  • 6,731
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 ...
X Y's user avatar
  • 6,213
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 ...
Markus von Broady's user avatar
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. ...
rint's user avatar
  • 113
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.
Nra's user avatar
  • 1
2 votes
Accepted

Create big mathematical object directly from array data bypassing tolist

Finally, this solution works for me: ...
Certes's user avatar
  • 61
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: ...
Cornivius's user avatar
  • 1,896
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: ...
Vincent Decc's user avatar
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 ...
Jakemoyo's user avatar
  • 5,587
1 vote
Accepted

How to run custom script (via python) after use "delete object" or "rename object"

...
Jakemoyo's user avatar
  • 5,587
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: ...
Vanuan's user avatar
  • 101
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 ...
Vanuan's user avatar
  • 101
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
Jovany González's user avatar
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 ...
Harry McKenzie's user avatar
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.
mod nop's user avatar
  • 431
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 ...
ShaderFallback's user avatar
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 ...
Digital_Utopia's user avatar
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.
Dgc's user avatar
  • 353
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 ...
Martin's user avatar
  • 11
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 ...
Crantisz's user avatar
  • 36.1k
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: ...
Crantisz's user avatar
  • 36.1k
0 votes

Batch simplify shader node

try with this, works in blender 4.0 ...
Arturo's user avatar
  • 1

Top 50 recent answers are included