点击查看详细介绍

UG二次开发获取面的最外边缘实例代码 精华帖

woiusr 9年前 19441 140

购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008  QQ号:85585969  


//获取面的最外边缘实例代码
#include <uf.h>
#include <uf_exit.h>
#include <uf_ui.h>
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
#        include <strstream>
#   include <iostream>
        using std::ostrstream;
        using std::endl;        
        using std::ends;
        using std::cerr;
#else
#        include <strstream.h>
#   include <iostream.h>
#endif
#include <uf_csys.h>
#include <uf_obj.h>
#include <uf_modl.h>
//设置选择的实体类型
static int init_proc( UF_UI_selection_p_t select, void *user_data )
{
int  errorCode   = 0;
int  num_triples = 1; //选择类型 数量
UF_UI_mask_t mask_triples[]={UF_face_type,0,0,}; //定义选择类型
errorCode = UF_UI_set_sel_mask(select, UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC,num_triples, mask_triples);
if( errorCode == 0)
{
return UF_UI_SEL_SUCCESS;
}
 else
{
 return UF_UI_SEL_FAILURE;
}
}
extern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )
{
    /* Initialize the API environment */
    int errorCode = UF_initialize();
    if ( 0 == errorCode )
    {
  char *message="提示!请选择表面。";
  char *title="请选择表面";
  int  scope=UF_UI_SEL_SCOPE_WORK_PART;//UF_UI_SEL_SCOPE_NO_CHANGE
  int  response;
  tag_t object_tag;
  double  cursor[3]={0.0};
  tag_t view=NULL_TAG;
UF_UI_lock_ug_access (UF_UI_FROM_CUSTOM);//加锁
UF_UI_select_with_single_dialog(message,title,scope,init_proc,NULL,&response,&object_tag,cursor,&view);  //选择框
UF_DISP_set_highlight(object_tag,0); //1高亮显示 0不高亮显示
UF_UI_unlock_ug_access (UF_UI_FROM_CUSTOM);//解锁
  if (response==UF_UI_OBJECT_SELECTED) 
  {
     //获得面最外边缘

●●●请先 登陆注册 后查看●●●

     int      loops_count=0;
     UF_MODL_ask_loop_list_count(loops_list,&loops_count);//查询数量
     for (int l_i=0; l_i<loops_count; l_i++)
     {
        int    loops_type=0;              //类型
        uf_list_p_t   edge_list=NULL_TAG; //边缘菜单指针ID
        UF_MODL_ask_loop_list_item(loops_list,l_i,&loops_type,&edge_list);      
        if (1==loops_type)                //边界=1, 洞=2, 其他=3
        {
           int  edge_count=0;             //边缘数量
           UF_MODL_ask_list_count ( edge_list, &edge_count );
           for(int edge_i=0; edge_i<edge_count;edge_i++)
           {
                          n=n+1;
              UF_MODL_ask_list_item( edge_list,edge_i,&edge_id[n-1]);     //n-1 是因为 数组是从0开始的
              UF_MODL_create_curve_from_edge(edge_id[n-1],&edge_id[n-1]); //提取实体边缘  
           } 
         }
      }
       if (n!=0)
      {
        char msg[32]="";
        sprintf(msg, "%d",n);
        uc1601(msg,1);
      }
      else
      {
            uc1601("UGapi提示!你选择的面没有发现边缘(比如:首尾相连的圆柱面不返回边缘)",1);
      }  
   }
        errorCode = UF_terminate();
    }
   return;
}
extern "C" int ufusr_ask_unload( void )
{
        return (UF_UNLOAD_IMMEDIATELY); 
}


6

最新回复 (140)
  • leader_ld 9年前
    1

    学习中,看看有没有帮助

  • waqa1314 VIP会员 9年前
    2

    学习中,看看有没有帮助

  • jimk 9年前
    3

    学习一下,谢谢分享。

  • q1355188058 8年前
    4

    学习,谢谢oooo

  • f1405602 8年前
    5

    学习学习楼主 *** 爆了的没有?

  • pm906026115 8年前
    6

    xiexiessssssss!

  • wucrew 8年前
    7

    谢谢分享,学习,辛苦了

  • zhouyuxing 8年前
    8

    66666666666666

  • HYZ谢谢 8年前
    9

    谢谢分享,学习,辛苦了

  • strbirofsum 8年前
    10

    谢谢分享

  • yangyaokai 8年前
    11

    学习中,看看有没有帮助

  • wgp1109 8年前
    12

    谢谢分享谢谢分享谢谢分享

  • yccong 8年前
    13

    学习中,谢谢楼主分享!

  • sunny7191 8年前
    14

    谢谢楼主分享,受教了

  • pengfujun VIP会员 8年前
    15

    谢谢分享,学习,辛苦了

请登录后发表新帖