r/blenderpython • u/Teeskey • Aug 07 '24
I just released my most complex addon yet: BlendAI! It comes with many powerful AI features and works based on a credit system. Link in the video description
r/blenderpython • u/Teeskey • Aug 07 '24
r/blenderpython • u/Maleficent-Watch-533 • Aug 29 '24
I don't know much about coding i kinda understand the very basics so i am using chatgpt and other AIs to help me make it but i got stuck and the AI is just giving me the same code without any difference so basically i am trying to make an addon that takes the selected 3d model and takes each part and laies it out inside a mesh that i input the dimensions of basically like maxcut (i cant use max cut because it doesnt use weird shapes and i want it tin blender) so right now i cant get the xyz input field to work and there is a bunch of errors that i cant get the AI to fix
here is what i have so far
import bpy
import mathutils # Use mathutils for Blender math functions
class MyAddonSettings(bpy.types.PropertyGroup):
"""Stores dimensions for the addon"""
dimensions_x = bpy.props.FloatProperty(name="Dimension X", default=1.0)
dimensions_y = bpy.props.FloatProperty(name="Dimension Y", default=1.0)
dimensions_z = bpy.props.FloatProperty(name="Dimension Z", default=1.0)
class CopyPasteFlatOperator(bpy.types.Operator):
"""Copy and Paste Flat Operator"""
bl_idname = "object.copy_paste_flat" # Unique identifier
bl_label = "Copy Paste Flat" # Label displayed in the menu
def execute(self, context):
selected_meshes = bpy.context.selected_objects
new_collection = bpy.data.collections.new("Copied Meshes")
bpy.context.scene.collection.children.link(new_collection)
container_mesh = bpy.data.meshes.new(name="Container Mesh")
container_mesh.from_pydata(coords=[], edges=[], faces=[]) # Empty mesh data
container_object = bpy.data.objects.new(
name="Container", object_data=container_mesh
)
bpy.context.collection.objects.link(container_object)
container_object.scale = (
context.scene.my_addon.dimensions_x,
context.scene.my_addon.dimensions_y,
context.scene.my_addon.dimensions_z,
)
for mesh in selected_meshes:
mesh_copy = mesh.copy()
mesh_copy.data = mesh.data.copy()
new_collection.objects.link(mesh_copy)
mesh_copy.location = container_object.location + (
context.scene.my_addon.dimensions_x / 2,
context.scene.my_addon.dimensions_y / 2,
context.scene.my_addon.dimensions_z / 2,
)
max_x, max_y, max_z = (
context.scene.my_addon.dimensions_x,
context.scene.my_addon.dimensions_y,
context.scene.my_addon.dimensions_z,
)
min_x, min_y, min_z = -max_x, -max_y, -max_z
mesh_copy.scale = (
min(1.0, max_x / mesh_copy.dimensions.x),
min(1.0, max_y / mesh_copy.dimensions.y),
min(1.0, max_z / mesh_copy.dimensions.z),
)
return {'FINISHED'} # Indicate successful execution
class LayoutDemoPanel(bpy.types.Panel):
"""Creates a Panel in the scene context of the properties editor"""
bl_label = "Blender addon"
bl_idname = "SCENE_PT_layout"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "object"
def get_settings(cls):
return bpy.context.scene.my_addon
def draw(self, context):
layout = self.layout
settings = self.get_settings()
layout.prop(settings, "dimensions_x")
layout.prop(settings, "dimensions_y")
layout.prop(settings, "dimensions_z")
layout.label(text="Create Mesh and Paste Copies:")
row = layout.row()
row.scale_y = 3.0
row.operator("object.copy_paste_flat")
def register():
bpy.utils.register_class(MyAddonSettings) # Register the property group first
bpy.utils.register_class(LayoutDemoPanel)
bpy.utils.register_class(CopyPasteFlatOperator)
bpy.types.Scene.my_addon = bpy.props.PointerProperty(type=MyAddonSettings)
def unregister():
del bpy.types.Scene.my_addon
bpy.utils.unregister_class(CopyPasteFlatOperator)
bpy.utils.unregister_class(LayoutDemoPanel)
bpy.utils.unregister_class(MyAddonSettings)
if __name__ == "__main__":
register()
r/blenderpython • u/LeadershipLeather826 • Apr 01 '23
r/blenderpython • u/juancarlv • Aug 24 '20
I am trying to make the script but l can't manage to open more than one.
I am using de 3dview panel and it only works with one os link
I got the def and invoke it however it only works for the first app
I need some ideas to solve this because I am relatively new in script in phyton
Thanx you in advance
r/blenderpython • u/Sridharan8085 • Nov 12 '17
I want python script for helicopter game any one know that help me
r/blenderpython • u/abhi_physics90 • Feb 14 '26
r/blenderpython • u/perception-eng • Apr 12 '23
r/blenderpython • u/bandoftheshadow • Sep 22 '24
Sorry, I don't know if it's annoying to ask for help with ChatGPT generated code. I gather it's a little imperfect. I myself am not a coder (hence ChatGPT).
import bpy
import os
# Define the directory to search for .gltf files
directory_path = r"D:\STOCK IMAGES\3D Stock Models\Buildings_RUINED WALLS\07 Brick wall scan (great detail but no tops or sides)"
# Search for .gltf files in the directory
gltf_file = None
for file_name in os.listdir(directory_path):
if file_name.endswith(".gltf"):
gltf_file = os.path.join(directory_path, file_name)
break # Stop after finding the first .gltf file
if gltf_file:
# Import the found GLTF file
bpy.ops.import_scene.gltf(filepath=gltf_file)
# Unparent all objects while keeping their transformation
for obj in bpy.context.scene.objects:
if obj.parent is not None:
obj.select_set(True)
bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM')
# Delete all empties
for obj in bpy.context.scene.objects:
if obj.type == 'EMPTY':
obj.select_set(True)
bpy.ops.object.delete()
# Join all mesh objects into one
bpy.ops.object.select_all(action='DESELECT')
for obj in bpy.context.scene.objects:
if obj.type == 'MESH':
obj.select_set(True)
bpy.context.view_layer.objects.active = obj # Set one of the meshes as the active object
bpy.ops.object.join() # Join the selected meshes
# Weld vertices by removing doubles
bpy.ops.object.mode_set(mode='EDIT') # Switch to edit mode
bpy.ops.mesh.select_all(action='SELECT') # Select all vertices
bpy.ops.mesh.remove_doubles(threshold=0.001) # Merge vertices that are very close
bpy.ops.object.mode_set(mode='OBJECT') # Return to object mode
print(f"Imported and cleaned: {gltf_file}")
else:
print("No .gltf files found in the specified directory.")I simply want to automate the importing of sketchfab scans so they unparent and merge.
r/blenderpython • u/aeroaks • Nov 16 '16
Is it possible to extract a 2d view (top, side view etc) from a 3d view in blender?
If yes then could you direct me towards the solution. I complete newbie.
r/blenderpython • u/DanteYYY • Sep 20 '20
I'm looking for someone that can write me 2 simple addon templates. I don't really have time to learn python and i can't get what i want from the short tutorials on YT so i want to pay someone to write me 2 relatively customizable templates.
First one - N-Panel that allows me to append specific collection from a .Blend.
Good example of that would be Botaniq (https://blendermarket.com/creators/polygoniq) addon that has pretty much everything i would like. Only talking about "Spawn Asset" button.

If possible, button should be skipped directly into the "spawn asset" menu removing top 4 checkboxes and "make editable" checkbox.



All i need from this is to just have that kind of menu for appending collections with assets. I'm not asking for 100% copy of course, this is just an example of what i'm looking for. Main purpose for that is so i can have 1 blend file in the addon folder with my assets and append them easily. Bonus points if i can also append brushes with custom icons, i don't know if that's possible in a one addon but it would be great if it was possible. Mainly talking about texture draw brushes but sculpt brushes are appreciated too. It all should work like a normal addon so i can share it with friends.
In the code itself i'd like to have descriptions for segments of the code and it should be most importantly easy to change up so i can reuse it for different addons.
Second Addon - N-Panel like above but this time just really really simple including only 3 tabs found in the armature tab, "Skeleton", "Pose Library" and "Custom Properties"
nothing more nothing less. Should take that data from the active armature. Simply want it to make my personal rigs a bit easier to use for external users. All 3 tabs should be collapsible.



I hope i'm not asking for too much and it all should be relatively easy to write.
PayPal only, price will be discussed privately. If you're interested in working on those addons for me either add me on Discord DanteBoi#3228 or just leave your contact info here. Please straight up show me what did you do in Python so far just so i can see if i can trust you and tell me the pay you expect for it. Thank you ^^
If i'm posting this in a wrong place, please forward me to a correct one. I tried to look around for some kind of addon commissions but i couldn't really find anything.
Originally posted in r/blender but decided to post here too.
r/blenderpython • u/REDDIT-IS-TRP • Dec 13 '23
Report: Error igme Froxy owap vjun. Python: Traceback (most recent call last): File "C:\Users\censored\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\FZRandomizer_3_0_3.py", line 3039, in execute multiOBJ(context) File "C:\Users\censored\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\FZRandomizer_3_0_3.py", line 1114, in multiOBJ buildChars(name, generations, genCodesList, proxyParametersList) File "C:\Users\censored\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\FZRandomizer_3_0_3.py", line 1186, in buildChars ng= buildHostProxy(genCodesList) File "C:\Users\censored\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\FZRandomizer_3_0_3.py", line 1493, in buildHostProxy ng= make_hostcollgroup(host, proxy, genCodesList) File "C:\Users\censored\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\FZRandomizer_3_0_3.py", line 646, in make_hostcolLgroup hostcoll_group.inputs.new("NodeSocketGeometry", "Input") AttributeError: 'GeometryNodeTree' object has no attribute 'inputs'
r/blenderpython • u/dphamiltonbradford • Sep 26 '18
r/blenderpython • u/Zyaku_ • May 17 '21
Title. Sometimes it's fine if I toggle the system console off again but sometimes it still crashes. Why does this happen ? It makes the scripting experience pretty bad
r/blenderpython • u/Pie-Guy • Jun 25 '21
Hi,
I have watched a couple of tutorials on setting up an IDE (VSCode) with blender. In one video the presenter uses Python that comes with Blender. In another, he downloads the latest python and uses it.
Is there any reason to do one or the other?
Thanks,
Robb
r/blenderpython • u/monica_b1998 • Dec 04 '18
r/blenderpython • u/monica_b1998 • Oct 28 '18
r/blenderpython • u/Competitive-Rain-664 • Apr 03 '26
I’ve been pushing myself to learn the scripting side of Blender for a freelance goal on June 5th. This project uses bpy to generate the text, convert it to mesh, separate the letters, and then 'hand off' the animation from keyframed movement to a Rigid Body physics simulation.
Each letter has a unique material instance so I could pulse the Emission strength individually during the jump. Proud of how the 'squash and stretch' logic combined with the physics hit!
Shoutout to 'Mc kenzie for some loop logic and that rigid body physic part too ,
I got it from one of his tutorials en my AI thought partner for helping me debug the node-tree logic!..
r/blenderpython • u/miraoister • Sep 23 '20
Im not a coding person, im a 3d modelling person, it took 7 years to get a basic understanding of that and scripting/animating is beyond me.
what I would like to learn is this:
Object moves to a point then stops.
ideally i need some sort of script which has vairables I could expeirment with, such as the speed etc.
then I could add bits on as needed and work out what each bit does. (thats how I learn!)
could some one copy paste a bit of code below to help us out?
thank you!
r/blenderpython • u/-dadderall- • Sep 05 '20
r/blenderpython • u/SauceFiendGlobza • Mar 05 '25
Hello Everyone, I’ve been trying to create depth map from the python API but I have not been getting a lot of success. I try save it in EXR file but the Z channel keeps on getting saved as the V channel. Has anyone ever gotten theirs to work
r/blenderpython • u/abhi_physics90 • May 14 '26
Mesh Writer is a searchable symbol library (with a built-in SVG editor) that turns symbols, SVGs, math characters and emojis, into Geometry Nodes curves or 3D mesh or 3D Curves.
With over 5,000+ symbols and 3,700+ SVG assets, Mesh Writer streamlines the full workflow — search, insert, import materials, and convert to mesh or Geometry Nodes,
Get it now on Superhive: Get Mesh Writer
r/blenderpython • u/SalaiVedhaViradhan • Apr 15 '26
r/blenderpython • u/[deleted] • Jun 08 '20
I'm working on a custom exporter. I'm not too familiar with blender and its API, so I looked at the obj exporter and got a bit confused at what it's trying to do.
I'm only interested in exporting basic geometry (for now) in a way that makes sense for a 3d game engine, so vertices can't have multiple values for the same attribute etc, but also I want to use as few vertices as possible. I'm not interested in export performance yet as my meshes are meant to be generally small.
Currently I have a working solution that works like this:
Create an empty dictionary that maps vertex information to an index
For each entry in the mesh loops:
Gather all attributes (vertex index, normal, uvs, etc) into a single object and check if it exists in the dictionary.
If it doesn't:
Add the entry as the key and set value to be the current dictionary size. The value will also be used as the output index for this loop entry.
Add the attributes as a new Vertex in the output vertices list.
If it does exist, use that value as the output index of this loop entry.
Add the output index to the output indices list.
I don't feel very good about hashing and comparing floating point numbers, but then again I assume blender explicitly uses the exact same floating point value when the normal is supposed to be the same so hashing and equality checking will work as expected.
Is what I'm doing the right way or is there a more proper way to do this? Does blender have an integer id for unique normals, colors, uvs, etc the way it does for positions that I can use instead of hashing floats?