NX二次开发,对象上色

#include <uf_defs.h>
#include <uf_ui_types.h>
#include <uf.h>
#include <uf_ui.h>
#include <uf_modl.h>
#include <uf_obj.h>
#include <uf_modl_primitives.h>
#include <uf_object_types.h>
#include <uf_part.h>
#include <stdlib.h> 
#include <stdio.h> 
#include <time.h> 
#include <iostream>
#include <NXOpen/Session.hxx>
#include <NXOpen/UI.hxx>
#include <NXOpen/NXMessageBox.hxx>
#include <NXOpen/Callback.hxx>
#include <NXOpen/NXException.hxx>
#include <NXOpen/BlockStyler_UIBlock.hxx>
#include <NXOpen/BlockStyler_BlockDialog.hxx>
#include <NXOpen/BlockStyler_PropertyList.hxx>
#include <NXOpen/BlockStyler_Group.hxx>
#include <NXOpen/BlockStyler_SelectObject.hxx>
#include <NXOpen/BlockStyler_ObjectColorPicker.hxx>
#include <NXOpen/BlockStyler_Enumeration.hxx>
//获取枚举控件
		PropertyList *enumProps = enum0->GetProperties();
		int corId,colorIndex = enumProps->GetEnum("Value");
		delete enumProps;
		enumProps = NULL;
		switch (colorIndex)
		{
		case 0: corId = 159;	break;
		case 1: corId = 4;   	  break;
		case 2: corId = 36;	  break;
		case 3: corId = 190; 	break;
		case 4: corId = 186; 	break;
		case 5: corId = 104; 	break;
		case 6: corId = 164; 	break;

		default:corId = 159;
		}
		//设置控件颜色
		PropertyList *colorPicker = colorPicker0->GetProperties();
		vector<int> setColor(1);
		setColor[0] = corId;
		colorPicker->SetIntegerVector("Value",setColor);
		delete colorPicker;
		colorPicker = NULL;

		UF_initialize(); 
		std::vector<TaggedObject*>objects=this->selection0->GetProperties()->GetTaggedObjectVector("SelectedObjects");

		//创建链表
		uf_list_p_t List;
		UF_MODL_create_list(&List);
		//将tag添加到链表
		for ( int i=0;i<objects.size();i++) // size 列表长度
		{   
			UF_MODL_put_list_item(List,objects[i]->Tag());			
		}
		//查询链表数量

		int Count;
		UF_MODL_ask_list_count(List, &Count);

		tag_t ObjectTag = NULL_TAG;
		for (int i = 0; i < Count; i++)
		{
			//获取链表里的所有tag
			UF_MODL_ask_list_item(List, i, &ObjectTag);
			//循环上色
			UF_OBJ_set_color(ObjectTag,corId);
		}
		
		//删除链表
		UF_MODL_delete_list(&List);
		UF_terminate();

  

  

猜你喜欢

转载自www.cnblogs.com/liuxiaoqing1/p/12014806.html
今日推荐