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
0 votes
0 answers
6 views

I get AttributeError:'Mesh' object has no attribute 'subdiv_prop'

I have the below addon installed in Blender 3.3. I get AttributeError:'Mesh' object has no attribute 'subdiv_prop' on line 137 when I click the 'Project Image' button. How do I resolve this? ...
  • 93
0 votes
1 answer
9 views

Invoke function before closing script (Ctrl + C)

I'm running a local server using http.server like this: ...
  • 337
0 votes
0 answers
9 views

How to select the surface and import png image to it?

I want have the multiple png images that I want to apply them to a predefined 3d object template. This can easily be done by choosing the option shown in the image attached and then select the .png ...
0 votes
1 answer
11 views

Is there a way to batch change the text with script

So I have 10 txt objects, named 1-10 accordingly, is there a way to insert smth in the python console to change them from "txt" to these names that I have on the left part of the screenshot?
0 votes
0 answers
9 views

Why does my new n Pannel UI ALWAYS get called misc? [closed]

I've been following a few tutorials about creating custom UI's in python, and every time I create one, the UI pannel just gets named "misc". I've changed the bl_label and bl_catagory and it ...
0 votes
0 answers
13 views

My blender script crashes on running

I'm new to all of this and I tried creating a script that redo's certain actions on converting and editing a model in 1 click. It currently seems to just always crash near the end and I got no clue ...
0 votes
0 answers
18 views

how to display Modifier panel visible in N-panel?

I want to display the modifier panel in the Npanel, I have achieved the panel like this, but I cant't display the added modifiers: This is my code: ...
  • 1
0 votes
0 answers
12 views

Call Substance Sampler from Blender [closed]

Could it be possible to call Substance Sampler(SS) from Blender. From what I know , you can run python scripts in SS. The idea is: make a new panel in Blender press a button to import a photo of a ...
  • 1
0 votes
0 answers
10 views

How to get the session UUID of the collection in blender 3.3 to make_override_library() operator

I am a developer of a pipeline manager for a studio. When switching to blender version 3.3, it turned out that the bpy.ops.object.make_override_library() operator ...
0 votes
1 answer
12 views

Cannot create library override

I'm trying to create a library override after linking objects into my scene like this: ...
  • 337
0 votes
0 answers
12 views

Color space of GLSL shader

This is the color (1/255, 1/255, 1/255) of the built-in shader ...
  • 3,238
1 vote
1 answer
15 views

Use File Browser to select FOLDER not FILE

I'd like to use Blender to visualize several things that I have in a folder. I am visualizing a dataset which might contain a pointcloud, a 3D model, among others. I'd like to be able to select the ...
  • 113
0 votes
0 answers
11 views

How to move object across rendered image but do not change rotation from camera's view

I am trying to write a blender script that moves an object in across a rendered image. The object will appear to rotate, but is it possible to make the object appear the same even moving it across the ...
  • 1
2 votes
1 answer
42 views

How to keep the same zoom level?

How do I keep the same zoom level such that the image resolution is always the same? i.e. when I change the viewport size the zoom level should stay the same for example if this is my view: when I ...
  • 337
0 votes
0 answers
13 views

Render starts before script finishes

I am attempting to run a script in -background (headless) mode to generate an image from an addon. This script works in the GUI script window. When I run it with -b, I get no errors but the render ...
0 votes
0 answers
8 views

Wait for screen_full_area to complete

First I'm trying to make blender window go into maximised mode Then I'm trying to make the VIEW_3D area to go into Full screen Area and then make the camera fit ...
  • 337
0 votes
1 answer
11 views

Use data from selected object in python scripting

In this picture I have a cube selected and in the transform panel you can see the cube's data, such as location and rotation. Is there a way to use the data of this selected object, like the x-...
  • 56
0 votes
0 answers
10 views

Group objects using notepad file of objects to group

I want to group some of the objects in a large Blender file. I would like to list the objects to be grouped in a notepad file which is saved in the same location as the blender file. Example test case ...
0 votes
0 answers
10 views

Do something when an enumerator is changed

When I choose an option for one of my enumators in my script, I can tell from the "info" space that there is a command: bpy.context.scene.[name].[name of enumerator] = '[option]' I want to ...
  • 56
0 votes
0 answers
10 views

fullscreen after changing workspace

I'm trying to change my workspace then make the VIEW_3D in that workspace fullscreen, using this as a reference this is what I've come up with so far: ...
  • 337
0 votes
1 answer
9 views

How to change window size from script?

I'm trying to set my window to full screen/maximised mode How do I achieve this via script? I tried this answer but it's obviously for windows operating system whereas I'm using Ubuntu 22.04.1 LTS
  • 337
0 votes
1 answer
14 views

How to make camera fit viewport in fullscreen mode?

I'm trying to get my camera to fit the entire viewport (home button) in fullscreen mode and this is what I've come up with so far: ...
  • 337
1 vote
1 answer
28 views

Satellite rotation

