AlexeyN2
Newbie | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Здравствуйте. Есть задача написать программу на С++, которая будет скруглять 3 сплайна. Код отладил, ошибок и предупреждений не выдает, делает dll-ку, но в UG NX5 сплайны рисует, но не скругляет. В чем дело? Вот код: #ifdef WIN32 #define USE_MFC #endif #ifdef USE_MFC #include <afxdlgs.h> #include <afx.h> #endif #include <NXOpen/Session.hxx> #include <NXOpen/Part.hxx> #include <NXOpen/PartCollection.hxx> #include <NXOpen/Point.hxx> #include <NXOpen/PointCollection.hxx> #include <NXOpen/Curve.hxx> #include <NXOpen/Spline.hxx> #include <NXOpen/Sketch.hxx> #include <NXOpen/SketchCollection.hxx> #include <NXOpen/NXObjectManager.hxx> #include <NXOpen/Arc.hxx> #include <NXOpen/CurveCollection.hxx> #include <Ug_spline.hxx> #include <fstream> /***************************************************************************** ** Activation Methods *****************************************************************************/ /* Explicit Activation ** This entry point is used to activate the application explicitly, as in ** "File->Execute UG/Open->User Function..." */ extern DllExport void ufusr( char *parm, int *returnCode, int rlen ) { int i; bool is_periodic=false; // double param[5]; /* Initialize the API environment */ int errorCode = UF_initialize(); NXOpen::Session *theSession = NXOpen::Session::GetSession(); NXOpen::Part *workPart = theSession->Parts()->Work(); if ( workPart == NULL ) workPart = theSession->Parts()->NewDisplay("File2Points", NXOpen::Part::UnitsMillimeters); const UgObject* part_or_obj=UgSession::getWorkPart(); int N=5; double delta; std::vector <double> knots(9); delta = 1.0/((double)(N-4+1)); for(i = 0; i < 4; i++) knots[i]=0; for(i = 4; i < N ; i++) knots[i] = (i-4+1)*delta; for(i = N; i < N + 4; i++) knots[i] = 1; std::vector <Point4> points4(5); std::vector <Point4> points4_1(5); std::vector <Point4> points4_2(5); for(i = 0; i < N ; i++) points4[i] = Point4::Point4(i,i,i,1); for(i = 0; i < N ; i++) points4_1[i] = Point4::Point4(0.2*i,0,0,1); for(i = 0; i < N ; i++) points4_2[i] = Point4::Point4(i+0.8,i,i,1); UgSpline *spline=UgSpline::create(4,knots,points4,part_or_obj); UgSpline *spline1=UgSpline::create(4,knots,points4_1,part_or_obj); UgSpline *spline2=UgSpline::create(4,knots,points4_2,part_or_obj); NXOpen::Spline *s1 = (NXOpen::Spline*)NXOpen::NXObjectManager::Get(spline->getTag()); NXOpen::Spline *s2 = (NXOpen::Spline*)NXOpen::NXObjectManager::Get(spline1->getTag()); NXOpen::Spline *s3 = (NXOpen::Spline*)NXOpen::NXObjectManager::Get(spline2->getTag()); NXOpen::Point3d p1(0,0,0); NXOpen::Point3d p2(0.8,0,0); NXOpen::Point3d p3(0.8,0,0); NXOpen::Point *point1; point1 = workPart->Points()->CreatePoint(p1); NXOpen::Point *point2; point2 = workPart->Points()->CreatePoint(p2); NXOpen::Point *point3; point3 = workPart->Points()->CreatePoint(p3); std::vector <NXOpen::SketchConstraint*> c; double rad=1; NXOpen::Sketch *s; NXOpen::SketchCollection *sc; sc=workPart->GetSketches(); s=sc->GetOwningSketch(s2); std::vector <NXOpen::Arc *> Fillet1=s->Fillet( s1,s2,s3, p1,p2,p3, rad, NXOpen::Sketch::TrimInputOptionTrue, NXOpen::Sketch::DeleteThirdCurveOptionTrue, NXOpen::Sketch::CreateDimensionOptionTrue, NXOpen::Sketch::AlternateSolutionOptionTrue, c); /* Terminate the API environment */ errorCode = UF_terminate(); } extern int ufusr_ask_unload( void ) { return(UF_UNLOAD_IMMEDIATELY); } |