其他分享
首页 > 其他分享> > NXOpen-创建固定约束

NXOpen-创建固定约束

作者:互联网

void CreateFixedConstraint(tag_t component)
{
	if (NULL_TAG == component)
	{
		return;
	}

	NXOpen::Session *theSession = NXOpen::Session::GetSession();
	NXOpen::Part *workPart(theSession->Parts()->Work());

	NXOpen::Positioning::ComponentPositioner *componentPositioner1 = workPart->ComponentAssembly()->Positioner();
	componentPositioner1->ClearNetwork();
	componentPositioner1->SetPrimaryArrangement(NULL);
	componentPositioner1->BeginAssemblyConstraints();

	NXOpen::Positioning::Network *network1 = componentPositioner1->EstablishNetwork();
	NXOpen::Positioning::ComponentNetwork *componentNetwork1(dynamic_cast<NXOpen::Positioning::ComponentNetwork *>(network1));
	componentNetwork1->SetMoveObjectsState(true);
	componentNetwork1->SetDisplayComponent(NULL);
	componentNetwork1->SetNetworkArrangementsMode(NXOpen::Positioning::ComponentNetwork::ArrangementsModeExisting);

	NXOpen::Assemblies::Component *component1(dynamic_cast<NXOpen::Assemblies::Component *>(UDS::ToNXObj(component)));
	NXOpen::Positioning::Constraint *constraint1 = componentPositioner1->CreateConstraint(true);
	NXOpen::Positioning::ComponentConstraint *componentConstraint1(dynamic_cast<NXOpen::Positioning::ComponentConstraint *>(constraint1));
	componentConstraint1->SetConstraintType(NXOpen::Positioning::Constraint::TypeFix);

	NXOpen::Positioning::ConstraintReference *constraintReference1 = componentConstraint1->CreateConstraintReference(component1, component1, false, false, false);

	componentNetwork1->Solve();
	componentPositioner1->ClearNetwork();
	theSession->UpdateManager()->AddToDeleteList(componentNetwork1);
	componentPositioner1->DeleteNonPersistentConstraints();
	componentPositioner1->EndAssemblyConstraints();
}

标签:false,创建,Positioning,componentPositioner1,约束,NXOpen,componentNetwork1,NULL
来源: https://www.cnblogs.com/xbnxopen/p/15324731.html