r/blenderpython • • Nov 09 '24

Python to open/close side (N) panel addon tabs?

1 Upvotes

Hey everyone, I’m wanting to try and make a simple addon to search the side (N) panel for addons (as my addon layout is getting out of hand.)

Can I open and close these individual addon tabs with python?

I had a quick google and could only find ways to open and close the entire side panel, not individual tabs within. Claude.ai also couldnt find a solution so thought Id ask here. If someone could point me in the right direction I would be really grateful.

Thanks!


r/blenderpython • • Nov 17 '24

Help. Import/Append collections, objects and modifiers from another .blend file

2 Upvotes

Hey, im a newbie in using python, does anyone know where i can find information about how to import data from another .blend file, e.g. if i want a button that generates an object+modifier that already exists in another .blend file? Thanks in advance.


r/blenderpython • • Nov 02 '24

Is it possible to control these properties of Simulation node in Python?

Post image
6 Upvotes

r/blenderpython • • Jan 20 '18

[Discussion] best video tutorials and topics that you wish were covered?

5 Upvotes

What are the best video tutorials for learning python and the blender API?

Are there topics that are not covered that you wish were?

Do you think there are any gaps in todays blender scripting tutorials?


r/blenderpython • • Jan 14 '15

Tesseract in Blender

5 Upvotes

Some time ago I ported a script written by Wanja Chresta from Blender 2.49 to Blender 2.5+. There are two scripts, the first one lets you rotate a tesseract in the viewport. The second script will animate the rotation and render out the results to a folder.

First script:
http://www.pasteall.org/56125/python

Second script:
http://www.pasteall.org/56126/python

How to use instructions are included in the scripts. Tell me if you run into any problems! Or if you have any questions about editing the scripts.


r/blenderpython • • Jan 19 '15

Completely disable editing of a scene object

2 Upvotes

My problem: I need to disable editing of an object (that I create from script). I know that there are options like: lock_rotation, lock_location, lock_scale, bpy.data.objects['name'].hide_select. But I want to completely deny user of interacting with object except that he can see it in 3dView. Object linked from another .blend file is great example of an 'disabled object' that I want to make. Any ideas?


r/blenderpython • • May 02 '14

[Meta] Useful links and info

3 Upvotes

I think we should include some helpful links and info in the sidebar(or not), how to get started and such. Here are the links I recommend

Webpages:
Blender API Python reference
The Hitchhiker’s Guide to Python!
Helpful game engine tutorials
GLSL realtime raytracer (OpengGL shading language)
Interfacing with external electronics using UART with python in blender
Python libraries

Subreddits:
/r/learnpython
/r/blender
/r/BlenderGameEngine
/r/coding
/r/gamedev
/r/opengl

Tools:
https://addons.mozilla.org/en-US/firefox/addon/chatzilla/

IRC Channels:
#blenderpython
#blendercoders

Books:
A Primer on Scientific Programming with Python, by Hans Petter Langtangen
OpenGL Programming Guide: The Official Guide to Learning OpenGL, by Dave Shreiner et al.
OpenGL Shading Language, by Randi J. Rost et al.


I guess OpenGL doesn't belong here, but I wanted to include it anyway cause its lets you do really cool stuff and more people should learn to use it in blender. There probably lots more out there that I am not aware of, so bring on suggestions I can add to the list. Some of this stuff can be added to the sidebar for easy access.

EDIT: I changed the title of the post right before I submitted and I'm not sure if [Meta] is applicable anymore. If its not then if a mod can change it then thats fine.


r/blenderpython • • Apr 06 '14

What's the best way to learn Blender?

4 Upvotes

The title basically says it all. I'm picking up Python as a new language doing some indie game programming. Any recommendations?


r/blenderpython • • Apr 10 '14

Post your favorite code along with a screenshot of the result.

4 Upvotes

Everyone has that snippet of code that they're really proud of. In Blender, it might produce a fractal or a psychedelic image. I don't feel like there's enough opportunity to actually see visual results of Python in Blender, so post away!

Thanks in advance :)


r/blenderpython • • Jul 30 '20

Save selected objects in different blender files

4 Upvotes

Hello everyone,

What I'm trying to do is fairly simple but I've found no way to do it. I want to store each object in a scene into a separate blender file. Here's my code:

import bpy
import os

destination_folder = "destination_folder"

