2023年3月21日火曜日

円柱  回転 3軸 骨格円柱

aaa

https://ia2023sha.blogspot.com/2023/03/blog-post_51.html





# z軸方向

import bpy
import math

# シリンダーを作成する
bpy.ops.mesh.primitive_cylinder_add(radius=2.5, depth=60.0, location=(-0.0, 0.0, 0.0))
cylinder = bpy.context.object


# シリンダーの回転と位置を設定する 
cylinder.rotation_euler = (0, 0, math.pi/2)
cylinder.location = (0.0, 0.0, 0.0)





# X軸方向

import bpy
import math

# シリンダーを作成する
bpy.ops.mesh.primitive_cylinder_add(radius=2.5, depth=60.0, location=(-0.0, 0.0, 0.0))
cylinder = bpy.context.object


# シリンダーの回転と位置を設定する 
cylinder.rotation_euler = (0, math.pi/2,0 )
cylinder.location = (0.0, 0.0, 0.0)





# Y軸方向

import bpy
import math

# シリンダーを作成する
bpy.ops.mesh.primitive_cylinder_add(radius=2.5, depth=60.0, location=(-0.0, 0.0, 0.0))
cylinder = bpy.context.object


# シリンダーの回転と位置を設定する 
cylinder.rotation_euler = ( math.pi/2, 0, 0 )
cylinder.location = (0.0, 0.0, 0.0)








# Repeat the animation after 5 seconds
for i in range(end_frame+1, repeat_frame+1):
    bpy.context.scene.frame_set(i)
    bpy.context.object.location = end_pos
    bpy.context.object.keyframe_insert(data_path="location", index=-1)





カメラ

# Add a camera and set its position
cam_data = bpy.data.cameras.new('Camera')
cam = bpy.data.objects.new('My Camera', cam_data)
bpy.context.scene.collection.objects.link(cam)
cam.location = (0.0, -30.0, 0.0)

# Add a track constraint to the camera to follow the sphere
track_constraint = cam.constraints.new(type='TRACK_TO')
track_constraint.target = bpy.context.object
track_constraint.track_axis

# Add the camera to the collection
my_collection = bpy.data.collections.get(my_collection_name)
my_collection.objects.link(cam)


ここでは、カメラの名前を"My Camera"に設定し、bpy.data.collections.get()メソッドを使用して"My Collection"コレクションを取得して、そのコレクションにカメラを追加しています。












#コレクションに名前を付けるには、以下のようにします:

import bpy
import math


my_collection_name = "あああああ"


# コレクションを作成する
col = bpy.data.collections.new("My Collection")
bpy.context.scene.collection.children.link(col)


# コレクションに名前を付ける
col.name = my_collection_name



# オブジェクトに名前を付ける
cylinder.name = "My Cylinder"







移動とカメラ セット






import bpy
import math

#コレクションに名前を付けるには、以下のようにします:
my_collection_name = "3軸 円柱"

# コレクションを作成する
col = bpy.data.collections.new(my_collection_name)
bpy.context.scene.collection.children.link(col)

# コレクションに名前を付ける
col.name = my_collection_name



# z軸方向

import bpy
import math

# シリンダーを作成する
bpy.ops.mesh.primitive_cylinder_add(radius=2.5, depth=60.0, location=(-0.0, 0.0, 0.0))
cylinder = bpy.context.object

# オブジェクトに名前を付ける
cylinder.name = "Z軸 Cylinder"


# シリンダーの回転と位置を設定する 
cylinder.rotation_euler = (0, 0, math.pi/2)
cylinder.location = (0.0, 0.0, 0.0)



# Set start and end frames
start_frame = 1
end_frame = start_frame + 200

# Define the start and end positions
start_pos = (-300.0, 0.0, 0.0)
end_pos = (300.0, 0.0, 0.0)

