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

How can I export my blender model as a python script

I am using Blender 2.77. When we select File > Export from the menu, the default export options Blender gives are .3ds, .fbx, .bvh, .ply, .obj, .x3d/.wrl, .stl, .svg...
bot4u's user avatar
  • 323
5 votes
2 answers
2k views

Blender gets very slow to draw a scene having large number of plane?

I have a very simple python script to generate planes in the scene. I want to generate 50000 planes in a scene, to compensate for unavailability of POINT primitive, so that i can render a point cloud. ...
ZeroGravity's user avatar
5 votes
1 answer
5k views

How to create a button on the n-panel?

I would like to make a custom button on the N-panel. I already went through blender's templates and amended the ui button script to 2.8 but I don't understand where and how I should implement my code ...
four two's user avatar
  • 980
5 votes
1 answer
2k views

How can I drive the Switch nodes True/False value?

In the compositor I would like to add a driver to the Switch Node. I want to watch a frame value from a VSE strip. When the current frame count equals the Strip start frame I want to switch the node. ...
3pointedit's user avatar
  • 8,916
4 votes
2 answers
3k views

Store each animation frame as new object

Is it possible to store each animation frame as a new object? I searched quite a long time now on google and was wondering that I cannot find any information about this. I just have a simple model ...
daniel's user avatar
  • 103
4 votes
1 answer
552 views

Handler-script updates in viewport but not in render

I'm completely stuck :-/ I've made a handler-script, that takes with every new frame a new line from the text-editor and puts that line into the text-object in 3d-space. It works absolutely fine - ...
Andi 's user avatar
  • 691
4 votes
3 answers
2k views

Is there a way to get a list of coplanar faces using Python?

Is there a way in Python to get a list of faces that are coplanar to a particular face similar to the way the command "Select Linked Flat Faces" works, but without actually requiring me to change the ...
MrFlamey's user avatar
  • 3,819
4 votes
3 answers
4k views

Python : Get selected objects in outliner

To get the selected object in viewport, we use : bpy.context.selected_objects But in outliner, if i select some objects there, then what is the python function to ...
andio's user avatar
  • 2,064
4 votes
1 answer
202 views

Is the active object and zeroth selected object always the same?

I see a lot of scripts on BSE that use for example bpy.ops.mesh.primitive_cube_add() cube = context.selected_objects[0] instead of one of ...
batFINGER's user avatar
  • 83.5k
4 votes
2 answers
7k views

Rounded caps on a Bezier Curve pipe

This may be a simple question. Essentially I am procedurally generating random 3D figures using a bezier curve and bezier circle bevel object, however, one of the only things I can't figure out how ...
switchup621's user avatar
4 votes
1 answer
464 views

Link selection between VSE strip and object?

My current workflow for a project I am working on uses empties in the 3D-View to more easily control properties of strips in the VSE via drivers. However sometimes it gets a little confusing which ...
PGmath's user avatar
  • 25k
3 votes
3 answers
2k views

How do I prevent object from moving when parenting object to a bone?

I've been trying different examples to parent an object to a bone without the object moving (aka keep_transform), but no matter what I try it always offsets: ...
Logic1's user avatar
  • 335
3 votes
1 answer
3k views

Python: Check if vertex is on camera field of view [duplicate]

Suppose I have the following camera perspective. As you can see some of the Cube vertices are visible from the camera, others are not. Is there a way from python to detect if a certain vertex is in ...
wsfax's user avatar
  • 396
3 votes
2 answers
3k views

Python: Bisect mesh into n parts, without separate 'LOOSE'

Using Python I want to split a mesh into tiles. All the solutions to this question rely on bpy.ops.mesh.separate(type='LOOSE'). But this leads to problems in the ...
Jip's user avatar
  • 103
2 votes
1 answer
2k views

set a specified vertex color to black via python

how to set the vertex color in the center of the mesh to black and the rest of the vertices to red via python? a lot of the answers just tell me that i can color all the vertices in one face like that:...
Heixue's user avatar
  • 117
