Cancel
Showing results for 
Search instead for 
Did you mean: 

starting ITK or SOA from within an NX open program while using NX manager

Experimenter
Experimenter

I have the following task: I have to write some customization within NX manager using NX open dot net (VB or Csharp) and I have to create a custom relation between the workpart (itemrevision) to a custom item (the item, so not an itemrevision). I think this will involve some custom ITK or SOA called from within NX Open. I have some experience writing NX open dot net code and also written some simple ITK customizations within the BMIDE, but I have no clue about how these 2 can be somehow linked to achieve what we need here...

Any advice on helping me further on this will be appreciated. Thanks in advance!

3 REPLIES 3
Highlighted

Re: starting ITK or SOA from within an NX open program while using NX manager

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Hi @jcrp ,

The NXOpen code:

public static int Save_CGM()
    {
        try
        {
            //NXOpen.PDM.PartBuilder.PartFileNameData partInfo1;
            //NXOpen.PDM.
            // partInfo1 = <NXOpen.PDM.PartBuilder>.AssignPartFileName("00000571", "A", "specification", "00000571_A_Sheet 1")
            string part_fspec = "";
            theUfSession.Part.AskPartName(workPart.Tag, out part_fspec);

            string part_number = "";
            string part_revision = "";
            string part_file_type = "";
            string part_file_name = "";
            theUfSession.Ugmgr.DecodePartFileName(part_fspec, out part_number, out part_revision, out part_file_type, out part_file_name);
            
            string input_string = part_number.ToString() + "|" + part_revision.ToString() + "|" + output_file[0].ToString();
            int out_code = 0;
            string out_string = "";
            theUfSession.Ugmgr.InvokePdmServer(6971942,input_string, out out_code, out out_string);
            log_f.WriteLine("   **ADD CGM DATASET return code: " + out_code.ToString());
        }

        catch (Exception ex)
        {
            //---- Enter your exception handling code here -----
            theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
        }

        return 0;
    }

And the ITK code:

int TC_ALL_USER_INVOKE_PDM_SERVER_invoke_pdm_server(int *decision, va_list args)
{
	int
		ec = ITK_ok;

	*decision = ALL_CUSTOMIZATIONS;

	int  input_code = va_arg(args, int);          /* args 1 */
	char *input_string = va_arg(args, char *);    /* args 2 */
	int  *output_code = va_arg(args, int *);      /* args 3 */
	char **output_string = va_arg(args, char **); /* args 4 */

	//TC_write_syslog("\n TC ALL USER INVOKE PDM SERVER register...\n");
	//TC_write_syslog(" input_code = %d\n", input_code);
	//TC_write_syslog(" input_string = %s\n", input_string);

	switch (input_code)
	{
	case 6971942:
		TC_write_syslog("ADD CGM DATASET switch\n");
		*decision = ONLY_CURRENT_CUSTOMIZATION;
		//*output_code = ADD_CGM_DATASET_to_ugpart(input_string);
		ADD_CGM_DATASET_to_ugpart(input_string);
		*output_code = sysret;
		//TC_write_syslog(" ADD_CGM_DATASET output_code = %d\n", output_code);
		break;

	default:
		*decision = ALL_CUSTOMIZATIONS;
		break;
	}

	//ECHO(" output_code = %d\n", output_code);
	//ECHO(" *output_string = %s\n", *output_string);
	TC_write_syslog("\n TC ALL USER INVOKE PDM SERVER register... finished.\n");

	return ec;
}

extern DLLAPI int TC_ALL_USER_INVOKE_PDM_SERVER_register_callbacks()
{
	//fprintf(stdout, "\nRegistering test_action_handler\n");
	//init_graphit_debug();
	CUSTOM_register_exit("TC_ALL_USER_INVOKE_PDM_SERVER", "USER_invoke_pdm_server",
		(CUSTOM_EXIT_ftn_t)TC_ALL_USER_INVOKE_PDM_SERVER_invoke_pdm_server);
	TC_write_syslog("\n TC ALL USER INVOKE PDM SERVER register...\n");

	return (sysret);
}
Attila Szepesi, Application Engineer, graphIT Ltd.
Production: NX12.0.2 NX1863 | TcUA 11.3
Development: VB.NET, C# Testing: NX--

Re: starting ITK or SOA from within an NX open program while using NX manager

Experimenter
Experimenter

Hi Attila ,

Thanks you very much for this example. This is really very helpful!

Re: starting ITK or SOA from within an NX open program while using NX manager

Experimenter
Experimenter

Some additional information which might be helpful to other users diving into this: http://plmdojo.com/prog/pdmserver-intro/#.XO6Lj_ZuJaQ.