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
10
votes
2answers
2k views

Alternate between user input and automation in one-step script

I would like my script to do the following : Save selected object's name and add an object (automation) Let user move the added object where he wants (user input, stopped with leftclick) Move the 3D ...
13
votes
1answer
4k views

Insert keyframe on an object's custom property with Python

How can I add keyframes to custom properties with python? Usually, I can use the function object.keyframe_insert(data_path="location") but I couldn't find the ...
5
votes
2answers
2k views

How to interface with blender using IPython from terminal?

Is there any way to interface with blender using IPython in blender 2.68? I have tried many many options over the past couple of days and none of them have worked for me... The best option for me ...
4
votes
2answers
2k views

How do I change UV coordinates while the game engine is running?

I'd like to do a map in a game that moves with the actor. What is the proper syntax to move uv coordinates around and have the game engine update the result?
3
votes
1answer
322 views

Can game settings be changed dynamically?

I manipulate a game property using logic bricks. I can read the property in the following script and set the value of ...
3
votes
2answers
3k views

Can modifiers be computed and applied from the command line?

For heavy modifiers, the time it takes to compute can range between a few seconds to half an hour or longer. Can modifiers be added, computed, and applied from the command line with some sort of ...
28
votes
4answers
4k views

Why avoid bpy.ops?

Simple and maybe stupid question: I was reading this lot of time, that "you should avoid using bpy.ops, or "instead of ...
3
votes
1answer
1k views

How to change the current action on dope sheet editor with script?

I am trying to load multiple animations, I use dope sheet editor to manage the animations. I have a couple of matrices, what I want to use bone by bone, then insert keyframe one by one. My problem is ...
16
votes
1answer
11k views

How to read vertices of quad faces using Python API?

Preferable in object mode. I have a mesh I know is made of quads only. I want my script to iterate through each quad and do something with the coordinates of each of the four vertices. I have read ...
4
votes
2answers
2k views

How can a Method from a startup Script be invoked?

This is a follow up of How could a single Python script run when Blender is started?. Simply adding a method to a newly created file in Blender\scripts\startup ...
13
votes
2answers
4k 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, ...
4
votes
1answer
555 views

Python scripting Blender with Luxrender

Do you know how could I render a scene with luxrender using the python API of blender and luxrender ? I found their Python API, but I don't find a way to render the scene thanks to luxrender with a ...
4
votes
2answers
1k views

How can I call the active brush within my script?

I am attempting to modify sculpt brush settings via a custom menu. To do this I'm setting a string property to specify the setting I wish to modify. Since these settings are dependent on the active ...
23
votes
3answers
11k views

Is there a way to restart a modified addon?

I'm currently twiddling with an old addon and insert some print statements for debugging. Currently I'm restarting Blender each time to see the new messages. Is there a way to 'refresh' an already ...
11
votes
1answer
4k views

Run an edit-mode operator on every object in the scene

I want to untriangulate every object in my scene with this script: ...
5
votes
1answer
4k views

Changing settings of the 3D view with Python