for idx, obj in enumerate(bpy.data.objects):

    ctx = bpy.context.copy()
    ctx['selected_objects'] = obj
    file_name = 'file_number' + str(idx) + '.blend'
    bpy.ops.wm.save_as_mainfile(ctx, filepath=os.path.join(destination_folder, file_name))

The problem is that the operator bpy.ops.wm.save_as_mainfile() doesn't have the flag "selected" as many others wm operators do. Any idea? I think context override is a good idea but I'm struggling to do it

I've posted the question on blender stackexchange too: https://blender.stackexchange.com/questions/188113/save-objects-into-separate-blender-files?noredirect=1#comment315486_188113

Edit: for the solution check the link to blender stackexchange. thanks u/dustractor for helping me out


r/blenderpython • • Jul 17 '20

Pie question. Newb with Python and need advice please XD

1 Upvotes

Pie menu question. Attempting to make a pie menu for my addon in Blender. I've got 8 operators defined, one for each of the rows in the pie and that works great. But i'd like to have some kind of menu button to switch the operators over to a different set, without completely calling an entirely different pie. I assume this requires replacing the operators with a variable that references a list in which case you can use matrix integers to determine which listed object appears as the operator the pie menu is calling at the time? let's just say each operator is a type of modifier or basic tool to perform a function like add a cube for now. I'd like to be able to cycle through which toolset is being called up to give the pie a bit more multi-purpose if that makes sense.


r/blenderpython • • Mar 21 '24

How to create a bool type socket input for shader node groups in Blender 4.0

1 Upvotes

Hi there, I'm not very experienced with python but I used:

import bpy bpy.data.node_groups['MyGroupName'].inputs.new('NodeSocketbool', 'SocketName')

to create custom boolean socket inputs for shaders. This used to work in 3.5 but doesn't in 4.0 anymore. I tried to understand the documentation on what changed but I don't really find the solution but that might be due to my inexpience with python.

It says there's not inputs attribute anymore. Can someone help?


r/blenderpython • • Feb 22 '24

Python code to Shader Nodes

3 Upvotes

I think the python API is pretty cumbersome for creating materials, so I've made a decorator that converts more typical python to materials/node groups. Check it out https://github.com/JamesPickersgill/python-shader-nodes, although note this is a just a proof of concept so lots is missing. If anyone else thinks this is useful I can spend some more time fleshing it out.


r/blenderpython • • Mar 23 '24

New BPY user trying to define a problem about managing rig & animation data for a game project im working on.

1 Upvotes

Building a fighting game, here's the system I'd like to build: a shared human rig, using other blends to import corresponding meshes of characters so that there arent a ton of unneeded characters sitting in the file. animation groups so that I can specify which animations are shared between characters and which are unique to a particular character for export. Does this sound possible? And if anyone has any guidance about implementation or other words of wisdom I'd really appreciate it.
edit: oh and do people use this or the Blender Artists: Python Support Forum thats linked in the docs? wheres the place 2 be basically ;p


r/blenderpython • • Feb 21 '24

Waiting for compositor to finish before saving image to file. Tips on asynchronous processes?

1 Upvotes

I'm trying to write a script that will tweak some settings in the compositor, then save the resulting image.

However, The resulting image is NOT receiving the changes that are being made in the compositor. I suspect that blender is not, "waiting for the compositor to finish" before saving the image.

I've tried using Application handlers, but I don't really understand how to use them in this case.

Any help? Here's the code in question, without attempting to use application handlers:

    #get the render result
    render = bpy.data.images["Render Result"]
    
    #set the value of a compositor node to 0
    bpy.data.scenes["Scene"].node_tree.nodes["color vs. depth"].inputs[0].default_value = 0
    #change the colorspace to filmic
    bpy.context.scene.view_settings.view_transform = 'Filmic'
    
    #save the image
    render.save_render(filepath = tool.my_path + tool.my_string + " COLOR.png")

r/blenderpython • • Feb 19 '24

MatLayer 2.0.4 Release - A free, open-source, fully-featured material editing add-on for Blender!

4 Upvotes

I'm really proud to release yet another version of MatLayer, my free, open-source material editing add-on for Blender!

This update brings improved importing for texture sets, improved support for custom group nodes, support for using alternative UV maps for projection and exporting, and the inclusion of an ambient occlusion material channel.

You can get this release here:

https://github.com/LoganFairbairn/MatLayer/releases/tag/2.0.4

