Questions tagged [scripting]

Questions concerning scripting in Blender using the Python programming language. Also use this tag for questions about scripting in OSL (Open Shading Language).

Filter by
Sorted by
Tagged with
1
vote
1answer
18 views

Update Scene.statistics for verts, faces, tris count after modifiers

I've written a python batching function that runs though a list of OBJ files. It imports the OBJ, adds some modifiers, then saves. I want to know the statistics at the start and at the end. However, I ...
2
votes
1answer
24 views

Move the object to the center of the camera viewport

I'm new to Blender. I wrote a Python script where I sequentially read the camera poses from a csv file (real user traces), move the camera accordingly and render the scene. In my scene, there is a ...
0
votes
0answers
29 views

context.active_object vs context.scene.objects.active

Both context.active_object and context.scene.objects.active allow to get the active object in the scene. In most cases, they ...
0
votes
0answers
21 views

Combining low sample renders has more noise than one large render

I am trying to create a script, that would allow me to merge multiple images, rendered with different seeds and different sample amounts into one image with a higher sample amount. The script is using ...
0
votes
0answers
18 views

Copying vertex data in a blender script

I'm trying to make an add-on where the add-on copies the positions of the selected vertices and pastes it to another set of selected vertices to change their positions. I know how to access the ...
0
votes
1answer
32 views

Sculpting tool wont work for any object that I place

The starting object I can sculpt, all others I can’t, I don’t understand why. I have seen the thread where it explained that the clip end should not be set to infinite, and it even had a nice picture. ...
0
votes
0answers
21 views

Calculate rotation angle of each uv triangle

I try to create a javascript/python function that works like 'Preserve UVs' in 3DS Max. So the goal is to be able to modify the position of vertices without breaking/stretching/... the uv map. The uv ...
0
votes
1answer
9 views

Why FloatVectorProperty of subtype 'QUATERNION' is of type EULER?

The FloatVectorProperty gets subtype argument to change the data type of float vector. After setting this argument to subtype <...
2
votes
1answer
24 views

How do I add a custom UI Panel to image editor with Python?

I am trying to add a panel to the sidebar in the image editor. I used the template "UI Panel Simple" provided by Blender. The template works just fine if I leave it as is, but if I change &...
0
votes
0answers
32 views

Install "AnimAll" Addon with python

I'm running a python script outside of Blender GUI using the bpy module. For my code I need the "animAll" add-on from Blender, but I get an error when I try to enable it. It seems that ...
0
votes
0answers
26 views

Python, how to change F-Curve modifier toggles for all action groups/channels

How can we access those F-Curve toggles via python code? We did not found any info about those in documentation. We have already looked here and here. https://docs.blender.org/api/current/bpy.types....
0
votes
0answers
28 views

Combining 2 blender scripts and modify blender functions [closed]

i am working on a script with another programmer. We use it to read the pitch (or the frequencies) from an mp3 file to drive an animation with it. So far is our progress in 2 seperate Scripts: He is ...
1
vote
0answers
13 views

Python scripting: (3d print optimization) How to rotate face exact number of degrees in specified direction

I am experimenting with optimizing geometry for 3d printing. Premise is pretty simple: As additive manufacturing doesn’t work well with overhangs it’s usually suggested to have overhangs of no more ...
1
vote
2answers
31 views

Python Scripting: Assign existing geometry node group to newly generate object

I'm creating a number of objects in a loop, how can I assign an existing Geometry Node group to these created objects? I've tried to assign data.node_group.name the name of the group but that just ...
1
vote
1answer
30 views

Add Modifier options to a line of py [duplicate]

What is the syntax to add option/types to a modifier line of py. thanks
0
votes
1answer
25 views

Blender Python: Can't open Font on Windows

I have been troubles setting up my default font in my script. I have tried , bpy.ops.font.open(filepath="C:\\Windows\\Fonts\\comic.ttf"), but the result ...
0
votes
0answers
22 views

