Nxopen 直齿轮参数化设计

news2025/1/29 7:06:42

NXUG1953 Visualstudio 2019 参考论文: A Method for Determining the AGMA Tooth Form Factor from Equations for the Generated Tooth Root Fillet

//FullGear

// Mandatory UF Includes
#include <uf.h>
#include <uf_object_types.h>

// Internal Includes
#include <NXOpen/ListingWindow.hxx>
#include <NXOpen/NXMessageBox.hxx>
#include <NXOpen/UI.hxx>

// Internal+External Includes
#include <NXOpen/Annotations.hxx>
#include <NXOpen/Assemblies_Component.hxx>
#include <NXOpen/Assemblies_ComponentAssembly.hxx>
#include <NXOpen/Body.hxx>
#include <NXOpen/BodyCollection.hxx>
#include <NXOpen/Face.hxx>
#include <NXOpen/Line.hxx>
#include <NXOpen/NXException.hxx>
#include <NXOpen/NXObject.hxx>
#include <NXOpen/Part.hxx>
#include <NXOpen/PartCollection.hxx>
#include <NXOpen/Session.hxx>
#include <NXOpen/PointCollection.hxx>
#include <NXOpen/Features_PointFeatureBuilder.hxx>
#include <NXOpen/Features_BaseFeatureCollection.hxx>
#include <NXOpen/MathUtils.hxx>
#include <NXOpen/Features_StudioSplineBuilderEx.hxx>
#include <NXOpen/Features_FeatureCollection.hxx>
#include <NXOpen/Point.hxx>
#include <NXOpen/Features_Extrude.hxx>
#include <NXOpen/Features_ExtrudeBuilder.hxx>
#include <NXOpen/GeometricUtilities_BooleanOperation.hxx>
#include <NXOpen/Direction.hxx>
#include <NXOpen/DirectionCollection.hxx>
#include <NXOpen/GeometricUtilities_Limits.hxx>
#include <NXOpen/GeometricUtilities_Extend.hxx>
#include <NXOpen/SectionCollection.hxx>
#include <NXOpen/Features_AssociativeArcBuilder.hxx>
#include <NXOpen/Features_AssociativeArc.hxx>
#include <NXOpen/SelectPoint.hxx>
#include <NXOpen/CurveFeatureRule.hxx>
#include <NXOpen/Features_StudioSpline.hxx>
#include <NXOpen/Spline.hxx>
#include <NXOpen/Arc.hxx>
#include <NXOpen/NXObjectManager.hxx>
#include <NXOpen/ScRuleFactory.hxx>

// Std C++ Includes
#include <iostream>
#include <sstream>

using namespace NXOpen;
using std::string;
using std::exception;
using std::stringstream;
using std::endl;
using std::cout;
using std::cerr;

//------------------------------------------------------------------------------
// NXOpen c++ test class 
//------------------------------------------------------------------------------
class MyClass
{
    // class members
public:
    static Session *theSession;
    static UI *theUI;

    MyClass();
    ~MyClass();

	void do_it();
	void print(const NXString &);
	void print(const string &);
	void print(const char*);
	NXOpen::Point3d Involutecurve(double alphax, double rb);
	NXOpen::Point* pointcreat(NXOpen::Point3d InputPoint, NXOpen::BasePart* part1);
	void POINTconstruction(NXOpen::Point* point1, NXOpen::BasePart* part1);
	NXOpen::Point3d Rotz(double thetai, NXOpen::Point3d inputpoint3d, NXOpen::MathUtils* Ms);
	NXOpen::NXObject* splinecreatbypoint(std::vector<NXOpen::Point* > CurvePoint, NXOpen::BasePart* part1);
	std::vector<NXOpen::Point* > CreatSymmetricPoint(std::vector<NXOpen::Point* > CurvePoint, NXOpen::BasePart* part1);
	NXOpen::NXObject* arccreatthreepoint(std::vector<NXOpen::Point* > ARCPoint, NXOpen::BasePart* part1);
	void addsplinetosection(NXOpen::NXObject* splinexnObject, NXOpen::Section* sectionx, tag_t splinexTag, NXOpen::Point3d helpPoint, NXOpen::Part* GPart);
	void addarctosection(NXOpen::NXObject* arcxnObject, NXOpen::Section* sectionx, tag_t arcxTag, NXOpen::Point3d helpPoint, NXOpen::Part* GPart);
	std::vector<NXOpen::Point* >RotZPoint(std::vector<NXOpen::Point* > Point11, double theta, NXOpen::MathUtils* Ms, NXOpen::BasePart* part1);
private:
	BasePart *workPart, *displayPart;
	NXMessageBox *mb;
	ListingWindow *lw;
	LogFile *lf;
};

//------------------------------------------------------------------------------
// Initialize static variables
//------------------------------------------------------------------------------
Session *(MyClass::theSession) = NULL;
UI *(MyClass::theUI) = NULL;