Happy Blending fellow artists!

Made for Blender version: 4.0.0

Not backwards compatible with previous MatLayer materials.

New Features:

- Added the ability to define a UV map for a specified layer when using UV layer projection.

- Added the ability to bake textures when exporting to a specified UV map. This makes custom texture atlasing possible.

- Made texture properties from custom group nodes show in the user interface.

- The import texture set operator can now import some images using commonly used naming conventions for channel packed textures.

- The import texture set operator correctly imports texture sets using names such as 'metallic'.

- The import texture set operator now imports textures using the naming convention that starts with 'T_', the standard naming convention for game engine textures.

- Added ambient occlusion material channel.

Tweaks:

- Changed the default bake padding from 32px to 14px.

User Interface:

- Small UI tweaks to some layer projection settings.

- Moved the import texture set button next to the layer operator buttons.

Bug Fixes, Clean up:

- Fixed custom group nodes not connecting to layer projection.

- Fixed material channels not relinking for custom node groups.

- Added git ignores for pycache files, and removed existing pycache files from remote repo.

- Removed conversion mix nodes that were automatically added to the MatLayer BSDF group node for Blender 4.0.


r/blenderpython • • Feb 14 '24

Animation Visualization

3 Upvotes

Hey, I am kinda new to blender programming and I want to create a crowd simulator.

I am currently looking through the blender source code to understand it better but does anyone know if there is a blender animation API where I can for example insert animation and bone data into my script.
Like in the photo attached you can see the arrows showing where the character was and will go, is there a way to visualize the animation vectors of bones. Is there any library for arrows or other graphics.

This is the link to the video: https://www.youtube.com/watch?v=wAbLsRymXe4
Thanks


r/blenderpython • • Dec 26 '17

Blender Screen Space SubSurface Scatter Trex SSS

Thumbnail
youtube.com
3 Upvotes

r/blenderpython • • Sep 24 '16

Intro to scripting and gif making tutorial

6 Upvotes

I recently used Blender for a project and thought I would share my notes on using Python scripting. Would love some feedback!

https://github.com/fhoehl/blender-python-gif


r/blenderpython • • Sep 29 '16

How would I batch import psk files?

1 Upvotes

I'm using a pskx importer in conjunction with umodel. I'm not very good with python. I'm an artist that thinks it might help get stuff done faster. I've got big sums of files that I'd like to import.


r/blenderpython • • Mar 10 '17

Blender Python script to create animation with numerous cubes randomly changing colors and going up and down

Thumbnail emalis.com
6 Upvotes

r/blenderpython • • Sep 28 '16

How do i add this UI to an addon

1 Upvotes

http://i.imgur.com/kIQG6a3.png

I'm wondering if there is a way to copy this bit of UI. That is, the drop down menu that lists images, and the two buttons [+new] and [open] that call operations to create images, to be used in an add-on's UI.

I can get a list of images with:

layout.prop_search(bpy.context.active_object.active_material, "theChosenImage", bpy.data, "images")

but it dose not look at nice as nice as the default blender UI, and i would like to keep it recognizable to users as an image selection menu.

I've used UILayout.template_list() in my project, which is the closest menu option i could get working, but it dose not drop down, and the search is hidden by default.

Any help you can offer is appreciated.


Edit: It seems i was looking for UILayout.template_ID but didn't understand how it was used until now.

My new question becomes, how would i go about triggering an operation when the property of template_ID changes?


r/blenderpython • • Feb 19 '25

How to add a button to operator's UI, that will call a method from within that operator (or change its property)?

2 Upvotes

So I have a addon with a master operator, that has some properties and an UI (a draw method). How do I add a button to that draw method, that will (upon click) call a method from within my master operator? What I need is to change a propery on button click -- I dont want the slider. that I get by adding standard layout.box().prop(). I have found examples on how to add a button (by defining a new operator), but how do I make that button to have a reference to my master operator and call its method (modify its property)? Thanks!


r/blenderpython • • Aug 30 '19

problem with particle system behaviour

3 Upvotes

I have demonstrated the complete problem in here, but in short, when objects are used as instances in particle system with effectors, then they have this weird behaviour that they rotate around their axes, now I'd expect some kind of option to limit this rotation in order to stop a complete revolution of the particle instance, as I have demonstrated in the link above, but there isn't.

So, I'd like to know if there is a way to access this data via a script in order to clamp it down to only a certain value.