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
14
votes
3answers
3k views

Is it possible to render only keyframes from Dope-sheet?

I want to render only keyframes from Dope-sheet without the in-between frames. Effectively creating hold of last keyframe till there is new keyframe by re-saving (not re-rendering) the previously ...
14
votes
1answer
2k views

Access skin modifier radius data

With Skin Modifier, we can "weight" a vertex (in Edit Mode) so that the resulting Skin mesh is bigger or smaller - similar to Curve objects which has "Scale Feather" adjustable. Manually, we can hit ...
14
votes
1answer
6k views

How to switch rendering engine via python script

I managed to compile Blender as a Python import module. When I do bpy.ops.render.render(write_still=True) it renders with cycles. How can I render by using Blender ...
14
votes
1answer
5k views

How to create macro/record actions while modeling

I'd like to record my actions and create a macro. I've tried allready two things: 1) copying actions from Info panel and pasting them to text aditor. Then adding the lines: ...
13
votes
3answers
27k 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 ...
13
votes
2answers
6k views

How to get a new mesh with modifiers applied using Blender Python API?

I've been scouring the Blender Python API docs for a way to get access to the mesh data that is displayed in the view-port. (with modifiers applied - WYSIWYG) For reference, this was possible with ...
13
votes
1answer
22k views

Duplicating a mesh object [duplicate]

I would like to duplicate a mesh object, but on a particular object. Right now this is working: ...
13
votes
1answer
4k 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 ...
13
votes
2answers
10k views

How can I get a list of all objects named 'foo*'?

