New answers tagged

1 vote
Accepted

Link (With Driver) a Custom Property Value to a newly generated piece of Text

Here's a proposal based on your explanation : Define a custom prop on bpy.types.Object. Add a callback to its update method, ...
Gorgious's user avatar
  • 30.3k
3 votes

Wait for compositor to finish before saving image to file - Python Scripting

You can check if the compositor is processing with bpy.app.is_job_running. You do have to delay your script a little bit because the compositor process doesn't start until your script finishes. You ...
Gorgious's user avatar
  • 30.3k
0 votes

Python print object volumes with the 3D-Print Toolbox

i used this from simplifying the existing code: ...
Patrick Samples's user avatar
3 votes

Python remove unlinked nodes in all materials scene

The code you posted will get the current active object and a material from that. So you could make it iterate over all materials in the blend like this. ...
Andreas Rånman's user avatar
0 votes

Filtering socket in custom node tree inputs

You need to override valid_socket_type(idname) of class TestTree(NodeTree) https://docs.blender.org/api/master/bpy.types....
iwHiteRabbiT's user avatar
0 votes

migrating a rigify script from 3.x to 4.x -- Bone Collections replaced layers

According to a reply to my bug report, I'm out of luck if I clean up by deleting the original rig and only kept the meta-rig, or if I used (in my cases) a DAZ importer add-on. On the original rig, ...
james_t's user avatar
  • 5,351
1 vote

Checking face visibility to a camera with dot product doesn't alway work in perspective view

The solution I found, in case of perspective view, is to calculate the dot product between the face normal and the vector given by the line connecting the center of the camera with the center of the ...
Luca Saiani's user avatar
2 votes
Accepted

Blender Docs Misleading? 'Invalid Keyword' Error with Inherited Properties

First, there is a difference between the class bpy.types.BoolProperty (docs) and the function bpy.props.BoolProperty (docs). ...
scurest's user avatar
  • 10.1k
0 votes

How do I run a script on multiple .blend files from the command line?

I put up together an Autohotkey script that does exactly that (requires Windows and Autohotkey v1 installed) https://github.com/Flowgun/BlenderBatcher
Nidhal Flowgun's user avatar
1 vote

why dont I see the objects in my scene, when using python

So, it turns out that the order of the command-line arguments to Blender matters. Putting bubbles5.blend after ...
Hugh Perkins's user avatar
1 vote
Accepted

How do you correctly add UI elements to adhere to the typing spec?

As pointed out by @Gorgious: Just a quirk of the API I think, I suggest to suppress the warning in the vs code settings. To answer the question, I don't think you can adhere to the spec and define ...
Harry McKenzie's user avatar
2 votes

Store Geometry Node attribute via Python in an evaluated object

If you want to add data on top (logically after; actually below, as seen in the Properties panel) of a modifier, you need to do it with another modifier, "dynamically". You can do so with ...
Markus von Broady's user avatar
0 votes

How to call Operator inside another Operator

Baking is basically rendering so it's tricky to call it from a script and carry on with another stuff after that, because rendering is... special. :D It's possible to do that using handlers and a ...
Martynas Žiemys's user avatar
2 votes

Move a vertex programmatically from Python

You don't need to switch to edit mode as you're directly modifying mesh data, with no use of bpy.ops. Instead ensure you're in object mode from the begining. I've ...
lemon's user avatar
  • 58.4k
1 vote

Problems with multiple calls of Geometry Nodes from a Python script?

After some research I finally found a similar problem here Evaluate a geometry node tree in python As we assumed, it is some update or evaluation issue. The given workoround also works for me, i.e. ...
Andy's user avatar
  • 191
0 votes

What is the correct way to add settings from the Bone Properties tab to a Sidebar Panel?

I just figured out the answer a few days ago. ...
Sonario648's user avatar
1 vote
Accepted

update callback for CollectionProperty item, propagate to other collection items

You could do something like this in your property group definition : ...
Gorgious's user avatar
  • 30.3k
2 votes

Bake Fluid Simulation via CLI or Python?

In Blender 4.0.2, I hunted around for a while. The bake function, from Brecht's answer above, complained about 1-2 args, and I didn't know how to solve that. Here's ...
Hugh Perkins's user avatar
0 votes

Erroneous .whl file naming when installing bpy

I realized that somehow my PATH was set to my Python 3.7 install first before my Python 3.11. I rebuilt the wheel using the correct path and it removed the suffix <...
porkchopsandwhiches's user avatar
1 vote

Replacing elements in the selected object's material name

Try this ...
scurest's user avatar
  • 10.1k
0 votes
Accepted

Can "Exclude from View" be kept disabled during an append? Can it be done with Python?

You'd have to add your own custom logic when appending with a python script, because the exclude state is not stored on the collection but on the view layer (as illustrated by your code snippet). If ...
Gorgious's user avatar
  • 30.3k
1 vote

Is there any way to create a boolean input to a ShaderNodeGroup in Blender 4.x using python?

In Blender 4.1 you can do bpy.data.node_groups['NodeGroup'].interface.new_socket( name='My Socket', in_out='INPUT', socket_type='NodeSocketBool', ) The ...
scurest's user avatar
  • 10.1k