How can automate a specific process of importing, editing, and exporting scenes?

I have some pre-existing GLTF scenes (or objects) that I've been using Blender to modify and re-format so that I can export them as .FBX scenes that Unreal Engine 4 can import properly. While I've ...
2
votes
1answer
43 views

Run a script on Blender startup WITH PREFERENCES

Please read before marking as duplicate! [STORY] In short: I have a script that needs to run on Blender startup with AddonPreferences. I'm using app handlers to "tell" it to do stuff on ...
0
votes
1answer
26 views

Object Pointer Property in Adjust Last Operation panel gives weird results

I want to have an object field in the Adjust Last Operation panel: the object selected there would be used in several modifiers I add. However I noticed two things: if I use the Eyedropper to select ...
0
votes
0answers
22 views

Access the original Props for exporting OBJ files

I recently wrote a script for batch exporting OBJ files. The problem is that for every export option I had to create a Custom property to "feed" the bpy.ops.export_scene.obj() in order to ...
3
votes
1answer
29 views

How can I store and restore a 3D view per view layer?

I'm working on a construction scene with a number of view layers managing the different work contexts (different buildings, different floors, structural elements, plumbing, electricity, etc.). I'd ...
0
votes
1answer
29 views

Is there a way to python script the intersect boolean operation?

I have a mesh object that I would like to script an operation on. I know how how to do it manually, I just can't figure out how to script it. If you open the file attached, you should see the letter &...
2
votes
2answers
117 views

How to link data from a .blend relative to the current Blender version's addons

I'm trying to link certain data-blocks (node groups) from a .blend file stored in the addon folder of the current blender version. I want to be able to switch blender version and for all the links to ...
0
votes
0answers
22 views

Import into Blender the files mentioned in an excel list

is it possible to import into Blender the files mentioned in an excel list? For example the excel list could be saved in a folder called “resources”, and the same folder contains also different ...
0
votes
1answer
33 views

The module called msvcrt causes Blender crashing even if it does existing in Python list

My goal is to simplify and create my own version of screencast key addon and this is my baby-stepping. What I'm doing here is to display a key on the screen that user pressed. However, the module <...
0
votes
1answer
59 views

Is there a way to quickly assign vertex groups?

i have a plane with 1024 different faces on it. i am attempting to set each 1 of these faces to a different vertex group is there a way to do this via script?
0
votes
0answers
26 views

merge two or more materials with python

I have a scene with many objects and many materials. I'd like to create a script than substitute an existing material (let's call it "Mat2") with another existing material "Mat1", ...
0
votes
0answers
23 views

Add autorun script to rig

So I've seen that some rigs like the Cloud rig that it has a script that autoruns every time the blend file is opened. Also, when the rig is linked, the script comes with it. And since I have a rig ...
5
votes
2answers
374 views

Print Material Color of Active Object

I feel like I'm close on this one. I am trying to print the material color of the active object. Currently it is printing a value, but when I select a new active object, it prints the same value. I'm ...
0
votes
0answers
16 views

running ros2 node in blender python env

I'm trying to run a ROS2 node within blender. The node should render a frame and then publish it to a topic. I'm not sure how to import rclpy and cv_bridge to pyenv of blender. Anyone here done ...
0
votes
0answers
9 views

Alembic Cruves to work in animation

I have an anmination using hair, inported as alembic curves that isn't working in render. I know that there's some problems with this but is there any workarounds? I can manually go through the ...
0
votes
0answers
17 views

Unregister Add-On Class That's Registered Earlier

