通过UI结合代码生成倒圆角功能,有成就感!
void selectedge::initialize_cb()
{
try
{
group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));
edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()- >FindBlock("edge_select0"));
expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()- >FindBlock("expression0"));}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());
}
}
int selectedge::apply_cb()
{
int errorCode = 0;
try
{
//---- Enter your callback code here -----
Session *theSession = Session::GetSession();
Part *workPart(theSession->Parts()->Work());
Part *displayPart(theSession->Parts()->Display());
Features::Feature *nullFeatures_Feature(NULL);
Features::EdgeBlendBuilder *edgeBlendBuilder1;
edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);
ScCollector *scCollector1;
scCollector1 = workPart->ScCollectors()->CreateCollector();
std::vector<Edge *> seedEdges;
std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects(); //获取选择的对象
for (int i=0;i<selectob.size();i++)
{
seedEdges.push_back(dynamic_cast<Edge*>(selectob));
}
double dia = expression0->Value(); //获取表达式的值
stringstream DIA;
DIA << dia;
EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;
edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);
std::vector<SelectionIntentRule *> rules1(1);
rules1 = edgeMultipleSeedTangentRule1;
scCollector1->ReplaceRules(rules1, false);
edgeBlendBuilder1->SetTolerance(0.001);
edgeBlendBuilder1->SetAllInstancesOption(false);
edgeBlendBuilder1->SetRemoveSelfIntersection(true);
edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);
edgeBlendBuilder1->SetLimitFailingAreas(true);
edgeBlendBuilder1->SetConvexConcaveY(false);
edgeBlendBuilder1->SetRollOverSmoothEdge(true);
edgeBlendBuilder1->SetRollOntoEdge(true);
edgeBlendBuilder1->SetMoveSharpEdge(true);
edgeBlendBuilder1->SetTrimmingOption(false);
edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);
edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);
edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);
int csIndex1;
csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());
Features::Feature *feature1;
feature1 = edgeBlendBuilder1->CommitFeature();
edgeBlendBuilder1->Destroy();
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
errorCode = 1;
selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
return errorCode;
}
说明:因为字数有限制,这里只贴出关键代码。
Great 如果我选择是一个实体,怎么自动将所有的边倒圆角呢? 遍历加判断
页:
[1]