Monday, February 27, 2012

BOM Table Relations

I've decided to post the "relations" from one of my fancier ProE (Creo) BOM tables here, both to preserve it for myself and as an example that might be helpful to others. For the most part, I've worked out how the syntax works via trial and error. The table itself may be downloaded from here. It is set up to support a particular drawing style, bubbles, etc, but does demonstrate some of what can be achieved with "relations" scripts.

It does things like use the part file names as part numbers, generate dash numbers for purchased parts, and displays weights. One peculiarity of our drawing format is that we indicate in our assembly bubbles what sheet a part is detailed on. To do that, we have to put the sheet number into a parameter, and hook it into the table, so the table can feed it into the BOM bubbles.

/**** Set part_num equal to the assembly file name, which is assumed to be a drawing number.
/**** Takes only first 8 characters, in order to eliminate dash numbers if there is one
part_num = extract(asm_name, 1, 8)

/**** Create dash number, using the assembly file name and find number,  for parts with part_type = P, part_number = "", and no part_number
index_num=rpt_index

IF exists("asm_mbr_part_number") == no
    asm_mbr_part_number = ""
ENDIF

IF asm_mbr_name == asm_mbr_part_number
    displayed_part_number = asm_mbr_name
ELSE
    displayed_part_number = "P/N<>FileName"
ENDIF

IF asm_mbr_part_type == "P" | asm_mbr_part_number == "auto" | asm_mbr_part_number == "Auto" | asm_mbr_part_number == "AUTO"
    displayed_part_number = part_num + "-" + itos( index_num)
endif

/**** For "F" parts, compare layout sheet # to callout sheet #, use a "-" in the bubble if they are the same
DETAIL_BUBBLE = "N/A"
DETAIL_TABLE = ""
IF asm_mbr_part_type == "F"
    IF exists("asm_mbr_detail_sheet") & exists("asm_mbr_bubble_sheet")
        if asm_mbr_detail_sheet == asm_mbr_bubble_sheet
            DETAIL_BUBBLE = "-"
            DETAIL_TABLE = itos(asm_mbr_detail_sheet)
        else
            DETAIL_BUBBLE = asm_mbr_detail_sheet
            if asm_mbr_detail_sheet                DETAIL_TABLE = itos(asm_mbr_detail_sheet) + "," + itos(asm_mbr_bubble_sheet)
            else
                DETAIL_TABLE = itos(asm_mbr_bubble_sheet) + "," + itos(asm_mbr_detail_sheet)
            endif
        endif
        spaces = (6.9 - string_length(DETAIL_TABLE))/2
        space_chars = extract("       ",1,spaces)
        DETAIL_TABLE = DETAIL_TABLE + space_chars
    else
        DETAIL_TABLE = "Part Type 'F' require int params 'DETAIL_SHEET' and 'BUBBLE_SHEET' in model."
        DETAIL_BUBBLE = DETAIL_TABLE
    endif
endif

/**** Calculate mass times qty for each part
total_weight = rpt_qty * asm_mbr_mass

/**** Compare calculated weight to vendor advertized weight
IF exists("asm_mbr_vendor_weight")
    delta_weight = asm_mbr_mass - asm_mbr_vendor_weight
else
    delta_weight = "<>"
endif

/**** If there is a material, use the data. Note: really handling sub-asseblies here, since they do not have a material
mat_name = "N/A"
IF exists("asm_mbr_ptc_material_name") == yes
    density_value = asm_mbr_pro_mp_density
    if exists("asm_mbr_density")
        density_value = "!!DensParam"
    endif

    /**** Use material description if it exists
    mat_name = asm_mbr_ptc_material_name
    material_callout=mat_name
    if mat_name != "UNASSIGNED" & exists("asm_mbr_ptc_material_ptc_material_description")
        mat_desc = asm_mbr_ptc_material_ptc_material_description
        if mat_desc != ""
            material_callout=mat_desc
        endif
    endif
endif

No comments: