2023年7月30日日曜日

20230731b 光時計セット 追加 円板 メッシュ マテリアル


ああああああ




blender python 


xy平面に 円を作って
半径 1
円の中心 000


色を付けたい
メッシュ 作った?
マテリアルは?


import bpy

# Set the circle's radius and center
radius = 1
center = (0, 0, 0)

# Create a new mesh circle with filled ngon
bpy.ops.mesh.primitive_circle_add(radius=radius, location=center, fill_type='NGON')

# Rename the circle object
circle_obj = bpy.context.active_object
circle_obj.name = "Circle_XY"

# Set the color for the circle
color = (0.8, 0.2, 0.3)  # Use RGB values (range 0.0 to 1.0)
material_name = "Circle_Material"

# Check if the material already exists, otherwise create a new one
if material_name not in bpy.data.materials:
    material = bpy.data.materials.new(name=material_name)
else:
    material = bpy.data.materials[material_name]

# Assign the color to the material
material.use_nodes = False
material.diffuse_color = color

# Create a material slot and assign the material to the circle object
if not circle_obj.data.materials:
    circle_obj.data.materials.append(material)
else:
    circle_obj.data.materials[0] = material








ああああああああああああああああああああああああああああああああああああああ




#半径1の円板 xy yz zx

import bpy
import math

def create_circle_on_plane(plane, color):
    # Set the circle's radius and center
    radius = 1
    center = (0, 0, 0)

    # Create a new mesh circle with filled ngon
    bpy.ops.mesh.primitive_circle_add(radius=radius, location=center, fill_type='NGON')

    # Rename the circle object
    circle_obj = bpy.context.active_object
    circle_obj.name = "Circle_" + plane

    # Check if the material already exists, otherwise create a new one
    material_name = "Circle_Material_" + plane
    if material_name not in bpy.data.materials:
        material = bpy.data.materials.new(name=material_name)
    else:
        material = bpy.data.materials[material_name]

    # Assign the color to the material
    material.use_nodes = False
    material.diffuse_color = color

    # Create a material slot and assign the material to the circle object
    if not circle_obj.data.materials:
        circle_obj.data.materials.append(material)
    else:
        circle_obj.data.materials[0] = material

    if plane == "YZ":
        # Swap Y and Z components of the vertices for YZ plane
        for vertex in circle_obj.data.vertices:
            temp_y = vertex.co.y
            vertex.co.y = vertex.co.z
            vertex.co.z = temp_y

        # Z-axis rotation (90 degrees) for YZ plane
        rotation_angle = math.radians(90)
        bpy.context.view_layer.objects.active = circle_obj
        bpy.ops.transform.rotate(value=rotation_angle, orient_axis='Z')
    elif plane == "ZX":
        # Swap Y and Z components of the vertices for ZX plane
        for vertex in circle_obj.data.vertices:
            temp_y = vertex.co.y
            vertex.co.y = vertex.co.z
            vertex.co.z = temp_y

# xy plane - 薄青 (Light Blue)
create_circle_on_plane("XY", (0.2, 0.2, 0.9, 1.0))

# yz plane - 淡赤 (Light Red)
create_circle_on_plane("YZ", (0.8, 0.2, 0.1, 1.0))

# zx plane - 薄緑 (Light Green)
create_circle_on_plane("ZX", (0.1, 0.9, 0.3, 1.0))









一緒に実行すると 色が 同じ成ってしまう



# xy 平面 

import bpy
import math

# Set the circle's radius and center
radius = 1
center = (0, 0, 0)

# Create a new mesh circle with filled ngon
bpy.ops.mesh.primitive_circle_add(radius=radius, location=center, fill_type='NGON')

# Rename the circle object
circle_obj = bpy.context.active_object
circle_obj.name = "Circle_XY"

# Set the color for the circle
color = (0.2, 0.2, 0.9, 1.0)  # Use RGBA values (range 0.0 to 1.0) with 1.0 for full opacity
material_name = "Circle_Material"

