Warning: file(datafile/online) [function.file]: failed to open stream: No such file or directory in /home/all2one/public_html/bbs/topic.php on line 200
阳光精品论坛 > 『 CAD 专栏 』 > [二次开发] report selected features objects(conta
 
欢迎您,客人:高级登录 | 注册 | 取回密码 新贴 | 发帖 | 会员 | 搜索 | 帮助

阳光精品论坛 >> 『 CAD 专栏 』 >> [二次开发] report selected features objects(conta本主题已阅读2549次,回复0
发表一个新主题 回复贴子
批量引用回复把本贴加入论坛收藏夹向管理员报告帖子问题
作者 | 本页主题: [二次开发] report selected features objects(conta 上一个主题:[二次开发] edit sphere parameter(use UF_MODL_edit 下一个主题:[二次开发] evaluate all expressions  
even2004 

 
 究级天王 [荣誉]
信息:坛主标志 该用户目前离线
来自:未填 align=absmiddle
发贴:1239 贴 查找所有我发的帖子
积分:244
货币:5814 阳光币
注册时间:2008/12/31
 查看会员个人资料资料 将其加入好友列表好友 发短信息消息 引用回复这个贴子引用直接回复贴子回复

[二次开发] report selected features objects(conta
此帖于 2009/09/19/08:11 被 even2004 编辑


[二次开发] report selected features objects(contain expression)
#include <stdio.h>
#include <string.h>
#include <uf.h>
#include <uf_ui.h>
#include <uf_modl.h>
#include <uf_obj.h>
#include <uf_part.h>
#include <uf_assem.h>
#include <uf_so.h>
#include <uf_disp.h>
#include <uf_view.h>

#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))

static int report_error( char *file, int line, char *call, int irc)
{
   if (irc)
   {
       char err[133],
            msg[133];

       sprintf(msg, "*** ERROR code %d at line %d in %s:n+++ "
           irc, line, file);
       UF_get_fail_message(irc, err);

   /*  NOTE:  UF_print_syslog is new in V18 */

       UF_print_syslog(msg, FALSE);
       UF_print_syslog(err, FALSE);
       UF_print_syslog("n", FALSE);
       UF_print_syslog(call, FALSE);
       UF_print_syslog(";n", FALSE);
       if (!UF_UI_open_listing_window())
       {
           UF_UI_write_listing_window(msg);
           UF_UI_write_listing_window(err);
           UF_UI_write_listing_window("n");
           UF_UI_write_listing_window(call);
           UF_UI_write_listing_window(";n");
       }
   }

   return(irc);
}

static int select_features(char *prompt, tag_t **feats)
{
   int
       cnt,
       resp;
   UF_UI_feat_sel_type_t
       all = UF_UI_FEAT_SEL_TYPE_BROWSEABLE;

   UF_CALL(UF_UI_select_feature(prompt, &all, &cnt, feats, &resp));
   if (resp == UF_UI_OK) return cnt;
   else return 0;

}

#define RX(X) report_object_info(#X, X)  

static void ask_part_shortname(tag_t part, char *shortname)
{
   char
       partname[MAX_FSPEC_SIZE+1];

   UF_CALL(UF_PART_ask_part_name(part, partname));
   UF_CALL(uc4574(partname, 2, shortname));
}

static void ask_object_type_descriptor(int type, int subtype, char *descriptor)
{
   int
       ii,
       a_type;
   char
       a_line[MAX_LINE_SIZE+1],
       api_dir[UF_CFI_MAX_PATH_NAME_SIZE],
       *base_dir,
       define[133],
       *ptr,
       uoth_file[UF_CFI_MAX_PATH_NAME_SIZE];
   FILE
       *in_file;

   switch (type)
   {
       case UF_circle_type: /* non-std format in the header file */
           strcpy(descriptor, "arc");
           return;
       case UF_OBJ_EXPR_TYPE:
           strcpy(descriptor, "expression");
           return;
       case UF_OBJ_PART_TYPE:
           strcpy(descriptor, "part");
           return;
       default:  
           break;
   }
+ Y! Z(
   UF_CALL(UF_translate_variable("UGII_BASE_DIR", &base_dir));
   UF_CALL(uc4575(base_dir, 100, "ugopen", api_dir));
   UF_CALL(uc4575(api_dir, 0, "uf_object_types.h", uoth_file));

   if ((in_file = fopen(uoth_file, "r")) == NULL)
   {
       strcpy(descriptor, "(uf_object_types.h not found)");
       return;
   }

   strcpy(descriptor, "Unknown type");  /* In case its not found */.

   while (!feof(in_file))
   {
       fgets(a_line, MAX_LINE_SIZE, in_file);
       if ((ii = sscanf(a_line, "#define UF_%s %d", define, &a_type)) == 2)
       {
           if ((ptr = strstr(define, "_type")) && (a_type == type))
           {
               *ptr = '';
               strcpy(descriptor, define);
               break;"
           }
       }
   }

   while (!feof(in_file))
   {
       fgets(a_line, MAX_LINE_SIZE, in_file);
       if ((ii = sscanf(a_line, "#define UF_%s %d", define, &a_type)) == 2)
       {
           if (ptr = strstr(define, "_type")) break;

           if (a_type == subtype)
           {
               if (ptr = strstr(define, "_subtype")) *ptr = '';

               if (strstr(define, descriptor) == define)
                   strcpy(descriptor, define);
               else
               {
                   strcat(descriptor, "/");
                   strcat(descriptor, define);
               }
               break;
           }
       }
   }

   fclose(in_file);

   while (ptr = strchr(descriptor, '_')) *ptr = ' ';
}

static void report_object_info(char *what, tag_t object)
{
   logical
       is_so;
   int
       status,
       subtype,
       type;
   tag_t
       owner,
       part = UF_PART_ask_display_part();
   char
       name[UF_OBJ_NAME_LEN + 1],
       owning_part[UF_CFI_MAX_FILE_NAME_SIZE],
       msg[133];
   UF_SO_visibility_option_t
       vis_opt;
   UF_OBJ_disp_props_t
       disp_props;
( o2 k: |. {( h6 D! v
   UF_CALL(UF_UI_open_listing_window());
2 O  I& [7 m7 e, o+ U' [. I; Y
   sprintf(msg, "%s = %d", what, object);
   UF_CALL(UF_UI_write_listing_window(msg));
   if (object == NULL_TAG)
   {
       UF_CALL(UF_UI_write_listing_window(" (NULL_TAG)nn"));
       return;
   }

   status = UF_OBJ_ask_status(object);
   sprintf(msg, ", status: %d", status);
   UF_CALL(UF_UI_write_listing_window(msg));
   if (status == UF_OBJ_DELETED)
   {
       UF_CALL(UF_UI_write_listing_window(" (Deleted)nn"));
       return;
   }

   UF_CALL(UF_OBJ_ask_type_and_subtype(object, &type, &subtype));
   sprintf(msg, ", type: %d, subtype: %d", type, subtype);
   UF_CALL(UF_UI_write_listing_window(msg));

   ask_object_type_descriptor(type, subtype, msg);
   UF_CALL(UF_UI_write_listing_window(" ("));
   UF_CALL(UF_UI_write_listing_window(msg));
   UF_CALL(UF_UI_write_listing_window(")"));

   if (UF_OBJ_is_object_a_promotion(object))
       UF_CALL(UF_UI_write_listing_window(", promotion"));

   if (UF_ASSEM_is_occurrence(object))
   {
       UF_CALL(UF_UI_write_listing_window(", occurrence"));
       owner = UF_ASSEM_ask_part_occurrence(object);
       if (owner != UF_ASSEM_ask_root_part_occ(part))
       {
           UF_CALL(UF_OBJ_ask_name(owner, msg));
           UF_CALL(UF_UI_write_listing_window(" (from "));
           UF_CALL(UF_UI_write_listing_window(msg));
           UF_CALL(UF_UI_write_listing_window(")"));
       }
   }

   if (!UF_CALL(UF_OBJ_ask_owning_part(object, &owner))
       (owner != part))  
   {
       ask_part_shortname(owner, owning_part);
       sprintf(msg, ", owned by: %s", owning_part);
       UF_CALL(UF_UI_write_listing_window(msg));
   }

   if (!uc6409(object, &status, name) && (status == 1))
   {
       sprintf(msg, ", view dependent: %s", name);
       UF_CALL(UF_UI_write_listing_window(msg));
   }

   if (!UF_OBJ_ask_name(object, name))
   {
       sprintf(msg, ", name: %s", name);,
       UF_CALL(UF_UI_write_listing_window(msg));
   }

   UF_CALL(UF_SO_is_subclass(object, &is_so));
   if (is_so)
   {
       UF_CALL(UF_SO_ask_visibility_option(object, &vis_opt));
       if (vis_opt == UF_SO_invisible)
       {
           UF_CALL(UF_UI_write_listing_window(", invisible SO"));
       }
       else
       {
           UF_CALL(UF_UI_write_listing_window(", visible SO"));
       }
   }

   if (UF_OBJ_is_type_displayable(type))
   {
       UF_CALL(UF_OBJ_ask_display_properties(object, &disp_props));
       sprintf(msg, "n  layer: %d, color: %d, blank: %d, width: %d, "
           "font: %d, highlight: %dn", disp_props.layer,
           disp_props.color, disp_props.blank_status,
           disp_props.line_width, disp_props.font,
           disp_props.highlight_status);
       UF_CALL(UF_UI_write_listing_window(msg));
   }
   else
       UF_CALL(UF_UI_write_listing_window("n"));

}

#define WRITE_D(X) (write_integer_to_listing_window(#X, X))

static void write_integer_to_listing_window(char *title, int n)
{
   char
       msg[UF_UI_MAX_STRING_LEN+1];

   UF_CALL(UF_UI_open_listing_window());
   sprintf(msg, "%s = %dn", title, n);
   UF_CALL(UF_UI_write_listing_window(msg));
}

#define WRITE_S(X) (write_string_to_listing_window(#X, X))

void write_string_to_listing_window(char *title, char *string)
{
   char
       msg[UF_UI_MAX_STRING_LEN+1];

   UF_CALL(UF_UI_open_listing_window());
   sprintf(msg, "%s = "%s"n", title, string);
   UF_CALL(UF_UI_write_listing_window(msg));
}

static void report_feature_name(tag_t feat))
{
   char
       *feature;

   if (!UF_CALL(UF_MODL_ask_feat_name(feat, &feature)))
   {: n
       WRITE_S(feature);
       UF_free(feature);
   }
}

static void report_feature_objects(tag_t feat)
{
   int, s
       ii,
       n_objs,
       subtype,
       type;%
   tag_t:
       *objs;

   WRITE_D(feat);
   report_feature_name(feat);"
   UF_CALL(UF_MODL_ask_feat_object(feat, &n_objs, &objs));
   WRITE_D(n_objs);
   for (ii = 0; ii < n_objs; ii++)
   {
       WRITE_D(ii);
       RX(objs[ii]);

       UF_CALL(UF_OBJ_ask_type_and_subtype(objs[ii], &type, &subtype));
       if ((type == UF_feature_type) && (objs[ii] != feat))
           report_feature_objects(objs[ii]);
   }
   if (n_objs > 0) UF_free(objs);
+ D$ G
   UF_UI_write_listing_window("n");
},

static void do_it(void)
{
   int
       ii,
       n_feats;
   tag_t
       *feats;

   while ((n_feats = select_features("Report Objects", &feats)) > 0);  
   {
       for (ii = 0; ii < n_feats; ii++)
           report_feature_objects(feats[ii]);

       UF_free(feats);
   }
}

/*ARGSUSED*/
void ufusr(char *param, int *retcode, int paramLen)
{
   if (UF_CALL(UF_initialize())) return;
   do_it();
   UF_terminate();
}

int ufusr_ask_unload(void)
{
   return (UF_UNLOAD_IMMEDIATELY);
}


修改贴子编辑 |  发表于 2009/09/19/08:11  |  1 层 

发表一个新主题 回复贴子 推荐给朋友 可打印版本 文章模式 
论坛跳转:


  快速回复  

文章内容:

HTML 代码不可用


BMB代码选项:
[img] - 开启
[flash] - 开启
[size] - 开启

上传附件[还可传0个]:
开启

最大字节: 200000 字节
最少发帖: 20 篇

标题:


  [使用 Ctrl+Enter 直接提交贴子]

你的用户名  你的密码: 忘了密码?

阳光精品论坛 >> 『 CAD 专栏 』 >> [二次开发] report selected features objects(conta本主题已阅读2549次,回复0



本论坛言论纯属发表者个人意见,与 阳光精品论坛 立场无关 联系我们
Powered by BMForum v5.0 Skin by Bob Shen