Skip to main content
1-Visitor
August 19, 2016
Question

"ProElemtreeElementAdd" does not work!

  • August 19, 2016
  • 1 reply
  • 1018 views

PRO_E_FEATURE_TREE   

|   

|--PRO_E_FEATURE_TYPE   

|   

|   

|   

|   

|   

|   

|   

|--PRO_E_INT_PARTS 

     |--PRO_E_FEATURE_INTERSECTION     

          |--PRO_E_FEATURE_INTERSECT_PART             

          |--PRO_E_FEATURE_INTERSECT_LEVEL

how to program?

ProElement elem_PRO_E_FEATURE_INTERSECTION=NULL;
   ProElement elem_PRO_E_FEATURE_INTERSECT_PART=NULL;
   ProElement elem_PRO_E_FEATURE_INTERSECT_LEVEL=NULL;

   status = ProElementAlloc(PRO_E_FEATURE_INTERSECTION,&elem_PRO_E_FEATURE_INTERSECTION );
   if(status!=PRO_TK_NO_ERROR) continue;

   status = ProElemtreeElementAdd(elem_PRO_E_INT_PARTS,NULL,elem_PRO_E_FEATURE_INTERSECTION);
   if(status!=PRO_TK_NO_ERROR) continue;

   status = ProElementAlloc(PRO_E_FEATURE_INTERSECT_PART,&elem_PRO_E_FEATURE_INTERSECT_PART);
   if(status!=PRO_TK_NO_ERROR) continue;

anynone can help me?

    1 reply

    15-Moonstone
    August 23, 2016

    Hi,

    here is an example to create a Datum plane:


    void createADatumPane(ProMdl mdl, ProFeature * csys, int c_sys_pane_type, wchar_t * panename, ProFeature * feat) {
    ProElement pro_e_feature_tree, pro_e_feature_type, elem_const_type, elem_offset, pro_e_std_feature_name, elem_consts, elem_offset_ref;
    ProErrorlist errs;
    ProError tkerr;
    ProValueData value_data;
    ProValue value;
    ProFeatureCreateOptions opts[1];
    ProName wide_string = L"";
    ProModelitem p_mdl_itm;
    ProSelection sel;

    ProElementAlloc(PRO_E_FEATURE_TREE, &pro_e_feature_tree);

    ProElementAlloc(PRO_E_FEATURE_TYPE, &pro_e_feature_type);
    value_data.type = PRO_VALUE_TYPE_INT;
    value_data.v.i = PRO_FEAT_DATUM;
    ProValueAlloc(&value);
    ProValueDataSet ( value, &value_data );
    ProElementValueSet ( pro_e_feature_type, value );
    ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_feature_type );

    if (panename != NULL) {
      wcscpy_s(wide_string, PRO_NAME_SIZE, panename);

      ProElementAlloc(PRO_E_STD_FEATURE_NAME, &pro_e_std_feature_name);
      value_data.type = PRO_VALUE_TYPE_WSTRING;
      value_data.v.w = wide_string;
      ProValueAlloc(&value);
      ProValueDataSet(value, &value_data);
      ProElementValueSet(pro_e_std_feature_name, value);
      ProElemtreeElementAdd(pro_e_feature_tree, NULL, pro_e_std_feature_name);
    }

    ProElementAlloc (PRO_E_DTMPLN_CONSTRAINTS, &elem_consts);
    ProElemtreeElementAdd (pro_e_feature_tree, NULL, elem_consts);

    ProElementAlloc (PRO_E_DTMPLN_CONSTRAINT, &elem_offset);
    ProElemtreeElementAdd (elem_consts, NULL, elem_offset);

    ProElementAlloc(PRO_E_DTMPLN_CONSTR_TYPE, &elem_const_type);
    value_data.type = PRO_VALUE_TYPE_INT;
    value_data.v.i = c_sys_pane_type;
    ProValueAlloc(&value);
    ProValueDataSet(value, &value_data);
    ProElementValueSet(elem_const_type, value);
    ProElemtreeElementAdd(elem_offset, NULL, elem_const_type);

    if (csys != NULL) {
      ProSelection selection;
      ProReference ref;

      ProElementAlloc(PRO_E_DTMPLN_CONSTR_REF, &elem_offset_ref);
      if (ProSelectionAlloc(NULL, csys, &selection) != PRO_TK_NO_ERROR) writeRunnerLog(L"m2", 2);;
      if (ProSelectionToReference(selection, &ref) != PRO_TK_NO_ERROR) writeRunnerLog(L"m3", 2);;
      if (ProElementReferenceSet(elem_offset_ref, ref) != PRO_TK_NO_ERROR) writeRunnerLog(L"m4", 2);;
      ProElemtreeElementAdd(elem_offset, NULL, elem_offset_ref);
    }

    opts[0] = PRO_FEAT_CR_DEFINE_MISS_ELEMS;

    ProMdlToModelitem(mdl, &p_mdl_itm);
    ProSelectionAlloc(NULL, &p_mdl_itm, &sel);
    tkerr = ProFeatureCreate(sel, pro_e_feature_tree, opts, 1, feat, &errs);
    if (tkerr != PRO_TK_NO_ERROR) {
      writeRunnerLog(L"Can't create the datum pane.", 2);
    } else {
      setCost(1);
    }
    ProSelectionFree(&sel);

    ProElementFree(&pro_e_feature_tree);
    }

    Not much documentation, but I think you'll get out the needed code block to create elements out of these example.

    Br,

    Eike