iCAx开思工具箱

标题: 请深夜摔键盘帮助 [打印本页]

作者: haorizhi002    时间: 2005-5-25 20:41
标题: 请深夜摔键盘帮助
你好
我正在做个课题,要通过交互方式,选择工程图中的线或圆
但我用uf_ui_select_with_dialog怎么试都不行。
你能帮帮我吗?
你个问题已经困我二周了。
多谢了
以下是我的程序
void ufusr(char *param, int *retcode, int param_len)
{
  
  if(!UF_initialize())
  {
    GetPoint();
    UF_terminate();
  }
}
  
void GetPoint()
{
  int res;
  int num_intersects;
  int type;
  int n_visible,display = 1;
  int n_clipped;
  int i,j;
  
  tag_t *visible;
  tag_t *clipped;
  tag_t view_tag;
  tag_t line_tag;
  
  double point[3],dp[3];
  double z_vec[3];
  double viewmatrix[9];
  double firstp[3],secondp[3];
  double my_point[3];
  
  char view_name[100],mes[133];
  int response,count;
  tag_p_t objects;
  res = UF_UI_select_with_class_dialog("no cur","this",UF_UI_SEL_SCOPE_WORK_PART_AND_OCC, NULL,NULL,[$response, &count, &objects)]
    if(res)
    {
      UF_get_fail_message(res,mes);
      uc1601(mes,1);
    }
}
int ufusr_ask_unload(void)
{
    return (UF_UNLOAD_IMMEDIATELY);
}
static int init_proc(
    UF_UI_selection_p_t select,
    void *user_data)
{
  int res;
    UF_UI_mask_t mask_triples[] = {
      {UF_circle_type,UF_all_subtype,UF_OBJ_no_property},
    {UF_line_type,UF_all_subtype,UF_OBJ_no_property},
    {UF_solid_type,UF_solid_edge_subtype,UF_OBJ_solid_body_property},
      {UF_drafting_entity_type,UF_draft_note_subtype,UF_OBJ_no_property},
      {UF_drafting_entity_type,UF_draft_label_subtype,UF_OBJ_no_property},
      {UF_drafting_entity_type,UF_draft_id_symbol_subtype,UF_OBJ_no_property},
      {UF_drafting_entity_type,UF_draft_fpt_subtype,UF_OBJ_no_property},
      {UF_drafting_entity_type,UF_draft_cntrline_subtype,UF_OBJ_no_property},
      {UF_drafting_entity_type,UF_draft_linear_cntrln_subtype,UF_OBJ_no_property},
      {UF_drafting_entity_type,UF_draft_full_cir_cntrln_subtype,UF_OBJ_no_property},
      {UF_drafting_entity_type,UF_draft_part_cir_cntrln_subtype,UF_OBJ_no_property},//
      {UF_drafting_entity_type,UF_draft_full_blt_circle_subtype,UF_OBJ_no_property},
      {UF_drafting_entity_type,UF_draft_part_blt_circle_subtype,UF_OBJ_no_property},//
      {UF_drafting_entity_type,UF_draft_offset_cntrpt_subtype,UF_OBJ_no_property},
      {UF_drafting_entity_type,UF_draft_cyl_cntrln_subtype,UF_OBJ_no_property},
      {UF_drafting_entity_type,UF_draft_sym_cntrln_subtype,UF_OBJ_no_property},//
      {UF_drafting_entity_type,UF_draft_crosshatch_subtype,UF_OBJ_no_property},
      {UF_drafting_entity_type,UF_draft_area_fill_subtype,UF_OBJ_no_property},
      {UF_drafting_entity_type,UF_draft_solid_fill_subtype,UF_OBJ_no_property},//
      {UF_drafting_entity_type,UF_draft_intersection_subtype,UF_OBJ_no_property},
      {UF_drafting_entity_type,UF_draft_target_point_subtype,UF_OBJ_no_property},
      {UF_drafting_entity_type,UF_draft_user_defined_subtype,UF_OBJ_no_property},
      {UF_drafting_entity_type,UF_draft_assorted_parts_subtype,UF_OBJ_no_property},
      {UF_drafting_entity_type,UF_all_subtype,UF_OBJ_no_property},
      {UF_group_type,UF_all_subtype,UF_OBJ_no_property},
      {UF_view_type,UF_all_subtype,UF_OBJ_no_property},
    {UF_user_defined_object_type,UF_all_subtype,UF_OBJ_no_property}};
    res = UF_UI_set_sel_mask(select,UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC,27,mask_triples);
    if(res)
    {
      return (UF_UI_SEL_FAILURE);
    }
    return (UF_UI_SEL_SUCCESS);
}
作者: 深夜摔键盘    时间: 2005-5-25 20:56
呵呵,不帮了。
  
