【NX】NX二次开发中拉伸曲线完整范例

之前做项目测试用到的代码,开发的版本是NX8.5的32位版本,这个代码实现起来也不难,其实就是调用了UG的API而已。

【NX】NX二次开发中拉伸曲线完整范例_第1张图片

 

那么我在这里提供完整的代码:

//author:autumoon
//邮箱:[email protected]
//日期:2023-08-03 
/*****************************************************************************
**
** wave_test.cpp
**
** Description:
**     Contains Unigraphics entry points for the application.
**
*****************************************************************************/

/* Include files */
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
#   include 
#   include 
using std::ostrstream;
using std::endl;    
using std::ends;
using std::cerr;
#else
#   include 
#   include 
#endif
#include 
#include 
#include 

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#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],
			msg[133];

		sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
			irc, line, file);
		UF_get_fail_message(irc, err);

		UF_print_syslog(msg, FALSE);
		UF_print_syslog(err, FALSE);
		UF_print_syslog("\n", FALSE);
		UF_print_syslog(call, FALSE);
		UF_print_syslog(";\n", FALSE);

		if (!UF_UI_open_listing_window())
		{
			UF_UI_write_listing_window(msg);
			UF_UI_write_listing_window(err);
			UF_UI_write_listing_window("\n");
			UF_UI_write_listing_window(call);
			UF_UI_write_listing_window(";\n");
		}
	}

	return(irc);
}

tag_t selcurve()
{
	char *message1 = "选择平面";
	UF_UI_selection_options_t opts1;
	UF_UI_mask_t mask1;
	int response1;
	double cursor1[3];
	tag_t planeid, view1;
	int unhighlight1;
	unhighlight1=0;
	opts1.other_options = 0;
	opts1.reserved = NULL;
	opts1.num_mask_triples = 1;
	opts1.mask_triples = &mask1;
	opts1.mask_triples->object_type = UF_solid_type;
	opts1.mask_triples->object_subtype = 0 ;
	opts1.mask_triples->solid_type = UF_UI_SEL_FEATURE_ANY_FACE ;

	//opts1.scope = UF_UI_SEL_SCOPE_WORK_PART;

	opts1.scope = UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY;

	UF_UI_select_single(message1,&opts1,&response1,
		&planeid,cursor1,&view1);
	UF_DISP_set_highlight(planeid,unhighlight1);

	return planeid;
}

void open()
{
	tag_t face = selcurve();
	tag_t object_in_par=UF_PART_ask_display_part();
	tag_t linked_feature;
	UF_CALL(UF_WAVE_create_linked_face (face, NULL_TAG, object_in_par, TRUE, &linked_feature));
	uf_list_p_t object;
	UF_MODL_create_list(&object);
	UF_MODL_ask_feat_faces (linked_feature, &object);
	char *taper_angle = "0.0";
	char *limit[2] = {"0.0", "25.0"};
	double ref_p[3]={0,0,100};
	double direction[ 3 ]={0.0,0.0,1.0};
	UF_FEATURE_SIGN create = UF_NULLSIGN;
	uf_list_p_t features ;
	UF_MODL_create_list(&features);
	UF_MODL_create_extruded (object, taper_angle, limit, ref_p, direction, create,&features );
	UF_MODL_delete_list(&object);
	UF_MODL_delete_list(&features);
}


/*****************************************************************************
**  Activation Methods
*****************************************************************************/
/*  Unigraphics Startup
**      This entry point activates the application at Unigraphics startup */
extern DllExport void ufsta( char *param, int *returnCode, int rlen )
{
	/* Initialize the API environment */
	if( UF_CALL(UF_initialize()) ) 
	{
		/* Failed to initialize */
		return;
	}

	/* TODO: Add your application code here */
	open();

	/* Terminate the API environment */
	UF_CALL(UF_terminate());
}

/*****************************************************************************
**  Utilities
*****************************************************************************/

/* Unload Handler
**     This function specifies when to unload your application from Unigraphics.
**     If your application registers a callback (from a MenuScript item or a
**     User Defined Object for example), this function MUST return
**     "UF_UNLOAD_UG_TERMINATE". */
extern int ufusr_ask_unload( void )
{
	return( UF_UNLOAD_IMMEDIATELY );
}

欢迎交流与讨论。

你可能感兴趣的:(nx二次开发,算法)