Monday, October 7, 2013

Teamcenter: ITK BOM Clone Trick

I have searched this API usage in GTAC and the result was none. After writing many lines of code, found that one single API can rule out the change.
(Sometimes SMALL things can do BIG).
int Clone_init()
{
    tag_t tItem         = NULLTAG;
    tag_t tItemRev      = NULLTAG;
    tag_t tBomWindow    = NULLTAG;
    tag_t tBomLine      = NULLTAG;
    tag_t tNewProd      = NULLTAG;
    tag_t tRevRuleTag   = NULLTAG;
   
    //top line item holding the whole structure
    tItem = ITEM_find_item("000236");
    tItemRev = ITEM_find_rev("000236","A");
   
    ITK_CALL( BOM_create_window ( &tBomWindow ) );
    ITK_CALL ( BOM_set_window_pack_all (tBomWindow, true));
    ITK_CALL ( CFM_find ("Latest Working", &tRevRuleTag ));
    ITK_CALL ( BOM_set_window_config_rule (tBomWindow, tRevRuleTag ));
    ITK_CALL( BOM_set_window_top_line ( tBomWindow, tItem, tItemRev, NULLTAG, &tBomLine ));
    //This API is similar to File->New->Item from Template option.
    ITK_CALL( ME_create_product_from_template( "","A","Test Name","Test Desc",tItemRev,tRevRuleTag,tBomWindow,"Product.Template.Cloning",&tNewProd ));
    return 0;
}

THE RESULT:

2 comments:

  1. Hi Bharat,
    I have never used this API, but it does look interesting. Could you explain the usecase where you had to use this. Also, the API description says "Clone a Product revision recursively from input revision id". Could you explain this.

    ReplyDelete
    Replies
    1. Hello,

      If you want to copy/clone the exact whole structure to a new one, you should write a recursive method to traverse the whole structure and then create a new structure with same object names.

      Instead of using a recursive method, the above API will help you to do the same.

      Regards
      Bharat

      Delete