r/blenderpython • u/Meta_Riddley • Aug 09 '14
r/blenderpython • u/Meta_Riddley • May 28 '14
The API Navigator
Just found an addon that seems interesting. If you open user preference panel and under the addon tab. There is an addon called API Navigator. Now activate it and open the text editor. Press ctrl+T to bring up that properties tab and scroll down to the API navigator. Now you can mess around with that.
r/blenderpython • u/abhi_physics90 • Feb 14 '26
Mesh Writer: 20% Launch discount for limited time!!
r/blenderpython • u/Maleficent-Watch-533 • Aug 29 '24
i need help finishing this addon
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):
Get the selected meshes
selected_meshes = bpy.context.selected_objects
Create a new empty collection to store the copies
new_collection = bpy.data.collections.new("Copied Meshes")
bpy.context.scene.collection.children.link(new_collection)
Create a new mesh with specified dimensions (from panel properties)
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,
)
Copy and paste each mesh, adjusting its location within the new mesh
for mesh in selected_meshes:
mesh_copy = mesh.copy()
mesh_copy.data = mesh.data.copy()
Link the copy to the new collection
new_collection.objects.link(mesh_copy)
Adjust location to be flat and centered within the container mesh
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,
)
Ensure copied mesh stays within container boundaries (basic approach)
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"
Define the properties for dimensions
def get_settings(cls):
return bpy.context.scene.my_addon
def draw(self, context):
layout = self.layout
settings = self.get_settings()
Add input fields for dimensions (using FloatProperty)
layout.prop(settings, "dimensions_x")
layout.prop(settings, "dimensions_y")
layout.prop(settings, "dimensions_z")
Big button to trigger operator
layout.label(text="Create Mesh and Paste Copies:")
row = layout.row()
row.scale_y = 3.0
row.operator("object.copy_paste_flat")
def register():
Ensure LayoutDemoPanel is registered before Scene
bpy.utils.register_class(MyAddonSettings) # Register the property group first
bpy.utils.register_class(LayoutDemoPanel)
bpy.utils.register_class(CopyPasteFlatOperator)
Now register the property in the Scene
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/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/juancarlv • Aug 24 '20
Open varios programs portables like a calculatoran so on, in a panel interface blender
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
Helicopter script
I want python script for helicopter game any one know that help me