//------------------------------------------------------------------------------
// Constructor 
//------------------------------------------------------------------------------
MyClass::MyClass()
{

	// Initialize the NX Open C++ API environment
	MyClass::theSession = NXOpen::Session::GetSession();
	MyClass::theUI = UI::GetUI();
	mb = theUI->NXMessageBox();
	lw = theSession->ListingWindow();
	lf = theSession->LogFile();

    workPart = theSession->Parts()->BaseWork();
	displayPart = theSession->Parts()->BaseDisplay();
	
}

//------------------------------------------------------------------------------
// Destructor
//------------------------------------------------------------------------------
MyClass::~MyClass()
{
}

//------------------------------------------------------------------------------
// Print string to listing window or stdout
//------------------------------------------------------------------------------
void MyClass::print(const NXString &msg)
{
	if(! lw->IsOpen() ) lw->Open();
	lw->WriteLine(msg);
}
void MyClass::print(const string &msg)
{
	if(! lw->IsOpen() ) lw->Open();
	lw->WriteLine(msg);
}
void MyClass::print(const char * msg)
{
	if(! lw->IsOpen() ) lw->Open();
	lw->WriteLine(msg);
}

NXOpen::Point3d MyClass::Involutecurve(double alphax, double rb)
{
	double rx = rb / cos(alphax);
	double thetax = tan(alphax) - alphax;
	double xx = -rx * sin(thetax);
	double yy = rx * cos(thetax);
	NXOpen::Point3d OutputPoint3d = {xx,yy,0.0} ;
	return OutputPoint3d;
}
NXOpen::Point* MyClass::pointcreat(NXOpen::Point3d InputPoint, NXOpen::BasePart* part1)
{
	NXOpen::Point* point;
	point = part1->Points()->CreatePoint(InputPoint);
	return point;
}
void MyClass::POINTconstruction(NXOpen::Point* point1, NXOpen::BasePart* part1)
{
	NXOpen::Features::Feature* nullNXOpen_Features_Feature(NULL);
	NXOpen::Features::PointFeatureBuilder* pointFeatureBuilder1;
	pointFeatureBuilder1 = part1->BaseFeatures()->CreatePointFeatureBuilder(nullNXOpen_Features_Feature);
	pointFeatureBuilder1->SetPoint(point1);
	NXOpen::NXObject* nXObject1;
	nXObject1 = pointFeatureBuilder1->Commit();
	pointFeatureBuilder1->Destroy();
}

NXOpen::Point3d  MyClass::Rotz(double thetai, NXOpen::Point3d inputpoint3d, NXOpen::MathUtils* Ms)
{
	NXOpen::Matrix3x3 Rzmatrix;
	Rzmatrix.Xx = cos(thetai);
	Rzmatrix.Xy = -sin(thetai);
	Rzmatrix.Xz = 0.0;
	Rzmatrix.Yx = sin(thetai);
	Rzmatrix.Yy = cos(thetai);
	Rzmatrix.Yz = 0.0;
	Rzmatrix.Zx = 0.0;
	Rzmatrix.Zy = 0.0;
	Rzmatrix.Zz = 1.0;
	NXOpen::Point3d outputpoint3d= Ms->Multiply(Rzmatrix, inputpoint3d);
	return outputpoint3d;
}
NXOpen::NXObject* MyClass::splinecreatbypoint(std::vector<NXOpen::Point* > CurvePoint, NXOpen::BasePart* part1)
{
	NXOpen::NXObject* nullNXOpen_NXObject(NULL);
	NXOpen::Features::StudioSplineBuilderEx* studioSplineBuilderEx;
	studioSplineBuilderEx = part1->Features()->CreateStudioSplineBuilderEx(nullNXOpen_NXObject);
	studioSplineBuilderEx->SetDegree(3);
	NXOpen::Features::GeometricConstraintData* geometricConstraintData;
	std::vector<Features::GeometricConstraintData*> constraints(CurvePoint.size());
	for (int gg = 0; gg < CurvePoint.size(); gg++)
	{
		NXOpen::Point* point = CurvePoint[gg];
		geometricConstraintData = studioSplineBuilderEx->ConstraintManager()->CreateGeometricConstraintData();
		geometricConstraintData->SetPoint(point);
		constraints[gg] = geometricConstraintData;
	}
	studioSplineBuilderEx->ConstraintManager()->SetContents(constraints);
	NXOpen::NXObject* nXObject;
	nXObject = studioSplineBuilderEx->Commit();
	Spline* returnSpline = studioSplineBuilderEx->Curve();
	return nXObject;
}
std::vector<NXOpen::Point* >MyClass::CreatSymmetricPoint(std::vector<NXOpen::Point* > CurvePoint, NXOpen::BasePart* part1)
{
	std::vector<NXOpen::Point* > CurvePoint1;
	for (int i = 0; i < CurvePoint.size(); i++)
	{
		NXOpen::Point* PP = CurvePoint[i];
		NXOpen::Point3d PP3d = PP->Coordinates();
		NXOpen::Point3d PP3df = { -PP3d.X,PP3d.Y,PP3d.Z};
		NXOpen::Point* pointi = pointcreat(PP3df, part1);
		CurvePoint1.push_back(pointi);
	}
	return CurvePoint1;
}

