Questions tagged [python]

Python is an object-oriented programming language. In Blender, it is used as a general purpose scripting language and to create add-ons to extend Blender's functionality.

Filter by
Sorted by
Tagged with
13 votes
4 answers
5k views

How to keyframe mesh vertices in Python

I'm updating all the vertex coordinates of a mesh frame-by-frame in python and need to animate but can not figure out how. Here is a small abstracted script - the python isn't pretty, but it makes an ...
uhoh's user avatar
  • 2,667
11 votes
3 answers
7k views

Object selection box in addon

In my addon panel, how can I have an object selection box? And what data type would I use to store the the selected object? It should look like this:
Garrett's user avatar
  • 6,556
25 votes
7 answers
33k views

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

I'm making an python script which create a lot of object and this could take a lot of time. My question is how to show to the user of my script, the "progression" of the script? For now I print an ...
lucblender's user avatar
  • 3,323
19 votes
1 answer
10k views

Controling compositor by python

I've been looking at the python code loging of Blender. But in there things get loged as mouse clicks. What i like to do is combine a few images into a larger one using compositor, but i need control ...
user613326's user avatar
16 votes
2 answers
1k views

What's the most reliable way of converting a material into reusable code blocks?

I'd like to convert certain materials into executable python code without having to re-code them from scratch each time. While doing some initial experimentation on the principled shader, I realized ...
brockmann's user avatar
  • 12.3k
13 votes
1 answer
16k views

Get/Set coordinates for UV vertices using Python

