NXOpen-孔加工
此代码可以利用NX录码,经供参考
void CreateHoleMach::SetPoint(tag_t operation, vector<tag_t> points)
{
NXOpen::Session *theSession = NXOpen::Session::GetSession();
NXOpen::Part* workPart = theSession->Parts()->Work();
NXOpen::CAM::HoleDrilling* holeDrilling = dynamic_cast<NXOpen::CAM::HoleDrilling*>(NXObjectManager::Get(operation));
NXOpen::CAM::HoleDrillingBuilder* holeDrillingBuilder = workPart->CAMSetup()->CAMOperationCollection()->CreateHoleDrillingBuilder(holeDrilling);
NXOpen::CAM::FBM::FeatureGeometry *featureGeometry = holeDrillingBuilder->GetFeatureGeometry();
NXOpen::CAM::FBM::MachiningFeatureGeometry *machiningFeatureGeometry=dynamic_cast<NXOpen::CAM::FBM::MachiningFeatureGeometry *>(featureGeometry);
NXOpen::CAM::GeometrySetList *geometrySetList = machiningFeatureGeometry->GeometryList();
NXOpen::CAM::CAMFeature *nullNXOpen_CAM_CAMFeature(NULL);
std::vector<NXOpen::Point *> allPoints;//以点举例,需转换成Point类型
for (auto point : points)
{
allPoints.push_back(dynamic_cast<NXOpen::Point*>(NXObjectManager::Get(point)));
}
for (int i = 0; i < allPoints.size(); ++i)
{
NXOpen::CAM::FBM::FeatureSet *featureSet = machiningFeatureGeometry->AddFeatureSet(nullNXOpen_CAM_CAMFeature, "NXHOLE");
geometrySetList->Append(featureSet);
std::vector<NXOpen::NXObject *> entities(1);
entities[0] = allPoints[i];
NXOpen::CAM::FBM::Feature *feature = featureSet->CreateFeature(entities);
}
holeDrillingBuilder->Commit();
holeDrillingBuilder->Destroy();
}