cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

How to create create varied items for inheritance feature using Pro/Toolkit?

How to create create varied items for inheritance feature using Pro/Toolkit?

Hi all,

I still have a TS call open but for sure someone will answer me there

I'm trying to create varied items on an inheritance feature using Pro/Toolkit

Varied dimension creation is ok but I cannot find a way to create varied parameter or varied feature

Perhaps I've to use otk or jlink instead of toolkit.

Thanks in advance


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
2 REPLIES 2

Hi Frédérick,

  I am also working on inheritance nowadays, but it is unsuccessful, it always told me "BAD_INPUT", can you share me your code about this?

I have a dozens of parts need to inheritance automatically, don't need to create the varied items, just only inheritance.

my email address: -

I am very appreciate if you can share me. thanks!

Here is my code, but it doesn't work, I can't figure out why? Can you help me?

/*====================================================================*\
FUNCTION : ProTestInheritMerge ()
PURPOSE  : Inherit Merge  general merge feature .
\*====================================================================*/
void ProTestInheritMerge ()
{
    ProError       err;
    ProElement     elem_root;
    ProSelection   sel;
    ProModelitem   modelitem;
ProErrorlist   errors;
ProFeature     feature;
ProFamilyName comp_name;
ProModelitem item_asm_csys,item_comp_csys,comp_item;
ProName asm_csys,comp_csys;
ProMdl       assembly,component;
ProSelection   _asm_csys,_comp_csys,comp_mdl;

err=ProMdlCurrentGet(&assembly);
if (err != PRO_TK_NO_ERROR)
    {
  AfxMessageBox(L"ProMdlCurrentGet failed!");
  return;
    }
ProStringToWstring(comp_name,"prt0001.prt");
err=ProMdlRetrieve(comp_name,PRO_MDL_PART,&component);
ProStringToWstring(asm_csys,"INSTALL");
ProStringToWstring(comp_csys,"INSTALL");
err = ProModelitemByNameInit(assembly,PRO_CSYS,asm_csys,&item_asm_csys);
if (err != PRO_TK_NO_ERROR)
    {
  AfxMessageBox(L"ProModelitemByNameInit((ProMdl)assembly failed!");
  return;
    }
err = ProModelitemByNameInit (component, PRO_CSYS,comp_csys, &item_comp_csys);
     if (err != PRO_TK_NO_ERROR)
    {
  AfxMessageBox(L"PRO_TK_BAD_INPUTS");
  return;
    }
ProAsmcomppath comp_path;
ProIdTable c_id_table;
c_id_table [0] = -1;
err =ProAsmcomppathInit ((ProSolid)assembly, c_id_table, 0, &comp_path);
if (err != PRO_TK_NO_ERROR)
    {
  AfxMessageBox(L"ProAsmcomppathInit failed!");
  return;
    }
err = ProSelectionAlloc (&comp_path, &item_asm_csys, &_asm_csys);
      if (err != PRO_TK_NO_ERROR)
    {
  AfxMessageBox(L"ProSelectionAlloc failed!");
  return;
    }
err = ProSelectionAlloc (NULL, &item_comp_csys, &_comp_csys);
if (err != PRO_TK_NO_ERROR)
    {
  AfxMessageBox(L"ProSelectionAlloccomponent failed!");
  return;
    }

ProFeatureCreateOptions  opts[] = {PRO_FEAT_CR_INCOMPLETE_FEAT};
static ElemTreeData tree[] = {
  {0, PRO_E_FEATURE_TREE,{(ProValueDataType)-1}},
  {1, PRO_E_FEATURE_TYPE, {PRO_VALUE_TYPE_INT, {PRO_FEAT_GEN_MERGE}}},
  {1, PRO_E_GMRG_FEAT_TYPE, {PRO_VALUE_TYPE_INT, {PRO_GEN_MERGE_TYPE_MERGE}}},
  {1, PRO_E_DSF_REF_MDL, {(ProValueDataType)-1}},
  {1, PRO_E_GMRG_MATERIAL_OPT, {PRO_VALUE_TYPE_INT, {PRO_GEN_MERGE_ADD_MATERIAL}}},
  //{1, PRO_E_GMRG_VARIED_ITEMS,  {(ProValueDataType)-1}},
  //{1, PRO_E_GMRG_COPY_DATUMS, {PRO_VALUE_TYPE_INT, {PRO_B_FALSE}}},
  //{1, PRO_E_DSF_PROPAGATE_ANNOTS, {(ProValueDataType)-1}},
  //{1, PRO_E_DSF_DTMS_FIT,  {(ProValueDataType)-1}},
  {1, PRO_E_DSF_DEPENDENCY, {PRO_VALUE_TYPE_INT, {PRO_DSF_ANNOT_DEPENDENT}}},

  //{2, PRO_E_DSF_ANNOT_CPY_ALL, {PRO_VALUE_TYPE_INT, {PRO_B_TRUE}}},
  //{2, PRO_E_DSF_ANNOT_DEPEND_ALL, {PRO_VALUE_TYPE_INT, {PRO_B_TRUE}}},
  //{2, PRO_E_DSF_ANNOT_AUTO_CPY_DTM , {PRO_VALUE_TYPE_INT, {PRO_B_TRUE}}},

  {2, PRO_E_DSF_EXT_LOCAL_TYPE, {PRO_VALUE_TYPE_INT, {PRO_DSF_PLACE_EXTERNAL}}},
  {2, PRO_E_DSF_SEL_REF_MDL, {PRO_VALUE_TYPE_SELECTION}},
  {2, PRO_E_DSF_PLACEMENT , {(ProValueDataType)-1}},
  //{2, PRO_E_DSF_DTM_FIT, {(ProValueDataType)-1}},

  {3, PRO_E_COMPONENT_CONSTRAINTS, {(ProValueDataType)-1}},
  {4, PRO_E_COMPONENT_CONSTRAINT, {(ProValueDataType)-1}},
  {5, PRO_E_COMPONENT_CONSTR_TYPE, {PRO_VALUE_TYPE_INT, {PRO_ASM_CSYS}}},
  {5, PRO_E_COMPONENT_COMP_CONSTR_REF, {PRO_VALUE_TYPE_SELECTION}},
  {5, PRO_E_COMPONENT_ASSEM_CONSTR_REF, {PRO_VALUE_TYPE_SELECTION}}};

/*--------------------------------------------------------------------*\
    Prepare value for the component model element.
\*--------------------------------------------------------------------*/
err=ProMdlToModelitem(component,&comp_item);
err = ProSelectionAlloc (NULL, &comp_item, &comp_mdl);
if (err != PRO_TK_NO_ERROR)
    {
  AfxMessageBox(L"ProSelectionAlloc ProMdlToModelitem failed!");
  return;
    }
    tree[7].data.v.r = comp_mdl;
/*--------------------------------------------------------------------*\
    Prepare value for the component and assembly reference element.
\*--------------------------------------------------------------------*/
    tree[12].data.v.r=_comp_csys;
    tree[13].data.v.r=_asm_csys;
/*--------------------------------------------------------------------*\
    Create element tree
\*--------------------------------------------------------------------*/
    err = ProUtilElemtreeCreate(tree, sizeof(tree)/sizeof(tree[0]),NULL, &elem_root);
if (err != PRO_TK_NO_ERROR)
    {
  AfxMessageBox(L"ProUtilElemtreeCreate failed!");
  return;
    }
/*--------------------------------------------------------------------*\
    Set up a selection structure for the feature context.
\*--------------------------------------------------------------------*/
    err = ProMdlToModelitem (assembly, &modelitem);
if (err != PRO_TK_NO_ERROR)
    {
  AfxMessageBox(L"ProMdlToModelitem failed!");
  return;
    }
err = ProSelectionAlloc (NULL, &modelitem, &sel);
if (err != PRO_TK_NO_ERROR)
    {
  AfxMessageBox(L"ProSelectionAlloc failed!");
  return;
    }
/*--------------------------------------------------------------------*\
    Assemble the component by feature creation.
\*--------------------------------------------------------------------*/
    err = ProFeatureWithoptionsCreate (sel, elem_root, opts,
sizeof(opts)/sizeof(opts[0]), &feature, &errors);

    if (err != PRO_TK_NO_ERROR)
    {
  AfxMessageBox(L"Assembly failed!");
    }
     if (err == PRO_TK_BAD_INPUTS)
    {
  AfxMessageBox(L"PRO_TK_BAD_INPUTS!");
    }

/*--------------------------------------------------------------------*\
    Free Allocated memory
\*--------------------------------------------------------------------*/
    err = ProElementFree(&elem_root);
    err = ProSelectionFree(&sel);
ProSelectionFree(&_asm_csys);
ProSelectionFree(&_comp_csys);
ProSelectionFree(&comp_mdl);
}


