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).
6,380
questions
1
vote
1
answer
2k
views
How to create many properties at the same time using list/arrays
I want to create some integer properties using loops just to save time and lines of code. So basically, the new properties should be something like this:
...
0
votes
2
answers
1k
views
Modal Operator Fixes
I am studying Python programming for Blender and recently started dealing with modal operators. The question I have is: There is a double call from the event of the modal operator for key-up and key-...
1
vote
0
answers
57
views
Typing in a game?
I made my own little... I guess one could call it a pictogram sort of language?
I want to be able to type it in a blender game, I've already made all the characters/letters but I'm not too sure on ...
1
vote
1
answer
332
views
Detect a Blender Keyboard Shortcut
How would I detect a Blender keyboard shortcut in edit mode? I'm trying to detect the merge operation (Alt+M), but I don't want to change the shortcut of anything, just execute a function at the same ...
7
votes
2
answers
5k
views
When declaring a panel, what does the 'bl_context' value need to be?
I'm confused about how to declare a panel.
I've tried to write a simple panel but it doesn't work:
...
2
votes
1
answer
1k
views
How do i create Palette UI object
I am trying to create a type bpy.types.UILayout.template_palette in my bpy.type.Panel.
In my ...
0
votes
0
answers
1k
views
Why do I get a invalid syntax error on this statement?
The script was working fine, until I added the screech.volume property. I didn't edit the 'if' statement in any way, but somehow I get this error on the line of the 'if' statement:
...
1
vote
1
answer
596
views
Change sequencer image strip filename through python
i'm trying to access and change the filename of image strips in the sequencer for a little addon i'm developping, but i'm stuck with invalid syntax, i think, and i can't find the correct way to put ...
3
votes
0
answers
210
views
Scripting an "open image" button input for image/env. textures?
Is there a way to script out a normal image/environment texture node with the exception of an "open image" button input that can be plugged into a node group and have that button actually be displayed ...
0
votes
0
answers
514
views
Python how to detect mouse click on 3D view
I Want to simulate pressure sensitivity based on mouse speed, but need a way to detect a mouse event and call a method to change the brush strength.
something like this:
...
4
votes
1
answer
21k
views
Blender 2.78 .obj import via script [duplicate]
So is importing .obj in 2.78 via script broken, or am I not doing it right? It's crashing on import in my script when I try and reference the object at all.
...
0
votes
1
answer
207
views
How to assign a specific color scale to all specific objects in the scene
I have some meshes in the scene (7 mesh objects for example). I want to assign each object a color. The color should vary in a specific scale. For example: green scale. So, first object has green ...
3
votes
1
answer
2k
views
How to reset all properties to their default values in a custom made User Interface Panel
I have created a UI Panel with some properties of type IntProperty().
bpy.types.Scene.myint = bpy.props.IntProperty(name="My Int Prop", default=9)
How can I ...
0
votes
1
answer
254
views
Auto-execution Cycles Node Trees
I have noticed that Blender doesn't redraw changes in Cycles Node tree when they made with Custom Property via scripted Drivers. I need run animation to see changes in real-time, but it isn't handy ...
3
votes
1
answer
3k
views
Move object to mouse position using python?
From top view(orthographic), I'd like to be able to click in the 3D view and move an object to where I clicked. I know I have to do this in a modal operator, what I need to know is how do I convert ...
1
vote
1
answer
1k
views
How to Programatically Render Multiple Times with Different Materials each
I have an animation about 170 frames long (not important).
In the animation I have Balls with a certain Material on them (UV map).
I'd like to have this Animation rendered 100 different times - each ...
1
vote
0
answers
408
views
How to draw(bgl) line while clicking point to point
I'm trying to figure out how to draw lines like the Carve addon's Line option. It starts by left clicking, and it adds a dot. Then it stretches a line to the next spot you click. I want this exact ...
1
vote
1
answer
2k
views
Sort a list of objects by their distance from a point
I have a list of objects like this [bpy.data.objects["Text.002], bpy.data.objects["Text.003], bpy.data.objects["Text.005], bpy.data.objects["Text.007]]
how can I ...
6
votes
2
answers
5k
views
Select object and recalculate normals via script?
I have a script that allows to import and export .obj files which is working fine. However, I'd like to perform some operations in between these calls, for example ...
3
votes
2
answers
421
views
Is there a way to make a game splitscreen in BGE
I want to make a 2 player game but I need it to use 2 cameras. Sorta like an fps. I'm not great with code, any help?
0
votes
1
answer
269
views
What's The Library Blender Uses to Draw?
ok, I tried to use PIL library in blender to render Particle system just by drawing circles in given locations, but this is not a good Idea, it takes much longer than expected, but the worst thing ...
1
vote
2
answers
978
views
How can I make a dropdown box of materials and run code when one is selected?
How would I go about making a property box that contained all the materials in a scene (in a Toolshelf (T) panel for example) and is able to pass the material in the list to another operator that ...
2
votes
1
answer
329
views
adding effect strip using script
I'm trying to construct a script to step through the active scene and:
1) find all the movie strips that the audio doesn't match the corresponding movie length
2) then add > effect strip > speed ...
4
votes
1
answer
3k
views
How to order a list of vertices based upon position?
I have a list of vertices:
But the list looks like this: [0, 1, 2, 3, 4, 5, 6, 7].
I need a script to sort the list to be like the order in the loop itself: ...
2
votes
2
answers
5k
views
FBX vertex weight import problem
I am getting a distortion with a rigged mesh due to the way that Blender imports FBX files. This is due to some kind of loss of accuracy that occurs while importing the vertex weights.
Here is a ...
2
votes
1
answer
1k
views
get all sequencer strips in python
Hello all blenderheads !
i'm trying to make a little script to collect then relink all sequencer strip in a blend file, i'm currently getting something, but only in the active scene, i can't get it ...
1
vote
1
answer
530
views
Pie Menu Box Overlapping Python Question
I've been trying to clean up a pie menu I created. As you can see from the screenshot, my menus overlap. I'm not entirely sure what options are available to me, I've created this looking at other ...
0
votes
1
answer
275
views
operator_enum of object.mesh_add and object.empty_add is displayed unexpected
i'm writing an addon, that's simplifying the ui of blender dynamically for mesh-editing only purposes. So i want to simpify the add-menu of the 3d-view. But there i've the Problem, that if i uses this ...
6
votes
0
answers
3k
views
How to change animated object's origin without ruining animation?
For example: I have a character and a spoon which he is holding and moving thanks to child of constrain. My character releases the spoon a little bit above a plate. So I came up with idea to use rigid ...
0
votes
1
answer
793
views
How to map/project bone coordinates to camera coordinates sytem/view?
I need the bone-head coordinates to be mapped on to the camera view. Actual scenario is to obtain the 3D coordinates of bone/joint. This is how I do it now.
...
0
votes
0
answers
151
views
Move all source data in a blend file to another folder
I have a .blend file with many movie strips, and movies inside meta strips, pointing to source files at say directory x
1) Does Blender have a way to change all the references to directory x to ...
11
votes
5
answers
11k
views
Batch rename objects with number sequence?
Is there a way to batch rename objects in a sequence similar to: object1, object2, object3...? Where 'object' would be any custom name?
I found the batch rename datablocks script and it was really ...
0
votes
2
answers
487
views
Moving a movie strip into next free channel
If a script tries to move a movie strip to a channel that is full, does the script abort with an error?
Is there a flag I could use, to increment the strips channel so it moves the strip to the next ...
1
vote
1
answer
192
views
move clip to next empty channel script
I have 10 to 20 movie clips on a single channel in the VSE.
1) Is there a way to distribute each clip to its own individual empty channel?
2) Keep the clips start point and extend the end points to ...
0
votes
1
answer
1k
views
Extrude to particular position
I use blender for 3d printing and often want to move vertices or extrude faces to a particular point.
For example
I have a face at the y coordinate 3.47. After selecting that face I often find I ...
3
votes
2
answers
2k
views
Blender Read Only Properties
Is there a way to check whether or not a Blender RNA or ID property is "Read-only" in python?
3
votes
2
answers
5k
views
Invalid Python expression when using driver with Python script
I'm trying to use a python script as an expression in a driver. It was working fine at first and then all of a sudden I get the error message ERROR: Invalid Python expression.
I've tried running the ...
1
vote
1
answer
3k
views
What is a more Pythonic way of setting the value of multiple attributes?
When a custom property is updated, this function is triggered and changes the boolean value of all the 10 others. It's a long and dirty code... is there better way to do it ?
...
1
vote
1
answer
189
views
Issues with manual culling, using BMesh
I have a camera and a monkey (suzanne) in the scene. I'm attempting to manually cull the back faces from the monkey.
The problem is that certain faces get culled, despite its normal seen from the ...
1
vote
1
answer
282
views
Custom mouse jumps to center when it reaches the edge of the game window
Recently, I've started teaching myself Blender Game Engine with video tutorials. Mostly I utilize Logic Bricks, but I'm attempting to branch out into Python scripts.
I have successfully created a ...
0
votes
1
answer
2k
views
Adding keyboard shortcut to a blender script
I know it's probably not the most elegant, or even a usable, solution, but is it possible to use a keyboard shortcut, say pageUP in a python blender script?
OR find out the code behind the shortcut, ...
0
votes
3
answers
2k
views
How to fix a disappeared addons tab in user pref. menu?
I was watching a video on how to script an addon. When I loaded my script, the addons tab menu disappeared. In the script in the bl_info properties I deleted the
"warning": "",
"wiki_url": "",
"...
0
votes
1
answer
218
views
Place colored line as texture
I am trying to create a folded paper like object using Blender. This is something I've created. Now, I want to color edges of the paper and the creases of the fold. Like if the crease is downwards I ...
0
votes
1
answer
2k
views
Rotate Pose Bone by world coordinates
I have the following information from an object: Rotation in degrees (absolute world coordinates) and position in absolute world coordinates.
My goal: to set the position and orientation of a pose ...
3
votes
2
answers
2k
views
Automatically Scale and Export All Files in Directory?
Is there a way to go through every .blend file in a directory and do the following with each:
Open the file.
Move the cursor to 0,0,0
Enter edit mode (there is ...
-1
votes
1
answer
512
views
Python, why is the enumerated list not changing the object in 3D View Property Shelf, while it's working in the Tool shelf
I wrote the following script to test creating a new panel in the properties shelf in 3D view (the one that toggles visibility using N).
The script is working for creating object, but the enumerated ...
1
vote
1
answer
350
views
Using a hint/information-bar like the trasformations are using
The transformation-operators of blender are showing some hints/informations on the header of the 3D-View. This hints/informations are replacing the default layout-elements of the header (...
0
votes
1
answer
237
views
how to manipulate objects using Seed button in real time
I cut a mesh into some random (N number) shapes. I also used random.seed(). So every time I run the code, I get new set of patterns.
Now, I want to do it with "UI Panel" with some variables as input ...
2
votes
1
answer
61
views
loop works only for 4 frames any idea why?
I'm trying to use scripting to create jumpy cone for fire purpose, and the loop works only for 4 frames, any idea why? Thanks in advance
...
6
votes
2
answers
12k
views
How to add modifiers using python script and set parameters?
I've found some code that could add a modifier but none can set parameters like Octree.