点击查看详细介绍

NXOpen C++ 对象遍历与查找

haolin2008 9年前 20558 188

购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008  QQ号:85585969  


NXOpen对象遍历与查找

通用NX对象包含永久NX对象和临时NX对象。
常用的永久NX对象有部件Part、几何体Body、面Face、边Edge、特征Feature等。
————————————————
NXOpen 把tag分的更细了比如:
Part *part; //声明部件数组
NXOpen::Point*point1; //声明点
Features::Feature*fcList; //声明特征数组
其它略
————————————————
NXOpen对象遍历与查找 都是通过“迭代的方法”比如 获得所有部件 和 获得所有特征 其它同理。
————————————————

//遍历所有部件
//打印所有部件路径
#include <NXOpen/Session.hxx> //有关Session绘画头文件
#include <NXOpen/Part.hxx> //有关部件头文件
#include <NXOpen/PartCollection.hxx> //有关部件头文件
#include <sstream>
#include <NXOpen/ListingWindow.hxx>

●●●请先 登陆注册 后查看●●●

————————————————

//循环遍历所有特征
//打印所有特征类型
#include <NXOpen/Session.hxx> //有关Session绘画头文件
#include <NXOpen/Part.hxx> //有关部件头文件
#include <NXOpen/PartCollection.hxx> //有关部件头文件
#include <NXOpen/Features_Feature.hxx> //有关特征头文件
#include <NXOpen/Features_CylinderBuilder.hxx> //有关特征头文件
#include <NXOpen/Features_FeatureCollection.hxx>//有关特征头文件
#include <NXOpen/Features_FeatureBuilder.hxx> //有关特征头文件
#include <sstream>
#include <NXOpen/ListingWindow.hxx>


Session *theSession = Session::GetSession(); //获得Session绘画
Part *workPart(theSession->Parts()->Work()); //获得工作部件

theSession->ListingWindow()->Open(); //打开信息窗口
theSession->ListingWindow()->WriteLine("输出所有特征类型信息\n");
Features::Feature*fcList;
Features::FeatureCollection *fc=workPart->Features();//迭代
Features::FeatureCollection::iterator itr=fc->begin();//获得第一个特征
for (;itr!=fc->end();++itr) //循环获得所有特征
{
fcList=(*itr); //获得特征赋值给fcList
theSession->ListingWindow()->WriteLine(fcList->FeatureType()); //获得特征类型打印
theSession->ListingWindow()->WriteLine("\n");
}

9

最新回复 (188)
  • wxwxwxwx 9年前
    1

    谢谢分享。。。。。。

  • yccong 9年前
    2

    学习中,谢谢楼主无私分享!

  • xyq407 9年前
    3

    学习中,谢谢楼主无私分享!

  • ahqqqq22 9年前
    4

    学习中,谢谢楼主无私分享!

  • habref 9年前
    5

    谢谢!

  • bwuds 9年前
    6

    谢谢!..................

  • zzhug 8年前
    7

    学习了,二次开发的资源真难找,,谢谢了!

  • f1405602 8年前
    8

    群主牛逼,高端大气上档次, *** 爆了

  • guizinj 8年前
    9

    高端大气上档次,牛逼了

  • pm906026115 8年前
    10

    duoxielouzhufenxiang

  • ctf001 8年前
    11

    kank高端大气上档次,牛逼了

  • q1355188058 8年前
    12

    谢谢楼主分享代码!!!学习研究

  • wucrew 8年前
    13

    学习一下,谢谢提供资料

  • 等你的 8年前
    14

    正在研究遍历,,,,,

  • xbp08301666 8年前
    15

    学习中,谢谢楼主无私分享!

请登录后发表新帖