/*录制:通过曲线网格创建曲面*/
bool CreateFaceThroughCurveMesh(tag_t cur1,tag_t cur2,tag_t bridgeCur1, tag_t bridgeCur2, tag_t& faceThroughCurveMesh)
{
try
{
Session* theSession = Session::GetSession();
Part* workPart(theSession->Parts()->Work());
Part* displayPart(theSession->Parts()->Display());
Features::Feature* nullFeatures_Feature(NULL);
Preferences::SessionModeling::BodyTypeOption bodyType1;
bodyType1 = theSession->Preferences()->Modeling()->BodyType();
if (!workPart->Preferences()->Modeling()->GetHistoryMode())
{
throw NXException::Create("Create or edit of a Feature was recorded in History Mode but playback is in History-Free Mode.");
}
Features::ThroughCurveMeshBuilder* throughCurveMeshBuilder1;
throughCurveMeshBuilder1 = workPart->Features()->CreateThroughCurveMeshBuilder(nullFeatures_Feature);
Section* section1;
section1 = workPart->Sections()->CreateSection(0.02413, 0.0254, 0.05);
throughCurveMeshBuilder1->PrimaryCurvesList()->Append(section1);
section1->SetAllowedEntityTypes(Section::AllowTypesCurvesAndPoints);
std::vector<IBaseCurve*> curves1(1);
Spline* spline1(dynamic_cast<Spline*>(NXObjectManager::Get(cur1)));
curves1[0] = spline1;
CurveDumbRule* curveDumbRule1;
curveDumbRule1 = workPart->ScRuleFactory()->CreateRuleBaseCurveDumb(curves1);
section1->AllowSelfIntersection(false);
std::vector<SelectionIntentRule*> rules1(1);
rules1[0] = curveDumbRule1;
NXObject* nullNXObject(NULL);
Point3d helpPoint1(0.0, 0.0, 0.0);
section1->AddToSection(rules1, spline1, nullNXObject, nullNXObject, helpPoint1, Section::ModeCreate, false);
Section* section2;
section2 = workPart->Sections()->CreateSection(0.02413, 0.0254, 0.05);
throughCurveMeshBuilder1->PrimaryCurvesList()->Append(section2);
section2->SetAllowedEntityTypes(Section::AllowTypesCurvesAndPoints);
std::vector<IBaseCurve*> curves2(1);
Spline* spline2(dynamic_cast<Spline*>(NXObjectManager::Get(cur2)));
curves2[0] = spline2;
CurveDumbRule* curveDumbRule2;
curveDumbRule2 = workPart->ScRuleFactory()->CreateRuleBaseCurveDumb(curves2);
section2->AllowSelfIntersection(false);
std::vector<SelectionIntentRule*> rules2(1);
rules2[0] = curveDumbRule2;
Point3d helpPoint2(0.0, 0.0, 0.0);
section2->AddToSection(rules2, spline2, nullNXObject, nullNXObject, helpPoint2, Section::ModeCreate, false);
Section* section3;
section3 = workPart->Sections()->CreateSection(0.02413, 0.0254, 0.05);
throughCurveMeshBuilder1->CrossCurvesList()->Append(section3);
section3->SetAllowedEntityTypes(Section::AllowTypesOnlyCurves);
std::vector<IBaseCurve*> curves3(1);
Features::BridgeCurve* bridgeCurve1(dynamic_cast<Features::BridgeCurve*>(NXObjectManager::Get(bridgeCur1)));
Spline* spline3(dynamic_cast<Spline*>(bridgeCurve1->FindObject("CURVE 1")));
curves3[0] = spline3;
CurveDumbRule* curveDumbRule3;
curveDumbRule3 = workPart->ScRuleFactory()->CreateRuleBaseCurveDumb(curves3);
section3->AllowSelfIntersection(false);
std::vector<SelectionIntentRule*> rules3(1);
rules3[0] = curveDumbRule3;
Point3d helpPoint3(0.0, 0.0, 0.0);
section3->AddToSection(rules3, spline3, nullNXObject, nullNXObject, helpPoint3, Section::ModeCreate, false);
Section* section4;
section4 = workPart->Sections()->CreateSection(0.02413, 0.0254, 0.05);
throughCurveMeshBuilder1->CrossCurvesList()->Append(section4);
section4->SetAllowedEntityTypes(Section::AllowTypesOnlyCurves);
std::vector<IBaseCurve*> curves4(1);
Features::BridgeCurve* bridgeCurve2(dynamic_cast<Features::BridgeCurve*>(NXObjectManager::Get(bridgeCur2)));
Spline* spline4(dynamic_cast<Spline*>(bridgeCurve2->FindObject("CURVE 1")));
curves4[0] = spline4;
CurveDumbRule* curveDumbRule4;
curveDumbRule4 = workPart->ScRuleFactory()->CreateRuleBaseCurveDumb(curves4);
section4->AllowSelfIntersection(false);
std::vector<SelectionIntentRule*> rules4(1);
rules4[0] = curveDumbRule4;
Point3d helpPoint4(0.0, 0.0, 0.0);
section4->AddToSection(rules4, spline4, nullNXObject, nullNXObject, helpPoint4, Section::ModeCreate, false);
//创建
faceThroughCurveMesh = throughCurveMeshBuilder1->CommitFeature()->Tag();
throughCurveMeshBuilder1->Destroy();
}
catch (exception& ex)
{
UF_UI_open_listing_window();
UF_UI_write_listing_window("通过曲线网格创建曲面失败\n");
return 1;
}
return 0;
}
【UG\NX二次开发】NXOpen 通过曲线网格(throughCurveMeshBuilder)
于 2023-11-09 15:18:53 首次发布