许多忙都不用帮的。像这些大众化的函数的使用,都在老贴子中解决了,去翻翻吧,我已经说了老贴的地址。
作者: 深夜摔键盘    时间: 2005-5-25 21:05
善意的批评一下了,这两个周,如果多花点时间学学C语言,这个问题也许就很好解决了。
  
UF_UI_select_with_class_dialog("no cur","this",UF_UI_SEL_SCOPE_WORK_PART_AND_OCC, NULL,NULL,[$response, &count, &objects)]  
它的第4个参数是一个函数指针,你把它弄成了NULL,但又在下面实现了init_proc。也就是说,你的init_proc函数是一个孤岛,永远不会有人调用它
  
我只看出了这点问题,UF_UI_select_with_class_dialog我没用过,如果还不行,就再仔细看看文档吧
作者: haorizhi002    时间: 2005-5-25 22:06
键盘兄:
楼上你说的问题我是知道的,我调用过
UF_UI_select_with_class_dialog("no cur","this",UF_UI_SEL_SCOPE_WORK_PART_AND_OCC, init_proc,[$data,&response, &count, &objects)]  
但还是不行
确确实实想请你帮助
作者: haorizhi002    时间: 2005-5-25 22:07
我希望你试一下
在modeling状态下当然好用
但在工程图条件下就不好用了
作者: 深夜摔键盘    时间: 2005-5-25 22:55
试过了,没什么问题啊。
  
进入制图模块后,我画了条直线,然后调用选择器,单步运行结果如下图:
object中是有值的,且函数返回值是0,reponse的值是2,也就是UF_UI_OK。
作者: haorizhi002    时间: 2005-5-26 21:16
大哥我要选的是工程图中的线!!!
在DRAWING模式下!!!
请指教
作者: 深夜摔键盘    时间: 2005-5-27 08:31
DRAWING模式下???
  
我进入了制图模块,然后建了一张图纸,然后在这个图纸上画了一条线,这不是你说的"DRAWING“模式吗?
作者: haorizhi002    时间: 2005-5-27 15:10
请在modeling模式下建一个正方体,
进入drafting模式,建立正投影,iso投影,tri投影
然后用uf_ui_select_with_class_dialog选择体上的线.这时就不行了。
多谢!
作者: 深夜摔键盘    时间: 2005-5-27 16:10
应该是实体的子类型缺少了edge子类型的问题。
  
一开始你就没说清楚问题。实体的投影图上的线不是孤立的,它是实体的附属。
  
你要选择实体的edge,那么要指定实体的edge子类型。
  
虽然你指定了那么多的制图类型,但没有用。实体的类型依然是UG默认的标准类型,而这种默认并不包含edge子类型。
  
你看看这个:
UF_solid_type only specifies solid bodies
and does not include faces or edges. To select faces or edges, you must
specify these object subtypes in mask_triples.
  
明白?
作者: haorizhi002    时间: 2005-5-27 18:31
键盘兄:
我虽然水平不高,但还算用功,为解决这个问题我将能想到的都试过了,你说的办法我尽管已经在上周试过了,不过我还是按你说的做了,结果还是不行。
你能抽一点时间再试一下,将例程发给我吗?
多谢。
作者: 深夜摔键盘    时间: 2005-5-27 19:53

有点晕,搞不定。
你用的也是NX3吗?
作者: 深夜摔键盘    时间: 2005-5-27 20:17
是不是在制图中,它们本来就是不可选的?
  
我看了看,好象只有查看对象信息时所用的选择器可以选,而删除所带的选择器就不行。
作者: haorizhi002    时间: 2005-5-28 11:29
我有个grip程序,可以做到这点.但我没有原代码!
所以我认为API也可以做到!
我用的是NX2.
作者: haorizhi002    时间: 2005-5-28 11:41
问一下,你知道如何在drafting模式下,如何得到点的3D坐标吗?
作者: 会思考的石头    时间: 2005-5-28 13:50
你要是把帖子的名字改一改,可能会有更多人帮你分析。




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