I got this UV map, and I want to set the position coordinates for all the four vertices to x=0.5 and y=0.5 (in the center of the ...
Nils Söderman's user avatar
13 votes
1 answer
8k views

How to handle creating a node group in a script?

I am attempting to make a python script that creates a nodegroup based on some scene properties, however the group_make operator needs to be in a node editor ...
gandalf3's user avatar
  • 156k
13 votes
1 answer
5k views

Bake Fluid Simulation via CLI or Python?

I would like to run a fluid simulation on a headless Ubuntu machine I have lying around. I did manage to find a bug report on the issue but to no avail. Has anyone else had any success? Or perhaps a ...
Robberbob's user avatar
  • 133
12 votes
1 answer
9k views

Dynamic EnumProperty by type of selection

Iam searching for a method to get a EnumProperty by the type of the object (Lamp, Geo, Camera) thats selected in the viewport. E.g. If the selected object is a lamp, it would be nice the enum ...
p2or's user avatar
  • 15.5k
11 votes
2 answers
7k views

How do I override context for bpy.ops.mesh.loopcut?

I am trying to use loopcut in a python script in Blender 2.71. I have tried using the following code from "Loop cut and slide using python script in blender": ...
Mike N.'s user avatar
  • 350
10 votes
1 answer
4k views

Auto-run scripts security options

We have a preferences option to enable auto-run of python scripts when opening blend files. We can also add paths that are excluded from auto-running scripts. Then we have a cli options to enable or ...
sambler's user avatar
  • 55.1k
8 votes
1 answer
4k views

How do you remove a draw handler after it's been added?

I'm making an attempt to use batFINGER's method from this answer for drawing some text on screen without a modal operator, but I'm finding I can't get the text to go away once it's been drawn. ...
andyV's user avatar
  • 623
7 votes
4 answers
6k views

Python: vertex normal according to World

If i get a normal of a vertex - i'll get it in local coordinates. For example: bpy.context.object.data.vertices[0].normal If an object will have rotation or ...
mifth's user avatar
  • 2,331
5 votes
2 answers
3k views

Object creation slows over time [duplicate]

I know that this has been asked before, but the answers that others have received did not help me much. When creating objects through Python, using bpy.ops.mesh.primitive_cube_add() there is an ...
doomslug's user avatar
  • 1,799
4 votes
1 answer
628 views

Copy existing property from e.g. Properties window to a custom panel

So if I have this custom panel in the 3D view, is there a way I can take a property from for example the properties window and paste it onto my panel below the "text" prop, without creating a new ...
Nils Söderman's user avatar
4 votes
2 answers
2k views

Handler frame_change_pre doesn't work in render

this works in viewport but not in render. ...
user3202179's user avatar
2 votes
2 answers
384 views

Same Video on each face, but with different time delay?

iam looking for a way to - like the title says - i want to put the same video on each face, but with different time delay. In other words, i want to create a kind of videowall. i found THIS: ...
froggyman's user avatar
  • 493
2 votes
1 answer
2k views

Create curve from Numpy Array using Python

I have looked through previous questions on this and many other boards and I cannot seem to find a previous answer. I have a largish Numpy generated ndarray that represents a harmonograph output (...
Terela02's user avatar
36 votes
2 answers
32k views

How to get the directory of open blend file? (from Python)

What's the best way to get the full directory of the current Blender file in Python? It should be cross-platform.
Garrett's user avatar
  • 6,556
30 votes
2 answers
60k views

How can I get vertex positions from a mesh?

I want to read the vertex x and y coordinates with a script or a function. How can I do that? The MeshVertex appears to have ...
B Newmark's user avatar
  • 1,240
23 votes
4 answers
26k views

Add Nodes to Material with Python

I have edited a script that creates some nodes, but the only problem is, it always created a new material. I want it to either add the nodes on the existing material, or a pre-defined material. Here ...
rioforce's user avatar
  • 2,032
18 votes
6 answers
18k views

Python - Set material to material slot

I am using the Blender Internal render engine. I have an material slot with no material assigned to it. How can I assign a material to a slot using python? This should work in edit mode as well. ...
Vader's user avatar
  • 14.6k
18 votes
6 answers
19k views

Rotate objects around their origin along a global axis (scripted) without bpy.ops

I have read so much about Blender rotation in the last two hours that my head is spinning, but I can not understand how to rotate strictly in global coordinates without using ...
uhoh's user avatar
  • 2,667
18 votes
2 answers
34k views

create mesh then add vertices to it in python

I would like to create a mesh, then interactively add vertices (afterwards, possibly through a loop) to it through python. Is that possible? I can't find enough info from other answers to really get ...
Jono's user avatar
  • 183
17 votes
3 answers
20k views

How can I get the camera's projection matrix?

As asked. I need a way to get the projection matrix of the active camera, via python. EDIT: I think this question is different from the one asked here, because getting a matrix is different from ...
Goran Milovanovic's user avatar
16 votes
4 answers
5k views

Workflow for developing add-on/script

I'm trying to figure out a good workflow for developing scripts and add-ons in Blender. Here's what I'm currently doing as I try my luck with a PyNode add-on: Open blender Create a text editor panel ...
ajwood's user avatar
  • 10k
16 votes
3 answers
14k views

Is it possible to use bpy.props.PointerProperty to store a pointer to an object?

If the user renames an object, the reference via string key is lost. Is it possible to store a pointer to an object in a property assigned to a class of bpy.types ...
pink vertex's user avatar
  • 9,836
10 votes
4 answers
3k views

How can I sort vertex positions sequentially indices in a closed area?

I need to sort the vertices sequentially to make an effect, something like this video. I know I should draw them by hand, but sometimes when I subdivide edges, vertex indexes will change. The vertices ...
Seyed Morteza Kamali's user avatar
8 votes
6 answers
2k views

How to create a Tetrix/Sierpinski Tetrahedron fractal radiating from 0,0,0 ? Python or nodes

Animation nodes method true to description has been provided by @lemon, Vote his answer UP UP UP! INFERIOR INFERIOR INFERIOR / different concept Mesh. I want to create it not by dissection of ...
t8ja's user avatar
  • 465
7 votes
3 answers
18k views

How to view python error messages? [duplicate]

I'm following a tutorial and I can´t go forward and finish the tutorial. My problem is that when i click on run script it gives me a problem saying "Python script fail, look in the console for now..." ...
Mr.BubleWay's user avatar
7 votes
2 answers
3k views

How can i add a text help window and a help button into the 3D View?

I have seen in a video form cgcookies that they added a Help button and a Help text box right into the 3D View. How can this be achieved within an Addon?
Gaia Clary's user avatar
  • 3,712
6 votes
3 answers
3k views

bpy/file browser: get selected file names

Is there a way in bpy to get a list of all selected files from the file browser? I have this code, but it is only for the active file selection: ...
MakerDrone's user avatar
5 votes
2 answers
7k views

Csv Import pointcloud into Blender

I have 24 points which correspond to 12 different "elements" (2 points per element) saved in an .csv file with the following column order (1: Element Name, 2: x, 3: y, 4: z). I would like to import ...
digit's user avatar
  • 657
5 votes
2 answers
5k views

How to get an event when an object is selected?

I've tried to find a way to do this using handlers and events, etc. Essentially I need to know when an object is selected. This isn't a click event, or another action based on user input, but instead ...
Sam Vimes's user avatar
  • 231
4 votes
2 answers
3k views

Fast keyframe insertion

I noticed that every time I insert a new keyframe on an object using the Python API, the insertion takes more time. Here are some timings of a keyframe insertion: 1st keyframe: 0.0176 ms 10000th ...
Ulwdo's user avatar
  • 43
3 votes
1 answer
3k views

How to load an image from disc and assign it to a newly created image texture node?

I'm trying to load an image from jpeg file and to add the material to the cube using the following code: ...
Dini's user avatar
  • 31
47 votes
3 answers
95k views

Selecting an object via scripting?

As shown below, I have 2 nested spheres, each with a different material (inner = "1", outer = "2"). Ultimately, I need to select the inner sphere (material "1") via ...
AaronJPung's user avatar
17 votes
1 answer
31k views

Duplicating a mesh object [duplicate]

I would like to duplicate a mesh object, but on a particular object. Right now this is working: ...
Raspberry's user avatar
  • 425
14 votes
3 answers
10k views

How can I manually calculate bpy.types.PoseBone.matrix using Blender's Python API?

I have this .blend file which has a simple scene, and a python script. There's a readme section in the script, but to give a general idea: There are two identical meshes in the scene, one skinned, and ...
fergal's user avatar
  • 627
13 votes
1 answer
16k views

Poly / Bezier curve from a list of coordinates

I'm trying to create curves from a list of points, I have the xyz coordinates in text files. I could make it manually via the python console for a single curve, but I have to do it many times and I ...
Matteo Caffini's user avatar
12 votes
3 answers
6k views

Duplicating non primitive mesh with Python

I've created a mesh I want to duplicate using python with specifications for the new duplicate's coordinates. How do I do that?
user14351's user avatar
  • 360
10 votes
2 answers
2k views

Copy framebuffer of 3D View into custom frame buffer

General question: Is there a reliable way to directly access the OpenGL framebuffer of a View3D for copying? (Please see the end of the post for more detailed questions) I need a very fast way to copy ...
reg.cs's user avatar
  • 488
10 votes
5 answers
9k views

Add Custom Menu at Specific Location in the Header

Blender has a built in template for adding a custom menu to the main header (INFO_HT_header). This can be found by going into the text editor under templates->Python->UI Menu. Can I relocate this ...
PolyMesh's user avatar
  • 625
10 votes
3 answers
2k views

How do I Create a script for geometry I create?

I was wondering, is there a possible way of selecting an object I create in blender and generating python code from it, so I am able to generate the object via code? I was wanting to do this for ...
Starius's user avatar
  • 1,114
9 votes
1 answer
4k views

Bundling python library with addon

I'm making an add-on that uses the websocket library from python. Is there a way to include it in the add-on .zip file? Or do I have to add it to the site packages folder in blenders included python ...
Joshua Anderson's user avatar
9 votes
3 answers
12k views

How to duplicate an object in 2.8 via the Python API

I know how to successfully duplicate an object by using bpy.ops.object.add_named(name = 'TemplateObjectName') If the template object named 'TemplateObjectName' ...
Dazotaro's user avatar
  • 901
9 votes
1 answer
8k views

Python Render Specific Frames

I'm new to blender scripting and with the api change in 2.56 I'm having difficulty finding relevant information. I'm trying to render 8 non-consecutive single frames to pngs. They are the same scene ...
AkBKukU's user avatar
  • 197
8 votes
2 answers
12k views

Change active collection

Is there a way to change the "active" collection? I can check witch collection is currently selected with this code: ...
johnzero7's user avatar
  • 359
8 votes
1 answer
778 views

Possible to create new Application Handler?

Blender's application handlers are listed here, but is it possible to create a new one? For example, I'd like an application handler which is a callback for every time I add a strip to the Video ...
Garrett's user avatar
  • 6,556
8 votes
1 answer
2k views

Use self and the slow python expression

In putting together an answer to Changing Multiple Influences Simultaneously I came across the Slow python script warning in the drivers editor Using a set up as outlined here driving a pose bone's ...
batFINGER's user avatar
  • 83.4k

1
2
3 4 5
51