iCAx开思工具箱

标题: 键盘兄,各位高手帮忙解释解释。 [打印本页]

作者: shuoqi    时间: 2005-9-7 08:44
标题: 键盘兄,各位高手帮忙解释解释。
我要用到UF_MODL_ask_edge_verts这个函数的时候,把ug帮助文件给出的这个函数的例子调试了一下,能通过,可是为什么ug在调用这个dll文件时,什么也出不来。这个函数的printf函数的输出都到哪里去了?
  
#include <stdio.h>
#include <uf_defs.h>
#include <uf_modl.h>
#include <uf.h>
#include <uf_ui.h>
#include <uf_object_types.h>
#define UF_CALL(X) (report( __FILE__, __LINE__, #X, (X)))
static int report( char *file, int line, char *call, int irc)
{
  if (irc)
  {
     char    messg[133];
     printf("%s, line %d:  %s\n", file, line, call);
     (UF_get_fail_message(irc, messg)) ?
       printf("    returned a %d\n", irc) :
       printf("    returned error %d:  %s\n", irc, messg);
  }
  return(irc);
}
static void do_ugopen_api(void)
{
  tag_t obj_id = 0;
  tag_t edge_id = 0;
  tag_t view;
  uf_list_p_t edge_list;
  uf_list_p_t face_list;
  UF_UI_selection_options_t opts;
  UF_UI_mask_t mask = {UF_solid_type,0,UF_UI_SEL_FEATURE_BODY};
  int edge_count = 0;
  int face_count = 0;
  int index, vertex, response;
  double p1[3]={0.0, 0.0, 0.0}, p2[3]={0.0, 0.0, 0.0}, cursor[3];
  opts.num_mask_triples = 1;
  opts.mask_triples = [$mask]
  opts.scope = UF_UI_SEL_SCOPE_WORK_PART;
  response = 4;
  do
  {
    UF_CALL(UF_UI_select_single("Select a solid body", &opts,
                              &response, &obj_id,
                              cursor, [$view))]
    if((response == 4) || (response == 5))
    {
      UF_MODL_ask_body_edges(obj_id, [$edge_list)]
      UF_MODL_ask_list_count(edge_list, [$edge_count)]
      UF_MODL_ask_body_faces(obj_id, [$face_list)]
      UF_MODL_ask_list_count(face_list, [$face_count)]
  
      for(index = 0; index < edge_count; index++)
      {
        printf("\nInfo for edge number: %d\n", index);
        UF_MODL_ask_list_item(edge_list, index, [$edge_id)]
        UF_MODL_ask_edge_verts(edge_id, p1, p2, [$vertex)]
        printf("The number of vertices is: %d\n", vertex);
        switch(vertex)
        {
          case 0:
            printf("There are no vertices on this edge.\n");
            break;
          case 1:
            printf("The X value of P1 is: %f\n", p1[0]);
            printf("The Y value of P1 is: %f\n", p1[1]);
            printf("The Z value of P1 is: %f\n", p1[2]);
            break;
          case 2:
            printf("The X value of P1 is: %f\n", p1[0]);
            printf("The Y value of P1 is: %f\n", p1[1]);
            printf("The Z value of P1 is: %f\n", p1[2]);
            printf("The X value of P2 is: %f\n", p2[0]);
            printf("The Y value of P2 is: %f\n", p2[1]);
            printf("The Z value of P2 is: %f\n", p2[2]);
            break;
          default:
            break;
        }
      }
    }
    printf("Total number of faces: %d\n", face_count);
  }while((response == 4) || (response ==5));
}
/*ARGSUSED*/
void ufusr(char *param, int *retcode, int param_len)
{
  if (!UF_CALL(UF_initialize()))
  {
    do_ugopen_api();
    UF_CALL(UF_terminate());
  }
}
int ufusr_ask_unload(void)
{
  return (UF_UNLOAD_IMMEDIATELY);
}
作者: along533    时间: 2005-9-7 11:28
当然不行了
  
你把你的
printf("The X value of P1 is: %f\n", p1[0]);
改成
sprintf(buffer,"The X value of P1 is: %f\n", p1[0]);
UF_UI_write_listing_window(buffer);
  
再在前面适当的地方添加一行:
UF_UI_open_listing_window();
  
再在定义变量的地方添加一行:
  
char buffer[256]="";
  
就行了
作者: shuoqi    时间: 2005-9-7 16:34
这位仁兄,我这样做了,也是没有任何反映啊?
作者: along533    时间: 2005-9-7 16:47
这样只是打开UG信息窗口,没有其它动作的
作者: along533    时间: 2005-9-7 16:49
你把你的每个
printf("The X value of P1 is: %f\n", p1[0]);  
都改成:
sprintf(buffer,"The X value of P1 is: %f\n", p1[0]);  
UF_UI_write_listing_window(buffer);  
  
我想应该有反映了
作者: halm    时间: 2005-9-7 17:09
printf() 这个破东西是不是打印在UG的在下面(就是出提示信息的旁边)
。。
作者: along533    时间: 2005-9-7 17:11
不是Printf,是sprintf,他是把整型,浮点型输出为字符串型
作者: halm    时间: 2005-9-7 17:14
我知道。。。sprintf(),
  
据说printf()也是可以打印的。
UF_UI_write_listing_window()是;另一种打印方法
作者: shuoqi    时间: 2005-9-7 17:49
是出现了。非常感谢along533,可是我不是很理解,printf究竟输出到哪里了,并且,我只加入一两句UF_UI_write_listing_window时为什么不能把这一两句输入到listing里啊。
作者: shuoqi    时间: 2005-9-7 21:02
哪位高手给解释一下,printf的输出到底去哪里了?
  
通过函数获得的一组数如何可以输入到一个数组中啊?
  
各位帮帮小妹吧,愁死了都。




欢迎光临 iCAx开思工具箱 (https://t.icax.org/) Powered by Discuz! X3.3