admin 发表于 2014-4-13 11:27:48

UG NX二次开发旋转特征代码分享



UG NX二次开发旋转特征代码分享

如何使用NX二次开发进行旋转

void lesson33_createRevolve::createRevolve(Sketch *sketch)
{
       Features::Feature *nullFeatures_Feature(NULL);

    Features::RevolveBuilder *revolveBuilder1;
    revolveBuilder1 = workPart->Features()->CreateRevolveBuilder(nullFeatures_Feature);
        revolveBuilder1->SetTolerance(0.001);
    Section *section1;
    section1 = workPart->Sections()->CreateSection(0.00095, 0.001, 0.05);
    revolveBuilder1->SetSection(section1);
    std::vector<Features::Feature *> features1(1);
        features1 = sketch->Feature();
    CurveFeatureRule *curveFeatureRule1;
    curveFeatureRule1 = workPart->ScRuleFactory()->CreateRuleCurveFeature(features1);
    std::vector<SelectionIntentRule *> rules1(1);
    rules1 = curveFeatureRule1;
    NXObject *nullNXObject(NULL);
    Point3d helpPoint1(0, 0, 0);
    section1->AddToSection(rules1, nullNXObject, nullNXObject, nullNXObject, helpPoint1, Section::ModeCreate, false);
    revolveBuilder1->SetSection(section1);
        // get UI value
        vector<TaggedObject*> selectedObjects = this->axis0->GetProperties()->GetTaggedObjectVector("SelectedObjects");
        Axis *axis1 = dynamic_cast<Axis *>(selectedObjects);
        revolveBuilder1->SetAxis(axis1);
        double startValue = this->expStartAngle->GetProperties()->GetDouble("Value");
        double endValue = this->expStartAngle1->GetProperties()->GetDouble("Value");
       stringstream s_startValue,s_endValue;
       s_startValue <<startValue;
       s_endValue <<endValue;
       revolveBuilder1->Limits()->StartExtend()->Value()->SetRightHandSide(s_startValue.str());
       revolveBuilder1->Limits()->EndExtend()->Value()->SetRightHandSide(s_endValue.str());
    Features::Feature *feature1;
    feature1 = revolveBuilder1->CommitFeature();
        revolveBuilder1->Destroy();
        section1->Destroy();
}


页: [1]
查看完整版本: UG NX二次开发旋转特征代码分享