怡宁塑胶模具设计

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

C++  

 

//选择过滤
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
std::vector<Selection::MaskTriple> maskArray(1);
maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_CYLINDRICAL_FACE);
selection0->GetProperties()->SetSelectionFilter("SelectionFilter", action, maskArray);

selection0->SetToolTip("选择圆柱面");
selection0->SetBitmap("revolved_face_collector");

 

UF_initialize();
//获取UI选取的圆柱面
std::vector<TaggedObject *> faces = selection0->GetSelectedObjects(); //得到圆柱面

char msg [256];

for ( int i = 0 ; i < faces.size();i++)
{
Face *face1 = dynamic_cast<Face *>(faces[i]);
edges = face1->GetEdges();
}

NXOpen::Edge::EdgeType edgetype;//2为圆边?
for(int i=0;i < edges.size();i++ )
{
Edge *edge1 = edges[i];
edgetype = edge1->SolidEdgeType(); //获取类型
if ( edgetype == 2 )
{
arcedges1.push_back(edges[i]);//如果是圆边就塞到容器
//获取边的信息
UF_EVAL_p_t evaluator;
UF_EVAL_initialize(edge1->Tag(), &evaluator);//使用UF_EVAL_ask_arc()函数需要先进行初始化

UF_EVAL_arc_t arcCoords;
UF_EVAL_ask_arc(evaluator, &arcCoords);////arc结构体中有曲线的参数(圆中,半径,是否整圆等相关信息)
double arcCenter[3] = { 0.00 };
arcCenter[0] = arcCoords.center[0];
arcCenter[1] = arcCoords.center[1];
arcCenter[2] = arcCoords.center[2];
double arcx_axis [3] = { 0.00 };
arcx_axis[0] = arcCoords.x_axis[0];
arcx_axis[1] = arcCoords.x_axis[1];
arcx_axis[2] = arcCoords.x_axis[2];
double arcy_axis [3] = { 0.00 };
arcy_axis[0] = arcCoords.y_axis[0];
arcy_axis[1] = arcCoords.y_axis[1];
arcy_axis[2] = arcCoords.y_axis[2];
double arcR[1] = { 0.00 } ;
arcR [0] = arcCoords.radius;
//确定给定的数据是否来自圆形曲线或边缘
bool boolIsArc;
UF_EVAL_is_arc(evaluator, &boolIsArc);
if (boolIsArc)
{
if (fabs(arcCoords.limits[0]) < 0.001 && fabs(arcCoords.limits[1] - 2 * PI) < 0.001)//判断是否是整圆
{
bool boolVal = true;//此圆是整圆
arcedges2.push_back(edges[i]);//是整圆就把边塞到容器
sprintf(msg, "边的中心:%.2f %.2f %.2f",arcCenter[0],arcCenter[1],arcCenter[2]);
theSession->ListingWindow()->WriteLine( msg);
sprintf(msg, "边半径:%.2f ",arcR [0]);
theSession->ListingWindow()->WriteLine( msg);
sprintf(msg, "边的X轴:%.2f %.2f %.2f",arcx_axis[0],arcx_axis[1],arcx_axis[2]);
theSession->ListingWindow()->WriteLine( msg);
sprintf(msg, "边的y轴:%.2f %.2f %.2f",arcy_axis[0],arcy_axis[1],arcy_axis[2]);
theSession->ListingWindow()->WriteLine( msg);
}
}
}
}

UF_terminate();

 

 

posted on 2021-03-13 14:25  怡宁塑胶模具设计  阅读(881)  评论(0编辑  收藏  举报