# Calculate the distance between start_pos and end_pos
distance = abs(math.sqrt((end_pos[0]-start_pos[0])**2 + (end_pos[1]-start_pos[1])**2 + (end_pos[2]-start_pos[2])**2))

# Set the speed multiplier
vvv_velocity = 1.0

# Calculate the velocity required to move the sphere at a constant speed
velocity = distance / (end_frame - start_frame) * vvv_velocity

# Move the sphere and cylinder from start_pos to end_pos at a constant speed
for i in range(start_frame, end_frame + 1):
    bpy.context.scene.frame_set(i)
    bpy.context.object.location = tuple(s + (e-s)*((i-start_frame)*velocity/distance) for s,e in zip(start_pos, end_pos))
    bpy.context.object.keyframe_insert(data_path="location", index=-1)
    bpy.context.object.keyframe_insert(data_path="scale", index=-1)

# Stop the sphere and cylinder from moving after reaching the end position
bpy.context.scene.frame_set(end_frame)
bpy.context.object.keyframe_insert(data_path="location", index=-1)
bpy.context.object.keyframe_insert(data_path="scale", index=-1)

# Set the waiting period
wait_frames = 40
end_frame += wait_frames

# Set the current frame to the end_frame
current_frame = end_frame

# Keep the sphere and cylinder at the end position and repeat the animation
repeat_frames = end_frame + 200
while True:
    current_frame += 1
    
    # Insert a keyframe at the current frame for the sphere and cylinder's location and scale
    bpy.context.scene.frame_set(current_frame)
    bpy.context.object.location = end_pos
    bpy.context.object.keyframe_insert(data_path="location", index=-1)
    bpy.context.object.keyframe_insert(data_path="scale", index=-1)
    
    # Stop the loop if current_frame reaches repeat_frames
    if current_frame == repeat_frames:
        break




My_Camera = "Zaxis"

# Create camera data
MyCam_data = bpy.data.cameras.new('My_Camera')

# Add a camera and set its position
cam = bpy.data.objects.new(My_Camera, MyCam_data)
bpy.context.scene.collection.objects.link(cam)
cam.location = (0.0, -30.0, 0.0)


# Add a track constraint to the camera to follow the sphere
track_constraint = cam.constraints.new(type='TRACK_TO')
track_constraint.target = bpy.context.object
track_constraint.track_axis





# X軸方向

import bpy
import math

# シリンダーを作成する
bpy.ops.mesh.primitive_cylinder_add(radius=2.5, depth=60.0, location=(-0.0, 0.0, 0.0))
cylinder = bpy.context.object


# オブジェクトに名前を付ける
cylinder.name = "X軸 Cylinder"


# シリンダーの回転と位置を設定する 
cylinder.rotation_euler = (0, math.pi/2,0 )
cylinder.location = (0.0, 0.0, 0.0)


# Set start and end frames
start_frame = 1
end_frame = start_frame + 200

# Define the start and end positions
start_pos = (-300.0, 0.0, 0.0)
end_pos = (300.0, 0.0, 0.0)

# Calculate the distance between start_pos and end_pos
distance = abs(math.sqrt((end_pos[0]-start_pos[0])**2 + (end_pos[1]-start_pos[1])**2 + (end_pos[2]-start_pos[2])**2))

# Set the speed multiplier
vvv_velocity = 1.0

# Calculate the velocity required to move the sphere at a constant speed
velocity = distance / (end_frame - start_frame) * vvv_velocity

# Move the sphere and cylinder from start_pos to end_pos at a constant speed
for i in range(start_frame, end_frame + 1):
    bpy.context.scene.frame_set(i)
    bpy.context.object.location = tuple(s + (e-s)*((i-start_frame)*velocity/distance) for s,e in zip(start_pos, end_pos))
    bpy.context.object.keyframe_insert(data_path="location", index=-1)
    bpy.context.object.keyframe_insert(data_path="scale", index=-1)

