【UG\NX二次开发】NXOpen 通过曲线网格(throughCurveMeshBuilder)

/*录制:通过曲线网格创建曲面*/
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;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

社恐猫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值