I am trying to make the rotation of the satellite around the Earth. I'm obtaining the satellite's position in the orbit from TLE elements and getting the XYZ of it. So moving along the trajectory (...
  • 21
0 votes
0 answers
18 views

Keyframing a pose asset in Python

I want to apply and keyframe a pose asset. The first part of applying a pose was described in this answer. However, I am not sure how to keyframe the action. This is my code: ...
  • 51
0 votes
2 answers
22 views

Create Rotation Matrix With Given Vectors

I have a set of 3 vectors defined by vertices: Vector1 - (x0, y0, z0), (x1, y1, z1) Vector2 - (x0, y0, z0), (x2, y2, z2) Vector3 - (x0, y0, z0), (x3, y3, z3) I want to create a rotation matrix from ...
1 vote
1 answer
27 views

RuntimeError: Operator bpy.ops.object.convert.poll() failed, context is incorrect

I'm trying to use bpy.ops.object.convert(target='MESH') in Blender 3.3 to apply all modifiers. Unfortunately, I get the error in the title and I don't get what's ...
  • 11
0 votes
1 answer
4 views

Vector works in console but not defined when run from the text editor

I was trying to scale a bunch of objects with a script and I tried this line on the console : thing.scale= Vector((1, 1, 1)) It works fine and set the scale of the ...
0 votes
1 answer
28 views

(Blender 3.2) How can I use Python to change the variable ID of the property in a driver?

Been searching for an answer to this for quite some time, but haven't been able to connect the missing pieces just yet! My setup is this: I have an armature, and an FBX object of a face with animation ...
0 votes
1 answer
27 views

How to select and rotate object in blender 3.1 with bpy and python?

I'm trying to select and rotate an object in a frame_change_pre-handler. Here is the function: ...
  • 205
3 votes
2 answers
119 views

Join objects that share location

I am trying to make a script that works kind of the same as Merge by Distance but to be used in Object mode. Basically, what I am trying to do is join all the ...
1 vote
1 answer
32 views

Adding an Operator to the Context Menu of a UIList

How may I add an operator to the Context Menu of a UI List? Context menus seem to be defined per Spaces (e.g. NODE_MT_context_menu in the below code). Could this ...
1 vote
1 answer
52 views

Rotating a 4x4 matrix

There is a method rotate is mathutils.Matrix class with the signature rotate(other). The ...
0 votes
1 answer
14 views

Black after exporting asset previews as images

I want to export asset previews as images. I borrowed some codes from Blender 3.0: Is there a way to quickly create thumbnails for material and object assets? and this github page. I first created ...
  • 1
0 votes
1 answer
18 views

Is there any way to assign a shortcut to multiple commands that you need to repeat again and again? a script may be?

I am working on some objects, all of them needs same commands/functions. Can anyone help me with something that can execute those commands step by step with one shortcut.
0 votes
1 answer
15 views

How to invoke draw_handler_add while running script?

I have a draw_handler_add like this: ...
  • 337
0 votes
1 answer
47 views

poll() Missing 'window' in context

I'm trying to 'INVOKE_DEFAULT' using thread in the following code: ...
  • 337
0 votes
0 answers
53 views

Invalid Context for apply_pose_asset

I am trying to apply a pose asset to an object and keyframe it. To do this I followed the approach from this question. I adapted the code for the question's answer to use the newer ...
  • 51
2 votes
1 answer
60 views

Rename all selected NLA tracks with the name of the actions they are holding

Is there a way to automatically rename all existing NLA tracks with the name of the action that they are holding? Tried to find some scripts but only found the one to create an NLA with the name of ...
  • 573
1 vote
1 answer
19 views

Store the currently selected bones in a variable using python

I have an Armature ("Armature1") with a few bones in it ("Bone","Bone.001","Bone.002", "Bone.003"). I'm in pose mode and I have selected two bones. (&...
  • 59
0 votes
0 answers
5 views

Reselect objects from list that I stored in avariable

I'm very new to scripting in Blender. How do I reselect a list of objects that I have previously stored in a variable? ...
  • 59
1 vote
1 answer
20 views

cannot set pixels to buffer image, incorrect sequence item type: B

I'm trying to run the script: ...
  • 337
0 votes
0 answers
27 views

How to get 3D viewport from gpu buffer?

I'm trying to get the 3D viewport and save it as an image much like this answer and so far this is my progress: ...
  • 337
0 votes
1 answer
28 views

Create a next button inside panel

I was working with the addon but I have stuck at this situation. I want to press the Next button inside panel then, new operators should pop up and the rest ...
  • 224
0 votes
0 answers
11 views

How to post code snippets [migrated]

Stupid question I'm sure... How do I paste properly formatted code in stackExchange? Whenever I try and post code snippets it gets posted as regular text Many thanks
  • 59
0 votes
0 answers
22 views

What is the best method for storing a variable that's callable in the register() function?

Here is the workflow for an add-on I'm designing: User downloads, installs, and activates add-on. User sets a path variable in the add-on preferences section, here the StringProperty is labeled ...
4 votes
1 answer
98 views

Understanding (euler) rotation in animation with script

I'm trying to write a script that animates a rubik's cube. I want to rotate the left side by 90°, then the front by -90° Step 1. (rotate left side by 90°): Step 2. (rotate front side by -90°): I've ...
0 votes
1 answer
16 views

How to find constrain by type with Python

I just made a simple demo. A cube/a bezier line. I want to add bezier as the target of Clamp To constrain by python. ...
  • 930
0 votes
1 answer
21 views

Python code for Align selected to active

I have one object selected, and another object is active. What is the python code for Object>Transform>Align Selected to Active? (requires the addon Object: Align Tools that ships with Blender.) ...
  • 59
1 vote
1 answer
13 views

save image as RGBA using python?

I'm using save() and I want the save color to be RGBA but by default it's set to RGB I tried ImageFormatSetting.color_mode='RGBA'...
  • 337
0 votes
1 answer
35 views

How to force draw_handler_add?

I have a draw function inspired from this answer: ...
  • 337

1
2 3 4 5
113