NXOpen::NXObject* MyClass::arccreatthreepoint(std::vector<NXOpen::Point* > ARCPoint, NXOpen::BasePart* part1)
{
	NXOpen::Point* starpoint = ARCPoint[0];
	NXOpen::Point* endpoint =  ARCPoint[1];
	NXOpen::Point* midpoint = ARCPoint[2];

	Features::AssociativeArc* nullFeatures_AssociativeArc(NULL);
	Features::AssociativeArcBuilder* associativeArcBuilder;
	associativeArcBuilder = part1->BaseFeatures()->CreateAssociativeArcBuilder(nullFeatures_AssociativeArc);
	Unit* unit;
	unit = associativeArcBuilder->Radius()->Units();
	associativeArcBuilder->SetStartPointOptions(Features::AssociativeArcBuilder::StartOptionPoint);
	associativeArcBuilder->SetEndPointOptions(Features::AssociativeArcBuilder::EndOptionPoint);
	associativeArcBuilder->SetMidPointOptions(Features::AssociativeArcBuilder::MidOptionPoint);
	associativeArcBuilder->Limits()->StartLimit()->SetLimitOption(GeometricUtilities::CurveExtendData::LimitOptionsAtPoint);
	associativeArcBuilder->Limits()->EndLimit()->SetLimitOption(GeometricUtilities::CurveExtendData::LimitOptionsAtPoint);
	associativeArcBuilder->Limits()->StartLimit()->Distance()->SetRightHandSide("0");
	associativeArcBuilder->Limits()->EndLimit()->Distance()->SetRightHandSide("0");
	associativeArcBuilder->StartPoint()->SetValue(starpoint);
	associativeArcBuilder->EndPoint()->SetValue(endpoint);
	associativeArcBuilder->MidPoint()->SetValue(midpoint);
	NXObject* nXObject;
	nXObject = associativeArcBuilder->Commit();
	associativeArcBuilder->Destroy();
	return nXObject;
}
void MyClass::addsplinetosection(NXOpen::NXObject* splinexnObject, NXOpen::Section* sectionx, tag_t splinexTag, NXOpen::Point3d helpPoint, NXOpen::Part* GPart)
{
	NXOpen::NXObject* nullNXOpen_NXObject(NULL);
	std::vector<NXOpen::Features::Feature*> features2(1);
	NXOpen::Features::StudioSpline* studioSpline1(dynamic_cast<NXOpen::Features::StudioSpline*>(GPart->Features()->FindObject(splinexnObject->JournalIdentifier())));
	features2[0] = studioSpline1;
	NXOpen::CurveFeatureRule* curveFeatureRule2;
	curveFeatureRule2 = GPart->ScRuleFactory()->CreateRuleCurveFeature(features2);
	std::vector<NXOpen::SelectionIntentRule*> rules2(1);
	rules2[0] = curveFeatureRule2;
	NXOpen::Spline* spline1(dynamic_cast<NXOpen::Spline*>(NXOpen::NXObjectManager::Get(splinexTag)));
	sectionx->AddToSection(rules2, spline1, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint, NXOpen::Section::ModeCreate, false);
}
void MyClass::addarctosection(NXOpen::NXObject* arcxnObject, NXOpen::Section* sectionx, tag_t arcxTag, NXOpen::Point3d helpPoint, NXOpen::Part* GPart)
{

	NXOpen::NXObject* nullNXOpen_NXObject(NULL);
	std::vector<NXOpen::Features::Feature*> features3(1);
	NXOpen::Features::AssociativeArc* associativeArc1(dynamic_cast<NXOpen::Features::AssociativeArc*>(GPart->Features()->FindObject(arcxnObject->JournalIdentifier())));
	features3[0] = associativeArc1;
	NXOpen::CurveFeatureRule* curveFeatureRule3;
	curveFeatureRule3 = GPart->ScRuleFactory()->CreateRuleCurveFeature(features3);
	std::vector<NXOpen::SelectionIntentRule*> rules3(1);
	rules3[0] = curveFeatureRule3;
	NXOpen::Arc* arc1(dynamic_cast<NXOpen::Arc*>(NXOpen::NXObjectManager::Get(arcxTag)));
	sectionx->AddToSection(rules3, arc1, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint, NXOpen::Section::ModeCreate, false);
}
std::vector<NXOpen::Point* >MyClass::RotZPoint(std::vector<NXOpen::Point* > inputPoint, double theta, NXOpen::MathUtils* Ms, NXOpen::BasePart* part1)
{
	std::vector<NXOpen::Point* > outputPoint;
	for (int i = 0; i < inputPoint.size(); i++)
	{
		NXOpen::Point3d Pointi3d = Rotz(theta, inputPoint[i]->Coordinates(), Ms);
		NXOpen::Point* point1i = pointcreat(Pointi3d, part1);
		outputPoint.push_back(point1i);
	}
	return outputPoint;
}






