Skip to main content

New answers tagged

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.5k
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,068
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,684
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,068
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,886
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,312
1 vote
Accepted

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

...
Jakemoyo's user avatar
  • 5,312
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
2 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
  • 35.9k
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
  • 35.9k
0 votes

Batch simplify shader node

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

Script to rearrange vertices evenly

Here's some code I wrote, I've only tested it a little, but it seems like it works pretty good: ...
Dgc's user avatar
  • 353
3 votes

Determine if a Python file is running in Blender?

IS_RUNNING_IN_BLENDER: bool = not hasattr(__builtins__, 'print') Blender's __builtins__ dict doesn't contain ...
Liam Laverty's user avatar
0 votes

Load properties from scene in another blend file (without contents)

Go to File>Append then select the file you want the properties from. If appending the entire scene isn't appending missed objects such as lights or cameras, you can choose the camera/light folder ...
Dgc's user avatar
  • 353
3 votes
Accepted

Issue with building a version of Blender 4.1.1 (GooEngine)

The error messages indicate that Blender is attempting to load some add-ons (io_scene_fbx and io_scene_gltf2) but fails because ...
Dgc's user avatar
  • 353
0 votes

How to use event in Custom Property?

I don't think this is possible to do solely with the FloatProperty by itself. Events only get called by operators. This method just uses an operator assigned to either of the arrow buttons to ...
Jakemoyo's user avatar
  • 5,312
0 votes

Including external Python libraries in Blender addon

The site package folder should be in sys.path and created for each Python version like site.getusersitepackages. You can use ...
unwave's user avatar
  • 2,993
0 votes
Accepted

Server GPUs are not being detected by Blender Cycles CUDA?

Your code is not executing. I know this because it contains errors. For example, the last line should show this error: NameError: the name 'd' is undefined. ...
Crantisz's user avatar
  • 35.9k
5 votes

How to Print to Console When Hidden?

Instead of iterating over areas of current screen, you need to iterate over areas of all workspaces. However, one workspace can be instanced multiple times (screens), but it conveniently lists them ...
Markus von Broady's user avatar
1 vote

NumPy errors with compatable addons 4.1

Blender 4.1 is Python 3.11 and Blender 4.0 is Python 3.10...
unwave's user avatar
  • 2,993
3 votes

Python While Loop Not Working?

A driver is evaluated in Python, and once Python part finishes, the value is returned to Blender and Blender uses this value in the field of the driver and continues evaluating the scene. But you say ...
Markus von Broady's user avatar
2 votes

How can I determine direction of flipped UVs?

(Using Blender 3.6.12) Progress Report (NB: This answer is still under work, and it will most probably evolved with feedbacks). Objectives To find a diagnostic process identifying faces with flipped ...
StefLAncien's user avatar
  • 5,067
0 votes

Python: Create a Geometry Node set up to join multiple Objects

Final Code if anyone is interested in this kind of tool. The loop is from Markus von Broady in the other answer and some other ai script and copy-pasted code from a couple other pages: ...
Cornivius's user avatar
  • 1,886
1 vote

Python: Link Join Geometry node and Group Output

After messing with The missing line was nt.outputs.new('NodeSocketGeometry', 'Geometry'). I have also added the counter part for the Group Input node nt.inputs.new('NodeSocketGeometry', 'Geometry') so ...
Cornivius's user avatar
  • 1,886
1 vote

How to determine whether the FCurve array_index is targetting a specific property?

A function to check driver fcurve allows array_index > 0 ...
X Y's user avatar
  • 6,068
3 votes

Interface Panel not Updating correctly

Another way: Add to line 57: def __del__(self): bpy.context.area.tag_redraw() ...
X Y's user avatar
  • 6,068
3 votes
Accepted

Interface Panel not Updating correctly

This is a different approach ...
Karan's user avatar
  • 2,381
4 votes

Python: Create a Geometry Node set up to join multiple Objects

What you're looking for is a loop. A loop in programming allows you to repeat a given operation some number of times - here you want to repeat the operation of adding a node for each selected object: <...
Markus von Broady's user avatar
1 vote

How can I determine direction of flipped UVs?

Are you sure the problem is even with the UVs and not your normal map? The mesh looks messed up with the normal in your blend file, however when I download the image you posted and apply that it looks ...
Jakemoyo's user avatar
  • 5,312
1 vote

How to pause function call(back) for ie intproperty value setting, which has update function?

ok, solving that was quite simple, just did not clicked SOLVED make pause flags by enabling & disabling code execution ba_props.py - add boolproperty as flag <...
aum hren's user avatar
2 votes
Accepted

How to reload ONE particular UI script? (an alternative to 'Reload Scripts' )

...
unwave's user avatar
  • 2,993

Top 50 recent answers are included