# Check if the material already exists, otherwise create a new one
if material_name not in bpy.data.materials:
    material = bpy.data.materials.new(name=material_name)
else:
    material = bpy.data.materials[material_name]

# Assign the color to the material
material.use_nodes = False
material.diffuse_color = color

# Create a material slot and assign the material to the circle object
if not circle_obj.data.materials:
    circle_obj.data.materials.append(material)
else:
    circle_obj.data.materials[0] = material





# yz 平面

import bpy

# Set the circle's radius and center
radius = 1
center = (0, 0, 0)

# Create a new mesh circle with filled ngon
bpy.ops.mesh.primitive_circle_add(radius=radius, location=center, fill_type='NGON')

# Rename the circle object
circle_obj = bpy.context.active_object
circle_obj.name = "Circle_YZ"

# Set the color for the circle
color = (0.8, 0.2, 0.1, 1.0)  # Use RGBA values (range 0.0 to 1.0) with 1.0 for full opacity
material_name = "Circle_Material"

# Check if the material already exists, otherwise create a new one
if material_name not in bpy.data.materials:
    material = bpy.data.materials.new(name=material_name)
else:
    material = bpy.data.materials[material_name]

# Assign the color to the material
material.use_nodes = False
material.diffuse_color = color

# Create a material slot and assign the material to the circle object
if not circle_obj.data.materials:
    circle_obj.data.materials.append(material)
else:
    circle_obj.data.materials[0] = material

# Swap Y and Z components of the vertices
for vertex in circle_obj.data.vertices:
    temp_y = vertex.co.y
    vertex.co.y = vertex.co.z
    vertex.co.z = temp_y

# Z-axis rotation (90 degrees)
import math
rotation_angle = math.radians(90)
bpy.context.view_layer.objects.active = circle_obj
bpy.ops.transform.rotate(value=rotation_angle, orient_axis='Z')






# zx 平面 

import bpy

# Set the circle's radius and center
radius = 1
center = (0, 0, 0)

# Create a new mesh circle with filled ngon
bpy.ops.mesh.primitive_circle_add(radius=radius, location=center, fill_type='NGON')

# Rename the circle object
circle_obj = bpy.context.active_object
circle_obj.name = "Circle_ZX"

# Set the color for the circle
color = (0.1, 0.9, 0.3, 1.0)  # Use RGBA values (range 0.0 to 1.0) with 1.0 for full opacity
material_name = "Circle_Material"

# Check if the material already exists, otherwise create a new one
if material_name not in bpy.data.materials:
    material = bpy.data.materials.new(name=material_name)
else:
    material = bpy.data.materials[material_name]

# Assign the color to the material
material.use_nodes = False
material.diffuse_color = color

# Create a material slot and assign the material to the circle object
if not circle_obj.data.materials:
    circle_obj.data.materials.append(material)
else:
    circle_obj.data.materials[0] = material

# Swap Y and Z components of the vertices
for vertex in circle_obj.data.vertices:
    temp_y = vertex.co.y
    vertex.co.y = vertex.co.z
    vertex.co.z = temp_y








 

基本系 配布 001 単位円 torus と xyz軸 円柱

https://drive.google.com/file/d/1adh0pC0n5MUfaPnsQcab8CnTvHu_JqLg/view?usp=drive_link

 

基本系 配布 002 単位2長さ balls

https://drive.google.com/file/d/1vyg5oFWmw_TK8nwp5TmVSfLH94I6rTaY/view?usp=drive_link

 

基本系 配布 003 単位2長さ balls 光時計セット 

https://drive.google.com/file/d/1u2Rn_nVBcewe39Vokua9C5n25cdivyyL/view?usp=drive_link

 

blender 基本系 配布 カタログ 2023 - zionad_mainのブログ https://mokuji000zionad.hatenablog.com/entry/2023/07/31/095208 






以下 ChatGPT との対話 修正記録 と メモ・ノート


ああああああああああああああああああああああああああああああああああああああああああああ