NXOpen遍历尺寸 UF获取尺寸值
作者:互联网
VS2010 NX8.5
#include <NXOpen/Annotations_Dimension.hxx>
#include <NXOpen/Annotations_DimensionCollection.hxx>
#include <NXOpen/Annotations.hxx>
#include <NXOpen/Drawings_DraftingView.hxx>
#include <NXOpen/Drawings_DraftingViewCollection.hxx>
UF_initialize();
//遍历图纸上的标注尺寸
NXOpen::Annotations::Dimension*Dimensions;//定义类型
vector<NXOpen::Annotations::Dimension*> DimensionsVector;//尺寸vector
NXOpen::Annotations::DimensionCollection *DIM=workPart->Dimensions();//迭代
NXOpen::Annotations::DimensionCollection::iterator itr = workPart->Dimensions()->begin();
for (;itr!=DIM->end();++itr) //循环获得所有尺寸
{
Dimensions=(*itr); //获得尺寸
DimensionsVector.push_back(Dimensions);
Point3d DimOrigin = Dimensions->AnnotationOrigin();//获取尺寸的位置
sprintf(msg,"尺寸位置 X:%.2f Y:%.2f Z:%.2f",DimOrigin.X,DimOrigin.Y,DimOrigin.Z);
theSession->ListingWindow()->WriteLine(msg);
//获取尺寸的值
int dim_type = 0;//尺寸的类型
double dim_origin[3];//原点坐标
UF_DRF_dim_info_p_t dim_info;
UF_DRF_ask_dim_info(Dimensions->Tag(), &dim_type, dim_origin, &dim_info);
string DimValue = dim_info->text_info->text->string;
theSession->ListingWindow()->WriteLine(DimValue);
}
UF_terminate();
标签:info,dim,include,Dimensions,NXOpen,尺寸,UF 来源: https://www.cnblogs.com/hqsalanhuang/p/14657015.html