ug二次開發加入部件workpiece

選擇當前視圖中的部件作爲部件,自動檢查是否已經添加過重複部件,如果添加過就不在添加,而是在其下添加文件。代碼如下

UF_UI_ONT_switch_view(UF_UI_ONT_geometry_mode);
	UF_OBJ_cycle_objs_in_part(UF_PART_ask_display_part(), UF_machining_geometry_grp_type, &geom_tag);//查詢座標系是否重複
	while (geom_tag != NULL_TAG)
	{
		UF_OBJ_ask_type_and_subtype(geom_tag, &geom_type, &geom_subtype);
		if (geom_subtype == UF_mill_geom_featr_subtype)
		{
			count_1++;
			UF_OBJ_ask_name(geom_tag, geom_name);
			if (!strcmp(geom_name, new_geom_name))
			{
				button_1 = 1;
				new_geom_tag = NULL_TAG;
				new_geom_tag = geom_tag;
				UF_OBJ_cycle_objs_in_part(UF_PART_ask_display_part(), UF_solid_type, &gongjian_tag);
				if (gongjian_tag != NULL_TAG)
				{
					UF_OBJ_ask_type_and_subtype(maopi_tag, &gj_type, &gj_subtype);
				}
				else
				{
					uc1601("請先創建或打開一個工件!\n在沒有工件情況下無法設置毛坯和幾何體", 1);
				}
			}
		}
		UF_OBJ_cycle_objs_in_part(UF_PART_ask_display_part(), UF_machining_geometry_grp_type, &geom_tag);
	}
	printf("總共有%d個工件", count_1);

	if (button_1 == 0)//如果標誌位爲0就說明沒有加過這個工件
	{
		UF_NCGEOM_create(mcs_type_name, mcs_subtype_name, &new_mcs_tag);
		UF_SETUP_ask_geom_root(setupTag, &geom_group);
		UF_NCGROUP_accept_member(geom_group, new_mcs_tag);
		UF_CSYS_ask_wcs(&wcs);
		UF_PARAM_set_tag_value(new_mcs_tag, UF_PARAM_MCS, wcs);
		UF_OBJ_set_name(new_mcs_tag, new_mcs_name);
		UF_CAM_opt_ask_subtypes(type_names[2], UF_CAM_OPT_STYPE_CLS_GEOM, &geom_sub_cnt, &geom_sub_names);
		UF_NCGEOM_create((char*)type_names[2], (char *)geom_sub_names[1], &new_geom_tag);
		UF_OBJ_set_name(new_geom_tag, new_geom_name);
		if (new_geom_tag != NULL)
		{
			UF_NCGROUP_accept_member(new_mcs_tag, new_geom_tag);
		}
		app_data_list[0] = (UF_CAMGEOM_app_data_p_t)UF_allocate_memory(sizeof(UF_CAMGEOM_app_data_t), &err_code);
		app_data_list[0] = NULL;//就相當於UF_free 
		UF_OBJ_cycle_objs_in_part(UF_PART_ask_display_part(), UF_solid_type, &gongjian_tag);
		if (gongjian_tag != NULL_TAG)
		{
			UF_OBJ_ask_type_and_subtype(maopi_tag, &gj_type, &gj_subtype);
		}
		else
		{
			uc1601("請先創建或打開一個工件!\n在沒有工件情況下無法設置毛坯和幾何體", 1);
		}
		UF_CAMGEOM_append_items(new_geom_tag, UF_CAM_part, 1, &gongjian_tag, app_data_list);		// 設置工件
		UF_CAMGEOM_append_items(new_geom_tag, UF_CAM_blank, 1, &gongjian_tag, app_data_list);		// 設置毛坯
	    //UF_CAMGEOM_append_items(WORKPIECE,UF_CAM_check,1,&area_face, app_data_list);		// 設置檢查體
		
		
	}
	else
		uc1601("存在重複工件", 0);
	UF_NCGROUP_accept_member(new_geom_tag, opt_tag);
	UF_UI_ONT_refresh();          //不加這句會不能馬上在界面中能顯示
	UF_DISP_refresh();
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章