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
8 votes
1 answer
13k views

Blender script import model and render it

I know python well, but I'm not familiar with blender. Is it possible to use the blender API to do this? Setup: Create a scene in which the the lights and cameras are pre-arranged. Run a python ...
Echeg's user avatar
  • 191
7 votes
2 answers
4k views

Blender scripting connect nodes

I'am beginner at python and blender. I' am trying to create simple addon for myself as part of learning process. I want to achieve that, if i run the script, mixrgb node is added to node tree and link ...
fyf's user avatar
  • 73
7 votes
2 answers
11k views

What units does the rotation argument expect when creating objects?

I want to create a lamp in blender using python. I want to give the lamp some rotation. As per the documentation I can set the initial rotation using a tuple of numbers in the function call like this <...
Vader's user avatar
  • 14.6k
7 votes
2 answers
5k views

How do I register 'Scene' properties with Python in 2.8?

I'm currently udpating some 2.7x script for 2.8. Everything is going fine except for one thing: Currently the script uses a class to store some properties like so: ...
Yadoob's user avatar
  • 83
6 votes
3 answers
7k views

Finding Vertices, Edges, Faces, and Tris using Python

I am trying to access the triangle count of an object with Python. All other python code displays itself when I hover my mouse over the corresponding button in the interface. When I go to the info bar ...
MattB's user avatar
  • 63
6 votes
4 answers
3k views

How do I make a weapon shoot at the center of the screen?

I've been researching this for weeks and only found bad results. I think its time for a good answer. I have a rocket launcher, so I can't "fake" the bullet. There is no way to fake a rocket. I need it ...
blackhole's user avatar
  • 2,374
5 votes
2 answers
5k views

How do a create a foldout UI panel?

I have an add-on with rather a lot of UI options and am trying to find a way to clean it up so that not all the options need to be shown at once. I've noticed that some of the default tools have ...
MrFlamey's user avatar
  • 3,819
4 votes
2 answers
590 views

Is there a workaround for the known bug in dynamic EnumProperty?

So I was making an addon with a dynamic EnumProperty and apparently ran into a known bug when trying to use Expand = True for this property in the panel. Although ...
Niels's user avatar
  • 174
4 votes
3 answers
4k views

Align to face normal vector

Help me rotation new object by normal a face other object. I have code that works half. The axes at the selected polygon and the new object must be the same code - http://pasteall.org/632513/python ...
Влад Киндюшов's user avatar
3 votes
1 answer
8k views

Get bone rotation in pose mode using Python

I want to get angles of joints in armature in pose mode, see the picture below. I tried to get local rotation of bones, but I can't find a way to do this. I tried: ...
Alexey Markov's user avatar
3 votes
2 answers
2k views

Copying an object with python without actually creating a new object

I ran across this script on another forum and would like to implement it. However, I'm running into a major bottle neck (performance-wise) when it gets to linking the new objects back to the scene ...
GeoJohn's user avatar
  • 249
2 votes
1 answer
1k views

Is there any way to export the last frame of a physics simulation from command line?

I have a basic rigid body physics sim, but I want to export the last frame of the simulation. So far I have tried setting the "current frame to the last frame of the simulation and exporting it that ...
Abhi Kondagunta's user avatar
0 votes
1 answer
2k views

How to populate UIList with all material slot in scene? 2.8

I make that script (Copy a piece from template UIList) Now i can draw My box with inside the active object material but i want to populate that with all material in scene, i not undertand , how to. ...
Noob Cat's user avatar
  • 1,145
23 votes
3 answers
19k views

Pointing the camera in a particular direction programmatically

