New answers tagged

0 votes

Python function to extrude plane in edit mode

Here's another way to extrude a face for 1000 extrude: ops method: 2 second my method: 0.006 second ...
user avatar
  • 2,201
0 votes

Python script creates Panel/Buttons in scripting workspace using the play button, but not when installed as add-on

Thanks to the kind folk over at blenderartists.org, I was able to get a resolution, there are multiple fields in bl_info that need to be filled out. The example provided for me was ...
user avatar
1 vote

asyncio serial inside blender

Here is the code. The problem in the first code is that I was calling close() just after creating the lop, so the timer couldn't made the loop advance. It's very obvius now... Here is the working code:...
user avatar
4 votes
Accepted

How to make it so that an EnumProperty is not animatable

TLDR; Add options=set() as a parameter when defining the EnumProperty to avoid passing the default {'ANIMATABLE'} value. ...
user avatar
  • 30.1k
0 votes

Python script creates Panel/Buttons in scripting workspace using the play button, but not when installed as add-on

Your panel class needs bl_category so that Blender will know which tab to add it to in the side panel. I tend to put mine in their own tab and use ...
user avatar
  • 30.1k
0 votes

asyncio serial inside blender

Well I solved it. For anyone interested, here is the repo with the sample code: https://github.com/RaulHuertas/BlenderSerialAsync See you!
user avatar
2 votes
Accepted

how to keyframe "animated" of rigid bodies to multiple objects

Instead of animating the balls at the beginning, parent them all to an empty then animate the empty only. For the balls, you only need to create an action that will be the Animated option on and off: ...
user avatar
  • 107k
0 votes

How do I append a text in a blend file from within an addon?

Just put your .blend file and this code in a folder, name the code 'init.py' and zip the folder. You need to rename some stuff on the script accordingly to your file. ...
user avatar
0 votes
Accepted

Get an object from unique identifier(memory location, id etc)

As far as I know, the most popular way to identify the object is using custom props. The workflow is: Register prop in add-on registration: ...
user avatar
  • 25.7k
2 votes

How to change the target object of a "COPY_LOCATION" constraint using Python

This script will check if any selected objects have a constraint of type Copy Location.If the constraint is found, their target attribute is set to a stated scene ...
user avatar
  • 1,082
3 votes
Accepted

How to change the target object of a "COPY_LOCATION" constraint using Python