In my export script I wish to export all object named 'foo*' in one format, and all objects named 'bar*' in another format. I could write 2 separate exporters that operate on the selection (so I ...
13
votes
2answers
7k views

How to get Blender's version number from Python?

How do I go about programmatically getting the Blender version number? Example: If I am running Blender 2.76, how would I get the version number from the python console?
13
votes
6answers
11k views

How to find if a point is inside a mesh?

I need a python script that would help me determine if a point is inside a cylindrical mesh. I tried the .pointInside(point, selected_all=False) but it is deprecated in the newer versions of blender ...
13
votes
2answers
5k views

How could a single Python script run when Blender is started?

I would like to have a few globally available functions which should not not depend on a .blend file. Is there a place (A setup.py, ...
13
votes
3answers
7k 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, ...
13
votes
2answers
5k views

Why does operators bl_idname have to contain 1 dot?

Since anything before and after the dot is arbitrary, why bother? Related error: ...
13
votes
2answers
9k views

How to automatically fit the camera to objects in the view?

I'm using blender to render avatar and avatar accessories on a website, however there is a problem, when a hat, or accessory is made a bit large, the it doesn't fit in the viewport, is there anyway to ...
13
votes
2answers
11k views

Controlling BGE properties with python script

I would like to know how to change the values of properties added using the "AddGameProperty" option in the game logic UI using python code? I want to write code that changes the 'Property' value in ...
13
votes
3answers
16k views

How to list all selected elements in python?

If I select a face of a cube and switch over to the internal Python console and pass: bpy.context.selected_objects I get: ...
13
votes
1answer
4k views

How to get reference to object(s) added by an operator?

From my python script I want to add some objects to scene and process them later (add constraints etc.). If the object to be added is an Empty, I can simply write: ...
13
votes
1answer
8k views

Blender python custom UI button run custom function?

I am currently in the process of writing a project in python for Blender to simulate crowds automatically. However I would need for there to be a custom UI to allow the user to choose their settings ...
13
votes
2answers
457 views

What do different execution contexts mean?

The documentation says that I can invoke an operator with a different execution context, either invoking or executing it. What I know is that invoke will most often ...
13
votes
1answer
601 views

Have second window with different perspective open only when a second monitor is connected?

I have Blender on my laptop, into which I sometimes plug an external monitor, and set up some different regions to make my workflow smoother/easier. When I save and close my project, the multiple ...
12
votes
3answers
5k 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?
12
votes
2answers
10k views

Add modifier to selected and another to active object

I am trying to set up an operator to use the BoolTool after I set a position and modifier on Selected object and a different one on the Active object. I basically need to move the selected object up ...
12
votes
4answers
4k 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 ...
12
votes
2answers
25k views

How to check if an object has a custom property with python?

The standard python hasattr() doesn't work for me, giving me False in every case: ...
12
votes
2answers
1k views

Making weather effects in the BGE

This type of snowfall looks nice: If that example was made in Blender Internal or Cycles, I'd say particles were used - but particles clearly don't work in the BGE. How can a weather effect such as ...
12
votes
2answers
4k views

How to Interpolate vectors in Python?

How to interpolate vector between 2 vectors in blender-python? I hope you get my question. Example:
12
votes
3answers
25k views

getting started: no module called bpy outside of Blender

After sudo apt-get install blender on Ubuntu 12.10, I have Blender version 2.63 However, I can not import the relevant ...
12
votes
1answer
13k 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 ...
12
votes
1answer
8k views

How to create a Folder/File Dialog?

So I need to allow the user of my script to choose a directory that contains images, and then run my script on each image. I already have my script made here. I looked at this question already, but ...
12
votes
4answers
18k views

How to toggle visibible / selectable / renderable for multiple objects?

For quite long time, I was looking for a faster way to toggle (or toggle off) visible / selectable and renderable for many objects, as illustrated below: I know we can do the relatively quick select ...
12
votes
1answer
2k views

Is it possible to add a button to an existing panel or node with python?

Is it possible to add a new button to an existing panel or an existing node that runs a custom operator? How can I do this?
12
votes
4answers
9k views

How to set active scene via Python?

I have code to make a copy of my scene. bpy.ops.scene.new(type='FULL_COPY') cloneScene = bpy.context.scene cloneScene.name = 'clone' I wish to adapt it so that ...
12
votes
3answers
6k views

Possible to replay repetitive tasks using Python?

Is there a way to do a particular task manually, generate the code for it automatically and update that code to do some task repeatedly? I'm looking for something like record macro functionality that'...
12
votes
1answer
13k 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: ...
12
votes
3answers
4k views

Controlling armature through python

I need to control an armature using Python so that I can animate a biped model using data from a text file. I've been using this tutorial and some other sources to try and do so, but I can never see ...
12
votes
2answers
2k views

Assign datablock to custom property

With bpy.props I can assign bool, int, float and string ...
12
votes
1answer
12k views

Select vertices of mesh in python

What is the python way to select vertices of a mesh? I've tried: for vert in obj.data.vertices: vert.select = True I ran the above code in edit mode, but ...
12
votes
1answer
7k views

How can I separate a single object file into multiple objects based on closed geometry?

Let's say you have a single obj with a number of separate closed 3D geometries in it. For example's sake, imagine you have an obj called neighborhoodfirehydrants.obj...
12
votes
2answers
1k views

Is there a way to calculate mean curvature of a triangular mesh?

So I've written a script which does this: Before: After: The code is: ...
12
votes
2answers
1k views

How to register global (i.e., unique per file) properties?

I need to store additional information in a .blend file, that occurs only once per file. So, attaching it to, for example, bpy.types.Scene doesn't help. Since <...
12
votes
2answers
5k views

How to add a "select path" input in a UI addon script?

I have to allow users of my addon to select a path via the directory browser window of blender. The path is already set in an external ".conf" file, but I need it to be customizable via blender GUI, ...
12
votes
2answers
6k views

How To use Visual Studio Code to write blender python script integrated with blender?

There are different options out there of Ides to write integrated python blender scripts. I'm a visual studio person and, even though there is no way to use it for that purpose, I was hoping with ...
12
votes
1answer
591 views

Would it be possible to create a new constraint "type" with python?

Obviously it is possible to add new mesh "type" with python in the list of create mesh. I think I read that it isn't possible to create a new "modifier" type with python. What about constraints type (...
12
votes
2answers
1k views

BGE. Is it possible to create transparent plane with blur filter?

17 09 2015 here is blend to test: https://dl.dropboxusercontent.com/s/cwpyem6zve6r2u4/blur5.blend I'm still trying to figure out how to add blur filter to plane to make under plane objects all ...
11
votes
3answers
1k 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. ...
11
votes
3answers
1k views

Where can the latest API documentation be found?

Some of my scripts scripts are broken e.g. bpy.ops.pose.armature_layers(layers=sel_layers) # 2.6 api has been (unnecessarily) renamed to ...
11
votes
1answer
4k views

What is the difference between items listed in bpy.ops bpy.data and bpy.context

When accessing items in a python script somethings are prefixed with bpy.data some with bpy.context and others with ...
11
votes
1answer
1k views

Converting code to work in blender with sliders

I have some Fragmentarium code that I would like to convert so it will work in Blender anyone have any ideas how I can do this? The code is below: ...
11
votes
2answers
26k views

How to rotate an object in Blender 2.74 using python script

I wanna rotate an object with this code below: ...