# Stop the sphere and cylinder from moving after reaching the end position
bpy.context.scene.frame_set(end_frame)
bpy.context.object.keyframe_insert(data_path="location", index=-1)
bpy.context.object.keyframe_insert(data_path="scale", index=-1)

# Set the waiting period
wait_frames = 40
end_frame += wait_frames

# Set the current frame to the end_frame
current_frame = end_frame

# Keep the sphere and cylinder at the end position and repeat the animation
repeat_frames = end_frame + 200
while True:
    current_frame += 1
    
    # Insert a keyframe at the current frame for the sphere and cylinder's location and scale
    bpy.context.scene.frame_set(current_frame)
    bpy.context.object.location = end_pos
    bpy.context.object.keyframe_insert(data_path="location", index=-1)
    bpy.context.object.keyframe_insert(data_path="scale", index=-1)
    
    # Stop the loop if current_frame reaches repeat_frames
    if current_frame == repeat_frames:
        break





My_Camera = "Xaxis"

# Create camera data
MyCam_data = bpy.data.cameras.new('My_Camera')

# Add a camera and set its position
cam = bpy.data.objects.new(My_Camera, MyCam_data)
bpy.context.scene.collection.objects.link(cam)
cam.location = (0.0, -30.0, 0.0)


# Add a track constraint to the camera to follow the sphere
track_constraint = cam.constraints.new(type='TRACK_TO')
track_constraint.target = bpy.context.object
track_constraint.track_axis






# Y軸方向

import bpy
import math

# シリンダーを作成する
bpy.ops.mesh.primitive_cylinder_add(radius=2.5, depth=60.0, location=(-0.0, 0.0, 0.0))
cylinder = bpy.context.object

# オブジェクトに名前を付ける
cylinder.name = "Y軸 Cylinder"


# シリンダーの回転と位置を設定する 
cylinder.rotation_euler = ( math.pi/2, 0, 0 )
cylinder.location = (0.0, 0.0, 0.0)




# Set start and end frames
start_frame = 1
end_frame = start_frame + 200

# Define the start and end positions
start_pos = (-300.0, 0.0, 0.0)
end_pos = (300.0, 0.0, 0.0)

# Calculate the distance between start_pos and end_pos
distance = abs(math.sqrt((end_pos[0]-start_pos[0])**2 + (end_pos[1]-start_pos[1])**2 + (end_pos[2]-start_pos[2])**2))

# Set the speed multiplier
vvv_velocity = 1.0

# Calculate the velocity required to move the sphere at a constant speed
velocity = distance / (end_frame - start_frame) * vvv_velocity

# Move the sphere and cylinder from start_pos to end_pos at a constant speed
for i in range(start_frame, end_frame + 1):
    bpy.context.scene.frame_set(i)
    bpy.context.object.location = tuple(s + (e-s)*((i-start_frame)*velocity/distance) for s,e in zip(start_pos, end_pos))
    bpy.context.object.keyframe_insert(data_path="location", index=-1)
    bpy.context.object.keyframe_insert(data_path="scale", index=-1)

# Stop the sphere and cylinder from moving after reaching the end position
bpy.context.scene.frame_set(end_frame)
bpy.context.object.keyframe_insert(data_path="location", index=-1)
bpy.context.object.keyframe_insert(data_path="scale", index=-1)

# Set the waiting period
wait_frames = 40
end_frame += wait_frames

# Set the current frame to the end_frame
current_frame = end_frame

# Keep the sphere and cylinder at the end position and repeat the animation
repeat_frames = end_frame + 200
while True:
    current_frame += 1
    
    # Insert a keyframe at the current frame for the sphere and cylinder's location and scale
    bpy.context.scene.frame_set(current_frame)
    bpy.context.object.location = end_pos
    bpy.context.object.keyframe_insert(data_path="location", index=-1)
    bpy.context.object.keyframe_insert(data_path="scale", index=-1)
    
    # Stop the loop if current_frame reaches repeat_frames
    if current_frame == repeat_frames:
        break