I'm trying to use Python to place a camera. I know the camera's location, and the forward and up vectors for the camera (i.e. the direction it's pointing and its orientation). How do I do this? I ...
David Given's user avatar
19 votes
1 answer
12k views

How to check if two meshes intersect in python?

I need to check if two meshes intersect or not. At the moment I have some python code to find intersections of world axes aligned bounding boxes, next step would be to implement check for mesh ...
Lissanro Rayen's user avatar
15 votes
3 answers
38k views

How do you get an object's position and rotation through script?

I'm working on a project that requires me to get some of the position and rotation values to give to an Arduino via pyserial, but after sifting through the Blender documentation I can't find how to ...
Carrot M's user avatar
  • 153
14 votes
2 answers
19k views

link new object to scene with python in 2.8

In Python 2.8, I would like to create copies of the object 'CubeTemplate' but am having no luck. I have reviewed every blender.stackexchange post on this subject (this, this, this and this) but ...
vndep's user avatar
  • 713
14 votes
2 answers
7k views

How to connect nodes to node group inputs and outputs in python?

How can I connect nodes in a node group to the input or output sockets? This connection here: I can't figure out how to access the group node_tree, and the Group ...
gandalf3's user avatar
  • 156k
12 votes
1 answer
2k views

How to get one UIList to control the contents of another UIList?

I have two dynamic lists. One is for strings and another one for objects. When the string changes I need the other list to show the objects assigned to the string in the first list. So I would need ...
tintwotin's user avatar
  • 2,266
12 votes
2 answers
14k views

Get center of geometry of an object

With Object > Transform > Origin to Geometry, an object's origin is moved to its geometry's center. How can I get this center in script? I don't want to move its origin, I just need to get its center....
user avatar
12 votes
1 answer
17k views

Add a simple vertex via python

How can I add a Vertex from a script? I'd like to create a line from the extrusion of a vertex. This is my script now: ...
isar's user avatar
  • 427
12 votes
1 answer
17k views

How display and use operator properties in a Python Blender UI panel?

I have try to make an UI Panel with my operator, but i can not create a panel with the 2 choices (axis and widht). I can create a button who launch a menu in the tools pannel, and the operator works ...
Fabrice's user avatar
  • 175
10 votes
1 answer
5k views

Why is accessing image data so slow?

This script in the Python console: ...
wchargin's user avatar
  • 9,412
9 votes
2 answers
6k views

Coordinates of corners of camera view border

How to get coordinates of corners of camera border in camera view relative to the viewport area? After checking ...
Sergey Krumas's user avatar
9 votes
4 answers
11k views

How to find number of animated frames in a scene via python?

I need to find the number of animated frames after importing a bvh file in blender. scene.frame_start and ...
Manu Tom's user avatar
  • 121
8 votes
1 answer
978 views

Getting area (region.view2d) pixel coordinates of 2D views (VSE, NLA)

I am looking to overlay a sound vis, using bgl, over strips in the NLA, VSE, like How can I find the area.region.view2d x,y, width and height of strips in the NLA and VSE editors using python?
batFINGER's user avatar
  • 83.4k
8 votes
3 answers
3k views

How can I exclude a collection from rendering with Python?

Can anybody help me write a script that excludes certain collections (for rendering)? In the outliner the tooltip says: Layer.Collection.exclude and ...
edna's user avatar
  • 806
8 votes
2 answers
8k views

How to cut a mesh into smaller pieces with python?

I have a big terrain object, I'm trying to write a script that cut it in smaller pieces and then I will export the pieces to other formats. This is required by a game engine because the mesh, if not ...
Hatoru Hansou's user avatar
7 votes
2 answers
6k views

How to make a curve path from scratch given a list of (x, y, z) points?

I want to move a soft body object in my scene on a path (curve path). For the path, I want to make it myself from scratch. I basically have a Python List containing (x, y, z) points and want to create ...
Amir's user avatar
  • 3,046
7 votes
1 answer
2k views

Execute a python function whenever the user interacts with the program

Is it possible to execute a function every time the user does something? I want the function to check what the last user interaction was and then, if the interaction was to rename something, to give ...
Jaroslav Jerryno Novotny's user avatar
7 votes
3 answers
2k views

Changing tooltip for menu entries which use the same operator

I have created a set of menu entries which all use the same operator, but with different operator parameters: As it is now all menu entries show the same tool tip. But i need to add different tool ...
Gaia Clary's user avatar
  • 3,712
7 votes
2 answers
1k views

Sun object not moving when Rendering Animation

I've problem Rendering sun rotation animation. Steps to reproduce: Create the sun object Set 1st keyframe Select keyframe Rotate sun object using the handle "I" > Select Rotation Set 10th keyframe (...
karlisup's user avatar
7 votes
4 answers
6k views

Disable Material Duplication

Anyone who has used Blender for a while has probably tried to duplicate a scene via Full Copy. They would have then found that in the duplicated scene, all of the materials were duplicated as well, ...
Shady Puck's user avatar
  • 8,827
6 votes
1 answer
704 views

handle vertex property changes with msgbus.subscribe_rna

I want to trigger a function when any mesh vertex is selected. After alot of research, using msgbus.subscribe_rna seems to be the way to go, unfortunately even though i can use it to trigger a ...
Thiedent's user avatar
  • 129
6 votes
2 answers
840 views

Addon: how to make Blender run check()/redraw when option changed?

Operators have a check() function that Blender calls when it wants to check if it should redraw. Exporters usually use this to attach a file extension to the file ...
scurest's user avatar
  • 9,486
6 votes
1 answer
3k views

Alternative to redraw_timer()

I have a script whose goal is to find all the visible vertices from the camera view. The simplest solution should work as follows: Go Into Camera View Update the view with ...
Axe Per's user avatar
  • 75
5 votes
4 answers
12k views

Set active image node with python

There's any way to change it directly by Python, or there's any way to set by Python what node image is the active to display in viewport (Textured) and bake?
VitorBalbio's user avatar
4 votes
1 answer
6k views

Principled BSDF via Python API

The title is general: how can we use the API to edit Principled BSDF properties? More specifically, I have a mesh that has vertex colors in it. The colors are fine, and I can use the mouse to have ...
amwink's user avatar
  • 43
3 votes
2 answers
2k views

How to draw shapes in the node editor with python bgl

I want to draw a diagram using shapes such as triangles and squares in the node editor. How can I do this?
John Roper's user avatar
3 votes
1 answer
2k views

Matrix math to translate, rotate, scale with respect to a pivot point in Object mode

So i need to need to replicate translate, rotate & scale with 3d cursor as pivot point action using Matrix or bmesh in a script. i read Rotate objects around their origin along a global axis (...
Prime007's user avatar
  • 183
2 votes
3 answers
1k views

Face edges angle - python

How can I find angles between the edges in a face, and then make a loop for all faces in an object. I know I can set it up in a blender and just read it, but I'd like to send these angles to a text ...
Kolkornik's user avatar
2 votes
1 answer
2k views

How to specify Nurbs path vertices in python?

I'm trying to write a script which creates a Nurbs path curve, bevels it, and then stores the location of each vertex/point in that curve. I've been writing it based on the code displayed in the info ...
flipsies's user avatar
0 votes
1 answer
2k views

Hide Panel With Python

I have a class that extends bpy.types.Panel. When a combination of items are chosen in another panel, I want this panel to appear, but not otherwise. Right now the panel will always show after being ...
user avatar
0 votes
1 answer
3k views

How to add/remove links to existing or new nodes using Python?

I have lots of objects consisting of many different meshes. Some of these meshes come with transparent materials applied to them. My goal is to modify the nodes list, add new nodes and change the ...
Amir's user avatar
  • 3,046
21 votes
4 answers
8k views

Convert Curves to Grease Pencil?

I'd like to know if there's a way/add-on to convert curves to Grease Pencil strokes? I know you can convert in the other direction, but I can't find anything to create Grease Pencil strokes from ...
Shawn Altorio's user avatar
18 votes
3 answers
20k views

How to get keyframe data from python?

I am looking for help on how to export armatures and their animations in a custom export script. I wish to have an animation format similar to BVH, i.e. a bunch of ...
rspencer's user avatar
  • 283
15 votes
4 answers
14k views

How to make Blender use Python2.x?

When Blender is installed, it creates its own copy of Python 3.x. However, I prefer to code in Python 2.x. This makes it difficult for me to work with newer versions of Blender. I would like to know ...
Gwen's user avatar
  • 11.6k
15 votes
4 answers
2k views

Replace matrix @ vector list comprehensions with something more efficient

I'm looking to replace list comprehensions like the following with something more efficient and I was wondering if numpy can be used. ...
MACHIN3's user avatar
  • 797
15 votes
3 answers
6k views

How to remotely run a Python script in an existing Blender instance?

I don't want to use /Application.../blender -P my_script.py but I want to tell a running Blender process to execute a script. Is there an existing method to tell ...
mipmip's user avatar
  • 293
11 votes
2 answers
5k views

Is there a way to acces external .blend file's data with python script?

I'm writing an addon to parse a directory (and its sub-dirs) to write an XML file which describe the tree-structure of the assets contained in that directory. At the moment, my standalone script works ...
Polosson's user avatar
  • 6,514

1 2
3
4 5
51