随笔 - 633,  文章 - 0,  评论 - 13,  阅读 - 48万
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

1.先选中骨骼
2.再运行代码

代码:

复制代码
import bpy
import pandas as pd

def print_bone_properties_to_csv(armature_obj):
    """
    打印骨骼的所有属性并将它们输出到一个CSV文件。

    :param armature_obj: Armature对象。
    """
    if armature_obj.type != 'ARMATURE':
        print("请选择一个Armature对象。")
        return

    # 存储骨骼属性的字典列表
    bones_data = []

    # 遍历骨骼对象中的所有骨骼
    for bone in armature_obj.data.bones:
        bone_data = {}
        bone_data['Bone Name'] = bone.name
        # 遍历骨骼的属性并添加到字典中
        for prop_name in dir(bone):
            if not prop_name.startswith('__'):
                prop_value = getattr(bone, prop_name)
                bone_data[prop_name] = prop_value
        bones_data.append(bone_data)

    # 创建DataFrame
    df = pd.DataFrame(bones_data)

    # 弹出保存文件对话框,让用户选择保存路径
    csv_file_path = bpy.path.abspath("//bones_properties.csv")  # 使用双斜杠作为Blender的跨平台路径分隔符
    bpy.ops.wm.save_as_mainfile(filepath=csv_file_path)

    # 导出DataFrame到CSV文件
    df.to_csv(csv_file_path, index=False)
    print(f"骨骼属性已导出到CSV文件: {csv_file_path}")

# 使用示例
# 确保在对象模式下
bpy.ops.object.mode_set(mode='OBJECT')  
armature_obj = bpy.context.view_layer.objects.active  # 假设活动对象是Armature

if armature_obj and armature_obj.type == 'ARMATURE':
    print_bone_properties_to_csv(armature_obj)
else:
    print("请选择一个Armature对象。")
复制代码

 

posted on   大话人生  阅读(49)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
历史上的今天:
2022-04-18 操作yaml-5
2022-04-18 fixture固件装饰器做用例的前后置-4
2018-04-18 pycharm(pythoon3)_django2.0_xadmin创建测试用例后台管理系统
点击右上角即可分享
微信分享提示