//------------------------------------------------------------------------------
// Do something
//------------------------------------------------------------------------------
void MyClass::do_it()
{

	NXOpen::Session* theSession = NXOpen::Session::GetSession();
	NXOpen::Part* GPart(theSession->Parts()->Work());
	NXOpen::Part* displayPart(theSession->Parts()->Display());
	NXOpen::MathUtils* Ms(theSession->MathUtils());

	lw->Open();
	char msg[256];

	//齿轮参数
	double mn = 6;
	double z = 20;
	double ToothWidth = 55.0;
	double Holediameter = 30.0;

	double ha = 1;
	double c = 0.25;
	double hf = (ha + c) * mn;
	double alphan = PI / 9;
	double theten = tan(alphan) - alphan;
	double d = mn * z;
	double r = d / 2;
	double da = d + 2 * ha * mn;
	double ra = da / 2;
	double db = d * cos(alphan);
	double rb = db / 2;
	double df = d - 2 * hf;
	double rf = df / 2;
	double beta = PI / z;
	double omegaS = PI / (2 * z) + theten;
	double alphaA = acos(rb / ra);

	// 齿条参数
	double cP = 0.25 * mn;
	double  rhofP = 0.38 * mn;
	double hfP = 1.25 * mn;
	double hFfP = hfP - cP;
	double P = PI * mn;
	double sP = 0.5 * P;
	double alphaP = PI / 9;

	double lB = 0.5 * sP + hFfP * tan(alphaP) + hFfP / tan(alphan);
	double etaB = lB / r;
	double xB = cos(-etaB) * (-hFfP / tan(alphan)) - sin(-etaB) * (r - hFfP);
	double yB = sin(-etaB) * (-hFfP / tan(alphan)) + cos(-etaB) * (r - hFfP);
	double rB = sqrt(pow(xB, 2) + pow(yB, 2));
	double alphaB = acos(rb / rB);
	double lC = 0.5 * sP + hFfP * tan(alphaP) + rhofP * cos(alphaP);
	double etaC = lC / r;
	double xC = cos(-etaC) * 0.0 - sin(-etaC) * (r - hfP);
	double yC = sin(-etaC) * 0.0 + cos(-etaC) * (r - hfP);

	double deltaS = 0.5;

	double S = rb / 2 * (1 / pow(cos(alphaA), 2) - 1 / pow(cos(alphaB), 2));

	std::vector<NXOpen::Point* > RInvolutePoint;
	for (int i = 1; i < 100; i++)
	{
		double Si = S - (i - 1) * deltaS;
		if (Si > 0)
		{
			double alphai = acos(sqrt(1 / (2 * Si / rb + 1 / pow(cos(alphaB), 2))));
			NXOpen::Point3d OutputPoint3d = Involutecurve(alphai, rb);
			NXOpen::Point3d OutputPoint3d1 = Rotz(-omegaS, OutputPoint3d, Ms);
			NXOpen::Point* Opoint = pointcreat(OutputPoint3d1, GPart);
			RInvolutePoint.push_back(Opoint);
		}
		else
		{
			double alphai = alphaB;
			NXOpen::Point3d OutputPoint3d = Involutecurve(alphai, rb);
			NXOpen::Point3d OutputPoint3d1 = Rotz(-omegaS, OutputPoint3d, Ms);
			NXOpen::Point* Opoint = pointcreat(OutputPoint3d1, GPart);
			RInvolutePoint.push_back(Opoint);
			break;
		}
	}


	double Xc0 = 0.5 * sP + hFfP * tan(alphaP) + rhofP * cos(alphaP);
	double Yc0 = r - (hfP - rhofP);
	double deltaA = 0.01;
	std::vector<NXOpen::Point* > RTransitionpoint;
	for (int k = 1; k < 1000; k++)
	{
		double thete = etaB - k * deltaA;
		if (thete > etaC)
		{
			double phi = atan((r * thete - Xc0) / (r - Yc0));
			double Xc = (Yc0 * tan(thete) - (r * thete - Xc0)) * cos(thete);
			double Yc = -(r - Yc0 / cos(thete) + (Yc0 * tan(thete) - (r * thete - Xc0)) * sin(thete));
			double alpha = PI + (PI / 2 - phi - thete);
			double Xf = Xc + rhofP * cos(alpha);
			double Yf = Yc + rhofP * sin(alpha);
			double xk = Xf;
			double yk = r + Yf;
			NXOpen::Point3d InputPoint3d = { xk, yk,0.0 };
			NXOpen::Point* Tpoint = pointcreat(InputPoint3d, GPart);
			RTransitionpoint.push_back(Tpoint);
		}
		else
		{
			break;
		}
	}

	double xD = rf * sin(beta);
	double yD = rf * cos(beta);
	double xM = (xC + xD) / 2;
	double yM = sqrt(pow(rf, 2) - pow(xM, 2));

	NXOpen::Point3d Cpoint3d = { xC,yC,0.0 };
	NXOpen::Point3d Dpoint3d = { xD,yD,0.0 };
	NXOpen::Point3d Mpoint3d = { xM,yM,0.0 };

	NXOpen::Point* Cpoint = pointcreat(Cpoint3d, GPart);
	NXOpen::Point* Dpoint = pointcreat(Dpoint3d, GPart);
	NXOpen::Point* Mpoint = pointcreat(Mpoint3d, GPart);

	RTransitionpoint[0] = RInvolutePoint.back();
	RTransitionpoint.push_back(Cpoint);

	std::vector<NXOpen::Point* > RDedendumcirclepoint;
	RDedendumcirclepoint.push_back(Cpoint);
	RDedendumcirclepoint.push_back(Dpoint);
	RDedendumcirclepoint.push_back(Mpoint);

	std::vector<NXOpen::Point* > LInvolutePoint;
	LInvolutePoint = CreatSymmetricPoint(RInvolutePoint, GPart);

	std::vector<NXOpen::Point* > LTransitionpoint;
	LTransitionpoint = CreatSymmetricPoint(RTransitionpoint, GPart);

	std::vector<NXOpen::Point* > LDedendumcirclepoint;
	LDedendumcirclepoint = CreatSymmetricPoint(RDedendumcirclepoint, GPart);


	NXOpen::Point* Hpoint = pointcreat({ 0.0,ra,0.0 }, GPart);

	NXOpen::Point* Apoint = RInvolutePoint[0];
	NXOpen::Point3d Apoint3d = Apoint->Coordinates();
	NXOpen::Point* ApointR = pointcreat({ Apoint3d.X,Apoint3d.Y,Apoint3d.Z }, GPart);
	NXOpen::Point* ApointL = pointcreat({ -Apoint3d.X,Apoint3d.Y,Apoint3d.Z }, GPart);

	std::vector<NXOpen::Point* > Addendumcirclepoint;
	Addendumcirclepoint.push_back(ApointL);
	Addendumcirclepoint.push_back(ApointR);
	Addendumcirclepoint.push_back(Hpoint);
	
	char Twidth[256];
	sprintf(Twidth, "%f", ToothWidth);

	NXOpen::Features::Feature* nullNXOpen_Features_Feature(NULL);
	NXOpen::Body* nullNXOpen_Body(NULL);
	NXOpen::Features::ExtrudeBuilder* extrudeBuilder1;
	extrudeBuilder1 = GPart->Features()->CreateExtrudeBuilder(nullNXOpen_Features_Feature);
	extrudeBuilder1->BooleanOperation()->SetType(NXOpen::GeometricUtilities::BooleanOperation::BooleanTypeCreate);
	extrudeBuilder1->SetDistanceTolerance(0.001);

	NXOpen::Section* section1;
	section1 = GPart->Sections()->CreateSection(0.00095, 0.001, 0.05);
	extrudeBuilder1->SetSection(section1);
	extrudeBuilder1->AllowSelfIntersectingSection(true);
	section1->SetAllowedEntityTypes(NXOpen::Section::AllowTypesOnlyCurves);
	section1->AllowSelfIntersection(true);

	std::vector<NXOpen::Body*> targetBodies1(1);
	targetBodies1[0] = nullNXOpen_Body;
	extrudeBuilder1->BooleanOperation()->SetTargetBodies(targetBodies1);
	extrudeBuilder1->Limits()->StartExtend()->Value()->SetRightHandSide(Twidth);
	extrudeBuilder1->Limits()->EndExtend()->Value()->SetRightHandSide("0");

	NXOpen::Point3d origin1;
	NXOpen::Vector3d vector1(0.0, 0.0, 1.0);
	NXOpen::Direction* direction1;
	direction1 = GPart->Directions()->CreateDirection(origin1, vector1, NXOpen::SmartObject::UpdateOptionWithinModeling);
	extrudeBuilder1->SetDirection(direction1);
	NXOpen::NXObject* nullNXOpen_NXObject(NULL);
	NXOpen::Point3d helpPoint1;
	
	for (int j = 0; j < z; j++)
	{
		double thetaj = j * 2 * PI / z;
		std::vector<NXOpen::Point* > Arc1jpoint;
		Arc1jpoint = RotZPoint(RDedendumcirclepoint, thetaj,Ms, GPart);
		NXObject* Arc1jnXObject = arccreatthreepoint(Arc1jpoint, GPart);

		tag_t Arc1jTag = NULL_TAG;
		Arc1jTag = Arc1jnXObject->Tag();
		
		std::vector<NXOpen::Point* > Spline2jpoint;
		Spline2jpoint = RotZPoint(RTransitionpoint, thetaj, Ms, GPart);
		NXObject* Spline2jnXObject = splinecreatbypoint(Spline2jpoint, GPart);
		tag_t Spline2jTag = NULL_TAG;
		Spline2jTag = Spline2jnXObject->Tag();

		std::vector<NXOpen::Point* > Spline3jpoint;
		Spline3jpoint = RotZPoint(RInvolutePoint, thetaj,Ms, GPart);
		NXObject* Spline3jnXObject = splinecreatbypoint(Spline3jpoint, GPart);
		tag_t Spline3jTag = NULL_TAG;
		Spline3jTag = Spline3jnXObject->Tag();

		std::vector<NXOpen::Point* > Arc4jpoint;
		Arc4jpoint = RotZPoint(Addendumcirclepoint, thetaj,Ms, GPart);
		NXObject* Arc4jnXObject = arccreatthreepoint(Arc4jpoint, GPart);
		tag_t Arc4jTag = NULL_TAG;
		Arc4jTag = Arc4jnXObject->Tag();

		std::vector<NXOpen::Point* > Spline5jpoint;
		Spline5jpoint = RotZPoint(LInvolutePoint, thetaj,Ms, GPart);
		NXObject* Spline5jnXObject = splinecreatbypoint(Spline5jpoint, GPart);
		tag_t Spline5jTag = NULL_TAG;
		Spline5jTag = Spline5jnXObject->Tag();

		std::vector<NXOpen::Point* > Spline6jpoint;
		Spline6jpoint = RotZPoint(LTransitionpoint, thetaj,Ms, GPart);
		NXObject* Spline6jnXObject = splinecreatbypoint(Spline6jpoint, GPart);
		tag_t Spline6jTag = NULL_TAG;
		Spline6jTag = Spline6jnXObject->Tag();

		std::vector<NXOpen::Point* > Arc7jpoint;
		Arc7jpoint = RotZPoint(LDedendumcirclepoint, thetaj,Ms, GPart);
		NXObject* Arc7jnXObject = arccreatthreepoint(Arc7jpoint, GPart);
		tag_t Arc7jTag = NULL_TAG;
		Arc7jTag = Arc7jnXObject->Tag();

		addarctosection(Arc1jnXObject, section1, Arc1jTag, helpPoint1, GPart);
		addsplinetosection(Spline2jnXObject, section1, Spline2jTag, helpPoint1, GPart);
		addsplinetosection(Spline3jnXObject, section1, Spline3jTag, helpPoint1, GPart);
		addarctosection(Arc4jnXObject, section1, Arc4jTag, helpPoint1, GPart);
		addsplinetosection(Spline5jnXObject, section1, Spline5jTag, helpPoint1, GPart);
		addsplinetosection(Spline6jnXObject, section1, Spline6jTag, helpPoint1, GPart);
		addarctosection(Arc7jnXObject, section1, Arc7jTag, helpPoint1, GPart);
	}

	NXOpen::Point* HalfholepointS= pointcreat({ Holediameter / 2,0.0,0.0}, GPart);
	NXOpen::Point* HalfholepointE = pointcreat({ -Holediameter / 2, 0.0,0.0 }, GPart);
	NXOpen::Point* HalfholepointM1 =pointcreat({0.0, Holediameter / 2,0.0 }, GPart);
	NXOpen::Point* HalfholepointM2 = pointcreat({ 0.0,-Holediameter / 2,0.0 }, GPart);

	std::vector<NXOpen::Point* > Halfhole1point;
	Halfhole1point.push_back(HalfholepointE);
	Halfhole1point.push_back(HalfholepointS);
	Halfhole1point.push_back(HalfholepointM1);
	
	NXOpen::NXObject* HolenXObject1 = arccreatthreepoint(Halfhole1point, GPart);
	tag_t HoleTag1 = NULL_TAG;
	HoleTag1 = HolenXObject1->Tag();
	addarctosection(HolenXObject1, section1, HoleTag1, helpPoint1, GPart);
	
	std::vector<NXOpen::Point* > Halfhole2point;
	Halfhole2point.push_back(HalfholepointS);
	Halfhole2point.push_back(HalfholepointE);
	Halfhole2point.push_back(HalfholepointM2);

	NXOpen::NXObject* HolenXObject2 = arccreatthreepoint(Halfhole2point, GPart);
	tag_t HoleTag2 = NULL_TAG;
	HoleTag2 = HolenXObject2->Tag();
	addarctosection(HolenXObject2, section1, HoleTag2, helpPoint1, GPart);
	
	extrudeBuilder1->SetParentFeatureInternal(false);
	NXOpen::Features::Feature* feature1;
	feature1 = extrudeBuilder1->CommitFeature();
	extrudeBuilder1->Destroy();
	
	// TODO: add your code here
	
}

