zoukankan      html  css  js  c++  java
  • NX二次开发-NXOpen::WCS Class Reference

     1 NX11+VS2013
     2 
     3 #include <NXOpen/Part.hxx>
     4 #include <NXOpen/PartCollection.hxx>
     5 #include <NXOpen/Session.hxx>
     6 #include <NXOpen/WCS.hxx>
     7 #include <NXOpen/CartesianCoordinateSystem.hxx>
     8 #include <NXOpen/CoordinateSystem.hxx>
     9 #include <NXOpen/CoordinateSystemCollection.hxx>
    10 using namespace NXOpen;
    11 
    12 
    13 NXOpen::Session *theSession = NXOpen::Session::GetSession();
    14 NXOpen::Part *workPart(theSession->Parts()->Work());
    15 NXOpen::Part *displayPart(theSession->Parts()->Display());
    16 
    17 //获取WCS相关信息
    18 NXOpen::CartesianCoordinateSystem* WcsData = workPart->WCS()->CoordinateSystem();
    19 
    20 //获得WCS的向量方向
    21 NXOpen::Vector3d xDirection;
    22 NXOpen::Vector3d yDirection;
    23 WcsData->GetDirections(&xDirection, &yDirection);
    24 
    25 //获得WCS的原点坐标
    26 Point3d WcsOrigin = workPart->WCS()->Origin();
    27 
    28 //围绕指定的轴旋转WCS
    29 double Angle = 45.0;
    30 workPart->WCS()->Rotate(NXOpen::WCS::AxisXAxis, Angle);
    31 
    32 //在工作部件中创建一个新的笛卡尔坐标系,即使WCS属于显示部件
    33 NXOpen::CartesianCoordinateSystem*  WcsNew = workPart->WCS()->Save();
    34 
    35 //将WCS的坐标系更改为一个新的坐标系
    36 //返回值是旧的坐标系。将WCS移动到新的坐标系位置后,将显示旧坐标系。
    37 NXOpen::Point3d origin1 = { 150.0, 0.0, 0.0 };
    38 NXOpen::Vector3d xDirection1 = { 1.0, 0.0, 0.0 };
    39 NXOpen::Vector3d yDirection1 = { 0.0, 1.0, 0.0 };
    40 NXOpen::CartesianCoordinateSystem *newCs = workPart->CoordinateSystems()->CreateCoordinateSystem(origin1, xDirection1, yDirection1);
    41 NXOpen::CartesianCoordinateSystem*  WcsOld = workPart->WCS()->SetCoordinateSystem(newCs);
    42 
    43 //在新的坐标系中创建一个WCS
    44 //返回值是WCS的旧坐标系
    45 NXOpen::Point3d origin2 = { 150.0, 0.0, 0.0 };
    46 NXOpen::Vector3d xDirection2 = { 1.0, 0.0, 0.0 };
    47 NXOpen::Vector3d yDirection2 = { 0.0, 1.0, 0.0 };
    48 NXOpen::CartesianCoordinateSystem *newCs1 = workPart->CoordinateSystems()->CreateCoordinateSystem(origin2, xDirection2, yDirection2);
    49 NXOpen::CartesianCoordinateSystem*  WcsOld1 = workPart->WCS()->SetCoordinateSystemCartesianAtCsys(newCs1);
    50 
    51 //设置WCS原点
    52 Point3d WcsOri = { 100.0, 100.0, 100.0 };
    53 workPart->WCS()->SetOrigin(WcsOri);
    54 
    55 //设置WCS的原点和方向矩阵
    56 Point3d WcsOri1 = { 100.0, 100.0, 100.0 };
    57 Matrix3x3 matrix = { 1, 0, 0, 0, 1, 0, 0, 0, 1 };
    58 workPart->WCS()->SetOriginAndMatrix(WcsOri1, matrix);
    59 
    60 //设置WCS的可见性
    61 workPart->WCS()->SetVisibility(false);
    62 
    63 //得到WCS的tag
    64 tag_t WcsTag = workPart->WCS()->Tag();
    65 
    66 //获得WCS的可见性
    67 bool WcsVis = workPart->WCS()->Visibility();

    2019年8月17日
    Caesar卢尚宇

  • 相关阅读:
    Xcode 配置常用变量(SRCROOT, PROJECT_DIR, PROJECT_NAME)
    Git submodule实战
    Charles抓Https的包
    Vue-Quill-Editor 富文本编辑器的使用
    vue计算属性无法监听到数组内部变化
    移动端键盘弹起导致底部按钮上浮解决方案
    js中数组删除 splice和delete的区别,以及delete的使用
    js实现复制input的value到剪切板
    treetable
    vue中状态管理vuex的使用分享
  • 原文地址:https://www.cnblogs.com/nxopen2018/p/11368763.html
Copyright © 2011-2022 走看看