首页 > 其他分享 >blender4.1-读取骨架下所有骨骼的名字,并保存在表格中

blender4.1-读取骨架下所有骨骼的名字,并保存在表格中

时间:2024-06-11 18:10:59浏览次数:11  
标签:读取 表格 mixamorig name names Bip001 armature bone blender4.1

保存在CSV中

import bpy
import csv

def get_bone_names(armature_name):
    bone_names = []
    # 找到骨架对象
    armature_obj = bpy.data.objects.get(armature_name)
    if not armature_obj or armature_obj.type != 'ARMATURE':
        print(f"Armature '{armature_name}' not found or is not an armature.")
        return bone_names

    # 遍历骨架中的所有骨骼
    for bone in armature_obj.pose.bones:
        bone_names.append(bone.name)

    return bone_names

def write_bone_names_to_csv(bone_names, csv_file_path):
    with open(csv_file_path, mode='w', newline='') as file:
        writer = csv.writer(file)
        writer.writerow(["Bone Name"])  # 写入标题
        for bone_name in bone_names:
            writer.writerow([bone_name])  # 写入每个骨骼的名称

# 获取骨架中所有骨骼的名称
bone_names = get_bone_names('Armature')

# 指定CSV文件的路径
csv_file_path = 'E:/guge/bone_names.csv'

# 将骨骼名称写入CSV文件
write_bone_names_to_csv(bone_names, csv_file_path)
print(f"Bone names have been written to {csv_file_path}")

2.保存在txt 中

 

import bpy

def get_bone_names(armature_name):
    # 找到骨架对象
    armature_obj = bpy.data.objects.get(armature_name)
    if armature_obj is None or armature_obj.type != 'ARMATURE':
        print(f"Armature '{armature_name}' not found or is not an armature.")
        return []

    # 存储骨骼名称的列表
    bone_names = [bone.name for bone in armature_obj.pose.bones]
    return bone_names

def write_bone_names_to_txt(bone_names, file_path):
    # 写入骨骼名称到文本文件
    with open(file_path, 'w') as file:
        for bone_name in bone_names:
            file.write(bone_name + '\n')  # 每个名称后添加换行符

# 骨架名称
armature_name = 'Armature'
# 骨骼名称列表
bone_names = get_bone_names(armature_name)

# 指定txt文件的路径
txt_file_path = 'E:/guge/bone_names.txt'

# 将骨骼名称写入txt文件,每个名字一行
write_bone_names_to_txt(bone_names, txt_file_path)
print(f"Bone names have been written to {txt_file_path}")

 3.对应骨骼

Biped_Root    Skadi_SwimSuit_A_arma            Armature

Pelvis       ||  Bip001-Pelvis          ||   mixamorig:Hips
Left_Thigh   ||  Bip001-L-Thigh         || mixamorig:LeftUpLeg
Left_Calf    ||  Bip001-L-Calf || mixamorig:LeftLeg
Left_Foot     || Bip001-L-Foot || mixamorig:LeftFoot
Right_Thigh   || Bip001-R-Thigh || mixamorig:RightUpLeg
Right_Calf     || Bip001-R-Calf || mixamorig:RightLeg
Right_Foot     || Bip001-R-Foot || mixamorig:RightFoot  
Spine        ||   Bip001-Spine     ||  mixamorig:Spine
Spine1       ||   Bip001-Spine1      || mixamorig:Spine1
Spine2        ||   Bip001-Spine2      || mixamorig:Spine2
Right_Clavicle || Bip001-R-Clavicle || mixamorig:RightShoulder
Right_UpperArm || Bip001-R-UpperArm || mixamorig:RightArm
Right_Forearm  || Bip001-R-Forearm || mixamorig:RightForeArm
Right_Hand     || Bip001-R-Hand || mixamorig:RightHand
Neck           || Bip001-Neck  ||mixamorig:Neck
Head          || Bip001-Head || mixamorig:Head
Left_Clavicle  || Bip001-L-Clavicle  || mixamorig:LeftShoulder
Left_UpperArm  || Bip001-L-UpperArm ||mixamorig:LeftArm
Left_Forearm  || Bip001-L-Forearm || mixamorig:LeftForeArm
Left_Hand     || Bip001-L-Hand || mixamorig:LeftHand

 