2 votes
1 answer
604 views

is there a way to streamline scripting these shaders and modifier keyframes?

Here is a simple demo script for keyframes on shaders and modifiers for multiple objects. In the future there will be much more going on, so I want to know if there is an easier way to do these kinds ...
uhoh's user avatar
  • 2,667
2 votes
1 answer
2k views

How do I add keyframes to a newly created action with no associated objects?

So I'm writing an animation import script... since animation bone names can differ from the armature's bones in question, I want to create the actions and edit their group names manually, and then ...
Tcll's user avatar
  • 201
1 vote
2 answers
1k views

How to get indices of the faces to which a material has been applied, using Python?

I have many objects similar to this and I import them into the scene using bpy.ops.import_scene.obj(filepath='model.obj', split_mode="OFF") to do some renderings ...
Amir's user avatar
  • 3,046
1 vote
1 answer
681 views

Bake an fcurve with visual transforms

I want to duplicate an existing animation and bake it with visual transforms applied, something like what the default nla baker does. For simplicity's sake say I need to do this for a single bone. ...
user avatar
1 vote
1 answer
1k views

How do I get the deformed coordinate of a vertex with Python?

How might someone find the deformed coordinate via Python or otherwise when using a subdivision modifier with the 'show on cage' option? For example, a subdivided cube with cage enabled and a vertex ...
Shiprex's user avatar
  • 160
1 vote
2 answers
2k views

Python How to make pose bone rotation toward a point?

I have the pose bone at a location and I would like for it to rotate to face a point Code: ...
Alphi Henry's user avatar
1 vote
1 answer
246 views

Distributed interaction visualization

I'm just getting started with blender and have been playing around with it for a few weeks. I have a pretty particular use case and wanted to see if blender could assist me in that. I have written a ...
joethemow's user avatar
  • 111
0 votes
1 answer
665 views

Changing active camera will yield an incorrect rendering (camera view not reflected)

I have defined a Blender class to help me abstract out details for rendering, object manipulation etc. I setup my scene using this class and put 12 cameras in it. Then I start rendering objects by ...
Amir's user avatar
  • 3,046
0 votes
1 answer
724 views

Access Audio Strips Sample data in Python for a Cross-Correlation

I want to perform an Audio Cross-Correlation in Blender (like with numpy.correlate) to align two Audio Strips. But I can't figure out how to access the Sample Data of an Audio Strip inside Blenders ...
Samoth's user avatar
  • 3,234
29 votes
9 answers
28k views

Efficient way to get selected vertices via python (without iterating over the entire mesh)

What's the best/fastest way to construct a list of selected vertices for a mesh object in python? I want to avoid iterating over every vertex in the mesh if possible, since that seems like a really ...
Qutorial's user avatar
  • 3,302
23 votes
5 answers
19k views

How to know which object is using a material

How to know which object is using a material. I know that a material is used 4 time -> picture under: I'm searching a solution with python and I'm blocked here : ...
lucblender's user avatar
  • 3,323
23 votes
2 answers
6k views

Blender UI Multithreading Progressbar

The following question might've been asked several times, but I've found no satisfactory answer. Short question: How can I show progress of background task in Blender UI? Explanation: I have a ...
mg007's user avatar
  • 811
17 votes
1 answer
11k views

How do I create a new object using Python in Blender 2.80?

As part of an existing add-on, I'm trying to create an object and add it to the scene using Python. I followed a Blender Cookbook tutorial found here: Three ways to create objects. I use the following ...
Justin's user avatar
  • 1,972
17 votes
2 answers
13k 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 ...
slixxed's user avatar
  • 173
15 votes
2 answers
9k views

Absolute path of files in Blender (with Python)

Functions such as os.path.exists(image.filepath) fail when Blender uses relative paths, This seems to be because Blender uses // ...
ideasman42's user avatar
14 votes
6 answers
22k views

How to open system console to get output from Blender on Mac OS 10?

