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
3
votes
2answers
139 views

Same Material with different key frames

Is it possible to have same (single) material object applied to different objects (mesh or curves) but have different key frames for each (mesh or curve)? I want to fade-in my text (which is curve) ...
3
votes
3answers
473 views

Pin cloth vertices at a specific set of frames, and un-pin otherwise (in python)

I am using Blender 2.82a and am trying to pin cloth vertices only at a specific set of frames. The broader context is to simulate actions on a cloth, where each action is parameterized by a cloth and ...
2
votes
1answer
475 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 ...
0
votes
1answer
492 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 ...
10
votes
2answers
8k views

Exporting UV coordinates

I'm having massive trouble exporting UV coordinates from Blender. I'm using the following code: ...
8
votes
4answers
13k 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 ...
5
votes
2answers
2k 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: ...
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 ...
7
votes
2answers
11k views

Understanding the Cycles 'Script' node

I've finally found a good example on the internet for a problem that I had in Blender, but it is made by the text window that looks like this - And then it makes a result like this - And it is ...
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'...
10
votes
2answers
4k 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 ...
7
votes
2answers
4k views

How to run a python script at regular intervals?

Is it possible to run a script every few seconds or so, while letting the interface update in the meantime? How can I do this?
7
votes
1answer
2k 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 ...
5
votes
1answer
2k 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 ...
4
votes
3answers
1k views

Rearranging elements of a panel

Is there a way to edit the position or hide some elements of an existing panel ? I know I can edit space_view3d.py but I prefer to do it properly. right now i'm appending some labels and they appear ...
4
votes
1answer
2k views

How to add points to a grease pencil stroke (or make new one) with python script?

I want to draw script-calculated curves with the grease pencil. Using this line of python I'm able to redefine the points of an existing stroke, shown below. So far I can't add a point like this: <...
5
votes
2answers
3k 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 ...
4
votes
2answers
3k 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: ...
3
votes
1answer
273 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 - ...
1
vote
2answers
1k views

Fast keyframe insertion

I noticed that every time I insert a new keyframe on an object using the Python API, the insertion takes more time. Here are some timings of a keyframe insertion: 1st keyframe: 0.0176 ms 10000th ...
15
votes
3answers
1k views

Add a custom curve mapping property for an add-on?

Question The title says it all. I want to be able to make this in Blender's UI, and sample it at specific points from an add-on: Problem There is very insufficient documentation on this, and I can't ...
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...
9
votes
1answer
5k 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 ...
6
votes
4answers
876 views

How can I sort vertex positions sequentially indices in a closed area?

I need to sort the vertices sequentially to make an effect, something like this video. I know I should draw them by hand, but sometimes when I subdivide edges, vertex indexes will change. The vertices ...
5
votes
4answers
3k views

How to extract/convert data from blender cache files .bphys into a human readable form via python

I am trying to extract position, velocity and rotation data from smoke simulation cache files .bphys. i have been attempting to convert the .bphys file into a more human readable form via python. ...
3
votes
2answers
1k views

How to set a random value for multiple shape keys?

My question is related to my previous asked one: How to set a specific value for multiple shape keys? I have about 300 shapekeys and want to set the random value for all of them . How to do it using ...
0
votes
2answers
591 views

How to add and use renamed Mirror modifier with Python?

In this code for 2.8, that works, I am creating a mirror modifier assigned to a cube. ...
7
votes
1answer
441 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 ...
4
votes
1answer
755 views

How do I get invoke_props_popup to work?

I'm trying to get invoke_props_popup to work. But my code produces this error: ...
3
votes
2answers
1k 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 ...
2
votes
2answers
1k views

Search custom properties in objects on the scene (Python)

Is it possible to somehow search all objects on the scene which have a custom property enabled using prop_search? I know how to do this with dynamic EnumProperty but it seems to be not an option as ...
2
votes
2answers
743 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 ...
1
vote
1answer
674 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 ...
1
vote
2answers
537 views

How to trigger LMB click events to activate a specific View node and update contents of 'Viewer Node' image data block using Python?

I am using two Viewer nodes to directly access pixel values of the rendering through bpy.data.images['Viewer Node'].pixels.I want to access the outputs of both of ...
1
vote
1answer
841 views

How do I display a property in the viewport without using a modal operator? [duplicate]

I want to display a property in the viewport without using a modal operator. is it possible? I found this, but I did not understand how I can use (I started with python).
32
votes
2answers
4k views

Techniques for modeling a network of blood vessels

If you've ever seen anything like Body Worlds or the Bodies: The Exhibition you'll know how they dissect individual organ systems and put them on display with a technique known as plastination. For ...
21
votes
3answers
14k views

Blender rendering automation (build script)

I would like to automate the proccess of rendering images (sprites). What I want to do is to render an image of the same model with different textures, ideally the texture filename would be passed as ...
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, ...
11
votes
1answer
2k 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 ...
10
votes
2answers
4k views

Getting the active region

How can I get the active region (i. e. the region the mouse pointer is over and keystrokes are sent to) with the Python API? Background: I want to manipulate the view_matrix of the region the mouse ...
9
votes
1answer
6k views

Running a script for each frame

If there is an object which has a property that which varies with each frame, would it be possible to to build a script that can access that property before each frame is rendered and thus change ...
4
votes
2answers
2k 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 ...
16
votes
1answer
12k 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 ...
9
votes
3answers
2k views

PyNodes API: transferring data between nodes with sockets

I'm developing a custom NodeTree using the PyNodes API (on Blender 2.70) for scientific analysis and am having trouble choosing the best way to transfer data between nodes via sockets. Right now I ...
9
votes
2answers
4k views

How to toggle to camera view via python?

Is there a way to programmatically achieve the same thing as pressing the 0 key the numpad?
3
votes
1answer
2k views

How can I change a custom property value in python? AttributeError: Writing to ID classes in this context is not allowed

I have a simple panel that I've made. I have a bunch of checkboxes and I want to use them to change the value of a few custom properties e.g. when the checkbox is unchecked, the value should be 0, and ...
8
votes
1answer
11k views

Adding Named Objects in Blender with Python API

Motivation: I would like to add multiple empties with sequential, but meaningful, names using the Python API with Blender. Issue: I cannot name the objects as I add them. Question: What can I add to ...
8
votes
2answers
5k views

AttributeError: '_RestrictData' object has no attribute 'filepath'

I'm working on a small post-save-hook, which is working pretty nicely only if the file is saved first and then the script is loaded later on. If I install my addon from the file and I save the ...
7
votes
2answers
4k views

Draw points on screen with bgl? (python)

I'd like to use bgl to draw dots points on 2d screen from 3d vertices in scene. I have lines working by using bgl.GL_LINE_LOOP but I couldn't find the full list of <...
6
votes
4answers
1k views

Sorting Collections Alphabetically in the Outliner

I have numerous objects categories that I used to organize in Groups through a script in Blender 2.79. I'm now trying to switch to blender 2.8 and use collections, but in the outliner the only ...

1 2
3
4 5
21