第五步,在button-click的消息响应函数create出feature
这一步的具体步骤和C#中完全一样的,大家也可以对比一下C++和C#NXOPEN的函数差异有多大。你可以看到基本上流程和函数都是一样的:
1。 先得到UG的session和workpart
2。 create feature builder
3。 set feature builder data
4。 commit feature。
void CtestdlgnBnClickedButton1()
{
// TODO: Add your control notification handler code here
//get ug session and display part
Session *theSession = Session::GetSession();
Part *workPart(theSession->GetParts()->GetWork());
Part *displayPart(theSession->GetParts()->GetDisplay());
//create feature builder
Featureseature *nullFeatures_Feature(NULL);
Features::BlockFeatureBuilder *blockFeatureBuilder1;
blockFeatureBuilder1 = workPart->GetFeatures()->CreateBlockFeatureBuilder(nullFeatures_Feature);
//set feature builder data
Point3d originPoint1(0.0, 0.0, 0.0);
blockFeatureBuilder1->SetOriginAndLengths(originPoint1, "100", "100", "100");
Body *nullBody(NULL);
blockFeatureBuilder1->SetBooleanOperationAndTarget(Featureseature::BooleanTypeCreate, nullBody);
//commit feature
Featureseature *feature1;
feature1 = blockFeatureBuilder1->CommitFeature();
}
呵呵,就很轻松的搞定了,是不是比以前简单了很多。 |