NXOpen::Session* theSession = NXOpen::Session::GetSession();
NXOpen::Part* workPart(theSession->Parts()->Work());
NXOpen::Part* displayPart(theSession->Parts()->Display());
double length = 100;
double widthth = 100;
double filletradius = 20;
double holeradius = 20;
NXOpen::Point3d p1, p2, p3, p4,p5,p6,p7,p8,c1,c2,c3,c4;
p1 = { -length/2,widthth/2- filletradius,0.0 };
p2 = { -length/2,-widthth / 2+filletradius,0.0 };
p3 = { -length / 2+ filletradius,-widthth / 2,0.0 };
p4 = { length / 2- filletradius,-widthth / 2 ,0.0 };
p5 = { -p2.X,p2.Y,p2.Z };
p6 = { -p1.X,p1.Y,p1.Z };
p7 = { p4.X,-p4.Y,p4.Z };
p8 = { p3.X,-p3.Y,p3.Z };
NXOpen::CurveCollection *curvecollection = workPart->Curves();
NXOpen::Line* Line1, *Line2, *Line3, *Line4;
Line1 = curvecollection->CreateLine(p1, p2);
Line2 = curvecollection->CreateLine(p3, p4);
Line3 = curvecollection->CreateLine(p5, p6);
Line4 = curvecollection->CreateLine(p7, p8);
Line1->SetVisibility(NXOpen::SmartObject::VisibilityOptionVisible);
Line2->SetVisibility(NXOpen::SmartObject::VisibilityOptionVisible);
Line3->SetVisibility(NXOpen::SmartObject::VisibilityOptionVisible);
Line4->SetVisibility(NXOpen::SmartObject::VisibilityOptionVisible);
c1 = { -length / 2 + filletradius,widthth / 2 - filletradius,0.0 };
c2 = { c1.X,-c1.Y,c1.Z };
c3 = { -c1.X,-c1.Y,c1.Z };
c4 = { -c1.X,c1.Y,c1.Z };
NXOpen::Vector3d xdirection = { 1.0,0.0,0.0 };
NXOpen::Vector3d ydirection = { 0.0,1.0,0.0 };
NXOpen::Arc* arc1, * arc2, * arc3, * arc4,*arc5;
arc1 = curvecollection->CreateArc(c1, xdirection, ydirection, filletradius, PI/2, PI);
arc2 = curvecollection->CreateArc(c2, xdirection, ydirection, filletradius, PI , 1.5*PI);
arc3 = curvecollection->CreateArc(c3, xdirection, ydirection, filletradius, 1.5 * PI, 2*PI);
arc4 = curvecollection->CreateArc(c4, xdirection, ydirection, filletradius, 0.0, PI/2);
NXOpen::Point3d c0 = { 0.0,0.0,0.0};
arc5 = curvecollection->CreateArc(c0, xdirection, ydirection, holeradius, 0.0, 2*PI);
NXOpen::Matrix3x3 matrix1;
matrix1.Xx = 1.0;
matrix1.Xy = 0.0;
matrix1.Xz = 0.0;
matrix1.Yx = 0.0;
matrix1.Yy = 1.0;
matrix1.Yz = 0.0;
matrix1.Zx = 0.0;
matrix1.Zy = 0.0;
matrix1.Zz = 1.0;
NXOpen::NXMatrix* nxmatrix1= workPart->NXMatrices()->Create(matrix1);
arc5 = curvecollection->CreateArc(c0, nxmatrix1, holeradius, 0.0, 2 * PI);
NXopen 二次开发 NXOpen::CurveCollection类 三点创建圆弧 CreateArc
于 2024-06-19 11:52:06 首次发布