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

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

 

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

//author:autumoon
//邮箱:9506@163.com
//日期:2023-08-03 
/*****************************************************************************
**
** wave_test.cpp
**
** Description:
**     Contains Unigraphics entry points for the application.
**
*****************************************************************************/

/* Include files */
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
#   include <strstream>
#   include <iostream>
using std::ostrstream;
using std::endl;    
using std::ends;
using std::cerr;
#else
#   include <strstream.h>
#   include <iostream.h>
#endif
#include <uf.h>
#include <uf_ui.h>
#include <uf_exit.h>

#include <stdio.h>
#include <uf.h>
#include <uf_ui.h>
#include <uf_curve.h>
#include <uf_modl.h>
#include <uf_part.h>
#include <uf_wave.h>
#include <uf_object_types.h>

#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 );
}

欢迎交流与讨论。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值