/*=============================================================*\
  Function:  ProUtilElemtreeCreate
  Purpose: Create element tree by the ElemTreeData structure
  Return :      PRO_TK_NO_ERROR if successfull,
\*=============================================================*/
ProError ProUtilElemtreeCreate(
    ElemTreeData *elemarr,     /* In : The array of ElemTreeData */
    int n_elem,       /* In : number of ElemTreeData in elemarr */
    ProElement base_tree,     /* In : the base tree */
    ProElement *elem_tree)     /* Out : element tree */
{
    ProElement elem_level[10], elem;
    ProValue value;
    int i;
    ProError err;

    if (base_tree!=NULL)
elem_level[0] = base_tree;

    for (i=0; i<n_elem; i++)
    {
err = ProElementAlloc((ProElemId)elemarr[i].elem_id, &elem);
if (err != PRO_TK_NO_ERROR)
     return (err);
if (elemarr[i].data.type != -1)
{
/*----------------------------------------------------------*\
    Add Element value
\*----------------------------------------------------------*/
     err = ProValueAlloc(&value);
     if (err != PRO_TK_NO_ERROR)
  return (err);
     err = ProValueDataSet(value, &elemarr[i].data);
     if (err != PRO_TK_NO_ERROR)
  return (err);
     err = ProElementValueSet(elem, value);
     if (err != PRO_TK_NO_ERROR)
  return (err);
}
/*----------------------------------------------------------*\
    Add Element to the tree
\*----------------------------------------------------------*/
if (elemarr[i].level!=0)
{
     err = ProElemtreeElementAdd(elem_level[elemarr[i].level-1], NULL,
  elem);
}
elem_level[elemarr[i].level] = elem;
}
    elem_tree[0] = elem_level[0];
    return (PRO_TK_NO_ERROR);
}

Top Tags