zoukankan      html  css  js  c++  java
  • 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();
    

      

      

  • 相关阅读:
    springboot mail+Thymeleaf模板
    jax-rs示例
    java enum的一种写法记录
    lintcode 最大子数组III
    lintcode 单词接龙II
    idea springboot热部署无效问题
    java8 Optional正确使用姿势
    Spring根据包名获取包路径下的所有类
    无状态shiro认证组件(禁用默认session)
    获取资源文件工具类
  • 原文地址:https://www.cnblogs.com/liuxiaoqing1/p/12014806.html
Copyright © 2011-2022 走看看