//------------------------------------------------------------------------------
// Entry point(s) for unmanaged internal NXOpen C/C++ programs
//------------------------------------------------------------------------------
//  Explicit Execution
extern "C" DllExport void ufusr( char *parm, int *returnCode, int rlen )
{
    try
    {
		// Create NXOpen C++ class instance
		MyClass *theMyClass;
		theMyClass = new MyClass();
		theMyClass->do_it();
		delete theMyClass;
	}
    catch (const NXException& e1)
    {
		UI::GetUI()->NXMessageBox()->Show("NXException", NXOpen::NXMessageBox::DialogTypeError, e1.Message());
    }
	catch (const exception& e2)
    {
		UI::GetUI()->NXMessageBox()->Show("Exception", NXOpen::NXMessageBox::DialogTypeError, e2.what());
    }
	catch (...)
    {
		UI::GetUI()->NXMessageBox()->Show("Exception", NXOpen::NXMessageBox::DialogTypeError, "Unknown Exception.");
    }
}


//------------------------------------------------------------------------------
// Unload Handler
//------------------------------------------------------------------------------
extern "C" DllExport int ufusr_ask_unload()
{
	// Unloads the image when the application completes
	return (int)Session::LibraryUnloadOptionImmediately;	
	
}

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2284096.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

初阶数据结构:链表(二)

