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

#include "ProToolkit.h"
#include "user_tk_error.h"

#include "ProCore.h"
#include "ProMdl.h"
#include "ProObjects.h"
#include "ProSizeConst.h"
#include "ProUtil.h"
#include "ProTKRunTime.h"

/*---------------------------------------------------------------------------*\
    Find circular datum curves and replace them with holes.
\*---------------------------------------------------------------------------*/
UserAddHoles( ProMdl p_part )
{
/*  .
    .
    .
*/
}

/*---------------------------------------------------------------------------*\
    Start Pro/ENGINEER. Load the part specified by the command line 
    argument and replace its datum curves with holes.
\*---------------------------------------------------------------------------*/
int main( int argc, char *argv[] )
{
    char      *a_char_ptr;
    ProFamilyMdlName  part_name;
    ProError   status;
    ProMdl     p_part;
    ProError   err;

/*---------------------------------------------------------------------------*\
    Start Pro/ENGINEER.
\*---------------------------------------------------------------------------*/
    if ( argc == 3) 
    {
      a_char_ptr = argv[1];
      a_char_ptr++;

      ProEngineerStart(a_char_ptr,"");
    }
    else 
    {
      ProTKPrintf("Usage : pt_simple_async +<pro_command> +<part_name>\n");
      exit(1);
    }

/*---------------------------------------------------------------------------*\
    Set up the part name from the argument list.
    (Assume that part name is preceded by '+' or '-', as for synchronous.)
\*---------------------------------------------------------------------------*/
    a_char_ptr = argv[2];
    a_char_ptr++;
    ProStringToWstring(part_name,a_char_ptr);

/*---------------------------------------------------------------------------*\
    Retrieve a part with that name.
\*---------------------------------------------------------------------------*/
    err=ProMdlnameRetrieve(part_name,PRO_MDLFILE_PART,&p_part);
    if (err!=PRO_TK_NO_ERROR)
    {
        ProTKPrintf("*** Failed to retrieve part %s\n", part_name);
        ProEngineerEnd();
    }

/*---------------------------------------------------------------------------*\
    Add the holes to the part
\*---------------------------------------------------------------------------*/
    UserAddHoles(p_part);

/*---------------------------------------------------------------------------*\
    Save the part
\*---------------------------------------------------------------------------*/
    err=ProMdlSave(p_part);
    ERROR_CHECK("async main","ProMdlSave",err);

/*---------------------------------------------------------------------------*\
    Terminate the Pro/ENGINEER session.
\*---------------------------------------------------------------------------*/
    ProEngineerEnd();
    return(0);
}