Skip to content

Instantly share code, notes, and snippets.

@demohero101
demohero101 / Ornekler.py
Created November 15, 2023 21:31
Ornekler
import bpy
# Create a red material
red_material = bpy.data.materials.new(name="RedMaterial")
red_material.diffuse_color = (1, 0, 0, 1) # Set color to red
# Assign the red material to selected objects
for obj in bpy.context.selected_objects:
obj.data.materials.append(red_material)
---------------------------------------------------------------
@demohero101
demohero101 / Sample1.py
Created November 13, 2023 13:44
ChatGPT Code 1
import bpy
# Clear existing mesh objects in the scene
bpy.ops.object.select_all(action='DESELECT')
bpy.ops.object.select_by_type(type='MESH')
bpy.ops.object.delete()
# Add a cube
bpy.ops.mesh.primitive_cube_add(size=2, location=(0, 0, 0))
@demohero101
demohero101 / Add Material.py
Created January 29, 2023 13:01
Add Material Example
class AddMaterial(bpy.types.Operator):
"""Add Material"""
bl_idname = "object.addmat_operator"
bl_label = "Add Material"
def execute(self, context):
ob = bpy.context.active_object
bpy.ops.object.shade_smooth()
@demohero101
demohero101 / pie_menu.py
Created October 9, 2022 12:31
Pie Menu Ornek
import bpy
from bpy.types import Menu
class PIE_MT_AddMeshObjects(Menu):
bl_idname = "PIE_MT_add_mesh_objects"
bl_label = "Add Mesh Objects"
def draw(self, context):
layout = self.layout
@demohero101
demohero101 / menuornekler.py
Created September 29, 2022 21:38
Blender Menu
# Basit Menü oluşturma
import bpy
class SimpleCustomMenu(bpy.types.Menu):
bl_label = "Add Objects"
bl_idname = "OBJECT_MT_simple_custom_menu"
def draw(self, context):
layout = self.layout
@demohero101
demohero101 / Add Objects.py
Created September 26, 2022 21:23
Add-on Example
bl_info = {
"name": "Add Objects",
"author": "Demohero",
"version": (1, 0),
"blender": (3, 3, 0),
"location": "View3D > Sidebar",
"description": "Adds objects to the scene",
"warning": "",
"doc_url": "",
"category": "Add Objects",
@demohero101
demohero101 / gist:b9eb95bf0b007ece48a4fdf6fe9379b3
Created September 24, 2022 12:04
Blender Python bl_context items
bl_context
{'object', 'interface', 'particle', '.paint_common', 'material', 'scene', '.vertexpaint', 'constraint', 'file_paths', 'data', 'physics', '.imagepaint_2d', 'save_load', '.mesh_edit', '.greasepencil_paint', '.posemode', '.imagepaint', '.objectmode', 'output', '.greasepencil_sculpt', 'system', 'input', 'world', '.paint_common_2d', 'render', 'editing', 'navigation', 'experimental', 'viewport', 'view_layer', '.armature_edit', '.greasepencil_vertex', 'modifier', 'addons', '.uv_sculpt', '.particlemode', 'animation', 'lights', 'shaderfx', 'keymap', 'bone_constraint', 'texture', 'bone', 'themes', '.weightpaint', '.sculpt_mode', '.greasepencil_weight'}
@demohero101
demohero101 / modules.py
Created February 20, 2022 14:23
ModulesOrnekler
# Modül oluşturma örnek
def greet(name):
print("Merhaba " + name)
--------
# Import
import mymodule
@demohero101
demohero101 / BlenderPython.py
Created February 4, 2022 20:30
Blender Python Examples
# Blender Menu Sample 1
import bpy
class MySimpleMenu(bpy.types.Operator):
bl_idname = "my.simple_menu"
bl_label = "My Simple Menu"
def add_to_menu(self, context) :
self.layout.operator("mesh.primitive_cube_add", icon = "LIGHTPROBE_CUBEMAP")
# Class for a car (Araba için class)
class Car():
# Class Variables (Class değişkenleri)
# Attributes (Özellikler)
model = "Golf"
color = "Sarı"
# Objects of Car class (Nesneler)
car1 = Car()