目录 一、前言 二、带头双向循环链表 1.带头双向循环链表的结构 &#xff08;1)什么是带头&#xff1f; (2)什么是双向呢&#xff1f; &#xff08;3&#xff09;那什么是循环呢&#xff1f; 2.带头双向循环链表的实现 &#xff08;1&#xff09;节点结构 &#xff08;2…

使用openwrt搭建ipsec隧道

背景&#xff1a;最近同事遇到了个ipsec问题&#xff0c;做的ipsec特性&#xff0c;ftp下载ipv6性能只有100kb, 正面定位该问题也蛮久了&#xff0c;项目没有用openwrt, 不过用了开源组件strongswan, 加密算法这些也是内核自带的&#xff0c;想着开源的不太可能有问题&#xff…

网络安全 | F5-Attack Signatures详解

关注&#xff1a;CodingTechWork 关于攻击签名 攻击签名是用于识别 Web 应用程序及其组件上攻击或攻击类型的规则或模式。安全策略将攻击签名中的模式与请求和响应的内容进行比较&#xff0c;以查找潜在的攻击。有些签名旨在保护特定的操作系统、Web 服务器、数据库、框架或应…

MATLAB绘图时线段颜色、数据点形状与颜色等设置,介绍

MATLAB在绘图时&#xff0c;设置线段颜色和数据点的形状与颜色是提高图形可读性与美观性的重要手段。本文将详细介绍如何在 MATLAB 中设置这些属性。 文章目录 线段颜色设置单字母颜色表示法RGB 值表示法 数据点的形状与颜色设置设置数据点颜色和形状示例代码 运行结果小结 线段…

