- 积分
- 0
- 注册时间
- 2013-4-13
- 仿真币
-
- 最后登录
- 1970-1-1
|
发表于 2013-7-15 10:44:37
|
显示全部楼层
来自 江苏无锡
/******************************************************************
* 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函数拉伸的自定义函数 可能有时候会出现问题 你自己参照吧 |
|