iCAx开思工具箱

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 23980|回复: 1
打印 上一主题 下一主题

【回答】请教问题之带螺纹的螺栓做法。其中用了boss

[复制链接]
跳转到指定楼层
楼主
发表于 2004-4-13 08:55:59 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
付程序如下:
  
// luomu.cpp : Defines the initialization routines for the DLL.
//
  
#include "stdafx.h"
#include "luomu.h"
#include <uf.h>
#include <uf_defs.h>
#include <uf_exit.h>
#include <uf_ui.h>
#include<uf_modl.h>
#include<uf_part.h>
#include <uf_csys.h>
#include <math.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
  
//
//  Note!
//
//    If this DLL is dynamically linked against the MFC
//    DLLs, any functions exported from this DLL which
//    call into MFC must have the AFX_MANAGE_STATE macro
//    added at the very beginning of the function.
//
//    For example:
//
//    extern "C" BOOL PASCAL EXPORT ExportedFunction()
//    {
//      AFX_MANAGE_STATE(AfxGetStaticModuleState());
//      // normal function body here
//    }
//
//    It is very important that this macro appear in each
//    function, prior to any calls into MFC.  This means that
//    it must appear as the first statement within the  
//    function, even before any object variable declarations
//    as their constructors may generate calls into the MFC
//    DLL.
//
//    Please see MFC Technical Notes 33 and 58 for additional
//    details.
//
  
/////////////////////////////////////////////////////////////////////////////
// CLuomuApp
  
BEGIN_MESSAGE_MAP(CLuomuApp, CWinApp)
  //{{AFX_MSG_MAP(CLuomuApp)
    // NOTE - the ClassWizard will add and remove mapping macros here.
    //    DO NOT EDIT what you see in these blocks of generated code!
  //}}AFX_MSG_MAP
END_MESSAGE_MAP()
  