I am a beginner with python, and prompted by my previous question, I was trying to set viewport shading to Solid and View Only Render to True with python. (The goal being to get the script in that ...
19
votes
4answers
12k views

What programming languages can I use in Blender?

What version of Python does Blender use and are other languages available? Also, does Python work the same in Blender as when you write console applications or when working with Pygame or are there ...
4
votes
1answer
721 views

how to report missing files in a list, usable in python script?

Is there any simple way to get all missing .blend libraries, in a python list, set, ...
15
votes
3answers
10k views

Quick way to get current opened filename in a script?

I'm looking for an efficient way to get the current .blend file name, in a python script. I know how to get its path, with ...
11
votes
2answers
637 views

Environment for implementing/testing Computer Graphics algorithms

I need to code up a computer graphics algorithm for Surface Registration. Briefly surface registration is the process of finding "optimal" one-one correspondence between surfaces, where the meaning ...
14
votes
1answer
2k views

How to pass multiple operator properties via UI layout?

Basically, I want to have a single operator which can do multiple things, based on some attributes values. ...
33
votes
2answers
18k views

Can I run a Python script step by step in Blender?

Can I run a python script step by step with normal blender, a build, external software or an addon? I'm developing a script (town generator) and I want to to execute the code step by step like a ...
5
votes
3answers
2k views

Scripting - How to create a game property?

I have a bunch of objects and need to create some common properties to all of them like this ...
8
votes
2answers
1k views

Is it possible to save certain parts of a screenshot

I'd like to reduce the time necessary to create screenshots. I want to skip reopening and cutting and saving. Instead I'd like to use a python script to determine the size of the part of the screen ...
10
votes
1answer
932 views

Can armature/bones be edited without edit mode?

I was looking after some information about armature and bones, so I can continue my importer script. I found some nice info here; no BMesh, and simple enough for my needs as beginner, so just perfect. ...
11
votes
2answers
4k 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 ...
18
votes
2answers
13k views

How to create a mesh programmatically, without bmesh?

I do not want to use BMesh this time. I want to create a mesh programmatically, for this purpose I created this short script to see what I do wrong in my importer script. In this script I try to ...
6
votes
1answer
944 views

How does one obtain the file path of the current .blend in the bge?

Specifically, how does one obtain the path to the current .blend when the blender game engine is running?
7
votes
2answers
804 views

Can I load 8bit bitmaps with Blender?

After looking at the documentation about supported file formats on wiki, I tried to use 8 bit BMP files as texture. (I know, old school, but I wanted to avoid conversions) However, the image appears ...
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, ...
15
votes
2answers
6k views

How to unlink material from a mesh, with python script?

Blender 2.68a, Python 3.3 I would like to unlink material from a mesh, and even after googling a hour I don't know how to do it. I only saw scripts that work in Blender 2.5x only for this. So could ...
11
votes
1answer
3k 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: ...
6
votes
2answers
1k views

How to print a list of enumerated items in Python

Let's say I want to create a new bone constraint in a script. Blender then tells me that it wants to know which type of constraint I want to create. Can I print a list of all possible types? I know ...
4
votes
1answer
286 views

How to do AddonPreferences using extensions_framework?

I have seen scripts taking user preference values using classes built over AddonPreferences. Is it possible to do the same using extensions_framework by Doug Hammond. Why I am asking this is I need to ...
5
votes
2answers
4k views

Manipulate BGE logic bricks through python

Is it (if at all) possible in Blender 2.6+? If not, will future versions of Blender support it? I see some old posts (this and this) saying that it is not possible. However, I found a recent post ...
5
votes
1answer
1k views

Relation between BGE framerate and Action framerate

By BGE framerate I mean the rate at which True pulse is fired (and thus attached Python controller script is executed) and by Action framerate I mean the rate at which the value returned by ...
8
votes
1answer
8k views

How to save an image created from python script including the alpha channel?

I have tried the following, and the resulting image file, when opened in GIMP, never contains an alpha channel, only R, G and B. ...
19
votes
5answers
11k views

How to access Render Result pixels from python script?

Render Result exists in bpy.data.images["Render Result"] but it contains no data. Also bpy.data.images["Render Result"].size[0] ...
6
votes
2answers
2k views

Select vertex if vertex color is dark

I've baked AO to vertex colors and would like to use the smooth modifier only on vertices that have a vertex color darker than 0.1 (for example). How can I select vertices whose colors are below that ...
6
votes
1answer
2k views

Calculating acceleration or velocity of a point on a rigid body?

I have a rigid body simulation involving a solid body. It is a simple simulation with a box shape on a plane. The plane is slid out from under the box so it falls due to gravity. Due to friction ...
2
votes
1answer
634 views

Getting vertex weights with the vertex proximity modifier

I am trying to use the Vertex Proximity Modifier to update vertex weights and hoping to be able to read the same with Python. I have a plane and a vertex group called "all" (which includes all the ...
12
votes
1answer
1k views

How to prevent malicious code execution loading blend files?

Since I download from time to time example files from blogs, wikis etc. I would like to know how I can avoid execution of malicious code. Is it enough to disable the autoexec switch and see what is ...
4
votes
1answer
337 views

How can I customize the Render Button in the Render GUI to execute a custom script

I am trying to customize the blender GUI so that I can customize the Render button in the GUI to call a customer script as opposed to the default option. I would like to know if there is a way to ...
3
votes
1answer
173 views

Timeline modal operator: how to get frame cursor to follow mouse

I'm trying to write a modal operator for the timeline, but I'm confused about how to get the current frame cursor in the timeline to follow a 'mousemove' event (and consequently, how to set the new ...
6
votes
1answer
4k views

Blender as python module, 'Context' object has no attribute 'object'

I understand that running blender without a GUI does not provide bpy.context for the 3d View. Can anyone help me with a work around. This results in a 'Context' ...
5
votes
1answer
970 views

Is it possible to change viewport draw mode when navigating?

I'd like to write a script to automate viewport draw mode switching when navigating the viewport. Could this be done with, say, a modal operator? I haven't written any modal operators before, so ...
9
votes
1answer
1k views

Console vs scripting python constants

Using 2.67b for python scripting I get this: while importing math, numpy on the scripting console, internal variables seem to be ...
42
votes
1answer
2k views

Custom trackpad pan/zoom/rotate behavior add-on

I'm trying to write an addon to customize the trackpad panning, zoomimg, and rotating gestures, but can't find a way to read the actual trackpad parameters for position and so on. The properties in ...
7
votes
2answers
2k views

Dynamic creation of properties for export script

This time I have a question about Properties in Blender. I want the operator window of my add-on to have one BoolProperty per action defined in ...
10
votes
2answers
5k views

How do you export bones relative to parent?

I'm currently writing an exporter script. So far, I can export meshes just fine, but I've got some problems with exporting the armature. According to the python api, there are three different types ...