首页 > 其他分享 >测量距离(面到面)

测量距离(面到面)

时间:2023-02-18 11:55:25浏览次数:27  
标签:workPart measureDistance1 测量 距离 cast NXOpen dynamic 面到 measureDistanceBuilder1

double Dis_faceFaec(tag_t Obj1, tag_t Obj2)//测量距离
{
NXOpen::Session *theSession = NXOpen::Session::GetSession();
NXOpen::Part *workPart(theSession->Parts()->Work());
NXOpen::Part *displayPart(theSession->Parts()->Display());

NXOpen::NXObject *nullNXOpen_NXObject(NULL);
NXOpen::MeasureDistanceBuilder *measureDistanceBuilder1;
measureDistanceBuilder1 = workPart->MeasureManager()->CreateMeasureDistanceBuilder(nullNXOpen_NXObject);

measureDistanceBuilder1->SetMtype(NXOpen::MeasureDistanceBuilder::MeasureTypeMinimum);


//measureDistanceBuilder1->SetInfoWindow(true);

 

//NXOpen::Features::Brep *brep1(dynamic_cast<NXOpen::Features::Brep *>(workPart->Features()->FindObject("UNPARAMETERIZED_FEATURE(290)")));
NXOpen::Face *face1(dynamic_cast<NXOpen::Face *>(NXOpen::NXObjectManager::Get(Obj1)));
measureDistanceBuilder1->Object1()->SetValue(face1);

NXOpen::Face *face2(dynamic_cast<NXOpen::Face *>(NXOpen::NXObjectManager::Get(Obj2)));
measureDistanceBuilder1->Object2()->SetValue(face2);

NXOpen::Unit *unit1(dynamic_cast<NXOpen::Unit *>(workPart->UnitCollection()->FindObject("MilliMeter")));
NXOpen::MeasureDistance *measureDistance1;
measureDistance1 = workPart->MeasureManager()->NewDistance(unit1, NXOpen::MeasureManager::MeasureTypeMinimum, false, face1, face2);

//measureDistance1->Information();


//获得距离
double Distance = measureDistance1->Value();

 

delete measureDistance1;

return Distance;
}

标签:workPart,measureDistance1,测量,距离,cast,NXOpen,dynamic,面到,measureDistanceBuilder1
From: https://www.cnblogs.com/firetuo/p/17132284.html

相关文章