/*
	Copyright (c) 2024 PTC Inc. and/or Its Subsidiary Companies. All Rights Reserved.
*/



/*---------------------- Pro/Toolkit Includes ------------------------*/
#include "ProToolkit.h"
#include "ProFeature.h"
#include "ProElemId.h"
#include "ProExtrude.h"
#include "ProModFeat.h"
#include "ProStdSection.h"
#include "ProElement.h"
#include "ProElempath.h"
#include "ProFeatType.h"
#include "ProFeatForm.h"
#include "ProSelection.h"
#include "ProSection.h"

#include "ProDtmCsys.h"
#include <ProSolid.h>

#define C_LOG(a) ProTKPrintf ("Status for %s is = %d\n", a, status ); \
	ERROR_CHECK( a, "UgSktExtrusionCreate.c", status );

#define C_PRINT(a) ProTKPrintf ( "%s\n", a);

static ProFileName message_file; 

/*---------------------- Function Prototypes -------------------------*/
ProError ProDemoGeneralCsysCreate();

/*------------------------- External Data ----------------------------*/
ProError ProDemoSectCreate();

/*------------------------- Global Data -----------------------------*/

/*===============================================================*\
FUNCTION : ProDemoGeneralCsysCreate
PURPOSE  : Demonstrates the creation of the extruded protrusion
           base feature.
\*===============================================================*/
ProError ProDemoGeneralCsysCreate()
{
  ProReference REPDEP_ref1;
  ProErrorlist            errors;
  ProMdl                  model;
  ProModelitem            model_item;
  ProSelection            model_sel;
  ProFeature              feature;
  ProFeatureCreateOptions *opts = 0;
  ProAsmcomppath          *p_comp_path = NULL;
  ProValue                value;
  char                    name[PRO_NAME_SIZE];
  ProError		  status;
  
  ProElement pro_e_feature_tree;
  ProElement pro_e_feature_type;
  ProElement pro_e_std_feature_name;
  ProElement pro_e_csys_origin_constrs;
  ProElement pro_e_csys_origin_constr;
  ProElement pro_e_csys_origin_constr_ref;
  ProElement pro_e_csys_offset_type;
  ProElement pro_e_csys_orientmoves;
  ProElement pro_e_csys_orientmove;
  ProElement pro_e_csys_orientmove_move_type;
  ProElement pro_e_csys_orientmove_move_val;
  ProElement pro_e_csys_orient_by_method;
  
  ProName 	wide_string;
  ProValueData 	value_data;
  ProSelection * p_select;
  int 		n_select;
  ProBoolean 	is_interactive = PRO_B_TRUE;
  
  ProStringToWstring ( message_file, "utilities.txt" ); 
  
  /*---------------------------------------------------------------*\
    Populating root element PRO_E_FEATURE_TREE 
  \*---------------------------------------------------------------*/
  C_PRINT( " *** Processing Element PRO_E_FEATURE_TREE *** " );
  status = ProElementAlloc ( PRO_E_FEATURE_TREE, &pro_e_feature_tree ); 
  C_LOG( " ProElementAlloc " );
  
  /*---------------------------------------------------------------*\
    Populating element PRO_E_FEATURE_TYPE 
  \*---------------------------------------------------------------*/
  C_PRINT( " *** Processing Element PRO_E_FEATURE_TYPE *** " );
  status = ProElementAlloc ( PRO_E_FEATURE_TYPE, &pro_e_feature_type );
  C_LOG( " ProElementAlloc " );
  status = ProElementIntegerSet(pro_e_feature_type,PRO_FEAT_CSYS);
  C_LOG( " ProElementIntegerSet" );
  status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, 
		pro_e_feature_type );
  C_LOG( " ProElemtreeElementAdd" );

  /*---------------------------------------------------------------*\
    Populating element PRO_E_STD_FEATURE_NAME
  \*---------------------------------------------------------------*/
  
  C_PRINT( " *** Processing Element PRO_E_STD_FEATURE_NAME *** " );
  status = ProElementAlloc ( PRO_E_STD_FEATURE_NAME, 
		&pro_e_std_feature_name ); 
  C_LOG( " ProElementAlloc " );
  ProStringToWstring ( wide_string, "MY_CS0" );
  status = ProElementWstringSet(pro_e_std_feature_name,wide_string);
  C_LOG( " ProElementWstringSet" );
  status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, 
		pro_e_std_feature_name );
  C_LOG( " ProElemtreeElementAdd" );

  /*---------------------------------------------------------------*\
    Populating  element PRO_E_CSYS_ORIGIN_CONSTRS
  \*---------------------------------------------------------------*/

  C_PRINT( " *** Processing Element PRO_E_CSYS_ORIGIN_CONSTRS *** " );
  status = ProElementAlloc ( PRO_E_CSYS_ORIGIN_CONSTRS, 
		&pro_e_csys_origin_constrs );
  C_LOG( " ProElementAlloc" );
  status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, 
		pro_e_csys_origin_constrs  );
  C_LOG( " ProElemtreeElementAdd" );
  
  /*---------------------------------------------------------------*\
    Populating  element PRO_E_CSYS_ORIGIN_CONSTR
  \*---------------------------------------------------------------*/
  C_PRINT( " *** Processing Element PRO_E_CSYS_ORIGIN_CONSTR *** " );
  status = ProElementAlloc ( PRO_E_CSYS_ORIGIN_CONSTR, 
		&pro_e_csys_origin_constr );
  C_LOG( " ProElementAlloc" );
  status = ProElemtreeElementAdd ( pro_e_csys_origin_constrs, NULL, 
		pro_e_csys_origin_constr  );
  C_LOG( " ProElemtreeElementAdd" );

  /*---------------------------------------------------------------*\
    Populating  element PRO_E_CSYS_ORIGIN_CONSTR_REF
  \*---------------------------------------------------------------*/
  C_PRINT( " *** Processing Element PRO_E_CSYS_ORIGIN_CONSTR_REF *** " );
  status = ProMessageDisplay ( message_file, "Select a reference CSYS");
  C_LOG( " ProMessageDisplay" );
  ProTKPrintf ( "Please select csys_ID_25 type of Modelitem\n");
  status = ProSelect ( "csys", 1, NULL, NULL, NULL, NULL, 
		&p_select, &n_select );
  C_LOG( " ProSelect" );
  if ( n_select <= 0 ) return -1; 
  status = ProElementAlloc ( PRO_E_CSYS_ORIGIN_CONSTR_REF, 
		&pro_e_csys_origin_constr_ref );
  C_LOG( " ProElementAlloc " );
  status = ProSelectionToReference( p_select[0],&REPDEP_ref1 );
  status = ProElementReferenceSet(pro_e_csys_origin_constr_ref,REPDEP_ref1);
  C_LOG( " ProElementReferenceSet" );
  status = ProElemtreeElementAdd ( pro_e_csys_origin_constr, NULL, 
		pro_e_csys_origin_constr_ref );
  C_LOG( " ProElemtreeElementAdd" );
  
  /*---------------------------------------------------------------*\
    Populating  element PRO_E_CSYS_OFFSET_TYPE
  \*---------------------------------------------------------------*/
  C_PRINT( " *** Processing Element PRO_E_CSYS_OFFSET_TYPE *** " );
  status = ProElementAlloc ( PRO_E_CSYS_OFFSET_TYPE, 
		&pro_e_csys_offset_type );
  C_LOG( " ProElementAlloc " );
  status = ProElementIntegerSet(pro_e_csys_offset_type,PRO_CSYS_OFFSET_CARTESIAN);
  C_LOG( " ProElementIntegerSet" );
  status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, 
		pro_e_csys_offset_type );
  C_LOG( " ProElemtreeElementAdd" );
  
  /*---------------------------------------------------------------*\
    Populating  element PRO_E_CSYS_ORIENTMOVES
  \*---------------------------------------------------------------*/
  C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVES *** " );
  status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVES, 
		&pro_e_csys_orientmoves );
  C_LOG( " ProElementAlloc" );
  status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, 
		pro_e_csys_orientmoves  );
  C_LOG( " ProElemtreeElementAdd" );
  
  /*---------------------------------------------------------------*\
    Populating  element PRO_E_CSYS_ORIENTMOVES
			-> PRO_E_CSYS_ORIENTMOVE
  \*---------------------------------------------------------------*/
  C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE *** " );
  status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE, 
		&pro_e_csys_orientmove );
  C_LOG( " ProElementAlloc" );
  status = ProElemtreeElementAdd ( pro_e_csys_orientmoves, NULL, 
		pro_e_csys_orientmove  );
  C_LOG( " ProElemtreeElementAdd" );
  
  /*---------------------------------------------------------------*\
    Populating  element PRO_E_CSYS_ORIENTMOVES
			-> PRO_E_CSYS_ORIENTMOVE
			   -> PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE
  \*---------------------------------------------------------------*/
  C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE *** " );
  status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE, 
		&pro_e_csys_orientmove_move_type );
  C_LOG( " ProElementAlloc " );
  status = ProElementIntegerSet(pro_e_csys_orientmove_move_type,PRO_CSYS_ORIENTMOVE_MOVE_OPT_ROT_X);
  C_LOG( " ProElementIntegerSet" );
  status = ProElemtreeElementAdd ( pro_e_csys_orientmove, NULL, 
		pro_e_csys_orientmove_move_type );
  C_LOG( " ProElemtreeElementAdd" );
  
  /*---------------------------------------------------------------*\
    Populating  element PRO_E_CSYS_ORIENTMOVES
			-> PRO_E_CSYS_ORIENTMOVE
			   -> PRO_E_CSYS_ORIENTMOVE_MOVE_VAL
  \*---------------------------------------------------------------*/
  C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE_MOVE_VAL *** " );
  status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE_MOVE_VAL, 
		&pro_e_csys_orientmove_move_val );
  C_LOG( " ProElementAlloc " );
  status = ProElementDecimalsSet( pro_e_csys_orientmove_move_val,4 );
  status = ProElementDoubleSet(pro_e_csys_orientmove_move_val,0.000000);
  C_LOG( " ProElementDoubleSet" );
  status = ProElemtreeElementAdd ( pro_e_csys_orientmove, NULL, 
		pro_e_csys_orientmove_move_val );
  C_LOG( " ProElemtreeElementAdd" );
  
  /*---------------------------------------------------------------*\
    Populating  element PRO_E_CSYS_ORIENTMOVES
			-> PRO_E_CSYS_ORIENTMOVE
  \*---------------------------------------------------------------*/
  C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE *** " );
  status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE, 
		&pro_e_csys_orientmove );
  C_LOG( " ProElementAlloc" );
  status = ProElemtreeElementAdd ( pro_e_csys_orientmoves, NULL, 
		pro_e_csys_orientmove  );
  C_LOG( " ProElemtreeElementAdd" );
  
  /*---------------------------------------------------------------*\
    Populating  element PRO_E_CSYS_ORIENTMOVES
			-> PRO_E_CSYS_ORIENTMOVE
			   -> PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE
  \*---------------------------------------------------------------*/
  C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE *** " );
  status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE, 
		&pro_e_csys_orientmove_move_type );
  C_LOG( " ProElementAlloc " );
  status = ProElementIntegerSet(pro_e_csys_orientmove_move_type,PRO_CSYS_ORIENTMOVE_MOVE_OPT_ROT_Y);
  C_LOG( " ProElementIntegerSet" );
  status = ProElemtreeElementAdd ( pro_e_csys_orientmove, NULL, 
		pro_e_csys_orientmove_move_type );
  C_LOG( " ProElemtreeElementAdd" );

  /*---------------------------------------------------------------*\
    Populating  element PRO_E_CSYS_ORIENTMOVES
			-> PRO_E_CSYS_ORIENTMOVE
			   -> PRO_E_CSYS_ORIENTMOVE_MOVE_VAL
  \*---------------------------------------------------------------*/
  C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE_MOVE_VAL *** " );
  status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE_MOVE_VAL, 
		&pro_e_csys_orientmove_move_val );
  C_LOG( " ProElementAlloc " );
  status = ProElementDecimalsSet( pro_e_csys_orientmove_move_val,4 );
  status = ProElementDoubleSet(pro_e_csys_orientmove_move_val,-90.000000);
  C_LOG( " ProElementDoubleSet" );
  status = ProElemtreeElementAdd ( pro_e_csys_orientmove, NULL, 
		pro_e_csys_orientmove_move_val );
  C_LOG( " ProElemtreeElementAdd" );

  /*---------------------------------------------------------------*\
    Populating  element PRO_E_CSYS_ORIENTMOVES
			-> PRO_E_CSYS_ORIENTMOVE
  \*---------------------------------------------------------------*/
  C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE *** " );
  status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE, 
		&pro_e_csys_orientmove );
  C_LOG( " ProElementAlloc" );
  status = ProElemtreeElementAdd ( pro_e_csys_orientmoves, NULL, 
		pro_e_csys_orientmove  );
  C_LOG( " ProElemtreeElementAdd" );
  
  /*---------------------------------------------------------------*\
    Populating  element PRO_E_CSYS_ORIENTMOVES
			-> PRO_E_CSYS_ORIENTMOVE
			   -> PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE
  \*---------------------------------------------------------------*/
  C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE *** " );
  status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE, 
		&pro_e_csys_orientmove_move_type );
  C_LOG( " ProElementAlloc " );
  status = ProElementIntegerSet(pro_e_csys_orientmove_move_type,PRO_CSYS_ORIENTMOVE_MOVE_OPT_ROT_Z);
  C_LOG( " ProElementIntegerSet" );
  status = ProElemtreeElementAdd ( pro_e_csys_orientmove, NULL, 
		pro_e_csys_orientmove_move_type );
  C_LOG( " ProElemtreeElementAdd" );
  
  /*---------------------------------------------------------------*\
    Populating  element PRO_E_CSYS_ORIENTMOVES
			-> PRO_E_CSYS_ORIENTMOVE
			   -> PRO_E_CSYS_ORIENTMOVE_MOVE_VAL
  \*---------------------------------------------------------------*/
  C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE_MOVE_VAL *** " );
  status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE_MOVE_VAL, 
		&pro_e_csys_orientmove_move_val );
  C_LOG( " ProElementAlloc " );
  status = ProElementDecimalsSet( pro_e_csys_orientmove_move_val,4 );
  status = ProElementDoubleSet(pro_e_csys_orientmove_move_val,0.000000);
  C_LOG( " ProElementDoubleSet" );
  status = ProElemtreeElementAdd ( pro_e_csys_orientmove, NULL, 
		pro_e_csys_orientmove_move_val );
  C_LOG( " ProElemtreeElementAdd" );
  
  /*---------------------------------------------------------------*\
    Populating  element PRO_E_CSYS_ORIENTMOVES
			-> PRO_E_CSYS_ORIENTMOVE
  \*---------------------------------------------------------------*/
  C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE *** " );
  status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE, &pro_e_csys_orientmove );
  C_LOG( " ProElementAlloc" );
  status = ProElemtreeElementAdd ( pro_e_csys_orientmoves, NULL, 
		pro_e_csys_orientmove  );
  C_LOG( " ProElemtreeElementAdd" );
  
  /*---------------------------------------------------------------*\
    Populating  element PRO_E_CSYS_ORIENTMOVES
			-> PRO_E_CSYS_ORIENTMOVE
			   -> PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE
  \*---------------------------------------------------------------*/
  C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE *** " );
  status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE, 
		&pro_e_csys_orientmove_move_type );
  C_LOG( " ProElementAlloc " );
  status = ProElementIntegerSet(pro_e_csys_orientmove_move_type,PRO_CSYS_ORIENTMOVE_MOVE_OPT_TRAN_X);
  C_LOG( " ProElementIntegerSet" );
  status = ProElemtreeElementAdd ( pro_e_csys_orientmove, NULL, 
		pro_e_csys_orientmove_move_type );
  C_LOG( " ProElemtreeElementAdd" );
  
  /*---------------------------------------------------------------*\
    Populating  element PRO_E_CSYS_ORIENTMOVES
			-> PRO_E_CSYS_ORIENTMOVE
			   -> PRO_E_CSYS_ORIENTMOVE_MOVE_VAL
  \*---------------------------------------------------------------*/
  C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE_MOVE_VAL *** " );
  status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE_MOVE_VAL, 	
		&pro_e_csys_orientmove_move_val );
  C_LOG( " ProElementAlloc " );
  status = ProElementDecimalsSet( pro_e_csys_orientmove_move_val,4 );
  status = ProElementDoubleSet(pro_e_csys_orientmove_move_val,100.000000);
  C_LOG( " ProElementDoubleSet" );
  status = ProElemtreeElementAdd ( pro_e_csys_orientmove, NULL, 
		pro_e_csys_orientmove_move_val );
  C_LOG( " ProElemtreeElementAdd" );
  
  /*---------------------------------------------------------------*\
    Populating  element PRO_E_CSYS_ORIENTMOVES
			-> PRO_E_CSYS_ORIENTMOVE
			   -> PRO_E_CSYS_ORIENTMOVE_MOVE_VAL
  \*---------------------------------------------------------------*/
  C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE *** " );
  status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE, &pro_e_csys_orientmove );
  C_LOG( " ProElementAlloc" );
  status = ProElemtreeElementAdd ( pro_e_csys_orientmoves, NULL, 
		pro_e_csys_orientmove  );
  C_LOG( " ProElemtreeElementAdd" );
  
  /*---------------------------------------------------------------*\
    Populating  element PRO_E_CSYS_ORIENTMOVES
			-> PRO_E_CSYS_ORIENTMOVE
			   -> PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE
  \*---------------------------------------------------------------*/
  C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE *** " );
  status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE, 
		&pro_e_csys_orientmove_move_type );
  C_LOG( " ProElementAlloc " );
  status = ProElementIntegerSet(pro_e_csys_orientmove_move_type,PRO_CSYS_ORIENTMOVE_MOVE_OPT_TRAN_Y);
  C_LOG( " ProElementIntegerSet" );
  status = ProElemtreeElementAdd ( pro_e_csys_orientmove, NULL, 
		pro_e_csys_orientmove_move_type );
  C_LOG( " ProElemtreeElementAdd" );
  
  /*---------------------------------------------------------------*\
    Populating  element PRO_E_CSYS_ORIENTMOVES
			-> PRO_E_CSYS_ORIENTMOVE
			   -> PRO_E_CSYS_ORIENTMOVE_MOVE_VAL
  \*---------------------------------------------------------------*/
  C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE_MOVE_VAL *** " );
  status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE_MOVE_VAL, 
		&pro_e_csys_orientmove_move_val );
  C_LOG( " ProElementAlloc " );
  status = ProElementDecimalsSet( pro_e_csys_orientmove_move_val,4 );
  status = ProElementDoubleSet(pro_e_csys_orientmove_move_val,200.000000);
  C_LOG( " ProElementDoubleSet" );
  status = ProElemtreeElementAdd ( pro_e_csys_orientmove, NULL, 
		pro_e_csys_orientmove_move_val );
  C_LOG( " ProElemtreeElementAdd" );
  
  /*---------------------------------------------------------------*\
    Populating  element PRO_E_CSYS_ORIENTMOVES
			-> PRO_E_CSYS_ORIENTMOVE
  \*---------------------------------------------------------------*/
  C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE *** " );
  status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE, &pro_e_csys_orientmove );
  C_LOG( " ProElementAlloc" );
  status = ProElemtreeElementAdd ( pro_e_csys_orientmoves, NULL, 
		pro_e_csys_orientmove  );
  C_LOG( " ProElemtreeElementAdd" );

  /*---------------------------------------------------------------*\
    Populating  element PRO_E_CSYS_ORIENTMOVES
			-> PRO_E_CSYS_ORIENTMOVE
			   -> PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE
  \*---------------------------------------------------------------*/
  C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE *** " );
  status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE, 
		&pro_e_csys_orientmove_move_type );
  C_LOG( " ProElementAlloc " );
  status = ProElementIntegerSet(pro_e_csys_orientmove_move_type,PRO_CSYS_ORIENTMOVE_MOVE_OPT_TRAN_Z);
  C_LOG( " ProElementIntegerSet" );
  status = ProElemtreeElementAdd ( pro_e_csys_orientmove, NULL, 
		pro_e_csys_orientmove_move_type );
  C_LOG( " ProElemtreeElementAdd" );

  /*---------------------------------------------------------------*\
    Populating  element PRO_E_CSYS_ORIENTMOVES
			-> PRO_E_CSYS_ORIENTMOVE
			   -> PRO_E_CSYS_ORIENTMOVE_MOVE_VAL
  \*---------------------------------------------------------------*/
  C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE_MOVE_VAL *** " );
  status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE_MOVE_VAL, 
		&pro_e_csys_orientmove_move_val );
  C_LOG( " ProElementAlloc " );
  status = ProElementDecimalsSet( pro_e_csys_orientmove_move_val,4 );
  status = ProElementDoubleSet(pro_e_csys_orientmove_move_val,300.000000);
  C_LOG( " ProElementDoubleSet" );
  status = ProElemtreeElementAdd ( pro_e_csys_orientmove, NULL, 
		pro_e_csys_orientmove_move_val );
  C_LOG( " ProElemtreeElementAdd" );

  /*---------------------------------------------------------------*\
    Populating  element PRO_E_CSYS_ORIENT_BY_METHOD
  \*---------------------------------------------------------------*/
  status = ProElementAlloc ( PRO_E_CSYS_ORIENT_BY_METHOD, 
                &pro_e_csys_orient_by_method );
  C_LOG( " ProElementAlloc " );
  status = ProElementIntegerSet(pro_e_csys_orient_by_method,PRO_CSYS_ORIENT_BY_SEL_CSYS_AXES);
  C_LOG( " ProElementIntegerSet" );
  status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, 
                pro_e_csys_orient_by_method );
  C_LOG( " ProElemtreeElementAdd" );

  /*---------------------------------------------------------------*\
    Creating the feature in the current model.
  \*---------------------------------------------------------------*/
  status = ProMdlCurrentGet (&model);
  if ( status != PRO_TK_NO_ERROR ) return ( status );
  status = ProMdlToModelitem( model, &model_item ); 
  status = ProSelectionAlloc (p_comp_path, &model_item,
			   &model_sel);
  

  status = ProArrayAlloc(1,sizeof(ProFeatureCreateOptions),
    1, (ProArray*)&opts);

  opts[0]= PRO_FEAT_CR_DEFINE_MISS_ELEMS;

  status = ProFeatureWithoptionsCreate (model_sel, pro_e_feature_tree,
    opts, PRO_REGEN_NO_FLAGS, &feature, &errors);
  C_LOG (" ProFeatureWithoptionsCreate"); 

  status = ProArrayFree((ProArray*)&opts);
  
  status = ProElementFree (&pro_e_feature_tree ); 
  C_LOG (" ProElementFree"); 
  
  return ( status );
}

#undef C_LOG
#undef C_PRINT