Understnading the BOM creation APIs
//Create BOM //Creates a new BOMView PS_create_bom_view( NULLTAG, "", "", parent_item,&bv ); ifail = AOM_save( bv ); ifail = AOM_save( parent_item ); ifail = AOM_unlock( parent_item ); //Creates an initial working revision of a BOMView, with no occurrences. ifail = PS_create_bvr( bv, "", "", false, parent_rev,&(parent->bvr) ); ifail = AOM_save( parent->bvr ); ifail = AOM_save( parent_rev ); ifail = AOM_unlock( parent_rev ); //Creates a number of occurrences linking the specified parent BOMView Revision and the child Item ifail = PS_create_occurrences( parent->bvr, item, NULLTAG,line->no_of_occs, &occs ); //Sets the quantity attribute of an occurrence. A negative quantity means "quantity undefined." ifail = PS_set_occurrence_qty( parent->bvr, occs[i], qty ); //Sets the sequence number of an occurrence. PS_set_seq_no( parent->bvr, occs[i],line->seq_no ); ifail = PS_set_occurrence_name( parent->bvr, occs[i],line->occ_name ); //Adds the specified Item or Item Revision as a substitute child for the specified occurrence ifail = PS_add_substitute( parent->bvr, occs[i],item, NULLTAG );//We have done creating BOM //But may required to add variant condition on occurrence
//First Create option to define/add variant condition on occurrence
//Creates a new classic (legacy) option
BOM_new_option( rev,line->options.ids[opt],"",BOM_option_mode_enum,&option,&option_rev,&ve,&veb)
AOM_save(ve)
//Add values to created option
BOM_add_option_rev_value( option_rev,line->options.ids[opt],&thrown_away_index );
if (ITK_ok != AOM_save(option_rev)|| ITK_ok != AOM_save(option)
|| ITK_ok != POM_save_required( rev, &save_required )
|| ( save_required && ( ITK_ok != AOM_save(rev) ) ) )
//Adding variant condition on occurrence
//Creates a new empty clause list. This is used to create a new variant condition
BOM_variant_new_clause_list( window, &clause_list )
//Appends a new clause onto the end of a clause list.
//How this clause is related to its predecessor.
//Must be either BOM_variant_operator_and or BOM_variant_operator_or.
BOM_variant_clause_append ( clause_list,BOM_variant_operator_and,option,
( ( option_eq_s[0] == '=' )? BOM_variant_operator_is_equal: BOM_variant_operator_not_equal ),
option_val_s )
// Create a condition from the clause_list expression
if (ITK_ok != BOM_variant_join_clause_list ( clause_list, &cond_ve )//Creates a new condition Variant Expression from the clause list
|| ITK_ok != BOM_variant_expr_load_if ( cond_ve, &loadif_ve )// Creates a "load if" type Variant Expression which can be attached to a BOM Line (or Occurrence) to control variant configuration of an assembly.
|| ITK_ok != BOM_new_variant_e_block ( &veb )//Returns a newly-created variant expression block
|| ITK_ok != BOM_set_variant_e_block ( veb, 1, &loadif_ve )//Overwrites a variant expression block with new data.
|| ITK_ok != PS_set_variant_data( parent->bvr, occs[i], veb )//Sets the variant condition for the occurrence to the specified variant expression block
|| ITK_ok != AOM_save ( loadif_ve )
|| ITK_ok != AOM_save ( veb )
)
//Deletes a clause list.
ifail = BOM_variant_delete_clause_list ( clause_list );
// Get the occurrences from BOM //This function will return the tags of all bom views related to the Item. ITEM_list_bom_views( parent_item, &bv_count, &bvs); //This function will return the tags of all BOMView revisions for the Item Revision ITEM_rev_list_bom_view_revs( parent_rev, &bvr_count, &bvrs); //Lists all of the occurrences of the specified BOMViewRevision. ifail = PS_list_occurrences_of_bvr( parent->bvr,&n_occs, &occs ); //Deletes the occurrence from its parent BOMView Revision. ifail = PS_delete_occurrence( parent->bvr, occs[i] ); ifail = AOM_save( parent->bvr ); ifail = AOM_unlock( parent -> bvr );
It may be better if you describe it in detail and from first. It's create confusion. Overall its ok
ReplyDeleteHi,
DeleteThanks Sumant
Comment in the code will help you to understand every byte of code,it explains the api which you can use to create bom with variant condition
Hi Harsha,
ReplyDeletePlease try using apis provided under com.teamcenter.services.strong.cad.* package
StructureManagement.BomLineVariantCondition
Thanks,
Anil Bhendarkar
Thank you sir for this wonderful ITK code.
ReplyDeleteIt will be better for beginner like me, if you explain this with a practical example...