Noobie here. Should I open Mac terminal and cd to /Applications/Blender/ which is where my Blender app is? Doesn't seem to work for me trying to run script from Text screen in Blender. I guess there ...
Dick Meehan's user avatar
14 votes
3 answers
3k 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: ...
Mike's user avatar
  • 191
13 votes
1 answer
8k 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...
Danielle's user avatar
  • 131
13 votes
2 answers
3k views

Assign datablock to custom property

With bpy.props I can assign bool, int, float and string ...
Germar's user avatar
  • 365
13 votes
4 answers
19k 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 ...
Leon Cheung's user avatar
  • 27.5k
12 votes
2 answers
14k views

How to add a UV Map to a Mesh Using Python

I've made a script that creates a mesh in Blender using a binary file containing mesh data. That works fine, but now I need to get textures on the mesh and I want to create a UV map from the UV data ...
MrFlamey's user avatar
  • 3,819
12 votes
2 answers
4k views

Import object without bpy.ops.wm.link_append

Is it possible to import an object from a library file through Python without using bpy.ops.wm.link_append? I want an object to appear in ...
user2683246's user avatar
12 votes
2 answers
9k views

Exporting UV coordinates

I'm having massive trouble exporting UV coordinates from Blender. I'm using the following code: ...
doxin's user avatar
  • 221
12 votes
3 answers
7k 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'...
steadyfish's user avatar
12 votes
1 answer
9k views

How to put together a driver with python

I'm trying to write a script to create the beginnings of a music visualizer but I'm having a hard time creating drivers to do it. My basic game plan is this: Calculate frequencies and step sizes For ...
Burritosaur's user avatar
11 votes
5 answers
13k views

How can I create a cylinder linking two points with Python?

I want to position a cylinder such that the center of one end is at (x0, y0, z0) and the center of the other end is at ...
Martin McBride's user avatar
11 votes
2 answers
17k views

How do I stick an object to another objects vertex?

I just created a plane and added a wave modifier to it, to simply make it look like something fluid. Now, I have an Object that I want to place on the surface of this fluid plane. But how do I do that?...
Marten Zander's user avatar
11 votes
2 answers
8k views

Incorrect matrix_world after transformation

This script changes the active object's location, it could also change the rotation or scale, it also prints the object's world matrix before and after changing the location. ...
David's user avatar
  • 48.9k
10 votes
2 answers
7k views

Changing object origin to arbitrary point without origin_set()?

Is there a way to change the origin of an object to an arbitrary point (via scripting) without using the operator origin_set()? I.e., isn't there a method or property on the object to do this? I ...
Jabberwock's user avatar
10 votes
4 answers
5k views

What ui would work for choosing from a long, long list?

I need the user to choose from a huge list of items. This is ugly and useless for lists longer than 100 items. I'm happy with the rest of the code. I just want a scrollable listbox really. ...
Ben L's user avatar
  • 621
10 votes
1 answer
10k views

Is it possible to put an if statement into the scripted expression of a driver?

If the y location of a certain object is greater than 0, I want to add a fixed amount to another object's driven channel. How do I achieve that?
Haunt_House's user avatar
  • 15.9k
9 votes
2 answers
5k views

unregistering a class

I have made a new object for the Add > Mesh menu and I would like to unregister it but when I try to with: if __name__ == "__main__": unregister() I get the ...
Whitequill Riclo's user avatar
9 votes
1 answer
6k views

Specify tile size for Blender Cycles rendering via the command line

I'd like to write a little piece of code which splits a frame into a few tiles and uses all available devices to render the still image. It seems like the Blender developers are working on such a ...
user1344's user avatar
9 votes
1 answer
9k views

How to find out why "context is incorrect"? [duplicate]

I have been trying to write my first addon for Blender over the last couple of days. One error I came across quite often is the context is incorrect error for an ...
user1809923's user avatar
8 votes
1 answer
9k views

Modify obj after import using python

I am trying to modify an object after importing it. This post is related to this question ...
Ross's user avatar
  • 257

1
3 4
5
6 7
51