My_Camera = "Yaxis"

# Create camera data
MyCam_data = bpy.data.cameras.new('My_Camera')

# Add a camera and set its position
cam = bpy.data.objects.new(My_Camera, MyCam_data)
bpy.context.scene.collection.objects.link(cam)
cam.location = (0.0, -30.0, 0.0)


# Add a track constraint to the camera to follow the sphere
track_constraint = cam.constraints.new(type='TRACK_TO')
track_constraint.target = bpy.context.object
track_constraint.track_axis

















# Repeat the animation after 5 seconds
for i in range(end_frame+1, repeat_frame+1):
    bpy.context.scene.frame_set(i)
    bpy.context.object.location = end_pos
    bpy.context.object.keyframe_insert(data_path="location", index=-1)







コレクションに名前を付けるには、以下のようにします:

import bpy
import math

# コレクションを作成する
col = bpy.data.collections.new("My Collection")
bpy.context.scene.collection.children.link(col)

# シリンダーを作成する
bpy.ops.mesh.primitive_cylinder_add(radius=2.5, depth=60.0, location=(-0.0, 0.0, 0.0))
cylinder = bpy.context.object

# コレクションにオブジェクトを追加する
col.objects.link(cylinder)

# シリンダーの回転と位置を設定する 
cylinder.rotation_euler = ( math.pi/2, 0, 0 )
cylinder.location = (0.0, 0.0, 0.0)

# コレクションに名前を付ける
col.name = "My Collection"


import bpy import math # コレクションを作成する col = bpy.data.collections.new("My Collection") bpy.context.scene.collection.children.link(col) # シリンダーを作成する bpy.ops.mesh.primitive_cylinder_add(radius=2.5, depth=60.0, location=(-0.0, 0.0, 0.0)) cylinder = bpy.context.object # コレクションにオブジェクトを追加する col.objects.link(cylinder) # シリンダーの回転と位置を設定する cylinder.rotation_euler = ( math.pi/2, 0, 0 ) cylinder.location = (0.0, 0.0, 0.0) # コレクションに名前を付ける col.name = "My Collection"






オブジェクトに名前を付けるには、以下のようにします:



import bpy
import math

# シリンダーを作成する
bpy.ops.mesh.primitive_cylinder_add(radius=2.5, depth=60.0, location=(-0.0, 0.0, 0.0))
cylinder = bpy.context.object

# オブジェクトに名前を付ける
cylinder.name = "My Cylinder"

# シリンダーの回転と位置を設定する 
cylinder.rotation_euler = ( math.pi/2, 0, 0 )
cylinder.location = (0.0, 0.0, 0.0)




import bpy import math # シリンダーを作成する bpy.ops.mesh.primitive_cylinder_add(radius=2.5, depth=60.0, location=(-0.0, 0.0, 0.0)) cylinder = bpy.context.object # オブジェクトに名前を付ける cylinder.name = "My Cylinder" # シリンダーの回転と位置を設定する cylinder.rotation_euler = ( math.pi/2, 0, 0 ) cylinder.location = (0.0, 0.0, 0.0)









bbb
togetter.com/t/c2022meetzionad
togetter.com/t/b2022meetzionad




twitter 新着検索 Dürer & 測距儀


aaa









bbb
twitter zionadchat
twitter に追い出されたら 連絡先は Gettr https://gettr.com/user/zionadchat
twitter サブアカウント https://twitter.com/2022zionad

old page いいい
new page いいい

目次 2022の目次 単純トリック hatena zionadchat
いいいいいいいい

202304220 thu 1333

aaa 下書き Dürer & 測距儀2022c085 連番 014 正三角形 6つの詳細 aaa ティコ・ブラーエ氏 2023年04月19日 下書き Dürer & 測距儀2022c085 連番 014 正三角形 6つの詳細  ゴルフ場 ...