Page 1 of 2 12 LastLast
Results 1 to 20 of 22
  1. #1
    Member pitiwazou's Avatar
    Join Date
    Jul 2013
    Location
    France
    Posts
    2,392

    [Addon] - Mesh Check

    Hi,

    I'm working on a new addon to check my meshes.

    The goal is to see Ngons and tri in the viewport when working on objects.

    Right now it uses vertex paint to show faces, a friend made me a little code for that and I finished to make an addon and use it when working in edit mode to clean my mesh.
    I implemented a part of CoDEmanX's script "mesh_face_info_select.py" to select Ngons and tri.

    It's a wip, and I hope it is possible to have an autorefresh in real time when the show faces is activated.
    I'm not as good to do this, so if someone can help me, don't hesitate !

    mesh_check.jpg

    Code:
     # ##### BEGIN GPL LICENSE BLOCK #####
    #
    #  This program is free software; you can redistribute it and/or
    #  modify it under the terms of the GNU General Public License
    #  as published by the Free Software Foundation; either version 2
    #  of the License, or (at your option) any later version.
    #
    #  This program is distributed in the hope that it will be useful,
    #  but WITHOUT ANY WARRANTY; without even the implied warranty of
    #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    #  GNU General Public License for more details.
    #
    #  You should have received a copy of the GNU General Public License
    #  along with this program; if not, write to the Free Software Foundation,
    #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    #
    # ##### END GPL LICENSE BLOCK #####
    
    
    bl_info = {
        "name": "Mesh Check",
        "author": "Clarkx, Cédric Lepiller, CoDEmanX",
        "version": (0, 0, 1),
        "blender": (2, 74, 0),
        "description": "Custom Menu to show faces, tri, Ngons on the mesh",
        "category": "3D View",}
    
    
    
    
    import bpy
    from bpy.props import EnumProperty
    
    
    bpy.types.Scene.show_faces = bpy.props.BoolProperty(default=False)
    
    
    ##CoDEmanX's code to select Ngons, tri  
    class DATA_OP_facetype_select(bpy.types.Operator):
        """Select all faces of a certain type"""
        bl_idname = "data.facetype_select"
        bl_label = "Select by face type"
        bl_options = {'REGISTER', 'UNDO'}
    
    
        face_type = EnumProperty(name="Select faces:",
                                 items = (("3","Triangles","Faces made up of 3 vertices"),
                                          ("4","Quads","Faces made up of 4 vertices"),
                                          ("5","Ngons","Faces made up of 5 and more vertices")),
                                 default = "5")
        @classmethod
        def poll(cls, context):
            return context.active_object is not None and context.active_object.type == 'MESH'
    
    
        def execute(self, context):
    
    
            bpy.ops.object.mode_set(mode='EDIT')
            bpy.ops.mesh.select_all(action='DESELECT')
            context.tool_settings.mesh_select_mode=(False, False, True)
    
    
            if self.face_type == "3":
                bpy.ops.mesh.select_face_by_sides(number=3, type='EQUAL')
            elif self.face_type == "4":
                bpy.ops.mesh.select_face_by_sides(number=4, type='EQUAL')
            else:
                bpy.ops.mesh.select_face_by_sides(number=4, type='GREATER')
    
    
            return {'FINISHED'}
    
    
    #Clarkx's code to show faces, Ngons and Tris with the vertex paint mode.
    class Show_Faces(bpy.types.Operator):
        bl_idname = "object.showfaces"
        bl_label = "Show Faces"
        bl_description = "Show Tri, Ngons and Faces"
        bl_options = {"REGISTER"}
        
        @classmethod
        def poll(cls, context):
            return True
        
        def execute(self, context):
            scn = context.scene
            
            bpy.context.scene.render.engine = 'BLENDER_RENDER'
            bpy.ops.object.mode_set(mode="VERTEX_PAINT")
    
    
            bpy.ops.mesh.vertex_color_remove()
            # Objet actif
            mesh = context.active_object.data
    
    
            # Creation d'un nouveau vertex color
            vertex_colors = mesh.vertex_colors.new().data
    
    
            # Pour chaque polygon de l'object
            for poly in mesh.polygons:
                
                # Recupération du nombre de vertices
                nbvert = len(poly.vertices)
                
                # Pour chaque vertex on assigne une couleur :
                for loop_index in poly.loop_indices:
    
    
                    # Rouge : Si le polygon a trois vertices
                    if nbvert == 3: # Triangle
                        vertex_colors[loop_index].color =  [0.603, 0.500, 0.117]
    
    
                    # Vert : Si le polygon a quatre vertices
                    if nbvert == 4: # Quad
                        vertex_colors[loop_index].color =  [0.5, 0.5, 0.5]
    
    
                    # Bleu : Si le polygon a un nombre de vertices > 4
                    if nbvert > 4: # Ngons
                        vertex_colors[loop_index].color =  [0.8, 0.146, 0.146]
                        
            bpy.ops.object.mode_set(mode="EDIT")
            bpy.context.space_data.viewport_shade = 'TEXTURED'  
            
            scn.show_faces = True
            
            
            
            return {"FINISHED"}    
    
    
    class Remove_Vertex_Color(bpy.types.Operator):
        bl_idname = "object.removevertexcolor"
        bl_label = "Remove Vertex Color"
        bl_description = "Remove Vertex Color to clean the List"
        bl_options = {"REGISTER"}
        
        @classmethod
        def poll(cls, context):
            return True
        
        def execute(self, context):
            scn = context.scene
            
            bpy.ops.mesh.vertex_color_remove()
            bpy.ops.object.mode_set(mode="OBJECT")
            bpy.context.space_data.viewport_shade = 'SOLID'
            scn.show_faces = False
    
    
            return {"FINISHED"} 
    
    
    class Show_Faces_Menu(bpy.types.Panel):
        bl_idname = "view3D.show_faces_menu"
        bl_label = "Mesh Check"
        bl_space_type = "VIEW_3D"
        bl_region_type = "TOOLS"
        bl_category = "Mesh Check"
        
        
        
        @classmethod
        def poll(self, context):          
            return context.active_object is not None and context.active_object.type == 'MESH'
        
        def draw(self, context):
            layout = self.layout
            scn = context.scene
            
            if scn.show_faces == False:
                
                layout.operator("object.showfaces", text='Show Faces', icon='COLOR')
                
            else:
                row = layout.row(align=True)
                row.operator("object.removevertexcolor", text='Hide Faces', icon='GHOST_ENABLED') 
                row.operator("object.showfaces", text='Refresh', icon='FILE_REFRESH')  
            
            
            #code by CoDEmanX to select Ngons, tri   
            ob = context.active_object
            
            info_str = ""
            tris = quads = ngons = 0
    
    
            for p in ob.data.polygons:
                count = p.loop_total
                if count == 3:
                    tris += 1
                elif count == 4:
                    quads += 1
                else:
                    ngons += 1
    
    
            info_str = "  Ngons: %i  Quads: %i  Tris: %i" % (ngons, quads, tris)
            
            col = layout.column()
            col.label(info_str, icon='MESH_DATA')
    
    
            col = layout.column()
            col.label("Select faces by type:")
    
    
            row = layout.row(align=True)
            row.operator("data.facetype_select", text="Ngons").face_type = "5"
            row.operator("data.facetype_select", text="Quads").face_type = "4"
            row.operator("data.facetype_select", text="Tris").face_type = "3"   
            
    
    
    def register():
        bpy.utils.register_module(__name__)
    
    
    def unregister():
        bpy.utils.unregister_module(__name__)
        
    if __name__ == "__main__":
        register()


    It's a wip, and I hope it will be possible to have an autorefresh in real time when the show faces is activated.
    I'm not as good to do this, so if someone can help me, don't hesitate !

    The best will be to have a button in the Npanel>shading to show those Ngons and tri in real time ^^

    Hope you like it and thx to Clarkx and CoDEmanX !
    Last edited by pitiwazou; 10-Apr-15 at 03:55.



  2. #2
    Member
    Join Date
    Jul 2010
    Location
    Dominican Republic
    Posts
    1,561
    this is similar to meshlint addon i hope mesh lint cant be real-time and add color for better visual feedback
    http://wiki.blender.org/index.php/Ex...eling/MeshLint



  3. #3
    Member
    Join Date
    Jul 2010
    Location
    Dominican Republic
    Posts
    1,561
    may be you can join force with meshlint creator and make a more robust addon



  4. #4
    Member MmAaXx's Avatar
    Join Date
    Jun 2008
    Location
    Tokyo
    Posts
    1,682
    you did it again



  5. #5
    Member pitiwazou's Avatar
    Join Date
    Jul 2013
    Location
    France
    Posts
    2,392
    Thx ^^

    I use Meshlint every day, but honesly I only use the select ngons.

    I think we can make a great tool for cleanning meshes, I'm a newbie in conding, so if someone want participate, it will be great ^^



  6. #6
    Member 1D_Inc's Avatar
    Join Date
    Mar 2012
    Location
    Russia
    Posts
    754
    Hello there
    You can use Fedge tool from 1D_Scripts, for searching different mesh checks in object or edit modes



  7. #7
    Member yii7's Avatar
    Join Date
    Sep 2012
    Location
    Turkey
    Posts
    690
    There is already a select mode for this; you can do this with Select Menu > Select Face by Sides > Set number of vertices in the panel and choose comparison method (greater , less than, equal)
    yiit.deviantart.com



  8. #8
    Member pitiwazou's Avatar
    Join Date
    Jul 2013
    Location
    France
    Posts
    2,392
    The problem is not to select faces, but to update automatically the vertex paint ^^



  9. #9
    Member yii7's Avatar
    Join Date
    Sep 2012
    Location
    Turkey
    Posts
    690
    Originally Posted by pitiwazou View Post
    The problem is not to select faces, but to update automatically the vertex paint ^^
    Sorry ; my bad.
    yiit.deviantart.com



  10. #10
    Wazou strikes again!

    Great idea, elegant resolve.
    It'd be awesome to have a live update, but even as is I find this very useful. I prefer this to mesh lint, way better from my point of view.

    You're spot on with so many things you're doing. If I could imagine a dream roadmap for blender, it'd be BI hiring you as a consultant! It's evident that all the stuff you do is from a user perspective, and one who has extensive experience from many platforms. Here's to hopes someone from the BI recognizes what you bring to the table.

    Thanks on sharing all the hard work!



  11. #11
    Member pitiwazou's Avatar
    Join Date
    Jul 2013
    Location
    France
    Posts
    2,392
    Thx OrAngE, but I'm not as good as you think ^^



  12. #12
    Member pitiwazou's Avatar
    Join Date
    Jul 2013
    Location
    France
    Posts
    2,392
    Update of Mesh Check By pistiwique !

    It's now in realtime, works well with Automatcap and keep the shading.

    https://github.com/pitiwazou/Scripts...pts/mesh_check




  13. #13
    Member
    Join Date
    Jan 2014
    Location
    Dresden
    Posts
    589
    Great Work!...Thanks for sharing!
    Happy New Year! May joy be with you...
    "Just simple, but not simpler!" (A.E.) / "Let`s do it 2018: http://t1p.de/57r4"



  14. #14
    indeed great work very useful for the retopo process.
    Big thanks to pistiwique (whoever he is ) and to you pitiwazou



  15. #15
    Awesome!
    Much appreciated, thanks.



  16. #16
    Member pitiwazou's Avatar
    Join Date
    Jul 2013
    Location
    France
    Posts
    2,392
    New BGL version soon available and modified by pistiwique !



    No more shaders ^^



  17. #17
    Member 1D_Inc's Avatar
    Join Date
    Mar 2012
    Location
    Russia
    Posts
    754
    Hi!
    We wrote a Fedge function (from 1D_Scripts tools), that locates tris/ngons, loose verts, loose edges, non-manifold edges and tiny-area polygons in object and edit modes!

    Attached Images Attached Images



  18. #18
    Member 1D_Inc's Avatar
    Join Date
    Mar 2012
    Location
    Russia
    Posts
    754
    It selects by step, ignoring hidden and evaluets by hitting space and entering "FFF" in search line



  19. #19
    Hello guys.
    This is the last release of the mesh check addon. The code is based on the Matpi's addon Borderline.
    You can download MechCheck here:
    https://github.com/pistiwique/mesh_check
    Last edited by pistiwique; 17-Aug-16 at 15:26.



  20. #20
    Member
    Join Date
    Oct 2011
    Location
    Stockholm
    Posts
    154
    Very nice, thanks for sharing!

    I'm wondering if the colors and face opacity options wouldn't be better in the Add-on settings instead of the Display tab, which is already quite cluttered? I assume one wouldn't want to change these settings often.
    Last edited by chafouin; 16-Aug-16 at 05:58.



Page 1 of 2 12 LastLast

Posting Permissions

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