NX Create NXOpen C project

2023-04-17T07:07:30Z
NX Open

Summary


Details

How to create NXOpen C project

Solution

Prerequisites to create NXOpen for C/C++ Project for Windows:- (NX2212)

Visual Studio 2019 Professional

16.11.7

Build 19.29.30137.0

––––––––––––––

C++ 14, C++ 17

Installing the NXOpenCApplication wizard

Note:Microsoft Visual Studio must be installed on the same workstation as the wizards.

 In the %UGII_BASE_DIR%\ugopen\NXOpenWizard\NXOpenCApplication\ directory, double-click the NXOpenCWizard.vsix to run the installer for the NX Open wizard

Steps: - 

1.Launch the Visual Studio 2019 application

2.File->New->Project

3.Select "NXOpenCApplication"->Click on "Next" button of "Create a new project" dialog.

4.Enter Project name->Click on "Create" button of "Configure your new project" dialog.

5.Set required "Application Type" i.e. "An internal application that can be activated from an NX session (DLL)"

6.Set required "Unload Application" i.e. "Automatically when Application completes"

7.Click on the "Create" button of "NXOpen C Wizard" dialog. 

8.Now add your application code in Program.c

9.To build the code perform Build->Build Solution.

Sample Open C API program

===========================

#include <stdio.h>

#include <string.h>

#include <uf.h>

#include <uf_assem.h>

#include <uf_modl.h>

#include <uf_obj.h>

#include <uf_part.h>

#include <uf_text.h>

#include <uf_ui.h>

#include <stdarg.h>

static void ECHO(char* format, ...)

{

char msg[UF_UI_MAX_STRING_LEN + 1];

va_list args;

va_start(args, format);

vsprintf(msg, format, args);

va_end(args);

UF_UI_open_listing_window();

UF_UI_write_listing_window(msg);

UF_print_syslog(msg, FALSE);

}

#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))

static int report_error(char* file, int line, char* call, int irc)

{

if (irc)

{

char err[133];

UF_get_fail_message(irc, err);

ECHO("*** ERROR code %d at line %d in %s:\n",

irc, line, file);

ECHO("+++ %s\n", err);

ECHO("%s;\n", call);

}

return(irc);

}

static void do_it(void)

{

ECHO("Executed Sample NX Open C program");

}

/*ARGSUSED*/

void ufusr(char* param, int* retcode, int paramLen)

{

if (UF_CALL(UF_initialize())) return;

do_it();

UF_terminate();

}

int ufusr_ask_unload(void)

{

return (UF_UNLOAD_IMMEDIATELY);

}

===================

KB Article ID# PL8706246

Contents

SummaryDetails

Associated Components

Open for C/C++