论文速读|Matrix-SSL:Matrix Information Theory for Self-Supervised Learning.ICML24

论文地址&#xff1a;Matrix Information Theory for Self-Supervised Learning 代码地址&#xff1a;https://github.com/yifanzhang-pro/matrix-ssl bib引用&#xff1a; article{zhang2023matrix,title{Matrix Information Theory for Self-Supervised Learning},author{Zh…

FPGA工程师成长四阶段

朋友&#xff0c;你有入行三年、五年、十年的职业规划吗&#xff1f;你知道你所做的岗位未来该如何成长吗&#xff1f; FPGA行业的发展近几年是蓬勃发展&#xff0c;有越来越多的人才想要或已经踏进了FPGA行业的大门。很多同学在入行FPGA之前&#xff0c;都会抱着满腹对职业发…

计算机组成原理(2)王道学习笔记

数据的表示和运算 提问&#xff1a;1.数据如何在计算机中表示&#xff1f; 2.运算器如何实现数据的算术、逻辑运算&#xff1f; 十进制计数法 古印度人发明了阿拉伯数字&#xff1a;0&#xff0c;1&#xff0c;2&#xff0c;3&#xff0c;4&#xff0c;5&#xff0c;6&#…

简化配置与动态表达式的 Spring EL

1 引言 在现代软件开发中,配置管理和动态逻辑处理是构建灵活、可维护应用程序的关键。Spring 框架以其强大的依赖注入和面向切面编程功能而闻名,而 Spring Expression Language (Spring EL) 则为开发者提供了一种简洁且强大的方式来简化配置并实现动态表达式。 1.1 Spring …

