Results 1 to 2 of 2

Thread: How in python select top faces?

  1. #1
    Member 3DMish's Avatar
    Join Date
    Feb 2017
    Location
    Ukraine
    Posts
    6

    How in python select top faces?

    Hello everyone, i have a question.
    How in python, select top faces?

    like this:
    p.0072.png



  2. #2
    Member 3DMish's Avatar
    Join Date
    Feb 2017
    Location
    Ukraine
    Posts
    6
    I FOUND. I found it in add-ons "3D Print Toolbox".


    Then I corrected it, here:
    Code:
    import bpy, math, bmesh
    from mathutils import Vector
    
    
    def bmesh_copy_from_object(obj, transform=True, triangulate=True, apply_modifiers=False):
        assert(obj.type == 'MESH')
    
    
        if apply_modifiers and obj.modifiers:
            import bpy
            me = obj.to_mesh(bpy.context.scene, True, 'PREVIEW', calc_tessface=False)
            bm = bmesh.new(); bm.from_mesh(me); bpy.data.meshes.remove(me)
            del bpy
        else:
            me = obj.data
            if obj.mode == 'EDIT': bm_orig = bmesh.from_edit_mesh(me); bm = bm_orig.copy()
            else: bm = bmesh.new(); bm.from_mesh(me)
    
    
        if transform: bm.transform(obj.matrix_world)
        if triangulate: bmesh.ops.triangulate(bm, faces=bm.faces)
        return bm
    
    
    obj = bpy.context.scene.objects.active
    bm = bmesh_copy_from_object(obj, transform=True, triangulate=False); bm.normal_update()
    
    
    fo = [ele.index for ele in bm.faces if Vector((0, 0, -1.0)).angle(ele.normal, 4.0) > (math.pi / 2.0)]
    
    
    bpy.ops.mesh.select_all(action='DESELECT')
    for i in fo:
        obj = bpy.context.edit_object
        bm = bmesh.from_edit_mesh(obj.data).faces[i].select = True
        bmesh.update_edit_mesh(obj.data, True)



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •