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).
1,290
questions
2
votes
1
answer
966
views
How to save multiple blender scripts (text-files) at once?
I want to write a script that saves all the text files inside a Blender file. Is there a way I can access the text files as a list and then select them individually?
Heres my script so far:
...
2
votes
1
answer
253
views
How to use Python API to create an interactive parametric mesh?
I want to add my custom mesh to Blender. I already know about vertices, edges, faces, bpy.data.meshes, etc, but I can't figure out how to create an interactive ...
2
votes
1
answer
917
views
OSL Texture Mapping [duplicate]
I'm new to OSL and Blender. I'm using the following code to generate a circle on a plane. The plane, however, appears to be split into two triangles. Can anyone explain how to fix this so my OSL ...
2
votes
2
answers
856
views
how to make an object follow a curve with the same speed as another animated object
Say I have an object which has an animation.
I have another object which is constrained to a curve. I want it to follow the curve BUT I want it to do it at the same speed as the animated object.
...
2
votes
2
answers
477
views
Scripting: Displacement modifier visual update required
started using blender recently (>2.8), and in particular I'm trying to do a lot of work via scripting and the use of modifiers.
In particular, I'm generating a circle via modifiers, with a ...
2
votes
1
answer
631
views
Get operator command from context menu?
Here is what I need to do: I need to add a button to this context menu (the one you get when you right click on any button):
like the one I added here at the bottom. I am using this code from the ...
2
votes
0
answers
127
views
How to hide a panel that appears twice? [duplicate]
I'm making an addon where I added a panel to a popover button. See the following example:
Here we can see (in image number 2) a popover button in Shadows. This panel is shown only on this button.
I ...
2
votes
1
answer
678
views
Setup bones on cloth sim so that you can transfer it to Unity via FBX export
So, I would like to have this happen with a script for each vertice of an object:
I just couldn't to make it work :/ Except only some parts of it (scripts found from everywhere).
Building blocks:
Add ...
2
votes
1
answer
630
views
Script to view animation preview panel in fullscreen
Similar to this post:
How to make the sequencer 'Preview' area fullscreen with python?
I am trying to have my script set the animation preview window to fullscreen without any other panels/...
2
votes
1
answer
1k
views
Python script unable to import modules [duplicate]
I'm trying to follow the scripts from the book The Blender Python API by Chris Conlan, and I've been unable to import modules in Python from Blender (2.81) on osx 10.15.2. What file structure / ...
2
votes
1
answer
1k
views
How to Update NodeSocketString Value inside a node group in a attribute node using python
I have an Attribute node inside a node group, and for the node group inputs, I have created a NodeSocketString, Using ...
2
votes
2
answers
680
views
how to access Render Result image layers python
My active image in image editor is Render Result image.
How do I access the layer via Python (I need it to be set to ...
2
votes
1
answer
78
views
2
votes
1
answer
2k
views
Python Stop-Motion Insert Keyframe
I'm creating a stop motion animation that requires to Insert Keyframes of visibility. I was attempting to work out a script to make this process faster for me, but being new to python this has evaded ...
2
votes
2
answers
7k
views
add object at specific location with python?
This might be a really stupid question-I'm working in bpy right now and want to add a plane at a specific location...I know that How to add an object at a specific posistion in Blender Game Engine ...
2
votes
1
answer
1k
views
Set material strength and keyframes in Cycles with Python
I am making a piano song animation in cycles where in exact places (if a piano button was hit) the piano string lights up (Emission shader Strength = 5) then fades away (so go back to 0 Strength in ...
2
votes
1
answer
1k
views
How to force the update of a property in python?
I'm writing a function that should return the frame when a field reaches a certain value in the property window.
To be more specific here the function:
...
2
votes
1
answer
963
views
How to manipulate position of mask layer using python
I'm using Blender 2.78 and playing around with making different video transition effects. I want to automate the dynamics of a mask layer(rectangle as seen below) and it all work fine if I add ...
2
votes
1
answer
2k
views
Getting os.system to work in Python Console?
I do this in the Python Console in Blender 2.64 on Ubuntu 11.04:
...
2
votes
2
answers
673
views
Difference between variable and property scope in a script
My __init__.py script creates a panel that lets a user select the figure (typically a humanoid figure imported from Poser) she wants to give shaders to, defines the ...
2
votes
1
answer
2k
views
Get the transform matrix for each frame
I'm new to scripting inside blender (two days). I have a camera folowing a path (a circle).
I have written the following code to get the location and rotation for each frame and write it to a file:
...
2
votes
2
answers
873
views
How to make the sequencer 'Preview' area fullscreen with python?
How do I, with python, select the sequencer area which has a view type as preview, to make it active/context? (And not select the "strip" window)
EDIT: My overall goal is to add a windowless, ...
2
votes
0
answers
1k
views
Import STL and render image
I am not very familiar with blender, more of a python programmer trying to use blender headless.
I want to import an STL to a scene and render an image from different angles. So I botched a code ...
2
votes
1
answer
1k
views
2
votes
1
answer
204
views
Python script - apply only to selected
Is there a way to tell the script to only apply the changes (moving keyframes in this case) to selected object(s)?
Here is the specific code I'm trying to modify:
...
2
votes
1
answer
397
views
Extracting a text string info (character's indices) to use it as a material mask
I think an image can say more than words sometimes... :)
The idea is to use a different color from the color ramp for each character in the string.
It's related to this question
2
votes
1
answer
980
views
Align object to view with Python
I was trying to a add a plane primitive using Blender Python and aligning it to the viewport.
I already tried setting align_view = True when adding it via Python, ...
2
votes
2
answers
2k
views
bpy.data.libraries.write not working?
I want to save selected objects into a separate .blend file in 2.8.
https://docs.blender.org/api/blender2.8/bpy.types.BlendDataLibraries.html
suggests:
...
2
votes
1
answer
3k
views
Opening a blender file during python script execution without changing context
During execution of a python script, I'm trying to import a .blend file. It's currently not an option to load the file when Blender boots, although ideally we would get the same result either way. I'm ...
2
votes
1
answer
2k
views
Blender how to periodically reload file (python)
I'm trying to write script that will automatically reload file every few seconds. In order to do that I wrote following plugin:
...
2
votes
2
answers
1k
views
Set object origin to minimum Z (set to floor) (using examples from @TLousky)
I'm working off examples found here:
Getting global axis value of the vertex with the lowest value
(and other from @georges and @tlousky, many thanks!)
I'm working off a csv example and an 'set Z ...
2
votes
1
answer
834
views
Blender function to transform a selected edge along a custom axis
How blender is Setup:
In Blender I have created a triangle and extruded it. Selected an edge and created a new transform in the UI and named it "Edge.001" it is currently active. Now I have selected ...
2
votes
1
answer
2k
views
View3D operations problem [duplicate]
Currently i am trying to change the viewport of the 3D View window using a python script. I am using this function
bpy.ops.view3d.viewnumpad(type='TOP');
But it ...
2
votes
2
answers
1k
views
Batch Selected to active Baking
I have to bake several objects, in combined type. Each (lowpoly) object take baking information from a selection of another (highpoly) object(s). Here is my bake panel config:
My problem is that i ...
2
votes
1
answer
898
views
Rendering video sequence editor by scripting
I'm trying to render all individual strips that I have in the video sequence editor in separate files automatically.
I started this script:
...
2
votes
1
answer
1k
views
How to define customized property in Material?
I'm working on my addon for Blender, which is a simple offline renderer.
I'm stuck at the material system for two days.
I would be much appreciated if anyone gives me a pointer.
The issue is that in ...
2
votes
2
answers
10k
views
How to set camera location in the scene while pointing towards an object with a fixed distance
I want to position the camera around an object using Blender's Python API. Assuming that an object is centered at (0, 0, 0), I want to move the camera around it ...
2
votes
0
answers
3k
views
Creating a generic IK/FK snap script
I've tried deconstructing the Rigify addon to isolate the script part that handles IK/FK snapping, but so far I've had no luck. Rigify is a very nice tool, but I'd like to get the snap functionality ...
2
votes
1
answer
1k
views
How to project back rendered depth maps to recover the ground-truth 3D shape using Blender?
You can discard the images I have uploaded and can simply use some camera angles of your choice to render depth maps of a 3D shape and then fuse the rendered depth maps to recover the underlying 3D ...
2
votes
2
answers
1k
views
move object without changing origin
I have an armature which has its origin at 0,0,0. I want to move the armature so that the lowest zvalue of it's bounding box is placed at 0,0,0 using python as shown below without changing the origin, ...
2
votes
2
answers
1k
views
Encoding Vertex Position into Vertex Colors
I got a model in -1 to 1 space and I want to encode each vertex position into the the vertex color for future use. There seems to be nothing by default to do that so I will have to use a custom script ...
2
votes
1
answer
884
views
frame_change_pre.append(handler) doesn't work
I wanna run a function each frame. So I create a new script and type in the following:
...
2
votes
1
answer
411
views
constraining object to a triangle plane
I've been looking all over the place and I can't seem to find the right constraint for this. I have a circle that needs to be constrained to a triangles area.
Limit Distance Constraint doesn't seem ...
2
votes
2
answers
2k
views
Can't get script to auto execute [duplicate]
I am an experienced python programmer, but just getting into the Blender API. I am stuck on trying to get a script to execute when the Blender file is loaded. I want to do all sorts of setup in this ...
2
votes
1
answer
1k
views
Creating a new particle texture using python scripting
How would I create a new texture for a particle system? I tried bpy.ops.texture.new() but that wouldn't create any type of texture.
2
votes
1
answer
477
views
Calculate surface by logarithmic function?
Is there any way to use the log() function in order to calculate the surface of a mesh?
2
votes
1
answer
1k
views
Using Python, how can I preset points in ShaderNode RGB Curves?
I have referred to
https://blenderartists.org/t/how-to-modify-rgb-curve-nodes-in-compositor/503936
hoping the technique would be same or similar for shader nodes.
I have also checked
Is there a way ...
2
votes
1
answer
350
views
Render subsection of frame
I'm hoping to be able to render frames of an animation where I render slices that are set to different points in the animation. This effect could easily be achieved in after effects but the render ...
2
votes
1
answer
3k
views
How to execute an operator from an EnumProperty?
I have a simple EnumProperty with let's say two buttons. Now i want to create a primitive with one of the buttons. But a click at the button does nothing. There is a bit missing. The operator needs to ...
2
votes
1
answer
850
views
What is the space used by Scene.ray_cast()?
This is the complete 2.8 documentation for Scene.ray_cast
ray_cast (view_layer, origin, direction, distance=1.70141e+38)
Cast a ray onto in object space
...