iCAx开思工具箱

标题: 【求助】 如何实现螺纹 [打印本页]

作者: haiying    时间: 2004-5-24 09:49
标题: 【求助】 如何实现螺纹
在一个圆柱体的两端生成螺纹程序如下:
//建左端螺纹
  tag_t face, s_face, c_face ,feature_eid;
      double point[3], dir[3], box[6], radius, rad;
   int i, num, type, sen;
    UF_MODL_symb_thread_data_t thread;
   // Get cylinder feature faces
  UF_MODL_ask_feat_faces(d1_id,[$list)]
UF_MODL_ask_list_count(list,[$num)]
   for (i=0;i<num;i++)
   {
     UF_CALL(UF_MODL_ask_list_item(list,i,[$face))]
  
     UF_CALL(UF_MODL_ask_face_data(face,&type,point,dir,box,
                                 [$radius,&rad,&sen))]
     if (type == 22) /* Planar face */
    s_face = face;
     if (type == 16) /* Cylindrical face */
      c_face = face;
   }
   UF_MODL_delete_list([$list)]
/*
   Create symbolic thread
*/
   thread.cyl_face = c_face;
   thread.start_face = s_face;
   thread.axis_direction[0]=0;
   thread.axis_direction[1]=0;
   thread.axis_direction[2]=1;
   thread.include_instances = UF_MODL_INCL_INSTANCES;
   thread.rotation=UF_MODL_RIGHT_HAND;
   thread.length_flag=UF_MODL_FIXED_LENGTH;
   thread.tapered = UF_MODL_NON_TAPERED;
   thread.num_starts = 1;
   thread.length="20";
   thread.form = "Metric";
   thread.method = "CUT";
   thread.callout = "M20_X_1";
   thread.major_dia = "20";
   thread.minor_dia = "18.981";
   thread.tapped_dia = "19.794";
   thread.pitch = "1";
   thread.angle = "60";
   UF_CALL(UF_MODL_create_symb_thread([$thread, &feature_eid))]
  if(!UF_CALL(UF_MODL_ask_symb_thread_parms(feature_eid, &thread)))
   {
//  Print data
     printf("Cylindrical face tag = %d\n", thread.cyl_face);
     printf("Start face tag = %d\n", thread.start_face);
     printf("Thread axis direction = (%f,%f,%f)\n",
       thread.axis_direction[0],thread.axis_direction[1],
       thread.axis_direction[2]);
     printf("Number of starts = %d\n", thread.num_starts);
     if (thread.include_instances == UF_MODL_INCL_INSTANCES)
       printf("Include instances = Yes\n");
     else
       printf("Include instances = No\n");
     if (thread.rotation == UF_MODL_RIGHT_HAND)
       printf("Rotation = Right_hand\n");
     else
       printf("Rotation = Left_hand\n");
     if (thread.length_flag == UF_MODL_FIXED_LENGTH)
       printf("Thread length flag = Fixed length\n");
     else
       printf("Thread length flag = Full thread\n");
     if (thread.tapered == UF_MODL_TAPERED)
       printf("Thread tapered = Yes\n");
     else
       printf("Thread tapered = No\n");
     printf("Length expression %s\n", thread.length);
     printf("Form = %s\n", thread.form);
     printf("Callout = %s\n", thread.callout);
     printf("Method = %s\n", thread.method);
     printf("Major diameter expression %s\n", thread.major_dia);
     printf("Minor diameter expression %s\n", thread.minor_dia);
     printf("Tapped diameter expression %s\n", thread.tapped_dia);
     printf("itch expression %s\n", thread.pitch);
     printf("Angle expression %s\n", thread.angle);
   }
  UF_free(thread.length);
   UF_free(thread.form);
   UF_free(thread.method);
   UF_free(thread.callout);
   UF_free(thread.major_dia);
   UF_free(thread.minor_dia);
   UF_free(thread.tapped_dia);
   UF_free(thread.pitch);
   UF_free(thread.angle);
}
可以实现
可是同样的在右端
//建右端螺纹  
tag_t face1, s_face1, c_face1 ,feature_eid1;
  uf_list_p_t list1;
   double point1[3], dir1[3], box1[6], radius1, rad1;
   int i1, num1, type1, sen1;
   
   UF_MODL_symb_thread_data_t thread1;
    // Get cylinder feature faces
  
