Skip to content
Snippets Groups Projects
createMesh.py 81.8 KiB
Newer Older
  • Learn to ignore specific revisions
  • Brendon Murphy's avatar
    Brendon Murphy committed
        FaceStart = len(verts)
    
        Height_Offset = Z_LOCATION
        Lowest_Z_Vert = 0
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        x = INNER_HOLE + EDGE_THICKNESS
    
        verts.append([x, 0.0, z])
        Lowest_Z_Vert = min(Lowest_Z_Vert, z)
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        Row += 1
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        x = PART_INNER_HOLE
        z = Height_Offset
    
        verts.append([x, 0.0, z])
        Lowest_Z_Vert = min(Lowest_Z_Vert, z)
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        Row += 1
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        x = PART_INNER_HOLE
        z = Height_Offset - PART_THICKNESS
    
        verts.append([x, 0.0, z])
        Lowest_Z_Vert = min(Lowest_Z_Vert, z)
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        Row += 1
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        x = INNER_HOLE + EDGE_THICKNESS
        z = Height_Offset - PART_THICKNESS
    
        verts.append([x, 0.0, z])
        Lowest_Z_Vert = min(Lowest_Z_Vert, z)
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        Row += 1
    
    
        sVerts, sFaces = SpinDup(verts, faces, 360, DIV_COUNT, 'z')
        sVerts.extend(verts)  # add the start verts to the Spin verts to complete the loop
    
        faces.extend(Build_Face_List_Quads(FaceStart, Row - 1, DIV_COUNT, 1))
    
        return sVerts, faces, 0 - Lowest_Z_Vert
    
    Aaron Keith's avatar
    Aaron Keith committed
    def add_12_Point_Nut(FLAT, HOLE_DIA, HEIGHT,FLANGE_DIA):
        return Create_12_Point(FLAT, HOLE_DIA,HOLE_DIA, HEIGHT,FLANGE_DIA)
    
    
    
    
    # ####################################################################
    #                   Create Internal Thread
    # ####################################################################
    
    def Create_Internal_Thread_Start_Verts(verts, INNER_RADIUS, OUTTER_RADIUS, PITCH, DIV,
                                           CREST_PERCENT, ROOT_PERCENT, Height_Offset):
    
        Ret_Row = 0
        # Move the offset up so that the verts start at
        # at the correct place (Height_Start)
        Height_Offset = Height_Offset + PITCH
    
        Height_Step = float(PITCH) / float(DIV)
        Deg_Step = 360.0 / float(DIV)
    
        Crest_Height = float(PITCH) * float(CREST_PERCENT) / float(100)
        Root_Height = float(PITCH) * float(ROOT_PERCENT) / float(100)
    
        Root_to_Crest_Height = Crest_to_Root_Height = \
                            (float(PITCH) - (Crest_Height + Root_Height)) / 2.0
    
        Rank = float(OUTTER_RADIUS - INNER_RADIUS) / float(DIV)
    
        for i in range(DIV + 1):
            z = Height_Offset - (Height_Step * i)
            if z > Height_Start:
                z = Height_Start
            x = sin(radians(i * Deg_Step)) * OUTTER_RADIUS
            y = cos(radians(i * Deg_Step)) * OUTTER_RADIUS
    
            verts.append([x, y, z])
        Height_Offset -= Crest_Height
        Ret_Row += 1
    
        for i in range(DIV + 1):
            z = Height_Offset - (Height_Step * i)
            if z > Height_Start:
                z = Height_Start
    
            x = sin(radians(i * Deg_Step)) * OUTTER_RADIUS
            y = cos(radians(i * Deg_Step)) * OUTTER_RADIUS
    
            verts.append([x, y, z])
        Height_Offset -= Crest_to_Root_Height
        Ret_Row += 1
    
        for i in range(DIV + 1):
            z = Height_Offset - (Height_Step * i)
            if z > Height_Start:
                z = Height_Start
    
            x = sin(radians(i * Deg_Step)) * INNER_RADIUS
            y = cos(radians(i * Deg_Step)) * INNER_RADIUS
    
            x = sin(radians(i * Deg_Step)) * (OUTTER_RADIUS - (i * Rank))
            y = cos(radians(i * Deg_Step)) * (OUTTER_RADIUS - (i * Rank))
    
            verts.append([x, y, z])
        Height_Offset -= Root_Height
        Ret_Row += 1
    
        for i in range(DIV + 1):
            z = Height_Offset - (Height_Step * i)
            if z > Height_Start:
                z = Height_Start
    
            x = sin(radians(i * Deg_Step)) * INNER_RADIUS
            y = cos(radians(i * Deg_Step)) * INNER_RADIUS
    
            x = sin(radians(i * Deg_Step)) * (OUTTER_RADIUS - (i * Rank))
            y = cos(radians(i * Deg_Step)) * (OUTTER_RADIUS - (i * Rank))
    
            verts.append([x, y, z])
        Height_Offset -= Root_to_Crest_Height
        Ret_Row += 1
    
        return Ret_Row, Height_Offset
    
    def Create_Internal_Thread_End_Verts(verts, INNER_RADIUS, OUTTER_RADIUS, PITCH,
    
                                         CREST_PERCENT, ROOT_PERCENT, Height_Offset,
                                         DIV_COUNT):
    
        Height_Step = float(PITCH) / float(DIV_COUNT)
        Deg_Step = 360.0 / float(DIV_COUNT)
    
        Crest_Height = float(PITCH) * float(CREST_PERCENT) / float(100)
        Root_Height = float(PITCH) * float(ROOT_PERCENT) / float(100)
    
        Root_to_Crest_Height = Crest_to_Root_Height = \
                            (float(PITCH) - (Crest_Height + Root_Height)) / 2.0
    
        Rank = float(OUTTER_RADIUS - INNER_RADIUS) / float(DIV_COUNT)
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        Num = 0
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        for j in range(2):
    
            for i in range(DIV_COUNT + 1):
    
                z = Height_Offset - (Height_Step * i)
    
    Brendon Murphy's avatar
    Brendon Murphy committed
                if z < Height_End:
                    z = Height_End
    
                x = sin(radians(i * Deg_Step)) * OUTTER_RADIUS
                y = cos(radians(i * Deg_Step)) * OUTTER_RADIUS
                verts.append([x, y, z])
    
    Brendon Murphy's avatar
    Brendon Murphy committed
            Height_Offset -= Crest_Height
            Ret_Row += 1
    
            for i in range(DIV_COUNT + 1):
    
                z = Height_Offset - (Height_Step * i)
    
    Brendon Murphy's avatar
    Brendon Murphy committed
                if z < Height_End:
                    z = Height_End
    
                x = sin(radians(i * Deg_Step)) * OUTTER_RADIUS
                y = cos(radians(i * Deg_Step)) * OUTTER_RADIUS
                verts.append([x, y, z])
    
    Brendon Murphy's avatar
    Brendon Murphy committed
            Height_Offset -= Crest_to_Root_Height
            Ret_Row += 1
    
            for i in range(DIV_COUNT + 1):
    
                z = Height_Offset - (Height_Step * i)
    
    Brendon Murphy's avatar
    Brendon Murphy committed
                if z < Height_End:
                    z = Height_End
    
                x = sin(radians(i * Deg_Step)) * INNER_RADIUS
                y = cos(radians(i * Deg_Step)) * INNER_RADIUS
    
    Brendon Murphy's avatar
    Brendon Murphy committed
                if j == Num:
    
                    # Fix T51338 -  seems that the placing a small random offset makes the mesh valid
                    rand_offset = triangular(0.0001, 0.009)
                    x = sin(radians(i * Deg_Step)) * (INNER_RADIUS + (i * Rank + rand_offset))
                    y = cos(radians(i * Deg_Step)) * (INNER_RADIUS + (i * Rank + rand_offset))
    
    
    Brendon Murphy's avatar
    Brendon Murphy committed
                if j > Num:
    
                    x = sin(radians(i * Deg_Step)) * (OUTTER_RADIUS)
                    y = cos(radians(i * Deg_Step)) * (OUTTER_RADIUS)
    
                verts.append([x, y, z])
    
    Brendon Murphy's avatar
    Brendon Murphy committed
            Height_Offset -= Root_Height
            Ret_Row += 1
    
            for i in range(DIV_COUNT + 1):
    
                z = Height_Offset - (Height_Step * i)
    
    Brendon Murphy's avatar
    Brendon Murphy committed
                if z < Height_End:
                    z = Height_End
    
                x = sin(radians(i * Deg_Step)) * INNER_RADIUS
                y = cos(radians(i * Deg_Step)) * INNER_RADIUS
    
    Brendon Murphy's avatar
    Brendon Murphy committed
    
                if j == Num:
    
                    x = sin(radians(i * Deg_Step)) * (INNER_RADIUS + (i * Rank))
                    y = cos(radians(i * Deg_Step)) * (INNER_RADIUS + (i * Rank))
    
    Brendon Murphy's avatar
    Brendon Murphy committed
                if j > Num:
    
                    x = sin(radians(i * Deg_Step)) * (OUTTER_RADIUS)
                    y = cos(radians(i * Deg_Step)) * (OUTTER_RADIUS)
    
                verts.append([x, y, z])
    
    Brendon Murphy's avatar
    Brendon Murphy committed
            Height_Offset -= Root_to_Crest_Height
            Ret_Row += 1
    
    
        return Ret_Row, Height_End  # send back Height End as this is the lowest point
    
    def Create_Internal_Thread(INNER_DIA, OUTTER_DIA, PITCH, HEIGHT,
                               CREST_PERCENT, ROOT_PERCENT, INTERNAL, DIV_COUNT):
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        verts = []
        faces = []
    
        INNER_RADIUS = INNER_DIA / 2
        OUTTER_RADIUS = OUTTER_DIA / 2
    
        Deg_Step = 360.0 / float(DIV_COUNT)
        Height_Step = float(PITCH) / float(DIV_COUNT)
    
        # less one pitch for the start and end that is 1/2 pitch high
        Num = int(round((HEIGHT - PITCH) / PITCH))
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        Row = 0
    
        Crest_Height = float(PITCH) * float(CREST_PERCENT) / float(100)
        Root_Height = float(PITCH) * float(ROOT_PERCENT) / float(100)
    
        Root_to_Crest_Height = Crest_to_Root_Height = \
                            (float(PITCH) - (Crest_Height + Root_Height)) / 2.0
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        Height_Offset = 0
        FaceStart = len(verts)
    
        Row_Inc, Height_Offset = Create_Internal_Thread_Start_Verts(
                                        verts, INNER_RADIUS, OUTTER_RADIUS, PITCH,
                                        DIV_COUNT, CREST_PERCENT, ROOT_PERCENT,
                                        Height_Offset
                                        )
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        Row += Row_Inc
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        for j in range(Num):
    
            for i in range(DIV_COUNT + 1):
                x = sin(radians(i * Deg_Step)) * OUTTER_RADIUS
                y = cos(radians(i * Deg_Step)) * OUTTER_RADIUS
                verts.append([x, y, Height_Offset - (Height_Step * i)])
    
    Brendon Murphy's avatar
    Brendon Murphy committed
            Height_Offset -= Crest_Height
            Row += 1
    
            for i in range(DIV_COUNT + 1):
                x = sin(radians(i * Deg_Step)) * OUTTER_RADIUS
                y = cos(radians(i * Deg_Step)) * OUTTER_RADIUS
                verts.append([x, y, Height_Offset - (Height_Step * i)])
    
    Brendon Murphy's avatar
    Brendon Murphy committed
            Height_Offset -= Crest_to_Root_Height
            Row += 1
    
            for i in range(DIV_COUNT + 1):
                x = sin(radians(i * Deg_Step)) * INNER_RADIUS
                y = cos(radians(i * Deg_Step)) * INNER_RADIUS
                verts.append([x, y, Height_Offset - (Height_Step * i)])
    
    Brendon Murphy's avatar
    Brendon Murphy committed
            Height_Offset -= Root_Height
            Row += 1
    
            for i in range(DIV_COUNT + 1):
                x = sin(radians(i * Deg_Step)) * INNER_RADIUS
                y = cos(radians(i * Deg_Step)) * INNER_RADIUS
                verts.append([x, y, Height_Offset - (Height_Step * i)])
    
    Brendon Murphy's avatar
    Brendon Murphy committed
            Height_Offset -= Root_to_Crest_Height
            Row += 1
    
        Row_Inc, Height_Offset = Create_Internal_Thread_End_Verts(
                                            verts, INNER_RADIUS, OUTTER_RADIUS,
    
                                            PITCH, CREST_PERCENT,
                                            ROOT_PERCENT, Height_Offset, DIV_COUNT
    
        Row += Row_Inc
        faces.extend(Build_Face_List_Quads(FaceStart, DIV_COUNT, Row - 1, FLIP=1))
    
        return verts, faces, 0 - Height_Offset
    
    Brendon Murphy's avatar
    Brendon Murphy committed
    
    
    def Nut_Mesh(props, context):
    
        verts = []
        faces = []
        Head_Verts = []
    
        Head_Faces = []
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        Face_Start = len(verts)
    
    Aaron Keith's avatar
    Aaron Keith committed
        
        
        if props.bf_Nut_Type == 'bf_Nut_12Pnt':
            Nut_Height = props.bf_12_Point_Nut_Height
        else:
            Nut_Height = props.bf_Hex_Nut_Height
        
    
        Thread_Verts, Thread_Faces, New_Nut_Height = Create_Internal_Thread(
                                                        props.bf_Minor_Dia, props.bf_Major_Dia,
    
    Aaron Keith's avatar
    Aaron Keith committed
                                                        props.bf_Pitch, Nut_Height,
    
                                                        props.bf_Crest_Percent, props.bf_Root_Percent,
                                                        1, props.bf_Div_Count
                                                        )
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        verts.extend(Thread_Verts)
    
        faces.extend(Copy_Faces(Thread_Faces, Face_Start))
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        Face_Start = len(verts)
    
    Aaron Keith's avatar
    Aaron Keith committed
        
        if props.bf_Nut_Type == 'bf_Nut_12Pnt':
            Head_Verts, Head_Faces, Lock_Nut_Rad = add_12_Point_Nut(
                                                    props.bf_12_Point_Nut_Flat_Distance,
                                                    props.bf_Major_Dia, New_Nut_Height,
                                                    #Limit the size of the Flange to avoid calculation error
                                                    max(props.bf_12_Point_Nut_Flange_Dia,props.bf_12_Point_Nut_Flat_Distance)
                                                    )
        else:
            Head_Verts, Head_Faces, Lock_Nut_Rad = add_Hex_Nut(
    
                                                    props.bf_Hex_Nut_Flat_Distance,
                                                    props.bf_Major_Dia, New_Nut_Height
                                                    )
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        verts.extend((Head_Verts))
    
        faces.extend(Copy_Faces(Head_Faces, Face_Start))
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        LowZ = 0 - New_Nut_Height
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        if props.bf_Nut_Type == 'bf_Nut_Lock':
            Face_Start = len(verts)
    
            Nylon_Head_Verts, Nylon_Head_faces, LowZ = add_Nylon_Head(
                                                            Lock_Nut_Rad, 0 - New_Nut_Height,
                                                            props.bf_Div_Count
                                                            )
    
    Brendon Murphy's avatar
    Brendon Murphy committed
            verts.extend((Nylon_Head_Verts))
    
            faces.extend(Copy_Faces(Nylon_Head_faces, Face_Start))
    
    Brendon Murphy's avatar
    Brendon Murphy committed
            Face_Start = len(verts)
    
            Nylon_Verts, Nylon_faces, Temp_LowZ = add_Nylon_Part(
                                                            Lock_Nut_Rad, 0 - New_Nut_Height,
                                                            props.bf_Div_Count
                                                            )
    
    Brendon Murphy's avatar
    Brendon Murphy committed
            verts.extend((Nylon_Verts))
    
            faces.extend(Copy_Faces(Nylon_faces, Face_Start))
    
        return Move_Verts_Up_Z(verts, 0 - LowZ), faces
    
    # ####################################################################
    #                    Create Bolt
    # ####################################################################
    
    Brendon Murphy's avatar
    Brendon Murphy committed
    
    def Bolt_Mesh(props, context):
    
        verts = []
        faces = []
        Bit_Verts = []
        Bit_Faces = []
        Bit_Dia = 0.001
        Head_Verts = []
    
        Head_Faces = []
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        Head_Height = 0.0
    
    
        ReSized_Allen_Bit_Flat_Distance = props.bf_Allen_Bit_Flat_Distance  # set default
    
        Head_Height = props.bf_Hex_Head_Height  # will be changed by the Head Functions
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        if props.bf_Bit_Type == 'bf_Bit_Allen' and props.bf_Head_Type == 'bf_Head_Pan':
    
            # need to size Allen bit if it is too big.
            if Allen_Bit_Dia(props.bf_Allen_Bit_Flat_Distance) > Max_Pan_Bit_Dia(props.bf_Pan_Head_Dia):
                ReSized_Allen_Bit_Flat_Distance = Allen_Bit_Dia_To_Flat(
                                                    Max_Pan_Bit_Dia(props.bf_Pan_Head_Dia)
    
                                                    )
                ReSized_Allen_Bit_Flat_Distance -= ReSized_Allen_Bit_Flat_Distance * 0.05   # It looks better if it is just a bit smaller
    
                # print ("Resized Allen Bit Flat Distance to ",ReSized_Allen_Bit_Flat_Distance)
    
        # Bit Mesh
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        if props.bf_Bit_Type == 'bf_Bit_Allen':
    
            Bit_Verts, Bit_Faces, Bit_Dia = Create_Allen_Bit(
                                                    ReSized_Allen_Bit_Flat_Distance,
                                                    props.bf_Allen_Bit_Depth
                                                    )
    
    Aaron Keith's avatar
    Aaron Keith committed
        if props.bf_Bit_Type == 'bf_Bit_Torx':
            Bit_Verts, Bit_Faces, Bit_Dia = Create_Torx_Bit(
                                                    Torx_Bit_Size_To_Point_Distance(props.bf_Torx_Size_Type),
                                                    props.bf_Torx_Bit_Depth
                                                    )
    
    
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        if props.bf_Bit_Type == 'bf_Bit_Philips':
    
            Bit_Verts, Bit_Faces, Bit_Dia = Create_Phillips_Bit(
                                                    props.bf_Philips_Bit_Dia,
                                                    props.bf_Philips_Bit_Dia * (0.5 / 1.82),
                                                    props.bf_Phillips_Bit_Depth
                                                    )
        # Head Mesh
        if props.bf_Head_Type == 'bf_Head_Hex':
            Head_Verts, Head_Faces, Head_Height = Create_Hex_Head(
                                                    props.bf_Hex_Head_Flat_Distance, Bit_Dia,
                                                    props.bf_Shank_Dia, props.bf_Hex_Head_Height
                                                    )
    
    Aaron Keith's avatar
    Aaron Keith committed
            
        elif props.bf_Head_Type == 'bf_Head_12Pnt':
            Head_Verts, Head_Faces, Head_Height = Create_12_Point_Head(
                                                    props.bf_12_Point_Head_Flat_Distance, Bit_Dia,
                                                    props.bf_Shank_Dia, props.bf_12_Point_Head_Height,
                                                    #Limit the size of the Flange to avoid calculation error
                                                    max(props.bf_12_Point_Head_Flange_Dia,props.bf_12_Point_Head_Flat_Distance)  
                                                    )
    
        elif props.bf_Head_Type == 'bf_Head_Cap':
    
            Head_Verts, Head_Faces, Head_Height = Create_Cap_Head(
                                                    Bit_Dia, props.bf_Cap_Head_Dia,
                                                    props.bf_Shank_Dia, props.bf_Cap_Head_Height,
                                                    props.bf_Cap_Head_Dia * (1.0 / 19.0),
                                                    props.bf_Cap_Head_Dia * (1.0 / 19.0),
                                                    props.bf_Div_Count
                                                    )
        elif props.bf_Head_Type == 'bf_Head_Dome':
            Head_Verts, Head_Faces, Head_Height = Create_Dome_Head(
                                                    Bit_Dia, props.bf_Dome_Head_Dia,
                                                    props.bf_Shank_Dia, props.bf_Hex_Head_Height,
                                                    1, 1, 0, props.bf_Div_Count
                                                    )
    
        elif props.bf_Head_Type == 'bf_Head_Pan':
    
            Head_Verts, Head_Faces, Head_Height = Create_Pan_Head(
                                                    Bit_Dia, props.bf_Pan_Head_Dia,
                                                    props.bf_Shank_Dia,
                                                    props.bf_Hex_Head_Height, 1, 1, 0,
                                                    props.bf_Div_Count
                                                    )
    
        elif props.bf_Head_Type == 'bf_Head_CounterSink':
    
            Head_Verts, Head_Faces, Head_Height = Create_CounterSink_Head(
                                                    Bit_Dia, props.bf_CounterSink_Head_Dia,
                                                    props.bf_Shank_Dia, props.bf_CounterSink_Head_Dia,
                                                    props.bf_CounterSink_Head_Dia * (0.09 / 6.31),
                                                    props.bf_Div_Count
                                                    )
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        Face_Start = len(verts)
    
        verts.extend(Move_Verts_Up_Z(Bit_Verts, Head_Height))
        faces.extend(Copy_Faces(Bit_Faces, Face_Start))
    
    Brendon Murphy's avatar
    Brendon Murphy committed
    
        Face_Start = len(verts)
    
        verts.extend(Move_Verts_Up_Z(Head_Verts, Head_Height))
        faces.extend(Copy_Faces(Head_Faces, Face_Start))
    
    Brendon Murphy's avatar
    Brendon Murphy committed
    
        Face_Start = len(verts)
    
        Thread_Verts, Thread_Faces, Thread_Height = Create_External_Thread(
                                                        props.bf_Shank_Dia, props.bf_Shank_Length,
                                                        props.bf_Minor_Dia, props.bf_Major_Dia,
                                                        props.bf_Pitch, props.bf_Thread_Length,
                                                        props.bf_Crest_Percent,
                                                        props.bf_Root_Percent, props.bf_Div_Count
                                                        )
    
    Aaron Keith's avatar
    Aaron Keith committed
        verts.extend(Move_Verts_Up_Z(Thread_Verts, 0))
    
        faces.extend(Copy_Faces(Thread_Faces, Face_Start))
    
        return Move_Verts_Up_Z(verts, Thread_Height), faces
    
    Aaron Keith's avatar
    Aaron Keith committed
    def Create_New_Mesh(props, context):
    
    Brendon Murphy's avatar
    Brendon Murphy committed
    
        verts = []
        faces = []
    
    Aaron Keith's avatar
    Aaron Keith committed
        edges = []
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        if props.bf_Model_Type == 'bf_Model_Bolt':
    
            # print('Create Bolt')
    
    Brendon Murphy's avatar
    Brendon Murphy committed
            verts, faces = Bolt_Mesh(props, context)
            sObjName = 'Bolt'
    
    Brendon Murphy's avatar
    Brendon Murphy committed
        if props.bf_Model_Type == 'bf_Model_Nut':
    
            # print('Create Nut')
    
    Brendon Murphy's avatar
    Brendon Murphy committed
            verts, faces = Nut_Mesh(props, context)
            sObjName = 'Nut'
    
        verts, faces = RemoveDoubles(verts, faces)
    
        verts = Scale_Mesh_Verts(verts, GLOBAL_SCALE)
    
    Aaron Keith's avatar
    Aaron Keith committed
        mesh = bpy.data.meshes.new(name=sObjName)
        mesh.from_pydata(verts, edges, faces)
    
        # useful for development when the mesh may be invalid.
        # Fix T51338 : Validate the mesh (the internal thread generator for the Nut
        # should be more reliable now, however there could be other possible errors)
        is_not_mesh_valid = mesh.validate()
    
        if is_not_mesh_valid:
    
            props.report({'INFO'}, "Mesh is not Valid, correcting")