OneonetのPyBE

Python,Blender,Excelのいろいろ

Python and Blender: A World Where the Gundam Hammer Doesn't Destroy Anything Part 1

The target of the attack is a single thin cylinder, like a pencil.
But by giving the pencil a weight of 1 ton, it becomes, "That's Gog, he's nothing."
I'll be fine.

Gundam Hammer: The Gundam Hammer is a physical melee weapon that takes the form of a flail, with a large spiked ball attached to the handle by a chain. It is useful in situations where beam weapons cannot be used. The chain is long enough that the weapon can be swung around the mobile suit to strike enemies at mid-range or thrown.

f:id:oneonet:20220316160045p:plain

#blender 3.0.0
import bpy

for item in bpy.data.meshes:
    bpy.data.meshes.remove(item)

bpy.ops.mesh.primitive_cone_add(radius1=1, radius2=0, depth=4,enter_editmode=False, align='WORLD', location=(0, 55.5, 70), scale=(1, 1, 1))
bpy.ops.mesh.primitive_ico_sphere_add(enter_editmode=False, align='WORLD', location=(0, 55.5, 70), scale=(5, 5, 5))
bpy.context.object.instance_type = 'FACES'
bpy.data.objects['円錐'].select_set(True)
bpy.data.objects['ICO球'].select_set(True)
bpy.ops.object.parent_set(type='OBJECT', keep_transform=True)

for i in range(0,20):
    bpy.ops.mesh.primitive_torus_add(location=(0, i*2.6, 70), major_radius=1.0, minor_radius=0.2, rotation=(0, 0, 0))
    bpy.ops.rigidbody.object_add()
    bpy.context.object.rigid_body.collision_shape = 'MESH'
    if i==0:
        bpy.context.object.rigid_body.type = 'PASSIVE'

for i in range(0,20):
    bpy.ops.mesh.primitive_torus_add(location=(0, i*2.6+1.3, 70), major_radius=1.0, minor_radius=0.2, rotation=(0, 1.57, 0))
    bpy.ops.rigidbody.object_add()
    bpy.context.object.rigid_body.collision_shape = 'MESH'

bpy.data.objects['ICO球'].select_set(True)
bpy.ops.rigidbody.constraint_add()
bpy.data.objects['トーラス.039'].select_set(True)
bpy.ops.object.parent_set(type='OBJECT', keep_transform=True)


bpy.ops.mesh.primitive_cylinder_add(enter_editmode=False, align='WORLD', location=(0, 0, 10), scale=(0.5, 0.5, 10))
bpy.ops.rigidbody.object_add()
bpy.context.object.rigid_body.mass = 1000

bpy.ops.mesh.primitive_plane_add(size=40, enter_editmode=False, align='WORLD', location=(0, 0, -1), scale=(1, 1, 1))
bpy.ops.rigidbody.object_add()
bpy.context.object.rigid_body.type = 'PASSIVE'