常用方法

#include <uf_defs.h>
#include <uf.h>
#include <uf_ui.h>
#include <uf_ui_types.h>
#include <iostream>
#include <uf_assem.h>
#include <UF_MODL.h>
#include <UF_OBJ.h>
#include <NXOpen/Session.hxx>
#include <NXOpen/UI.hxx>
#include <NXOpen/ListingWindow.hxx>
#include <NXOpen/NXMessageBox.hxx>
#include <NXOpen/Callback.hxx>
#include <NXOpen/NXException.hxx>
#include <NXOpen/BlockStyler_UIBlock.hxx>
#include <NXOpen/BlockStyler_BlockDialog.hxx>
#include <NXOpen/BlockStyler_PropertyList.hxx>
#include <NXOpen/Assemblies_Component.hxx>
#include <NXOpen/Assemblies_ComponentAssembly.hxx>
#include <NXOpen/Face.hxx>
#include <NXOpen/Line.hxx>
#include <NXOpen/LineCollection.hxx>
#include <NXOpen/NXObject.hxx>
#include <uf_part.h> //Part头文件
#include <NXOpen/Part.hxx> //Part头文件
#include <NXOpen/PartCollection.hxx> //Part头文件
#include <NXOpen/Positioning_ComponentConstraint.hxx>
#include <NXOpen/Positioning_ComponentNetwork.hxx>
#include <NXOpen/Positioning_ComponentPositioner.hxx>
#include <NXOpen/Positioning_Constraint.hxx>
#include <NXOpen/Positioning_ConstraintReference.hxx>
#include <NXOpen/Positioning_Network.hxx>
#include <NXOpen/Positioning_Positioner.hxx>
#include <NXOpen/Preferences_SessionAssemblies.hxx>
#include <NXOpen/Preferences_SessionPreferences.hxx>
#include <NXOpen/Sketch.hxx>
#include <NXOpen/SketchCollection.hxx>
#include <NXOpen/Update.hxx>
#include <NXOpen/Assemblies_Component.hxx>
#include <NXOpen/Assemblies_ComponentAssembly.hxx>
#include <NXOpen/Body.hxx>
#include <NXOpen/BodyCollection.hxx>
#include <NXOpen/Face.hxx>
#include <NXOpen/Line.hxx>
#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 <NXOpen/Features_AssociativeLine.hxx>
#include <NXOpen/NXObjectManager.hxx>
#include <NXOpen/DisplayableObject.hxx>
#include <NXOpen/DisplayManager.hxx>
#include <NXOpen/Expression.hxx> //表达式
#include <NXOpen/ExpressionCollection.hxx> //表达式
#include <NXOpen/Measure.hxx> //measrue测量
#include <NXOpen/MeasureAngle.hxx> //measrue测量
#include <NXOpen/MeasureAngleBuilder.hxx> //measrue测量
#include <NXOpen/MeasureManager.hxx> //measrue测量
#include <NXOpen/SelectDisplayableObject.hxx> //measrue测量
#include <NXOpen/SelectObject.hxx> //measrue测量
#include <NXOpen/TaggedObject.hxx> //measrue测量
#include <NXOpen/Unit.hxx> //measrue测量
#include <NXOpen/UnitCollection.hxx> //measrue测量
#include <NXOpen/BlockStyler_Wizard.hxx>
#include <sstream>

2,///////////////////////////////////////这里是一个比较NXopen中NXstring对象和char*的方法/////////////////////////////////////

Session *theSession = Session::GetSession();
Part *displayPart(theSession->Parts()->Display());
Part *workPart(theSession->Parts()->Work());

Features::Feature *fcList;
std::vector<NXObject *> entitiesArray; //std::vector是一种数组定义方式
Features::FeatureCollection *fc=workPart->Features();//迭代
Features::FeatureCollection::iterator itr=fc->begin();//获得第一个特征

for (;itr!=fc->end();++itr) //循环获得所有特征
{
fcList=(*itr); //获得特征赋值给fcList
NXString featType = NULL;
featType = fcList->FeatureType(); ////这里是一个比较NXopen中NXstring对象和char*的方法

/*theSession->ListingWindow()->WriteLine(fcList->FeatureType());*/
if(!strcmp(featType.GetLocaleText(),"LINE"))
{
//lineNum.push_back(fcList->Tag());

entitiesArray = fcList->GetEntities(); //GetEntities方法,实体下0对象,Lineg下1对对象,基准下7对象,点集下对象最多
lineNum.push_back(entitiesArray[0]->Tag());
}
}

2,

posted @ 2021-10-12 11:16  光量子  阅读(54)  评论(0编辑  收藏  举报