概述
NX/UG二次开发——创建曲面偏置体
- 创建曲面偏置体
- 1.曲面偏置
创建曲面偏置体
这里介绍了一种对模型曲面进行偏置来获得偏置体的方法。
1.曲面偏置
void OffsetFace(tag_t face, tag_t* offset_body)//传入参数face是要进行偏置的面tag;offset_body是函数创建好后的偏置体tag,通过指针传参
{
NXOpen::Session *theSession = NXOpen::Session::GetSession();
NXOpen::Part *workPart(theSession->Parts()->Work());
NXOpen::Part *displayPart(theSession->Parts()->Display());
tag_t offset_feat;
NXOpen::Features::Feature *nullNXOpen_Features_Feature(NULL);
NXOpen::Features::ThickenBuilder *thickenBuilder1;
thickenBuilder1 = workPart->Features()->CreateThickenBuilder(nullNXOpen_Features_Feature);
thickenBuilder1->SetTolerance(0.01);
thickenBuilder1->FirstOffset()->SetFormula("2.5");//2.5是第一个方向的偏置量,可以按需求修改。需要注意的是,如果曲面偏置量过大可能会因为曲面曲率问题报错。
thickenBuilder1->SecondOffset()->SetFormula("0");//0是第二个方向的偏置量,可以按需求修改
thickenBuilder1->BooleanOperation()->SetType(NXOpen::GeometricUtilities::BooleanOperation::BooleanTypeCreate);
std::vector<NXOpen::Body *> targetBodies1(1);
NXOpen::Body *nullNXOpen_Body(NULL);
targetBodies1[0] = nullNXOpen_Body;
thickenBuilder1->BooleanOperation()->SetTargetBodies(targetBodies1);
thickenBuilder1->RegionToPierce()->SetDistanceTolerance(0.01);
thickenBuilder1->RegionToPierce()->SetChainingTolerance(0.0094999999999999998);
NXOpen::SelectionIntentRuleOptions *selectionIntentRuleOptions1;
selectionIntentRuleOptions1 = workPart->ScRuleFactory()->CreateRuleOptions();
selectionIntentRuleOptions1->SetSelectedFromInactive(false);
std::vector<NXOpen::Face *> faces1(1);
NXOpen::Face *face1(dynamic_cast<NXOpen::Face *>(NXOpen::NXObjectManager::Get(face)));
faces1[0] = face1;
NXOpen::FaceDumbRule *faceDumbRule1;
faceDumbRule1 = workPart->ScRuleFactory()->CreateRuleFaceDumb(faces1, selectionIntentRuleOptions1);
delete selectionIntentRuleOptions1;
std::vector<NXOpen::SelectionIntentRule *> rules1(1);
rules1[0] = faceDumbRule1;
thickenBuilder1->FaceCollector()->ReplaceRules(rules1, false);
NXOpen::NXObject *nXObject1;
nXObject1 = thickenBuilder1->Commit();
NXOpen::Expression *expression1(thickenBuilder1->SecondOffset());
NXOpen::Expression *expression2(thickenBuilder1->FirstOffset());
offset_feat = thickenBuilder1->GetObject()->Tag();
thickenBuilder1->Destroy();
UF_MODL_ask_feat_body(offset_feat, offset_body);
}
最后
以上就是靓丽鲜花为你收集整理的NX/UG二次开发创建曲面偏置体创建曲面偏置体的全部内容,希望文章能够帮你解决NX/UG二次开发创建曲面偏置体创建曲面偏置体所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复