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
10 votes
2 answers
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 ...
matali's user avatar
  • 2,811
9 votes
3 answers
22k views

What is the Python script to set the current frame

I have made a script to generate a game asset in one click ( http://blenderartists.org/forum/showthread.php?383624-Dark-Blender-(Official-Thread)-optimized-for-sculpting-and-game-asset-creation ). My ...
Danyl Bekhoucha's user avatar
9 votes
2 answers
5k views

Remove Doubles on multiple objects

I'm trying to run the remove_doubles edit command on multiple selected objects. This is kinda what I got so far... ...
Dillz Sinden's user avatar
8 votes
1 answer
3k views

Python: Ctrl+Click for buttons (capture invocation event)

Is it possible to get if Ctrl key is pressed when I click on my python button? I would like make different behaviors for my button operator. Example: LMB - Select some objects CtrlLMB - Deselect ...
mifth's user avatar
  • 2,331
8 votes
2 answers
5k views

Blender ignores changes to python scripts

I have two scripts. One that runs the main logic and another that holds a set of functions that I want to call. However when I make a change to the functions script it is not updated. I have saved the ...
sydan's user avatar
  • 181
6 votes
1 answer
3k views

Is there a way to convert a mesh's UV's into a second mesh using a script?

So what I've been doing to bake Cycles depth maps is based on the following thread found on the BA.org forum and I've mentioned this here already but I'd like to take this a step further using a ...
MarcClintDion's user avatar
6 votes
1 answer
850 views

Using a single worker method for properties

I am creating many boolean properties and want to be able to control the properties with a single worker function. The property name will be the logic driver. Is this possible? If so how? Or do I need ...
A. Kal's user avatar
  • 75
6 votes
3 answers
4k views

Problem with casting rays from the camera into the scene for each pixel

To retrieve information about the objects that lie behind each pixel, I have to cast rays into the scene for each pixel of a rendered frame. My problem is that the ray directions which I calculate ...
user1033657's user avatar
5 votes
1 answer
3k views

How to get all collections of the current scene?

I'd like to get all collections in the current scene and can't find a way to do that. I found bpy.data.collections to get all collections stored in the blend and <...
Noob Cat's user avatar
  • 1,145
5 votes
2 answers
2k views

How to properly use ExportHelper's 'axis_conversion' method?

I am building an XAML export script for Blender. I want to rotate the scene 90 degrees in the X axis to make it Y-up. Currently I am using a matrix on a BMesh and that is rotating the models, but not ...
Haydn's user avatar
  • 173
5 votes
1 answer
3k views

How can I move a PoseBone to a specific world space position?

I have written some code that calculates the world space coordinate I want to move the bone to but i am having trouble figuring out how to get that back into the bones coordinates. ...
Chris Kline's user avatar
5 votes
1 answer
4k views

Strange object.ray_cast() behavior

object.ray_cast() is not behaving as I would expect in Blender 2.77. I understand that it expects object local coordinates, but this problem happens when the object ...
foobarbecue's user avatar
5 votes
3 answers
4k views

How can I create many objects quickly?

In my application I have to create up to some 1000 tetraders (objects with 4 vertices, 4 faces, 6 edges). As input I get only the absolute vertex coordinates for each tetraeder. From the mathematical ...
Peter Hilgers's user avatar
5 votes
1 answer
16k views

python script that reads text file containing coordinates and creates a path/curve for object to follow

I am a highschool student working at a college's engineering department for the summer. I just began working in blender and have intermediate knowledge of python. Could anyone share a script they've ...
Alyssa Shorak's user avatar
5 votes
1 answer
6k views

How to prevent memory leakage in Blender?

I have to load lots of objects/meshes(50k) in Blender and render them for which I have written a Python script. My meshes have lots of vertices/faces (in the range of ~[10k, 70k]). I noticed that ...
Amir's user avatar
  • 3,046
4 votes
1 answer
201 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.4k
4 votes
2 answers
1k views

Force a Blender operator to always start with default values

I'm writing an operator for which it is crucial that every time it gets called all the properties are set to their default values. The ops.object.delete has 1 param. use_global. It is always false, ...
Frederik Steinmetz's user avatar
3 votes
2 answers
2k views

Place objects on mesh using snap with Python script

I'd like to place objects on a mesh using snap with a python script in Blender 2.79, preferably on places where the gradient (steepness) of the mesh (terrain) is not too steep. From the snap ...
a-doering's user avatar
3 votes
1 answer
11k views

Exporting coordinates of vertices to CSV

I have a .3ds file which I import into Blender. Now what I'm trying to do is to export the coordinates of vertices into a .ply file. When I export these vertices into a .ply file they are not ...
Peter H.'s user avatar
3 votes
1 answer
2k views

Generate video sequencer project from a script

I have a number of different MP4 files. I want to create a Blender project file that has these files in a set order and each video stream starting at a set start time. I know the files, I know the ...
Goldiiman's user avatar
2 votes
2 answers
2k views

Add toggle hotkey to custom checkbox

I have a self made checkbox in a script. Now I want to create a hotkey in the Input manager to toggle it. What I have done so far is to create a keymap item with ...
Tiles's user avatar
  • 2,018
2 votes
1 answer
6k views

Batch exporting scene collections or selected objects using glTF-Blender-IO

I'm still new with python and scripting. I tried editing the obj exporter that I found. Since I'm exporting tons of object groups, I need each of scene collection or selected objects to be exported as ...
EatCodePlaySleep's user avatar
1 vote
2 answers
3k views

Setting mesh's origin in python (2.8)

If I create a cube, the origin is originally at the center of mass. I know how to move the origin to the center of one of its faces using the interface, but how can I do the same thing via Python?
Dazotaro's user avatar
  • 901
24 votes
3 answers
18k 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 ...
stacker's user avatar
  • 38.3k
20 votes
4 answers
41k views

How to get Python multiprocessing module working on windows?

I am trying to run a script within Blender that utilizes multiprocessing module. According to documentation it is possible to use it ( see note at the end of "...
elmo's user avatar
  • 732
19 votes
2 answers
61k views

Set active object with python

I want something along the following lines: ...
clankill3r's user avatar
  • 1,139
18 votes
4 answers
26k views

How to make object A a parent of object B via Blender's Python API?

I have two objects each of them hold in a variable. Now I want to parent them so object A is the parent of object B. How can I ...
Miguellissimo's user avatar
17 votes
1 answer
5k views

How can I get a list of the installed addons using the API?

How can I get a list of the installed addons and the version number so I can print out and use as a simple reference when checking for updated scripts? I've looked at ...
askinner432's user avatar
  • 1,055
16 votes
1 answer
5k views

python get "image" of 3D view for streaming / realtime EEVEE rendering

[SEE Edit #7 at the bottom for official, final question] I know its possible to take a screenshot with python of a particular window (take screenshots programmatically in bge?), but is there a better ...
B''H Bi'ezras -- Boruch Hashem's user avatar
16 votes
3 answers
25k views

How do I select specific vertices in blender using python script?

I have created a plane and have applied loop cut and slide twice horizontally and once vertically( using python script). With this done, I intend to select the top two corner vertices using python ...
Gabriel's user avatar
  • 591
15 votes
2 answers
15k 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 ...
Craig D Jones's user avatar
14 votes
3 answers
4k 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 ...
ashwin's user avatar
  • 1,739
14 votes
2 answers
8k 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 ...
Tom Pace's user avatar
  • 273
11 votes
1 answer
7k views

Using python to set object shading to 'smooth'

So I wish to create and object and set it's shading to 'smooth' using python. It seems simple enough but after trying every method I could find on the internet none of them worked for me. Here's a ...
Jordan Abbott's user avatar
11 votes
2 answers
2k views

Blender 2.8 - Field property declaration and dynamic class creation

Now that we need to use field for property declarations in Blender 2.8. I was wondering how this can be done when creating class dynamically using type() like so: ...
Stan Paillereau's user avatar
11 votes
4 answers
18k views

How to completely remove all loaded data from Blender?

I'm implementing a Blender Python script to do batch conversions. It works like this: for each model file found in a directory: Import the model Process it Export in other format The problem is, ...
Fr0stBit's user avatar
  • 211
11 votes
2 answers
3k views

Rotation around the cursor with low-level python (no bpy.ops)

In order to optimize my script, I would need some help to perform a rotation around the cursor (see Rotate object around cursor with Python) With low-level python, that means, without ...
Salvatore's user avatar
  • 757
9 votes
2 answers
6k views

New window with Python API?

How to create a new window with a certain dimensions (for example 40% of screen size) using Python API? Functionality-wise similar to File > User Preferences — a new window shows up with User ...
Mikhail Rachinskiy's user avatar
9 votes
3 answers
5k views

How to get the 3D coordinates of the visible vertices in a rendered image in Blender

I'm new to Blender and python and here is what I need: I have a 3D model in Blender and I've set camera parameters to view a specified region of the model. The following is the rendered image: I ...
Debaditya's user avatar
  • 367
8 votes
3 answers
3k views

Access view orientation from python?

Is it possible to access the alignment of the view from python? (e.g 'TOP', 'FRONT', 'RIGHT',...
gandalf3's user avatar
  • 156k
8 votes
1 answer
13k views

How to link/append with a Python script? [duplicate]

I want to append an element from another Blend file by a script. I found the Blender operator bpy.ops.wm.append which should do what I want. However, the API documentation is a bit unclear: ...
Gaia Clary's user avatar
  • 3,712
8 votes
2 answers
3k views

When should custom-properties be used instead of 'bpy.props'?

Python has two ways to define your own properties. Via bpy.propsAccessible from data-editor, or via buttons defined in scripts: ...
ideasman42's user avatar
7 votes
1 answer
3k views

How to get Color and Z-Depth from Viewer Node?

I read some article how to get the z-Depth values from the Viewer Node. So i created a scene with a camera and a Plane with distance z=2. Then i tried to get RGB values and also z-Depth with ...
vtni's user avatar
  • 281
7 votes
2 answers
5k views

How to call invoke_popup?

I just can't figure out how to create a custom popup which can receive data etc. What I want to do is let the user select one of the currently selected UV-layers and just hand that back to me. So I ...
WorldSEnder's user avatar
  • 1,606
7 votes
4 answers
5k views

How to programmatically load a python script in Text Editor and launch it

With python API, is it possible to load a (new) python script in the Text Editor and then launch it (to automate things !) ? I try this but it doesn't work : ...
Lebrun's user avatar
  • 131
6 votes
2 answers
3k views

Python: assign custom tag to vertices

Is it possible to associate a custom tag with each vertex? I would like to be able to number them... I have an export script that dumps 6000 vertices to file, I then run a simulation that generates ...
P i's user avatar
  • 3,881
6 votes
1 answer
6k views

How to access node tree of a selected node group in python?

Scenario: I have these two node group instances "Test 1" and "Test 2" containing image textures. Now I would like to modify nodes inside of a selected node group in python. To ...
Steffen's user avatar
  • 71
6 votes
1 answer
5k views

Getting the list of points that describe a Curve without converting to mesh

I've used mathutils.geometry.interpolate_bezier() in the past to create points for a curve using the bezier handle and knot coordinates. from the docs: ...
zeffii's user avatar
  • 39.4k
6 votes
3 answers
6k views

how to display an image in blender UI with python?

is it possible to display an image within the blender UI interface ? let say that i want to display a 500x500px image in the N panel in layout.box().column(), how ...
Fox's user avatar
  • 1,872
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

1 2 3
4
5
51