标签:读取,表格,mixamorig,name,names,Bip001,armature,bone,blender4.1
From: https://www.cnblogs.com/jingzaixin/p/18242521

相关文章

  • 08-表格和表单
    01-列表1.1常见列表1.2有序列表直接子元素只能是li<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metahttp-equiv="X-UA-Compatible"content="IE=edge"><metaname="vie......
  • blender4.1添加骨骼复制位置和复制旋转约束代码
    1.将骨架Skadi_SwimSuit_A_arma中的骨骼添加复制位置和复制旋转,目标选择骨架“Biped_Root”中对应的骨骼2.对应骨骼.txtBiped_Root||Skadi_SwimSuit_A_armaPelvis||Bip001-PelvisLeft_Thigh||Bip001-L-ThighLeft_Calf||Bip001-L-CalfLeft_Foot......
  • SSRF 漏洞实践:端口扫描与任意文件读取
    服务器端请求伪造(SSRF)是一种隐蔽且危险的安全漏洞,它允许攻击者欺骗服务器向其他服务器发送请求,从而访问或控制未经授权的系统。本文将通过实践案例,介绍SSRF漏洞在端口扫描和任意文件读取方面的应用,帮助您了解并防范这种漏洞。端口扫描SSRF漏洞可以用来探测目标服务器开......
  • 如何使用前端表格控件实现数据更新?
    前言小编之前分享过一篇文章叫《如何使用前端表格控件实现多数据源整合?》。今天,继续为大家介绍如何使用前端表格控件来更新已连接的数据源信息。环境准备SpreadJS在线表格编辑器:SpreadJS前端表格控件新版本新增了一款报表插件,该插件基于SpreadJS本身强大的表格能力,在DataM......
  • python快速生成二维码及读取二维码内容 pyqrcode MyQR pyzbar
    目录效果图生成二维码方式1:pyqrcode方式2:MyQR  读取二维码效果图生成二维码方式1:pyqrcode安装pipinstallpyqrcode代码实现importpyqrcode#text为保存在二维码的内容。text为完整链接时,扫描后可直接跳转到该链接text='https://www.baidu.com/'qr=pyqrc......
  • 【esp32 项目】中断读取按键
    原理图:图 按键部分图 单片机部分程序:KEY_USR 引脚配置成上拉输入在Arduino中,配置一个IO为上拉输入可以使用pinMode()函数和digitalWrite()函数。pinMode()函数用于设置引脚模式,而digitalWrite()函数用于设置上拉电阻。以下是一个示例代码,展示如何将Arduino的数字引脚3配......
  • 达梦数据库专用机报错会话读取数据页数超过资源限制设置值
    应用报错:专用机报错会话读取数据页数超过资源限制设置值 1、问题描述某单位程序中某个账户连接操作达梦数据库,日志中报错“会话读取数据页数超出超过资源限制值”,程序抛出异常处理并回退事务。此类问题一般出现在安全版ZYJ数据库上,像通用机的企业版数据库所有新建用户的资源......
  • Windows程序读取不了中文路径问题
    问题描述今天调试发现win32接口GetFileAttributesW居然不支持中文路径,于是寻找解决方案,找了半天,尝试用boost的fileystem库发现能用,而且boost能跨平台!不支持中文win32接口获取文件属性,当传入参数带有中文字符时,它获取的属性就会异常DWORDGetFileAttributesW([in]LPCWSTRlpFi......
  • mac免费的ntfs软件哪个好 MAC读取NTFS硬盘格式
    对于苹果用户来说,Mac电脑和移动硬盘已经成为日常工作中不可缺少的一部分,但有时我发现Mac打开移动硬盘只能读取无法写入,这是由于所连接的移动硬盘为NTFS格式。我们可以通过对硬盘格式化为Mac正常读写格式,或使用数据读写软件对NFTS硬盘进行写入数据。那么MAC有没有免费NTFS?今天......
  • ICESat-2 ATL08 数据批量读取
    ICESat-2ATL08数据概述ICESat-2(Ice,Cloud,andlandElevationSatellite-2)是美国宇航局(NASA)的一颗卫星,旨在测量地球的冰盖、云层和陆地的高程。ATL08数据产品专注于测量地表高程和植被的高度,主要用于研究森林、草地和冰川等地表特征。ATL08数据产品结构ATL08数据产品是......