【问题标题】:Selecting all Empties without Children选择所有没有子项的空
【发布时间】:2022-01-23 19:58:50
【问题描述】:

我有一个包含数千个零件的大型结构化模型。在 CAD 导出(到 fbx)期间,文件被简化并移除了许多小部件(如螺钉和垫圈)。但是,在 Blender 中,我现在有很多“空”,下面没有任何孩子。 我想选择所有没有子对象的空对象,这样我就可以将它们全部删除。

【问题讨论】:

    标签: blender fbx


    【解决方案1】:

    我的 python 有点生锈了,我敢肯定,有很多更好的方法可以做到这一点。但是,这是一个可以解决问题的 bpy 脚本。 选择根为空并运行脚本。然后可以删除选定的空。 要获取整个树中的所有空,脚本必须运行多次,直到没有更多的空被选择...

    import bpy
    
    root_object = bpy.context.object
    empties = []
    selected = []
    
    def select_children_recursive(obj_parent):
        for obj in obj_parent.children:
            select_children_recursive(obj)
            if obj.type == 'EMPTY':
                empties.append(obj)
    
    
    # call the function
    select_children_recursive(root_object)
    
    # deselect everyting
    bpy.ops.object.select_all(action='DESELECT')
    
    # select all empties that have NO children
    
    for obj in empties:
        if len(obj.children) == 0:
            selected.append(obj)
            obj.select_set(True)
    
    
    print('{} empties were selected'.format(len(selected)))
    print('Press x to delete them and re-run this script again multiple times in order to delete all empies throughout the entire structure.')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-11
      • 2019-01-05
      • 2015-03-03
      相关资源
      最近更新 更多