/////////////////////////////////////////////////////////////////////////////
// CLuomuApp construction
extern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )
{
    int errorCode = UF_initialize();
  AFX_MANAGE_STATE(AfxGetStaticModuleState());
  
    if ( 0 == errorCode ){
double l1_endpt1[3] = {2,sqrt(12),0.0};
  double l1_endpt2[3] = {4,0.0,0.0};
  double l2_endpt1[3] = {4,0.0,0.0};
  double l2_endpt2[3] = {2,-sqrt(12),0.0};
  double l3_endpt1[3] = {2,-sqrt(12),0.0};
  double l3_endpt2[3] = {-2,-sqrt(12),0.0};
double l4_endpt1[3] = {-2,-sqrt(12),0.0};
  double l4_endpt2[3] = {-4,0.0,0.0};
double l5_endpt1[3] = {-4,0.0,0.0};
  double l5_endpt2[3] = {-2,sqrt(12),0.0};
  double l6_endpt1[3] = {-2,sqrt(12),0.0};
  double l6_endpt2[3] = {2,sqrt(12),0.0};
  double direction[3] = {0.0,0.0,1.0};
  double ref_pt[3];
   
//  char *part_name = "arm";
  char *taper_angle = "0.0";
  char *limit1[2] = {"0.0", "5.0"};
  int english_units = 2, i, count = 6;
  tag_t objarray[6];
  uf_list_p_t loop_list, features;
  UF_FEATURE_SIGN sign= UF_NULLSIGN;
  UF_CURVE_line_t line1, line2, line3,line4,line5,line6;
   
  
  double  location[ 3 ] ={0.0,0.0,5.0};
  char * diame = "4.0";
  char * height ="6.0";
  char * angle = "0.0";
  
  double  planepnt[3]={0.,0.,5.0};
  double  planedir[3]={0.,0.,1.0};
  tag_t   plane_tag;
  tag_t  feature_obj_id;
  
  uf_list_p_t list;
  int num;
  tag_t c_face, s_face, face;
  UF_MODL_symb_thread_data_t thread;
  
  double point[3], dir[3], box[6], radius, rad;
  int  type, sen;
  tag_t feature_eid;
  
  line1.start_point[0] = l1_endpt1[0];
  line1.start_point[1] = l1_endpt1[1];
  line1.start_point[2] = l1_endpt1[2];
  line1.end_point[0]   = l1_endpt2[0];
  line1.end_point[1]   = l1_endpt2[1];
  line1.end_point[2]   = l1_endpt2[2];
  line2.start_point[0] = l2_endpt1[0];
  line2.start_point[1] = l2_endpt1[1];
  line2.start_point[2] = l2_endpt1[2];
  line2.end_point[0]   = l2_endpt2[0];
  line2.end_point[1]   = l2_endpt2[1];
  line2.end_point[2]   = l2_endpt2[2];
  line3.start_point[0] = l3_endpt1[0];
  line3.start_point[1] = l3_endpt1[1];
  line3.start_point[2] = l3_endpt1[2];
  line3.end_point[0]   = l3_endpt2[0];
  line3.end_point[1]   = l3_endpt2[1];
  line3.end_point[2]   = l3_endpt2[2];
  line4.start_point[0] = l4_endpt1[0];
  line4.start_point[1] = l4_endpt1[1];
  line4.start_point[2] = l4_endpt1[2];
  line4.end_point[0]   = l4_endpt2[0];
  line4.end_point[1]   = l4_endpt2[1];
  line4.end_point[2]   = l4_endpt2[2];
  line5.start_point[0] = l5_endpt1[0];
  line5.start_point[1] = l5_endpt1[1];
  line5.start_point[2] = l5_endpt1[2];
  line5.end_point[0]   = l5_endpt2[0];
  line5.end_point[1]   = l5_endpt2[1];
  line5.end_point[2]   = l5_endpt2[2];
  line6.start_point[0] = l6_endpt1[0];
  line6.start_point[1] = l6_endpt1[1];
  line6.start_point[2] = l6_endpt1[2];
  line6.end_point[0]   = l6_endpt2[0];
  line6.end_point[1]   = l6_endpt2[1];
  line6.end_point[2]   = l6_endpt2[2];
  
// UF_PART_new(part_name, english_units, [$part)]
  UF_CURVE_create_line([$line1,&objarray[0])]
  UF_CURVE_create_line([$line2,&objarray[1])]
  UF_CURVE_create_line([$line3,&objarray[2])]
  UF_CURVE_create_line([$line4,&objarray[3])]
  UF_CURVE_create_line([$line5,&objarray[4])]
  UF_CURVE_create_line([$line6,&objarray[5])]
   
  
  UF_MODL_create_list([$loop_list)]
  for(i = 0; i < count; i++) {
    UF_MODL_put_list_item(loop_list, objarray[i]);
  }
  UF_MODL_create_extruded(loop_list, taper_angle, limit1,
                          ref_pt, direction, sign, [$features)]
  
  UF_MODL_create_fixed_dplane( planepnt, planedir,
                                             [$plane_tag )]
  
   
  UF_MODL_create_boss (
            location,  
            direction,  
            diame,  
            height,  
            angle,  
            plane_tag,  
            [$feature_obj_id )]
  
  UF_MODL_ask_feat_faces(feature_obj_id,[$list)]
  UF_MODL_ask_list_count(list,[$num)]
  
  for (i=0;i<num;i++)
  {
    UF_MODL_ask_list_item(list,i,[$face)]
   
  
    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)]
  
  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="2.0";
  thread.form = "Unified";
  thread.method = "CUT";
  thread.callout = "4-4_UNC";
  
  thread.major_dia = "1.0";
  thread.minor_dia = "0.8512";
  thread.tapped_dia = "0.8985";
  thread.pitch = "0.125";
  thread.angle = "60";
  
  UF_MODL_create_symb_thread([$thread, &feature_eid)]
  
//  UF_PART_save();
/*get face of body   */
/*double point[3], dir[3], box[6], radius, rad;
  int t, num, type, sen;
UF_MODL_ask_feat_faces(sign,[$list)]
  UF_MODL_ask_list_count(list,[$num)]
/*
  Get face data
*/
  
/*
  
//----------------------- Create boss-----------------------   
  
double point[3], dir[3], box[6], radius, rad;
  int t, num, type, sen;
  
UF_FEATURE_SIGN sign1 =UF_NULLSIGN;
double  origin[ 3 ] ={0.0,0.0,5.0};
char *  height ="6";  
char *  diam ="4";
double  direction1[ 3 ] ={0.0,0.0,1.0};
tag_t  cyl_id ;
  UF_MODL_create_cyl1(sign1, origin,height,diam, direction, [$cyl_id )]
//------------------- Create a thread on boss---------------------  
  
//Get boss faces to use as start face and cylinder face of the thread  
  tag_t face, s_face,c_face,thread_id;   
  uf_list_p_t list;  
  
  UF_MODL_create_list([$list)]   
  UF_MODL_symb_thread_data_t thread;   
  UF_MODL_ask_feat_faces(cyl_id ,[$list)]     
  UF_MODL_ask_list_count(list,[$num)]   
  for (t=0;t<num;t++)   
  {     UF_MODL_ask_list_item(list,t,[$face)]     
  
  UF_MODL_ask_face_data(face,&type,point,dir,box,                                 
   [$radius,&rad,&sen)]   
  if ( (type == 22) && (fabs(dir[1]-1.0)< 10e-7) )     
   s_face = face; //start face     
  if (type == 16)      
   c_face = face;//cylinder face  
  }
  UF_MODL_delete_list([$list)] //create thread   
  char thread_length[10];   
  thread_length[0]='\0';    */
/* sprintf(thread_length,"%f",0.5*atof(L.value.string)-hi-2.0);*/      
/*
  thread.cyl_face = c_face;      
  thread.start_face = s_face;      
  thread.axis_direction[0]=0;      
  thread.axis_direction[1]=-1;      
  thread.axis_direction[2]=0;      
  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=thread_length;      
  thread.form = "Metric";      
  thread.method = "CUT";      
  thread.callout ="1-8_UNC";      
  thread.major_dia = "10";      
  thread.minor_dia = "8.917";     
  thread.tapped_dia = "9.813";     
  thread.pitch = "1.0";      
  thread.angle = "60";      
  UF_MODL_create_symb_thread([$thread, &thread_id)]  
  
*/
  
  }
  
        errorCode = UF_terminate();
    
}
  
extern "C" void ufusr_cleanup(void)
{
  
}
extern "C"  int ufusr_ask_unload( void )
{
    return( UF_UNLOAD_IMMEDIATELY );
  
}
CLuomuApp::CLuomuApp()
{
  // TODO: add construction code here,
  // Place all significant initialization in InitInstance
}
  
/////////////////////////////////////////////////////////////////////////////
// The one and only CLuomuApp object
  
CLuomuApp theApp;
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 支持支持
沙发
 楼主| 发表于 2004-4-13 09:00:00 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手板模型制作,在线3D打印服务

QQ|小黑屋|手机版|开思工具箱 CAD工具箱_CAM工具箱  

GMT+8, 2024-11-30 05:15 , Processed in 0.016236 second(s), 8 queries , Gzip On, Redis On.

Powered by Discuz! X3.3

© 2002-2024 www.iCAx.org

快速回复 返回顶部 返回列表