• Knowledge Fusion例子


    #! NX/KF 5.0
    #
    #*******************************************************************************************
    #				Design:	 GuiTu
    #        			Date  :  2017.9.8
    #				E_mall:	 1714787391@qq.com
    #				QQ    :  1714787391			
    #				name  :  批量层处理
    #*********#  文件名与类名  #****************************************************************
    Defclass:  guitu_setlayer (%ui_comp) ;
    
    (string) title:     "批量层处理";
    (string) cue:       "归途提示:选择要移动层对象";
    ############################    定义组区        ###########################################
    (list) DialogItems: {select_group:,fanyi_group:,set_group:};    # 对话框里组的  列表(list)
    
    ############################    参数声名区       ##########################################
    (any Parameter Modifiable)         layer_value: 256;
    (any Parameter Modifiable)         str:   "256";
    (any Parameter Modifiable)         str1:   "";
    (any Parameter Modifiable)         b1:   true;
    (any Parameter Modifiable)         b2:   true;
    (any Parameter Modifiable)         b3:   true;
    (any Parameter Modifiable)         b4:   true;
    (any Parameter Modifiable)         b5:   true; # 隐藏
    (any Parameter Modifiable)         b6:   true; # 草图
    
    (any Parameter Modifiable)         int:  256;
    
    ############################    UI界面 区       ##########################################
    (child) select_group:
    {
        class, %ui_comp_group;
        title, "选择目标";
        Members, {select_face: };  
    };
    
    
        
    (Child)  select_face: 
    {
    	Class, %ui_comp_selection;
      	Many, false;			     #是否多选
      	SnapPointOverlay, false;
      	SoUpdateOption, 3;
    
      	Tooltip, "选择目标";
      	Scope, 1;
      	FilterTriple, {{2,0,0},{3,0,0},{5,0,0},{9,0,0},{197,0,0},{70,0,0},{19,0,0},{20,0,0},{43,0,0}};	#选择类型		  	
      	SelectedObjects, {};		
      	SelectedObject, SelectedObjects:;  };
    (child) fanyi_group:
    {
      	class, %ui_comp_group;
     	title, "图层";
        	Members, {rh_label3:,rh_label4:,rh_label5:,rh_label6:, UI_button:,list_box:,integer:};   					#####表示在shaft_group:组下有多少子规则
    }; 
    
    (child) rh_label3: 
    {
            class,     %ui_comp_label;
            Title,     "遍历目标体="  ;
              topAttach,  select_face:  ;                             
    };
    (child) rh_label4: 
    {
            class,       %ui_comp_label;
            Title,    str1: ;
            leftAttach,  rh_label3:;
            topAttach,   select_face: ;
    };
    (child) rh_label5: 
    {
            class,     %ui_comp_label;
            Title,    "" ;
           topAttach, rh_label4: ;                             
    };
    (child) rh_label6: 
    {
            class,     %ui_comp_label;
            Title,    "提示:   "+"~n" +"你的图层类别没有设置或设置格式与本工具有异"+"~n"+"你可通过设置图层类别来获得更多可选图层列表信息"+"~n"+"了解更多信息请点击下列图标按钮";
            icon, "advwave_legend_icon_outofdate.bmp";	
            topAttach,  rh_label5:  ;
            leftAttach,  rh_label5:;                             
    };
    (Child) UI_button: 
    {
      Class, %ui_comp_button;
      Title, " ";
      icon,"informational_symbol.bmp"; # 
    };
    (Child) list_box: 
    {
      	Class, %ui_comp_list_box;
      	ListItems, Append_type_layer_string: ;	# 列表内容
      	SelectedItems, {};		#  返回选择的列表内容
      	selected, SelectedItems:;   
      	SingleSelect, false;            #  单选多选
      	ShowMoveUpDownButtons, true;    #  true显示上下移动按钮
      	DisplayRows, 4;			#  列表框的显示行数
    };
    (any)  int_value:      first ( SplitString(nth( if list_box:SelectedItems:={} then 1  else first(list_box:SelectedItems:)+1    ,Append_type_layer_string:),"   "));
    
    (Child) integer:
     {
        Title, " ";
      Class, %ui_comp_integer;
      value,int:;
      MaximumValue, 2^30;
      MinimumValue, -2^30;
      Width, 0;
    };
    (child) set_group:
    {
        class, %ui_comp_group;
        title, "设置";
        Members, {toggle:,toggle1: ,toggle2:,toggle4:,toggle5:,toggle3: };  
    };
    (Child) toggle: {
      Class, %ui_comp_toggle;
      title, "允许改动图层";
      value, b1:;
    };
    (Child) toggle1: {
      Class, %ui_comp_toggle;
      title, "仅相同图层";
      value, b2:;
    };
    (Child) toggle2: {
      Class, %ui_comp_toggle;
      title, "仅相同颜色";
      value, b3:;
    };
    (Child) toggle4: {
      Class, %ui_comp_toggle;
      title, "仅显示对象"; 
      value, b5:;
    };
    (Child) toggle5: {
      Class, %ui_comp_toggle;
      title, "不操作草图对象"; 
      value, b6:;
    };
    
    (Child) toggle3: {
      Class, %ui_comp_toggle;
      title, "区分样条cntl和thru"; 
      value, b4:;
    };
    
    
    ############################    代码 区       ##########################################
    
    # ********************************* 技术 一  获得选择对象信息 
    
    #获得选择目标 Type (类型)
                  (String)   a: ug_object_askType(first(select_face:SelectedObjects:));
                  (list)       a1:   askTypeSubtype(first(select_face:SelectedObjects:));
                  (String)   a2:  if  a:!="" then  a:  else "" ;
    
    #( askcolor  info)
                  (integer) color1: ug_vd_si_ask_color(first(select_face:SelectedObjects:));
    #( asklayer  info)
                  (integer) layer1: if a:="ug_body" then asklayer(first(select_face:SelectedObjects:)) else  nth(5,mqc_askEntityDisplayData(ug_cam_askObjectTag(first(select_face:SelectedObjects:))));
    
    
    #( 图层   信息 )
    
    
    #给定遍历的的类型进行遍历
    (Any) cycle:  ug_cycleObjectsByType({MakeName(a2:)},"");
    # 遍历处理(区分 "ug_spline_thru"和"ug_spline_cntl")
    (Any) cycledeal_1:  loop {
                           for $a from 0 to length(cycle:)-1;           
                           for $b is  $a +1;
                           if  ug_object_askType(nth($b,cycle:))= a:    append  {nth($b,cycle:)};
                           
                         }    ;
    
    (Any) cycledeal:   if  a2:="ug_spline_thru"|a2:="ug_spline_cntl"& toggle3:value:=true then  cycledeal_1:  else  cycle: ;  
    
    
    #+
    基准平面
    ug_cycleObjectsByType({ug_datum_plane},"")
    
    #-
    
    #**********************************技术 二 扩展技术  获得对象类型所在图层
    
    (list) Categoryinfor:  mqc_askCategory();
    (list) askEmptyLayers:  mqc_askEmptyLayers();
    (list) askEmptyLayersatCategory:  findDuplicates( askEmptyLayers:+ Append_type_layer:);
    
    #收集类型所在的层
    (any) select_layer:   nth(5,mqc_askEntityDisplayData(ug_cam_askObjectTag(first(select_face:SelectedObjects:))));  
    
    (any) Append_type_layer:  loop {
                           for $a from 0 to length(Categoryinfor:)-1;           
                           for $b is  $a +1;
                           for $m is  last(SplitString(first(nth($b,Categoryinfor:)),"_"));
                           if  last(SplitString(a:,"_"))=$m  return  {if ug_AskWorkLayer()=select_layer:   then  256  else 256,ug_AskWorkLayer()}+nth(4,(nth($b,Categoryinfor:)));
                           return is {256};
      }; 
    
    # 1 .将int list 变为 str list        2.区分空层和非空层   mqc_ask_layer_entities({$m}, ALL,true)
    (any) Append_type_layer_string:  loop {
                           for $a from 0 to length(Append_type_layer:)-1;           
                           for $b is  $a +1;
                           for $m is nth($b,Append_type_layer:);  
                            append { if  mqc_findSublist( $m,   {  askEmptyLayersatCategory: } )={}&ug_AskWorkLayer()=$m  then  stringValue($m )+"   "+stringValue(length(mqc_askObjectsInLayer({$m}, ALL,true)))+"  "+"工作层" else if  mqc_findSublist( $m,   {  askEmptyLayersatCategory: } )={}   then stringValue($m )+"   "+stringValue(length(mqc_askObjectsInLayer({$m}, ALL,true)))   else stringValue($m ) } ;   
                         }; 
    
    
    
    
    #*********************************  技术三 过滤机制
    #  收集颜色相同类型的object  toggle2:
    (list) sametypeColorobj: loop {
                           for $a from 0 to length(cycledeal:)-1;           
                           for $b is  $a +1;
                           for $m is  ug_vd_si_ask_color(nth($b,cycledeal:));
                           if  $m=color1:   Append  {nth($b,cycledeal:)} ;
                   }; 
    (list)  Colorobj:  if toggle2:value:=true then sametypeColorobj: else cycledeal:;
    #  收集图层相同类型的object   toggle1:
    (list) sametypelayerobj:  loop {
                           for $a from 0 to length(cycledeal:)-1;           
                           for $b is  $a +1;
                           for $m is    if a:="ug_body" then asklayer(first(select_face:SelectedObjects:)) else nth(5,mqc_askEntityDisplayData(ug_cam_askObjectTag(nth($b,cycledeal:))));  
                           if  $m=layer1:   Append  {nth($b,cycledeal:)} ;
     }; 
    (list)  layerobj:  if toggle1:value:=true then sametypelayerobj:  else cycledeal:;
    #  收集隐藏object   toggle4:
    (list) allblankobj:       mqc_askBlankedObjects(); 
    (list) selectobjblankobj:  loop {
                           for $a from 0 to length(cycledeal:)-1;           
                           for $b  is  $a +1;
                           for $m is   nth($b,cycledeal:); 
                           for $T  is   ug_cam_askObjectTag($m) ;
                           if mqc_findSublist( $T,   { allblankobj: } )={}   Append  {nth($b,cycledeal:)} ; # 表示仅仅收集没有隐藏对象
                         }; 
    (list)  blankobj:  if toggle4:value:=false then cycledeal:  else selectobjblankobj:;
    
    #****技术(一)------1 (过滤处理)
    # 判断是否选相同颜色
    (list)  setlayerobj:  ug_findDuplicates(ug_findDuplicates(blankobj:+layerobj: )+ug_findDuplicates(layerobj:+Colorobj:  )+ug_findDuplicates(blankobj:+Colorobj:  ) ) ;
    
    # sket过滤   setlayerobj:
    
    (list) askFeat:  mqc_askFeatures();
     (any) sket: loop {
                           for $a from 0 to length(setlayerobj:)-1;           
                           for $b is  $a +1;
                           for $m is nth($b,setlayerobj:);
                           for $objtag is  ug_cam_askObjectTag($m);
                           for $Featuretag is mqc_askFeatureOfObject ($objtag ); 
                           if  $Featuretag!=-1  append{$m}; 
    };
    # collect is skect object
     (any) sketFeat: loop {
                           for $a from 0 to length(sket:)-1;           
                           for $b is  $a +1;
                           for $m is nth($b,sket:);
                           for $objtag is  ug_cam_askObjectTag($m);
                           for $Featuretag is mqc_askFeatureOfObject ($objtag ); 
                           if second(mqc_askFeatureNameAndType($Featuretag))="SKETCH"  append{$m}; 
    };
    
    # decide whether or not to select an operation skect object through  toggle5:value: is true or false 
    
    (list)  endsetlayer:  if toggle5:value:=true then SetDifference(setlayerobj:,sketFeat:)  else setlayerobj:;
    
    
    #**********************************  技术 四   设置图层                 
     (any) setlayer: loop {
                           for $a from 0 to length( endsetlayer:)-1;           
                           for $b is  $a +1;
                            if toggle:value:=False return 0;
                           do ug_setObjectLayer(nth($b, endsetlayer:), makenumber(int_value:));
                         };                   
    
    (list)  demandValue: {setlayer:};               
                       
    
    
    
    
    
    
    #  对话框的初始化 1
    
    (Method integer) OnInitialize:(Instance $instance)
    @{
    	
    	
    	%ui_comp_setCacheValue(self(), int:,integer:,value);
                    %ui_comp_setCacheValue(self(), b1:,toggle:,value);
                     %ui_comp_setCacheValue(self(), b2:,toggle1:,value);
                    %ui_comp_setCacheValue(self(), b3:,toggle2:,value);
                    %ui_comp_setCacheValue(self(), b4:,toggle3:,value);
                   %ui_comp_setCacheValue(self(), b5:,toggle4:,value);
                   %ui_comp_setCacheValue(self(), b6:,toggle5:,value);
    #        if (string3:value:="guitu_information") then {%ui_comp_setCacheValue(self(), true,UI_button:,Visibility);} else    {%ui_comp_setCacheValue(self(), false ,UI_button:,Visibility);};
    
     if   (last(SplitString(a:,"_"))="point"&length(Append_type_layer_string:)=1) then 
                  {
    	%ui_comp_setCacheValue(self(), true, rh_label6: ,Visibility);
    	%ui_comp_setCacheValue(self(), true,UI_button:,Visibility);
                     } 
    else    
    	{
    	%ui_comp_setCacheValue(self(), false , rh_label6: ,Visibility);
    	 %ui_comp_setCacheValue(self(), false ,UI_button:,Visibility);
    	};
      
     if  (a2:="ug_spline_thru"|a2:="ug_spline_cntl")
    then 
                  {
    	%ui_comp_setCacheValue(self(), true,toggle3: ,Visibility);
    	
                     } 
    else    
    	{
    	%ui_comp_setCacheValue(self(), false , toggle3:  ,Visibility);
    	
    	};
    
    
    
    
    
    0;
    };
    
    #更新机制 2
    (Method integer ) Update:(Instance $instance)
    @{
    
       
          %ui_comp_setCacheValue(self(),Append_type_layer_string:,list_box: ,ListItems);
          %ui_comp_setCacheValue(self(),makenumber(int_value:),integer:,value);
        
            %ui_comp_setCacheValue(self(),  if a2:="" then "{"+format("%d",first(a1:))+","+format("%d",last(a1:)) +"}"+" :   可选图层列表" else a2: +" :   可选图层列表" ,rh_label5: ,Title);
           %ui_comp_setCacheValue(self(),   format("%d",length(endsetlayer:)),rh_label4: ,Title);
    
    
    if ($instance = UI_button:) then 
       @{
           ug_printValues( {" 批量层处理帮助 "});
        ug_printValues( {"======================"});
        ug_printValues( {"信息列表创建者      : "+ug_askUserName()});
        ug_printValues( {"日期              : "+dateTimeString(localTime? ,True)});
        ug_printValues( {"当前工作部件       : "+ug_askScenarioDirectory()+".prt"});
        ug_printValues( {"系统平台          : "+ug_askOSName()});
           ug_printValues( {"======= 过滤对象==========="});
          ug_printValues( {"颜色相同对象       : ",length(Colorobj:)});
           ug_printValues( {"图层相同          : ",length(layerobj:)});
           ug_printValues( {"隐藏对象          : ",length(blankobj:)}); 
           ug_printValues( {"遍历目标体        : ", length(setlayerobj: )});
       ug_printValues( {"sket:        : ", sketFeat:});
       ug_printValues( {"sket:        : ",setlayerobj:});
    
            ug_printValues({"草图对象        : ", length(setlayerobj: )-length(notsketFeat: )}); 
         ug_printValues( {"&&&&&&&&&&&&&&&&&&&      设置       &&&&&&&&&&&&&&&&&&&&&&&&&&&"});
         ug_printValues( {"***************允许移动图层                开关作用 ***********************  : "+ "~n" });
                      ug_printValues({"   是否移动对象 " + "~n" } );
         ug_printValues({ "***************仅相同图层                   开关作用 ***********************  : "+ "~n" });
                      ug_printValues({"   仅操作图层相同的类型对象 " + "~n" } );
         ug_printValues({ "***************仅相同图层                  开关作用 ***********************  : "+ "~n" });
                     ug_printValues({ "   仅操作图层相同的类型对象 " + "~n"  });
        ug_printValues( {"***************仅相同颜色                   开关作用 ***********************  : "+ "~n" });
                      ug_printValues({"   仅操作颜色相同的类型对象 " + "~n"  });
         ug_printValues( {"**************仅显示对象                   开关作用 ***********************  : "+ "~n" });
                      ug_printValues( {"仅操作当前显示的的类型对象 " + "~n" } );
          ug_printValues({ "*************区分样条cntl和thru       开关作用 ***********************  : "+ "~n" +
                      "原本以为样条分为'通过点'和'根据极点' 那么thru 应为'通过点'  而cntl 应为'根据极点' " + "~n" +
                       "但是经过后来测试发现并不是那回事 但也相似 "+"~n" +
                       "做逆向造型常用到截面线 这个命令截出的类型即为 cntl 型,还有就是使用'根据极点'创建得到的以及使用'通过点'当你选择的(次数=创建的点数)" + "~n" });
         
         
        }
    
       else 
           doNothing;
    
     if   (last(SplitString(a:,"_"))="ug_spline_thru"|length(Append_type_layer_string:)=1) then 
                  {
    	%ui_comp_setCacheValue(self(), true, rh_label6: ,Visibility);
    	%ui_comp_setCacheValue(self(), true,UI_button:,Visibility);
                     } 
    else    
    	{
    	%ui_comp_setCacheValue(self(), false , rh_label6: ,Visibility);
    	 %ui_comp_setCacheValue(self(), false ,UI_button:,Visibility);
    	};
    
    
     if  (a2:="ug_spline_thru"|a2:="ug_spline_cntl")
    then 
                  {
    	%ui_comp_setCacheValue(self(), true,toggle3: ,Visibility);
    	
                     } 
    else    
    	{
    	%ui_comp_setCacheValue(self(), false , toggle3:  ,Visibility);
    	
    	};
    
    
    
    
    
    0;
    };
    

      

  • 相关阅读:
    解决Maven关于本地jar包的打包处理
    微信公众帐号应用开发—本地调试
    字符串
    动态类型
    数字
    React文档(二十四)高阶组件
    React文档(二十三)Web Components
    React文档(二十二)context
    React文档(二十一)协调
    React文档(二十)不使用JSX
  • 原文地址:https://www.cnblogs.com/liuxiaoqing1/p/12024556.html
Copyright © 2020-2023  润新知