PLM之家NX 发表于 2014-5-5 22:45:05

UG NX二次开发源码分享: NX Open C++ 创建投影曲线 project curves




UG NX二次开发源码分享: NX Open C++ 创建投影曲线 project curves

此处使用的是 通过面的法向创建投影曲线,可以参考下!











int trimSteels::project_curves(vector<TaggedObject *>inputObjects,Plane *plane1)
{
        int errorCode = 0;
        try
        {
                // createProject curves

                Features::Feature *nullFeatures_Feature(NULL);

                Features::ProjectCurveBuilder *projectCurveBuilder1;

                projectCurveBuilder1 = workPart->Features()->CreateProjectCurveBuilder(nullFeatures_Feature);

                projectCurveBuilder1->SectionToProject()->SetDistanceTolerance(DISTANCETOLERANCE);

                projectCurveBuilder1->SectionToProject()->SetChainingTolerance(CHAININGTOLERANCE);

                projectCurveBuilder1->SectionToProject()->SetAngleTolerance(ANGLETOLERANCE);

                projectCurveBuilder1->SectionToProject()->SetAllowedEntityTypes(Section::AllowTypesOnlyCurves);

                projectCurveBuilder1->CurveFitData()->SetTolerance(DISTANCETOLERANCE);

                projectCurveBuilder1->CurveFitData()->SetAngleTolerance(ANGLETOLERANCE);

                int size = (int)inputObjects.size();
                std::vector<IBaseCurve *> curves1;
                for (int ii = 0 ; ii < size; ++ii)
                {
                        curves1.push_back(dynamic_cast<IBaseCurve*>(inputObjects));
                }

                NXOpen::CurveDumbRule *curveDumbRule1;

                curveDumbRule1 = workPart->ScRuleFactory()->CreateRuleBaseCurveDumb(curves1);

                projectCurveBuilder1->SectionToProject()->AllowSelfIntersection(true);

                std::vector<SelectionIntentRule *> rules1(1);
                rules1 = curveDumbRule1;
                NXObject *nullNXObject(NULL);
                Point3d helpPoint1(0, 0, 0);
                projectCurveBuilder1->SectionToProject()->AddToSection(rules1, nullNXObject, nullNXObject, nullNXObject, helpPoint1, Section::ModeCreate, false);

                plane1->Evaluate();

                projectCurveBuilder1->SetPlaneToProjectTo(plane1);

                projectCurveBuilder1->SetGapOption(true);

                projectCurveBuilder1->CurveFitData()->SetCurveJoinMethod(GeometricUtilities::CurveFitData::JoinGeneral);

                NXObject *nXObject1;
                nXObject1 = projectCurveBuilder1->Commit();

                projectCurveBuilder1->SectionToProject()->CleanMappingData();

                projectCurveBuilder1->Destroy();

        }
        catch(exception& ex)
        {
                //---- Enter your exception handling code here -----
                errorCode = 1;
                trimSteels::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
        }

        return errorCode;
}



希水长流 发表于 2014-5-15 17:18:05

创建完投影之后 如何能够获取投影曲线的指针呢?

希水长流 发表于 2014-5-15 17:54:14

版主 我找到接口了

593232280 发表于 2019-4-25 18:47:55

学习了,高手
页: [1]
查看完整版本: UG NX二次开发源码分享: NX Open C++ 创建投影曲线 project curves