找回密码
 注册
Simdroid-非首页
查看: 58|回复: 1

[二次开发] 如何使用UF_MODL_mswp_create_extrude函数

[复制链接]
发表于 2013-5-14 14:49:09 | 显示全部楼层 |阅读模式 来自 云南昆明
UF_MODL_mswp_create_extrude这个拉伸函数似乎功能比较强一些,但是它的设置比较难,拜求高手放一个这个函数的使用实例学习一下使用方法……
函数如下定义的:
int UF_MODL_mswp_create_extrude ( UF_MODL_mswp_extrude_p_t extrude, int * num_features, tag_t * * features ),初看只有三个参数,心里暗喜,可点开结构体一看……哎,还不如不看……
其中UF_MODL_mswp_extrude_s 结构体的定义如下:
struct UF_MODL_mswp_extrude_s
{
   tag_t                          section;
   tag_t                          direction;
   double                         dist_tol;
   double                         chain_tol;
   double                         planar_tol;
   double                         angle_tol;
   UF_MODL_mswp_limits_t          limits;
   UF_MODL_mswp_offsets_t         offsets;
   UF_MODL_mswp_taper_t           taper;
   UF_FEATURE_SIGN                sign;
   tag_t                          target_body;
   int                            heal_geom;
   logical                        solid_preferred;
};

它里面又包括UF_MODL_mswp_limits_t,UF_MODL_mswp_offsets_t,UF_MODL_mswp_taper_t三个结构体……
以UF_MODL_mswp_limits_t为例,UF_MODL_mswp_offsets_t 和它类似,UF_MODL_mswp_taper_t 最复杂……
其定义如下:
struct UF_MODL_mswp_limits_s
{
   logical                       symmetry;
UF_MODL_mswp_limit_t  start_limit;
   UF_MODL_mswp_limit_t  end_limit;
};
其中的UF_MODL_mswp_limit_t又是一个结构体,定义如下:
struct UF_MODL_mswp_limit_s
{
   UF_MODL_mswp_limit_type_t  limit_type;
   UF_MODL_mswp_limit_data_t  limit_data;
   logical surf_extend;
};
其中UF_MODL_mswp_limit_data_t 又来个共用体,定义如下:
union UF_MODL_mswp_limit_data_u
{
   UF_MODL_mswp_string_data_t         distance_data;
   UF_MODL_mswp_until_selected_data_t until_selected_data;
};
共用体中的UF_MODL_mswp_string_data_t和UF_MODL_mswp_until_selected_data_t 怎么又是结构体……
struct UF_MODL_mswp_string_data_s
{
   char   string[UF_MAX_EXP_LENGTH];
   tag_t  expression_tag;
};
struct UF_MODL_mswp_until_selected_data_s
{
   tag_t   selected_object;
};

看见了不,我都数不清套了几层了,我已经处于崩溃的边缘了,只要它再来一层,我,我,我就……

这,这,这玩意儿到底怎么赋值……我现在对里面的几个地方搞不懂,
第一:对于这个参数tag_t direction,它是个tag型数据,平时我们对direction不都是用double型数据赋值嘛,这个tag型让我纠结了好长时间,请教了一些高手,说用UF_SO_create_dirr_doubles函数创建一个矢量方向,它的输出就是tag型的数据,可问题又来了,这个函数涉及到SO(smart object)的概念,我这个小菜鸟从来就没有接触过这个玩意儿,甚至就没有听说过,怎么用呀……

第二:UF_MODL_mswp_string_data_s 中的变量怎么赋值,涉及到表达式的问题,我直接对其中的string[UF_MAX_EXP_LENGTH]=0, expression_tag =NULL_TAG,这样行不行,因为我拉伸的起始点距离是0.
还有其它什么偏置,拔模角什么的都是0,可是怎么赋值呢?

拜求高手指点一下,实在折腾不出来了
发表于 2013-7-15 10:44:37 | 显示全部楼层 来自 江苏无锡
Simdroid开发平台
/******************************************************************
* Purpose : 使用UserFunction API函数的方法拉伸一组曲线
* Autor      :
* Input       : sourceCurves - 需拉伸的曲线
                    direction1 - 拉伸的方向
                                        rDist - 拉伸的距离
* Output   : targetFace - 拉伸出的面
******************************************************************/
Body *Flatten4_flange::UFExtrudeCurves( vector<Curve *> sourceCurves, Vector3d direction1, double rDist )
{
        try
        {
                UF_CALL(UF_initialize());

                uf_list_p_t curveTagList;
                UF_CALL(UF_MODL_create_list(&curveTagList));
                for( unsigned int i = 0; i < sourceCurves.size(); ++i )
                {
                    UF_CALL( UF_MODL_put_list_item( curveTagList, sourceCurves[i]->GetTag() ) );
                }

                char *sTaperAngle = "0.0";
        char *slimit[2] = {"0", "0"};
                if( iMeshDirType == 1 )
                {
                        char sHeight[30];
                    sprintf_s( sHeight, "%f", rDist );
                        *slimit = sHeight;
                }
                else
                {
                        char sHeight[30];
                    sprintf_s( sHeight, "-%f", rDist );
                        *(slimit+1) = sHeight;
                }
               
                double ref_pt[3];
                double rDirection[3] = {direction1.X, direction1.Y, direction1.Z};
                UF_FEATURE_SIGN bFlag = UF_NULLSIGN;
                uf_list_p_t features;
            
                UF_CALL( UF_MODL_create_extruded( curveTagList, sTaperAngle, slimit, ref_pt, rDirection, bFlag, &features ) );
               
                tag_t featureTag = features->eid;
                UF_MODL_delete_list(&features);
               
                tag_t bodyTag;
                UF_MODL_ask_feat_body( featureTag, &bodyTag );

                UF_CALL(UF_terminate());

                Body *targetBody(NULL);
                targetBody = dynamic_cast<Body *>(NXObjectManager::Get(bodyTag));

                return targetBody;
        }
        catch(const NXException & ex)
        {
                theUI->NXMessageBox()->Show("拉伸曲线", NXOpen::NXMessageBox:ialogTypeError, ex.what());
                return NULL;
        }
}

这是一个有用的  使用UF函数拉伸的自定义函数  可能有时候会出现问题  你自己参照吧
回复 不支持

使用道具 举报

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

本版积分规则

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-4-25 21:00 , Processed in 0.028235 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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