//////////////////////////////////////////////////////////////////////
// Code Example: Transmitting Parts
//
//////////////////////////////////////////////////////////////////////
// This function is passed the step number. This allows for an application to
// produce code with several steps as demonstrated.
// Return 1 if you have finished, 0 if otherwise and -1 to exit.
int CMyCode::RunMyCode(int step)
{
//The code below is sample code. On exiting the function the bodies that
//exist will be drawn
static PK_BODY_t block;
char *key = "..\\Example Parts\\block";
PK_PART_receive_o_t receive_opts;
PK_PART_transmit_o_t transmit_opts;
int n_parts = 0;
PK_PART_t *parts = NULL;
CString text;
int finished = 0;
PK_ERROR_t err = PK_ERROR_no_errors;
switch( step )
{
case 1:
/* Create the block
Size: 10 x 10 x 10.
Location & orientation: default (pass NULL as pointer to
the basis_set argument). */
CExampleAppDoc::ExAppSetStatusBarString("Created a solid block for archiving to XT");
PK_BODY_create_solid_block( 10.0, 10.0, 10.0, NULL, &block );
break;
case 2:
PK_SESSION_ask_parts( &n_parts, &parts );
PK_PART_transmit_o_m( transmit_opts );
transmit_opts.transmit_format = PK_transmit_format_text_c;
err = PK_PART_transmit( n_parts, parts, key, &transmit_opts );
if( err == PK_ERROR_no_errors )
{
PK_ENTITY_delete(n_parts, parts);
CExampleAppDoc::ExAppSetStatusBarString("The block has been archived to XT format and deleted from the session");
}
if(n_parts > 0)
PK_MEMORY_free(parts);
break;
case 3:
PK_PART_receive_o_m( receive_opts );
receive_opts.transmit_format = PK_transmit_format_text_c;
err = PK_PART_receive( key, &receive_opts, &n_parts, &parts );
if( err == PK_ERROR_no_errors )
CExampleAppDoc::ExAppSetStatusBarString("The block has been received back into the Parasolid session");
if( n_parts > 0)
PK_MEMORY_free(parts);
break;
default:
finished = 1;
}
return finished;
}