怡宁塑胶模具设计

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

VS2010 NX8.5

 

//创建垂线
Features::AssociativeLine *nullFeatures_AssociativeLine(NULL);

Features::AssociativeLineBuilder *associativeLineBuilder1;
associativeLineBuilder1 = workPart->BaseFeatures()->CreateAssociativeLineBuilder(nullFeatures_AssociativeLine);
Plane *plane1;
plane1 = workPart->Planes()->CreatePlane(Facemidpoint, oneFaceVec1, SmartObject::UpdateOptionWithinModeling);
Unit *unit1;
unit1 = associativeLineBuilder1->Limits()->StartLimit()->Distance()->Units();
associativeLineBuilder1->Limits()->StartLimit()->Distance()->SetRightHandSide("0");
associativeLineBuilder1->SetStartPointOptions(Features::AssociativeLineBuilder::StartOptionPoint);
associativeLineBuilder1->StartAngle()->SetRightHandSide("0");
associativeLineBuilder1->EndAngle()->SetRightHandSide("270");
associativeLineBuilder1->Limits()->StartLimit()->SetLimitOption(GeometricUtilities::CurveExtendData::LimitOptionsAtPoint);
associativeLineBuilder1->Limits()->StartLimit()->Distance()->SetRightHandSide("0");
associativeLineBuilder1->Limits()->EndLimit()->SetLimitOption(GeometricUtilities::CurveExtendData::LimitOptionsAtPoint);
associativeLineBuilder1->Limits()->EndLimit()->Distance()->SetRightHandSide("0");
associativeLineBuilder1->SetStartPointOptions(Features::AssociativeLineBuilder::StartOptionInferred);
associativeLineBuilder1->Limits()->StartLimit()->Distance()->SetRightHandSide("0");
associativeLineBuilder1->Limits()->EndLimit()->Distance()->SetRightHandSide("0");
associativeLineBuilder1->SetStartPointOptions(Features::AssociativeLineBuilder::StartOptionPoint);
associativeLineBuilder1->Limits()->SetFullCircle(false);

Point *pointA = workPart->Points()->CreatePoint(Facemidpoint);//面中心点
Xform *nullXform(NULL);
Point *point2;
point2 = workPart->Points()->CreatePoint(pointA, nullXform, SmartObject::UpdateOptionWithinModeling);
associativeLineBuilder1->StartPoint()->SetValue(point2);
associativeLineBuilder1->SetEndPointOptions(Features::AssociativeLineBuilder::EndOptionAtAngle);
associativeLineBuilder1->Limits()->EndLimit()->SetLimitOption(GeometricUtilities::CurveExtendData::LimitOptionsValue);
associativeLineBuilder1->Limits()->SetFullCircle(false);
associativeLineBuilder1->Limits()->StartLimit()->Distance()->SetRightHandSide("0");
Edge *edge1 = dynamic_cast<Edge *>(selectEdgs[0]);//选择的边
associativeLineBuilder1->EndAtAngle()->SetValue(edge1);
associativeLineBuilder1->EndAtAngle()->SetValue(NULL);
associativeLineBuilder1->Limits()->SetFullCircle(false);
associativeLineBuilder1->Limits()->StartLimit()->Distance()->SetRightHandSide("0");
associativeLineBuilder1->EndAtAngle()->SetValue(edge1);
associativeLineBuilder1->Limits()->EndLimit()->Distance()->SetRightHandSide(doubleToNXString(distance1+1));//线的长度
associativeLineBuilder1->SetAssociative(true);

//NXObject *nXObject1;
//nXObject1 = associativeLineBuilder1->Commit();
Features::Feature *associativelin1;
associativelin1 = associativeLineBuilder1->CommitFeature();

associativeLineBuilder1->Destroy();

//sprintf_s(msg, "%d", associativelin1->Tag());
//theSession->ListingWindow()->WriteLine(msg);

Line *line1(dynamic_cast<Line *>(associativelin1->FindObject("CURVE 1")));//垂线转换
//求线的起点和终点
UF_CURVE_line_t line_coords;
UF_CURVE_ask_line_data(line1->Tag(), &line_coords );
sprintf_s(msg, "垂线起点 x:%.2f,y:%.2f,z:%.2f", line_coords.start_point[0],line_coords.start_point[1],line_coords.start_point[2]);
theSession->ListingWindow()->WriteLine(msg);
sprintf_s(msg, "垂线终点 x:%.2f,y:%.2f,z:%.2f", line_coords.end_point[0],line_coords.end_point[1],line_coords.end_point[2]);
theSession->ListingWindow()->WriteLine(msg);
//求交点
double ref_point [ 3 ];// = {Facemidpoint.X,Facemidpoint.Y,Facemidpoint.Z}
UF_CURVE_intersect_info_t out_info;
UF_CURVE_intersect(line1->Tag(), edge1->Tag(), ref_point, &out_info );

sprintf_s(msg, "是否有交点%d", out_info.type_of_intersection);
theSession->ListingWindow()->WriteLine(msg);
sprintf_s(msg, "交点 x:%.2f,y:%.2f,z:%.2f", out_info.curve_point[0],out_info.curve_point[1],out_info.curve_point[2]);
theSession->ListingWindow()->WriteLine(msg);

 

 

 

 

 

posted on 2021-04-13 07:40  怡宁塑胶模具设计  阅读(293)  评论(0编辑  收藏  举报