购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008 QQ号:85585969
使用NXOpen创建螺旋线的函数代码

以下对NXOpen录制的代码进行封装了函数,只需要提供4个参数就可以创建。
4个参数分别为:
string strVal[5] 5个字符串数组分别为:角度、直径、螺距、起始、终止
double origin[3] 螺旋线的原点位置
double xd[3] 螺旋线的X方向
double yd[3] 螺旋线的Y方向
使用方法:
string strVal[5]={"0","8.5","56","0","285"};
double origin[3] = { 0.0, 0.0, 0.0 };
double xd[3] = { 1.0, 1.0, 0.0 };
double yd[3] = { 0.0, 1.0, 0.0 };
tag_t helicalTag = CreateHelical(strVal, origin, xd, yd);
返回的 helicalTag 就是最后创建好的螺旋线的TAG。
函数代码:
tag_t MyClass::CreateHelical(string strVal[5], double origin[3], double xDirection[3], double yDirection[3])
{
Session *theSession = Session::GetSession();
Part *workPart(theSession->Parts()->Work());
Part *displayPart(theSession->Parts()->Display());
Features::Helix *nullFeatures_Helix(NULL);
Features::HelixBuilder *helixBuilder1;
helixBuilder1 = workPart->Features()->CreateHelixBuilder(nullFeatures_Helix);
helixBuilder1->SetOrientationOption(Features::HelixBuilder::OrientationOptionsSpecified);
helixBuilder1->StartAngle()->SetRightHandSide(strVal[0].c_str()); //角度
helixBuilder1->SizeLaw()->Value()->SetRightHandSide(strVal[1].c_str()); //直径
helixBuilder1->PitchLaw()->Value()->SetRightHandSide(strVal[2].c_str());//螺距
helixBuilder1->StartLimit()->Expression()->SetRightHandSide(strVal[3].c_str());//起始
helixBuilder1->EndLimit()->Expression()->SetRightHandSide(strVal[4].c_str());//终止

●●●请先
登陆 或
注册 后查看●●●
helixBuilder1->SetCoordinateSystem(cartesianCoordinateSystem1);
NXObject *nXObject1;
nXObject1 = helixBuilder1->Commit();
helixBuilder1->Destroy();
return nXObject1->Tag();
}