码迷,mamicode.com
首页 > 其他好文 > 详细

NX二次开发-NXOpen::CoordinateSystemCollection Class Reference

时间:2019-08-31 23:09:33      阅读:91      评论:0      收藏:0      [点我收藏+]

标签:标题   car   model   图片   sprintf   display   info   get   on()   

 1 NX11+VS2013
 2 
 3 
 4 #include <NXOpen/Section.hxx>
 5 #include <NXOpen/SectionCollection.hxx>
 6 #include <NXOpen/Part.hxx>
 7 #include <NXOpen/PartCollection.hxx>
 8 #include <NXOpen/CoordinateSystem.hxx>
 9 #include <NXOpen/CoordinateSystemCollection.hxx>
10 #include <NXOpen/CartesianCoordinateSystem.hxx>
11 #include <NXOpen/NXMatrix.hxx>
12 #include <NXOpen/NXMatrixCollection.hxx>
13 #include <NXOpen/Xform.hxx>
14 #include <NXOpen/XformCollection.hxx>
15 #include <NXOpen/Scalar.hxx>
16 #include <NXOpen/ScalarCollection.hxx>
17 #include <NXOpen/CylindricalCoordinateSystem.hxx>
18 #include <NXOpen/UI.hxx>
19 #include <NXOpen/NXMessageBox.hxx>
20 
21 
22 using namespace NXOpen;
23 using namespace std;
24 
25 
26     NXOpen::Session *theSession = NXOpen::Session::GetSession();
27     NXOpen::Part *workPart(theSession->Parts()->Work());
28     NXOpen::Part *displayPart(theSession->Parts()->Display());
29 
30     //创建一个新的笛卡尔坐标系(TRUE和FALSE,如果坐标系是临时的用TRUE,它将不会显示,也不会保存在部件中)
31     Point3d WcsOrigin1(100.0, 100.0, 100.0);//原点
32     Matrix3x3 WcsMatrix1 (1, 0, 0, 0, 1, 0, 0, 0, 1);//矩阵
33     NXOpen::CartesianCoordinateSystem* WcsNew1 = workPart->CoordinateSystems()->CreateCoordinateSystem(WcsOrigin1, WcsMatrix1, FALSE);
34 
35     //创建一个新的笛卡尔坐标系
36     Point3d WcsOrigin2(200.0, 200.0, 200.0);//原点
37     Vector3d xDirection2(1.0, 0.0, 0.0);//向量
38     Vector3d yDirection2(0.0, 1.0, 0.0);
39     NXOpen::CartesianCoordinateSystem* WcsNew2 = workPart->CoordinateSystems()->CreateCoordinateSystem(WcsOrigin2, xDirection2, yDirection2);
40 
41     //创建一个新的笛卡尔坐标系(TRUE和FALSE,如果坐标系是临时的用TRUE,它将不会显示,也不会保存在部件中)
42     Point3d WcsOrigin3(300.0, 300.0, 300.0);//原点
43     Matrix3x3 WcsMatrix3(1, 0, 0, 0, 1, 0, 0, 0, 1);//矩阵
44     NXOpen::NXMatrix* Matrix3 = workPart->NXMatrices()->Create(WcsMatrix3);//创建一个新的矩阵
45     NXOpen::CartesianCoordinateSystem* WcsNew3 = workPart->CoordinateSystems()->CreateCoordinateSystem(WcsOrigin3, Matrix3, FALSE);
46 
47     //创建一个新的笛卡尔坐标系
48     Point3d WcsOrigin4(400.0, 400.0, 400.0);//原点
49     Vector3d xDirection4(1.0, 0.0, 0.0);//向量
50     Vector3d yDirection4(0.0, 1.0, 0.0);
51     double Scale = 1;
52     NXOpen::Xform* xform = workPart->Xforms()->CreateXform(WcsOrigin4, xDirection4, yDirection4, SmartObject::UpdateOptionWithinModeling, Scale);
53     NXOpen::CartesianCoordinateSystem* WcsNew4 = workPart->CoordinateSystems()->CreateCoordinateSystem(xform, SmartObject::UpdateOptionWithinModeling);
54     WcsNew4->SetVisibility(SmartObject::VisibilityOptionVisible);//设置显示坐标系    
55 
56     //创建一个新的圆柱坐标系
57     Point3d WcsOrigin5(500.0, 500.0, 500.0);//原点
58     Vector3d xDirection5(1.0, 0.0, 0.0);//向量
59     Vector3d yDirection5(0.0, 1.0, 0.0);
60     NXOpen::CylindricalCoordinateSystem* WcsNew5 = workPart->CoordinateSystems()->CreateCylindricalCoordinateSystem(WcsOrigin5, xDirection5, yDirection5);
61 
62     //创建一个新的圆柱坐标系(TRUE和FALSE,如果坐标系是临时的用TRUE,它将不会显示,也不会保存在部件中)
63     Point3d WcsOrigin6(600.0, 600.0, 600.0);//原点
64     Matrix3x3 WcsMatrix6(1, 0, 0, 0, 1, 0, 0, 0, 1);//矩阵
65     NXOpen::NXMatrix* Matrix6 = workPart->NXMatrices()->Create(WcsMatrix6);//创建一个新的矩阵
66     NXOpen::CylindricalCoordinateSystem* WcsNew6 = workPart->CoordinateSystems()->CreateCylindricalCoordinateSystem(WcsOrigin6, Matrix6, FALSE);
67 
68     //创建一个新的圆柱坐标系
69     Point3d WcsOrigin7(700.0, 700.0, 700.0);//原点
70     Vector3d xDirection7(1.0, 0.0, 0.0);//向量
71     Vector3d yDirection7(0.0, 1.0, 0.0);
72     double Scale7 = 1;
73     NXOpen::Xform* xform7 = workPart->Xforms()->CreateXform(WcsOrigin7, xDirection7, yDirection7, SmartObject::UpdateOptionWithinModeling, Scale7);
74     NXOpen::CylindricalCoordinateSystem* WcsNew7 = workPart->CoordinateSystems()->CreateCylindricalCoordinateSystem(xform7, SmartObject::UpdateOptionWithinModeling);
75     WcsNew7->SetVisibility(SmartObject::VisibilityOptionVisible);//设置显示坐标系
76 
77     //迭代器遍历所有坐标系
78     vector<tag_t> AllCoordVector;//定义vector
79     NXOpen::CoordinateSystem* AllCoord;//定义类型
80     NXOpen::CoordinateSystemCollection::iterator Ite;//定义迭代器
81     for (Ite = workPart->CoordinateSystems()->begin(); Ite != workPart->CoordinateSystems()->end(); ++Ite)
82     {
83         AllCoord = (*Ite);
84         AllCoordVector.push_back(AllCoord->Tag());//获得坐标系的tag
85     }
86 
87     char msg[256];
88     sprintf_s(msg, "坐标系数量为:%d", AllCoordVector.size());
89     UI::GetUI()->NXMessageBox()->Show("标题", NXMessageBox::DialogTypeWarning, msg);
90 
91 
92 Caesar卢尚宇
93 2019年8月31日

技术图片

NX二次开发-NXOpen::CoordinateSystemCollection Class Reference

标签:标题   car   model   图片   sprintf   display   info   get   on()   

原文地址:https://www.cnblogs.com/nxopen2018/p/11440738.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!