点击查看详细介绍

在UG8.5下分析曲面最小圆弧出错(UG4.0下 OK)

hedg 20天前 97 1

UG NX 二次开发(C、C#、WPF)技术交流群:641226372      UG二次开发(C、C#、WPF)


/******************************************************************************
             Copyright (c) 1999 Unigraphics Solutions, Inc.
                       Unpublished - All Rights Reserved
*******************************************************************************/
/*
The following example requires a blank, open part. The code creates
a surface from 16 points.
*/
#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_modl.h>
#include <uf_obj.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 )
    {
        /* TODO: Add your application code here */
  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) 
  {
   UF_MODL_ask_feat_body (object_tag,&object_tag);
// 分析面
char msg[132];
double point[3];  //轴中心 点
double param[2],u1[3],v1[3],u2[3],v2[3],unit_norm[3],radii[2];
param[0] = 0.5;
param[1] = 0.5;
UF_MODL_ask_face_props(object_tag,param,point,u1,v1,u2,v2,unit_norm,radii);
UF_UI_open_listing_window(); //打开窗口
sprintf(msg, "radius:%.3f,%.3f\n", radii[0],radii[1]);
UF_UI_write_listing_window(msg);
  }
        /* Terminate the API environment */
        errorCode = UF_terminate();
    }
    /* Print out any error messages */
   return;
}

extern "C" int ufusr_ask_unload( void )
{
 return (UF_UNLOAD_IMMEDIATELY);
}

0

最新回复 (1)
  • nxopen 20天前
    1

    UF_MODL_ask_feat_body (object_tag,&object_tag);

    把这一行注释了

请登录后发表新帖