UF_MODL_ask_feat_faces(dd_id,[$list1)]
  UF_MODL_ask_list_count(list1,[$num1)]
   for (i1=0;i1<num1;i1++)
   {
     UF_CALL(UF_MODL_ask_list_item(list1,i1,[$face1))]
  
     UF_CALL(UF_MODL_ask_face_data(face1,&type1,point1,dir1,box1,
                                 [$radius1,&rad1,&sen1))]
     if (type1 == 22) /* Planar face */
   s_face1 = face1;
    if (type1 == 16) /* Cylindrical face */
   c_face1 = face1;
  }
   UF_MODL_delete_list([$list1)]*/
  
/*  Create symbolic thread*/
  
thread1.cyl_face = c_face1;
   thread1.start_face = s_face1;
   thread1.axis_direction[0]=0;
   thread1.axis_direction[1]=0;
   thread1.axis_direction[2]=-1;
   thread1.include_instances = UF_MODL_INCL_INSTANCES;
   thread1.rotation=UF_MODL_RIGHT_HAND;
   thread1.length_flag=UF_MODL_FIXED_LENGTH;
   thread1.tapered = UF_MODL_NON_TAPERED;
   thread1.num_starts = 1;
   thread1.length="20";
   thread1.form = "Metric";
   thread1.method = "CUT";
   thread1.callout = "M20_X_1";
   thread1.major_dia = "20";
   thread1.minor_dia = "18.981";
   thread1.tapped_dia = "19.794";
   thread1.pitch = "1";
   thread1.angle = "60";
   UF_CALL(UF_MODL_create_symb_thread([$thread1, &feature_eid1))]*/
  // Retrieve datahao le ,hao
  if(!UF_CALL(UF_MODL_ask_symb_thread_parms(feature_eid1, &thread1)))
   {
//  Print data
     printf("Cylindrical face tag = %d\n", thread1.cyl_face);
     printf("Start face tag = %d\n", thread1.start_face);
     printf("Thread axis direction = (%f,%f,%f)\n",
       thread1.axis_direction[0],thread1.axis_direction[1],
       thread1.axis_direction[2]);
     printf("Number of starts = %d\n", thread1.num_starts);
     if (thread1.include_instances == UF_MODL_INCL_INSTANCES)
       printf("Include instances = Yes\n");
     else
       printf("Include instances = No\n");
     if (thread1.rotation == UF_MODL_RIGHT_HAND)
       printf("Rotation = Right_hand\n");
     else
       printf("Rotation = Left_hand\n");
     if (thread1.length_flag == UF_MODL_FIXED_LENGTH)
       printf("Thread length flag = Fixed length\n");
     else
       printf("Thread length flag = Full thread\n");
     if (thread1.tapered == UF_MODL_TAPERED)
       printf("Thread tapered = Yes\n");
     else
       printf("Thread tapered = No\n");
     printf("Length expression %s\n", thread1.length);
     printf("Form = %s\n", thread1.form);
     printf("Callout = %s\n", thread1.callout);
     printf("Method = %s\n", thread1.method);
     printf("Major diameter expression %s\n", thread1.major_dia);
     printf("Minor diameter expression %s\n", thread1.minor_dia);
     printf("Tapped diameter expression %s\n", thread1.tapped_dia);
     printf("itch expression %s\n", thread1.pitch);
     printf("Angle expression %s\n", thread1.angle);
   }
   UF_free(thread1.length);
   UF_free(thread1.form);
   UF_free(thread1.method);
   UF_free(thread1.callout);
   UF_free(thread1.major_dia);
   UF_free(thread1.minor_dia);
   UF_free(thread1.tapped_dia);
   UF_free(thread1.pitch);
   UF_free(thread1.angle);
}
却实现不了
两端的程序是一样的!只是改了个变量而已!为什么不行呢?
请版主和各位高手指教!
作者: liberty000    时间: 2004-5-24 12:18
thread1.start_face 找错了吧,type==22的面圆柱上有2个,你找哪个?
作者: haiying    时间: 2004-5-24 15:29
谢谢liberty000!
那左端的螺纹为什么可以实现?type==22的面圆柱上虽有两个,可是它是否可以根据 thread1.axis_direction[0]=0;
          thread1.axis_direction[1]=0;
         thread1.axis_direction[2]=-1;
来判断出该在那个平面上呢?
我编译时会出现好多的错误!  
实在搞不懂!还望指教!
作者: liberty000    时间: 2004-5-24 17:18
利用平面的法线方向判断!
作者: haiying    时间: 2004-5-24 19:35
那具体要用到那个函数呢?
作者: bigban    时间: 2008-2-26 13:12
学习了,谢谢!!!










--------------------
CAD家园




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