python实现http文件服务器访问下载

//1.py import http.server import socketserver import os import threading import sys# 获取当前脚本所在的目录 DIRECTORY os.path.dirname(os.path.abspath(__file__))# 设置服务器的端口 PORT 8000# 自定义Handler&#xff0c;将根目录设置为脚本所在目录 class MyHTT…

在php中怎么打开OpenSSL

&#xff08;点击即可进入聊天助手&#xff09; 背景 在使用php做一些项目时,有用到用户邮箱注册等,需要开启openssl的能力 在php系统中openssl默认是关闭状态的,在一些低版本php系统中,有的甚至需要在服务器终端后台,手动安装 要打开OpenSSL扩展&#xff0c;需要进行以下步骤 …

二次封装的方法

二次封装 我们开发中经常需要封装一些第三方组件&#xff0c;那么父组件应该怎么传值&#xff0c;怎么调用封装好的组件原有的属性、插槽、方法&#xff0c;一个个调用虽然可行&#xff0c;但十分麻烦&#xff0c;我们一起来看更简便的方法。 二次封装组件&#xff0c;属性怎…

基于Springboot用axiospost请求接收字符串参数为null的解决方案

问题 ​ 今天在用前端 post 请求后端时发现&#xff0c;由于是以 Json对象的形式传输的&#xff0c;后端用两个字符串形参无法获取到对应的参数值 前端代码如下&#xff1a; axios.post(http://localhost:8083/test/postParams,{a: 1, b:2} ,{Content-Type: application/jso…

STM32 OLED屏配置

1.OLED简介 OLED&#xff08;Organic Light Emitting Diode&#xff09;&#xff1a;有机发光二极管 OLED显示屏&#xff1a;性能优异的新型显示屏&#xff0c;具有功耗低、相应速度快、宽视角、轻薄柔韧等特点 0.96寸OLED模块&#xff1a;小巧玲珑、占用接口少、简单易用&a…

DiffuEraser: 一种基于扩散模型的视频修复技术

视频修复算法结合了基于流的像素传播与基于Transformer的生成方法&#xff0c;利用光流信息和相邻帧的信息来恢复纹理和对象&#xff0c;同时通过视觉Transformer完成被遮挡区域的修复。然而&#xff0c;这些方法在处理大范围遮挡时常常会遇到模糊和时序不一致的问题&#xff0…

STM32完全学习——RT-thread在STM32F407上移植

一、写在前面 关于源码的下载&#xff0c;以及在KEIL工程里面添加操作系统的源代码&#xff0c;这里就不再赘述了。需要注意的是RT-thread默认里面是会使用串口的&#xff0c;因此需要额外的进行串口的初始化&#xff0c;有些人可能会问&#xff0c;为什么不直接使用CubMAX直接…

QT TLS initialization failed

qt使用QNetworkAccessManager下载文件&#xff08;给出的链接可以在浏览器里面下载文件&#xff09;&#xff0c;下载失败&#xff0c; 提示“TLS initialization failed”通常是由于Qt在使用HTTPS进行文件下载时&#xff0c;未能正确初始化TLS&#xff08;安全传输层协议&…

全面了解 Web3 AIGC 和 AI Agent 的创新先锋 MelodAI

不管是在传统领域还是 Crypto&#xff0c;AI 都是公认的最有前景的赛道。随着数字内容需求的爆炸式增长和技术的快速迭代&#xff0c;Web3 AIGC&#xff08;AI生成内容&#xff09;和 AI Agent&#xff08;人工智能代理&#xff09;正成为两大关键赛道。 AIGC 通过 AI 技术生成…

Golang之Context详解

引言 之前对context的了解比较浅薄&#xff0c;只知道它是用来传递上下文信息的对象&#xff1b; 对于Context本身的存储、类型认识比较少。 最近又正好在业务代码中发现一种用法&#xff1a;在每个协程中都会复制一份新的局部context对象&#xff0c;想探究下这种写法在性能…

VSCode+Continue实现AI辅助编程

Continue是一款功能强大的AI辅助编程插件&#xff0c;可连接多种大模型&#xff0c;支持代码设计优化、错误修正、自动补全、注释编写等功能&#xff0c;助力开发人员提高工作效率与代码质量。以下是其安装和使用方法&#xff1a; 一、安装VSCode 参见&#xff1a; vscode安…

Python 在Word中添加、或删除超链接

在Word文档中&#xff0c;超链接是一种将文本或图像连接到其他文档、网页或同一文档中不同部分的功能。通过添加超链接&#xff0c;用户可以轻松地导航到相关信息&#xff0c;从而增强文档的互动性和可读性。本文将介绍如何使用Python在Word中添加超链接、或删除Word文档中的超…