My requirement is to unregister a class before registering a new class with the same bl_idname. (As far as I understand bl_idname...
0
votes
1answer
24 views

Installing addon in 3.0 gives error [closed]

I can't install the Simply Cloth addon in blender 3.0 beta. It works fine in blender 2.9.3 but it gives me this error code and i don't reallly know how to fix it. The first time i try it gives me one ...
0
votes
1answer
21 views

How to get name(label) of the checkbox

As an example of a checkbox, I took Viewport Denoising (You can see it in the picture). I have a checkbox and I want to get its name(label) through a script. How to do it?
0
votes
1answer
13 views

Adjusting Freestyle Linestyle With Script

Been stuck on this for a few hours now and it's so frustrating because it seems so simple. I'm just trying to control the freestyle line set and line style settings in the View Layer Properties panel. ...
0
votes
0answers
27 views

StringProperty specific key operator

I'm making a StringProperty, and I want to make specific key(e.g. Enter-Key, or others) to do some operator. For example, if I type Enter-Key, the strings are changed by upper words. I found there is ...
0
votes
2answers
53 views

NoneType has no attribute "modifier" [duplicate]

...
1
vote
0answers
56 views

Update export plugin from 2.5 to 2.9 - animated mesh's vertex positions

I have an old export script that worked in Blender 2.5. Now I wanted to update it to 2.9. My export uses vertex based animation as the MD2 file format uses it, so I need the vertex per animation frame ...
1
vote
0answers
30 views

How to play a physics animation in a background python script?

I'm trying to run a simple physics simulation in my code. The problem is I need to run the script in the background. When I run the following code, I have no issues if Blender is open and I am running ...
6
votes
1answer
108 views

Adjust fall off custom curve of Vertex Weight Edit modifier using script

I'm writing a script to use with headless Blender but can't seem to figure out how to adjust the fall off curve of the Vertex Weight Edit modifier. Just want to move the upper point (1,1) down to ...
0
votes
0answers
14 views

Blender scripting selecting a collection [duplicate]

Hi i'm doing a simple plugin to speed up some common repedetive tasks I need to do in my workflow. Before running one of my scripts i would like to select a collection with one of these boxes and then ...
0
votes
1answer
20 views

Obtain distance of objects in a collection from camera (programmatically)

I'm new to Blender but not to programming. Can I obtain the distance of objects in a collections from the camera and maybe assign them to a list or a dictionary for further use? I looked at the docs ...
0
votes
0answers
28 views

Assigning multiple color to different faces of a polygon using polygon indices [duplicate]

I created a cuboid room in blender using Python which has 289 faces. I want to assign different color (RGB) values on different faces. For example, in the code below, the variables 'inner_polygon', '...
1
vote
0answers
128 views

Google colab wont render blender animations anymore. Always getting: Failed to create CUDA context (Unknown error) [closed]

Im using this notebook to try and render an animation using google colab. It was working fine a week ago but now i cant even render a single frame because it keeps giving me the error. Is there any ...
1
vote
2answers
55 views

How to find polygon number of a structure in blender? [duplicate]

I have created a cuboid room in blender using python and it has 289 faces as shown in the stats (in the image). How can I find which polygon number a particular face is ? For example, If I print the ...
0
votes
0answers
34 views

Any tips or documentations for improving blender python skills?

Recently, I set my goal to create my own screencast key for my python projects, but there's not much related instructions nor infos out there, like creating an ...
1
vote
0answers
18 views

Get operator pop-up current position

Is there any way to get the current position (x, y) of some active operator pop-up? I want to get the correct position even if for some reason I drag this pop-up from it invoke position (Meaning that ...
1
vote
1answer
69 views

How to create and access global variable which is defined on the preferences tab to another windows?

I'm working on a plugin modification which is a tool for exporting gltf. On the export windows, we have a choice to put "Copyright" & "Default Texture Location" parameters as ...
1
vote
1answer
45 views

Problems trying to use the builtin Spin tool from a Python script

I'm hoping someone can help me use the 3DView->Edit Mode builtin tool 'spin'. I've extruded a number of vertices and their edges to form a (closed) 2D face. The object is named called 'RocketNozzle'...
0
votes
0answers
38 views

Unexpected value in custom properties for a bone in pose mode?

From a Blender Python Console ...

1
2 3 4 5
103