NX二次开发-UFUN导出STL函数UF_STD_put_solid_in_stl_file

NX9+VS2012

#include <uf.h>
#include <uf_obj.h>
#include <uf_modl.h>
#include <uf_part.h>
#include <uf_std.h>
#include <NXOpen/Annotations.hxx>



UF_initialize();

std::vector<tag_t> SolidVector;
tag_t ObjectTag = NULL_TAG;
int Type, SubType, Body_Type;
char msg[256];
UF_OBJ_cycle_objs_in_part(UF_PART_ask_display_part(), UF_solid_type, &ObjectTag);
while (ObjectTag != NULL_TAG)
{
	UF_OBJ_ask_type_and_subtype(ObjectTag, &Type, &SubType);
	if (SubType == UF_solid_body_subtype)
	{
		UF_MODL_ask_body_type(ObjectTag, &Body_Type);
		if (Body_Type == UF_MODL_SOLID_BODY)
		{

			//打开用于二进制输出的STL文件
			void * file_handle = NULL;
			UF_STD_open_binary_stl_file("D:\\abc.stl",true,"",&file_handle);

			//将实体放入STL文件中
			int num_errors;
			UF_STD_stl_error_p_t  error_info;
			UF_STD_put_solid_in_stl_file(file_handle,NULL_TAG,ObjectTag,0,10000,0.0001,&num_errors,&error_info);

			//关闭STL文件
			UF_STD_close_stl_file(file_handle);


			UF_OBJ_set_color(ObjectTag, 186);
			SolidVector.push_back(ObjectTag);
		}
	}
	UF_OBJ_cycle_objs_in_part(UF_PART_ask_display_part(), UF_solid_type, &ObjectTag);
}

sprintf_s(msg, "当前有%d个实体", SolidVector.size());
UF_UI_open_listing_window();
UF_UI_write_listing_window(msg);


UF_terminate();

Caesar卢尚宇  [email protected]
2018年10月21日

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/lu1287580078/article/details/83246541