##  material_list1.py Version 1.00 (module macrolib.material_list1)

##  Copyright (c) 2007 Bruce Vaughan, BV Detailing & Design, Inc.

##  All rights reserved.

##  NOT FOR SALE. The software is provided "as is" without any warranty.

########################################################################

"""

Return a list of the material found on a member

SDS/2 Version 7.1?? required

"""

from member import Member

 

def iter_mtrl(mem):

    for i in range(mem.mtrl_quantity):

        yield mem.material(i)

 

def list_mtrl(mem):

    return [mem.material(i) for i in range(mem.mtrl_quantity)]

 

if __name__ == '__main__':

    from member import MemberLocate

    from macrolib.columnize import columnize

    from param import ClearSelection, dim_print

    from job import Job

    from macrolib.inch_print import inch_print

   

    def memMtrlList():

            mem = MemberLocate('Select member')

            ClearSelection()

            cw = 8

            print '%s%s%s\n%s' % (columnize('\nINDEX', cw, 'Center'), \

                                  columnize('DESCR', 2*cw, 'Center'),\

                                  columnize('MARK', cw, 'Center'), \

                                  "-"*(4*cw))

            #for i, m in enumerate(iter_mtrl(mem)):

            for i, m in enumerate(list_mtrl(mem)):

                print '%s%s%s' % (columnize(str(i), cw, 'Center'), \

                                  columnize(m.description, 2*cw, 'Center'), \

                                  columnize(m.piecemark, cw, 'Center'))

 

            jobBplList = ['PL'+'x'.join([inch_print(plate.thick), inch_print(plate.width)]) for plate in Job().plate_def()]

            print

            # print jobBplList

            print

            for mtrl in iter_mtrl(mem):

                    if mtrl.description in jobBplList:

                            print "The base/cap plate on this column is marked %s" % mtrl.piecemark

            print

               

    def plateDefList():

            for i, plate in enumerate(Job().plate_def()):

                    print 'Plate Number: %d  Description: PL%s' % (i+1, 'x'.join([inch_print(plate.thick), inch_print(plate.width), dim_print(plate.length)]))

                   

            print '\nAttributes of each plate object in the Plate Definition Schedule:'

            print ', '.join(dir(plate))

 

   

    memMtrlList()

    #plateDefList()

                       

'''

member mtrl index         material description        material piecemark

------------------------------------------------------------------------

        0                      HSS3x3x1/4                   hss16       

        1                    BPL3/8x5 7/16                    h7       

        2                    BPL3/8x5 7/16                    h7       

        3                    BPL3/8x5 7/16                    h7       

        4                    BPL3/8x5 7/16                    h7       

        5                       PL1/4x3                      p34       

        6                       PL1/4x3                      p34       

        7                       PL1/4x3                      p34        

        8                       PL1/4x3                      p34       

        9                       PL1/4x3                      p34       

        10                      PL1/4x3                      p34       

        11                      PL1/4x3                      p34       

        12                      PL1/4x3                      p34       

        13                   BPL3/8x5 7/16                    h9       

        14                      FL3/8x4                      p12        

        15                      FL3/8x4                      p12       

        16                      FL3/8x5                      p19       

        17                      FL3/8x5                      p19       

        18                      FL3/8x5                      p19       

        19                      FL3/8x5                      p19       

        20                      FL3/8x5                      p19       

        21                      FL3/8x5                      p19        

        22                      FL3/8x5                      p19       

        23                      FL3/8x5                      p19       

        24                      FL3/8x5                      p59       

        25                      FL3/8x5                      p59       

        26                       W16x26                      w16       

'''