There are two parts to this. First you need to create or set the constraints. Second you need to do the keyframing. Part 1: How to create and set constraints You need to locate the object, find (or ...
user avatar
  • 30.1k
0 votes
Accepted

How do I append a text in a blend file from within an addon?

I figured it out. Turns out my idea was right, but I couldn't do both scripts in one snippet. I also compressed it into a single button that does it all in order. ...
user avatar
1 vote

Rotation of an object around its local axis

This argument is optional ; but if you really want to deal with linear transformation matrices, you have to understand how it works. You could use matrices in order ...
user avatar
  • 306
1 vote

How to get the class type of a Blender Collection Property?

Another solution which doesn't rely on knowing the collection items' type beforehand. Get the property special dictionary construct by accessing the holder's (bpy_struct.id_data) custom properties (...
user avatar
  • 25.5k
0 votes

Geometry Node that put objects from collection in line?

You cannot make Geometry Node on Python. Geometry nodes are written on C++ and you can't mix Custom Python nodes and Geometry Nodes. But you can build this setup using existing Geometry Nodes: It ...
user avatar
  • 25.7k
1 vote

Read output of a Python subprocess

I have a very similar issue. A workaround for me is to append to a text file in the subprocess, and then read from that in the main loop. This most likely has large drawbacks, but it is functional.
user avatar
0 votes

Button dissapear when my addon was used 1 time

You need to set up your script like this: ...
user avatar
  • 2,464
1 vote
Accepted

Passing an arbitrary sized matrix as a property of an operator

I think I found a way, it is a bit awkward, but it works ¯_(ツ)_/¯ ...
user avatar
  • 2,464
2 votes

How to save User Preferences With Python without using bpy.ops.wm.save_userpref()?

Blender does not export a low level interface to the preferences file, nor is the format of the file documented. The interface is documented under Preference Operators and the contents, but not ...
user avatar
  • 30.1k
2 votes

How do I make this chunk separation algorithm I've been working on?

I can't tell all of what is going on with your code, there seems to be missing sections. Also you didn't post the error code so I can't really tell exactly how to fix your one specific problem. Your ...
user avatar
  • 2,464
0 votes

How to script the Rolling Shutter?

You can find the documentation here. To access the property use: bpy.context.scene.cycles.rolling_shutter_type = 'TOP' For some reason it doesn't update ...
user avatar
3 votes
Accepted

Why Does Normalize Function Overwrite the Original Variable?

A variable is a name that refers to an object. When you do x = y, you make x and y refer to the same object. So if you change that object, both x and y will observe ...
user avatar
  • 7,097
1 vote
Accepted

How to create single vertex using given coordinate?

Activate the addon Add Mesh: Extra Objects from Edit -> Preferences -> Add-Ons. Then you can add a Single Vert from the Add menu.
user avatar
1 vote

How mathutils.Vector.angle() use?

The output is not None. It is 0.6533257961273193. Try again use this code: ...
user avatar
2 votes
Accepted

How to Do Exponential Step Iteration in bpy.props.IntProperty()?

Yes it is possible. I made a sample panel with an increment/decrement stepper component that increments values of within power of 2. Apologies for the global variable hack. Anyone feel free to edit ...
user avatar
1 vote

Bpy get the name of a collection of object

There is no collection member in bpy.types.Object instead you need to search the collection for the object: ...
user avatar
  • 30.1k
1 vote

bpy scripting: Join objects in a collection

You have to make sure you have selected all the objects you want to join using obj.select_set(True) in the for loop and make sure one of the objects is active (...
user avatar
0 votes

Batch export with empty name

You can iterate over each object in bpy.data.objects and check if the type is EMPTY. You can then get the child object and ...
user avatar
1 vote

How can I create the holes in a sphere, "cone shaped"?

Yes, I know that wasn't asked, but I just love Geometry Nodes :D An Ico-Sphere is a good starting point here. The node Dual Mesh converts points into faces (and ...
user avatar
  • 10.7k
0 votes

Installing blender in ubuntu libopenimageio2.1 problem

I fixed it by recursively installing the sudo apt install libopenimageio2.1 and the all it's dependent packages
user avatar
  • 253
1 vote
Accepted

Find intersection between a line and a circle

It's a little difficult to know exactly what's going on with your set-up, but I tried to replicate it with a bezierCircle curve with a nurbs path bevel object for 2D thickness and a single vertex from ...
user avatar
  • 359
2 votes
Accepted

How to prevent depsgraph update triggers

Add-on developers are not able to stop updates to the dependency graph. The Python API only provides the ability to trigger updates, not to stop them. Internally, developers call functions such as <...
user avatar
  • 23.9k
1 vote
Accepted

Bpy: Add a modifier to every object in the scene that doesn't yet have one

Here you're looping over EXISTING modifiers and checking if they are of the correct type. You can make use of the barely used for ... else idiom to do what you're ...
user avatar
  • 25.5k
1 vote
Accepted

Bpy Set all objects to shade smooth

You can use this code to make it work: ...
user avatar
1 vote
Accepted

Python UI bool to hide or show UI elements?

The solution is, as usual, much simpler than I'd originally assumed. I have discovered in this question that 'if' functions work in layout! ...
user avatar
2 votes
Accepted

Blender doesn't recognize --python as a command line argument

When you run a Python script, sys.argv will be all arguments passed to Blender. That means if you call a Python functions that expects to "own" all of ...
user avatar
  • 7,097
1 vote
Accepted

Bpy check if each object is parented

If an object is parented, then its parent member will refer to the parent object. Otherwise, parent will be empty (...
user avatar
  • 30.1k
0 votes

Changing viewport shading with python

context did not work for me. Check this out if you are facing the same issue. Blender 2.8 : python code to switch shading mode (between wireframe and solid mode)
user avatar
  • 111
0 votes

How can I switch the shading mode between wireframe and solid mode?

The previous answers did not work for me. I found out while working on Goo package, the codes below always point to "Scripting" screen and do not list all screens such as Layout, Modeling.....
user avatar
  • 111
0 votes

How to solve the -- Module named mymodule not found -- once and for all?

If you have something like: myAddon ├── __init__.py ├── useful_utilts.py └── app └── folder └── some_file.py And you want to use a class ...
user avatar
  • 25.7k
3 votes

Simple Python script to be able to change the number of samples in a Blender startup script

.\blender -P 100_samples.py cube_animation.blend first runs the script, then opens the .blend file. ...
user avatar
  • 7,097
0 votes

Using data from dialog box to create image strip with Python script

This answer explains in general how to use a dialog box. In it, there is an execute function: ...
user avatar
  • 30.1k
1 vote

Built-In Python Templates to Blender 3.2

The ImportHelper class is not well documented, so I wrote this example to help explain it: ...
user avatar
  • 30.1k
0 votes

When you're running a modal operator, how to you know when the user has clicked on a button displayed in the 3dviewport?

Your modal handler needs to return {'PASS_THROUGH'} for any event it doesn't handle. Here's an example modal event handler that does that: ...
user avatar
  • 30.1k
1 vote

Unselect hidden mesh after unhide

Uncheck Select in your Keymap preferences. It'll work for Object Mode, Edit Mode and much more.
user avatar
2 votes

How can I remove all uv layers but the last one and rename it on multiple objects?

Another method which worked for me because the other method didn't. ...
user avatar
  • 25.5k
0 votes

How can I determine the origin of a property change in a blender panel?

Ended up solving this but thank you for the responses! I created a wrapper function, though a lambda function would have worked as well (I've used that previously elsewhere and should have done that ...
user avatar
  • 41
1 vote

Keymaps added with python don't work in addon `__init__.py`

Okay I guess I figured it out, I was accidentally using a new reference to the wm.addon_keyconfig each loop rather than at the start of the register_keymaps function. ...
user avatar
  • 2,464
1 vote

How to create a permanent timer?

Re-register a timer when open a new file ...
user avatar
  • 2,201
1 vote
Accepted

Align 3D cursor to face in python

Change 3D cursor Rotation ...
user avatar
  • 2,201

Top 50 recent answers are included