0 votes

Is possible to execute an operator (OT) from code and SHOW its UNDO panel?

Yes, it's possible. To get this functionality you should add the 'UNDO' key word to your operator's 'bl_options'. In the Blender's text editor there are a plenty of templates. Check out the one ...
Yaroslav's user avatar
  • 537
4 votes
Accepted

Is there a way to create custom Node types or Nodes Categories using Python?

Blender analyzes a node tree by starting with the output and checking what is connected to it. For each connected node, it looks up the node's type, and reads from a mapping (hard-coded in Blender ...
Markus von Broady's user avatar
1 vote
Accepted

Is there a way to change the active texture in texture paint mode using Python?

The active texture in texture paint is given by: bpy.data.materials['Material'].paint_active_slot It is modifiable. And the active material for an object ...
lemon's user avatar
  • 58.4k
0 votes

detect orbit events via API

I have sort of solved it this way. I am not quite happy with that though, because the UI won't respond to anything until the user orbits the camera. So I'm still hoping for better answers! To test it ...
David Pagnon's user avatar
0 votes

Using python to get data from another blend file

I manage to do the work by adding some step Draw the storyboard, 1 blender scene per shot export data in a csv file from the storyboard file open an empty file the launch a script that use the csv ...
adrien's user avatar
  • 21
2 votes
Accepted

How to Convert Coordinate object from Coordinate Node into Mapping Node?

Here is the second part of your script: ...
Crantisz's user avatar
  • 35k
5 votes
Accepted

Is it possible to use a piecewise function in property drivers?

try ((1/2)-(1/sqrt(3))*cos(var-pi/6)) if var < (1/3*pi) else ((-1/2)+(1/sqrt(3))*sin(var)) it is a ternary conditional operator. it works like this: ...
Chris's user avatar
  • 57.4k
2 votes
Accepted

Transformation constraint to the same object

Thanks! For those who might be interested in the bpy code, something like that worked: ...
David Pagnon's user avatar
2 votes

How to unlock location and rotation of multiple objects at once?

Easy solution for you: Select all objects, unlock and select from context menu: "Copy all to selected" (for all X Y Z axis) "Copy single to selected" (For X, Y or Z specifically) ...
Crantisz's user avatar
  • 35k
0 votes

How to get the speed of a Camera with Python?

Just a follow-up to the awesome script by @Leander. I had to make a couple of tweaks to get it to work on the current version of Blender (4.0). Lines 23-27: ...
Mark Stead's user avatar
2 votes
Accepted

How do I use bpy.ops.constraint.childof_set_inverse() in blender 4.0?

you can try this code here: ...
Chris's user avatar
  • 57.4k
2 votes

How to show to the user a progression in a script?

Blender 4.0 now has a built-in progress bar. Usage: layout.progress(factor = 0.5) layout.progress(factor = 0.8, type = 'RING', text = "Updating") ...
Rooster's user avatar
  • 121
1 vote
Accepted

MAC: executable binary within addon zip loses execute permission when addon zip is installed on Blender

The reason for this issue can be found in scripts/startup/bl_operators/userpref.py. Addons provided as zip files are extracted using ...
p2or's user avatar
  • 15.8k
0 votes

How to create a script that sets Particle Boid brain rules in Blender 4.0?

To make it work, you'll have to change like this: ...
carlosedubarreto's user avatar
0 votes
Accepted

How to extrude vertices along a curve in consistent order?

Turns out the issue was related to memory corruption, because I was re-using the same Curve object over and over. I am not exactly sure why, but deleting the ...
Midas's user avatar
  • 125
1 vote

How can I convert a CURVE to a MESH object

Turns out there is an even simpler solution, if you copy the evaluated mesh, it will create a mesh datablock you can use for real. ...
Gorgious's user avatar
  • 30.3k
1 vote

How to check if two meshes intersect in python?

Here's an extremely fast method using BVHTree. ...
Gorgious's user avatar
  • 30.3k
0 votes

How do you delete Screens from the .blend file?

The solution is to go to the Outliner and choose the Data API sub-editor, then untwirl the Screens and search for and check Runtime Data checkbox for the screens that you want to delete. After this, ...
Nidhal Flowgun's user avatar
0 votes

How do I make bpy.ops.image.save_as() to use my 'Output' settings

If you want to save render result Settings will be the same as output properties. If you want to save generated image, it will be png by default until you will not save it in other format type. If ...
Crantisz's user avatar
  • 35k
1 vote

Transformation constraint to the same object

the first step would be to make it work in the GUI You can add a layer of indirection, and then it works fine. Start by making an empty at the location of the plane. Parent your plane to this empty. ...
Nathan's user avatar
  • 23.6k
0 votes

python script for multi-bone keyframe_insert

Here is my script thus far: ...
james_t's user avatar
  • 5,351
2 votes
Accepted

Step-by-step debugging in Blender UI

The docs state that you can force an update from your script. It is discouraged because it can lead to instabilities. Expect crashes. However I don't think it's a problem if you only use it in a ...
Gorgious's user avatar
  • 30.3k

Top 50 recent answers are included