NXOpenc++创建块布尔运算并设图层

更新时间:2023-06-13 00:15:23 阅读: 评论:0

//创建杯头
结香Features::Feature *null_cylinder_feature(NULL);
Features::CylinderBuilder *cylinderBuilder;
cylinderBuilder = workPart->Features()->CreateCylinderBuilder(null_cylinder_feature);
cylinderBuilder->Height()->SetRightHandSide(kk1);
cylinderBuilder->Diameter()->SetRightHandSide(dd2);
cylinderBuilder->SetOrigin(point2);
cylinderBuilder->SetDirection(vec);
Features::Feature *feature1;
feature1 = cylinderBuilder->CommitFeature();
cylinderBuilder->Destroy();
/
/创建顶针杆
Features::CylinderBuilder *cylinderBuilder1;
cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(null_cylinder_feature);
cylinderBuilder1->BooleanOption()->SetType(NXOpen::GeometricUtilities::BooleanOperation::BooleanTypeUnite);
Features::BodyFeature* bodyFeat = dynamic_cast<Features::BodyFeature *>(feature1);
std::vector<NXOpen::Body *> bodies = bodyFeat->GetBodies();//feature to body
cylinderBuilder1->BooleanOption()->SetTargetBodies(bodies);
cylinderBuilder1->Height()->SetRightHandSide(lengh1);
cylinderBuilder1->Diameter()->SetRightHandSide(dia);
cylinderBuilder1->SetOrigin(point2);
cylinderBuilder1->SetDirection(vec);
Features::Feature *feature2;
feature2=cylinderBuilder1->CommitFeature();
cylinderBuilder1->Destroy();
Features::BodyFeature* bodyFeat1 = dynamic_cast<Features::BodyFeature *>(feature2);
std::vector<NXOpen::Body *> bodies1 = bodyFeat1->GetBodies();//feature to body(vector)
NXOpen::Body *body1=dynamic_cast<NXOpen::Body *>(bodies1[0]); //从vector中转出body
int enumValue2 = this->enum01->GetProperties()->GetEnum("Value");//获得顶针杯头是否需要定位
if (enumValue2==1)
{
double d3,d4;
d3=(d2-d1)/2-0.6;
d4=d2*2;
char sd[256],sd1[256];
sprintf(sd,"%f",d3);
sprintf(sd1,"%f",d4);
NXOpen::Features::Feature *nullNXOpen_Features_Feature(NULL);
NXOpen::Features::BlockFeatureBuilder *blockFeatureBuilder1= workPart->Features()->CreateBlockFeatureBuilder(nullNXOpen_Features_Feature);
NXOpen::Point3d originPoint1(point2.X+d1/2+0.6, point2.Y-(d2/2),point2.Z-k1);
blockFeatureBuilder1->SetOriginAndLengths(originPoint1, sd, sd1,kk1);
NXOpen::Features::Feature *feature3;
feature3 = blockFeatureBuilder1->CommitFeature();
blockFeatureBuilder1->Destroy();
Features::BodyFeature* bodyFeat2 = dynamic_cast<Features::BodyFeature *>(feature3);
std::vector<NXOpen::Body *> bodies2 = bodyFeat2->GetBodies();//feature to body(vector)
NXOpen::Features::BooleanFeature *nullNXOpen_Features_BooleanFeature(NULL);
NXOpen::Features::BooleanBuilder *booleanBuilder1;
booleanBuilder1 = workPart->Features()->CreateBooleanBuilderUsingCollector(nullNXOpen_Features_BooleanFeature);
booleanBuilder1->SetOperation(NXOpen::Features::Feature::BooleanTypeSubtract);
NXOpen::Body *body2=dynamic_cast<NXOpen::Body *>(
bodies2[0]);//从vector中转出body
booleanBuilder1->SetTarget(body1);//加入目标体
booleanBuilder1->SetTool(body2);//加入工具体
NXOpen::NXObject *nXObject1;
nXObject1 = booleanBuilder1->Commit();
booleanBuilder1->Destroy();
}
你是我心中的太阳//设置顶针颜色
NXOpen::DisplayModification *displayModification1;
displayModification1 = theSession->DisplayManager()->NewDisplayModification();
displayModification1->SetNewColor(36);
std::vector<NXOpen::DisplayableObject *> objects1(1);
objects1[0] = body1;
displayModification1->Apply(objects1);
delete displayModification1;
/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//设置图层
NXString str = this->string0->Value();//获得顶针图层
int layer=atoi(str.GetText());
std::vector<NXOpen::DisplayableObject *> objectArray1(1);
objectArray1[0] = body1;
workPart->Layers()->MoveDisplayableObjects(layer, objectArray1);
//图层设为可见
std::vector<NXOpen::Layer::StateInfo> stateArray1(1);
stateArray1[0] = NXOpen::Layer::StateInfo(layer, NXOpen::Layer::StateSelectable);
workPart->Layers()->ChangeStates(stateArray1, fal);
/
/////////////////////////////////////////////////////////////////////////////////////////////
//创建假体,创建杯头
//////////////////////////////////////////////////////////////////////////////////////////////
double a1=d2+1;
double b1;
if (d1<4)
{
b1=d1+0.5;
}
el b1=d1+1;
double f1=expDouble-20;
char diam1[120],diam2[120],lengh2[120];
sprintf(diam1,"%f",a1);
sprintf(diam2,"%f",b1);
sprintf(lengh2,"%f",f1);
//创建假体,创建顶针杆
Features::CylinderBuilder *cylinderBuilder3;
cylinderBuilder3 = workPart->Features()->CreateCylinderBuilder(null_cylinder_feature);
cylinderBuilder3->Height()->SetRightHandSide(lengh2);
cylinderBuilder3->Diameter()->SetRightHandSide(diam2);
cylinderBuilder3->SetOrigin(point2);
cylinderBuilder3->SetDirection(vec);
Features::Feature *jfeature2;
jfeature2=cylinderBuilder3->CommitFeature();
cylinderBuilder3->Destroy();
Features::BodyFeature* jbodyFeat1 = dynamic_cast<Features::BodyFeature *>(jfeature2);
std::vector<NXOpen::Body *> jbodies1 = jbodyFeat1->GetBodies();//feature to body(vector)
NXOpen::Body *jbody1=dynamic_cast<NXOpen::Body *>(jbodies1[0]); //从vector中转出body
Features::Feature *jfeature4;
if (enumValue2==1) //创建有定位的杯头假体
{
double jd3;
jd3=(d2/2+d1/2)+0.6;
double rd;
char jsd[256];
作业君sprintf(jsd,"%f",jd3);
double bie1;
if (d2<10)
{
bie1=((d2-d1)/2+0.6+d1)*2;//假体Y轴长度
rd=jd3/2;
}
el if (d2>=10 && d2<14)
{
bie1=d2+3;//假体Y轴长度
rd=2.5;
}
el if (d2>=14&& d2<20)
{
bie
1=d2+3;//假体Y轴长度
rd=3.5;
}
el if (d2>=20)
{齐云山风景区
bie1=d2+3;//假体Y轴长度
rd=4.5;
}
char radius[100];
sprintf(radius,"%f",rd); //倒角半径
char zhifu[100];
sprintf(zhifu,"%f%,%f%,%f",jsd,bie1,kk1);
NXOpen::Features::Feature *nullNXOpen_Features_Feature(NULL);
NXOpen::Features::BlockFeatureBuilder *blockFeatureBuilder2= workPart->Features()->CreateBlockFeatureBuilder(nullNXOpen_Features_Feature);
NXOpen::Point3d originPoint2(point2.X-d2/2, point2.Y-bie1/2,point2.Z-k1);
blockFeatureBuilder2->SetOriginAndLengths(originPoint2, jsd, zhifu,kk1);
NXOpen::Features::Feature *jfeature3;
jfeature3 = blockFeatureBuilder2->CommitFeature();
blockFeatureBuilder2->Destroy();
Features::BodyFeature* jbodyFeat2 = dynamic_cast<Features::BodyFeature *>(jfeature3);
std::vector<NXOpen::Body *> jbodies2 = jbodyFeat2->GetBodies();//feature to body(vector)
NXOpen::Body *jbody2=dynamic_cast<NXOpen::Body *>(jbodies2[0]);//从vector中转出body
//给所有竖直边倒角
std::vector<Edge*> edges = jbody2->GetEdges();//获得实体对象上所有的边
double vertxPoint1[3],vertxPoint2[3];
int vertxCount;
uf_list_t *verticalEdges = NULL;
UF_MODL_create_list(&verticalEdges);
tag_t blendFeatureTag = NULL_TAG;
for (int m=0;m<edges.size();m++)
{
UF_MODL_ask_edge_verts(edges[m]->Tag(),vertxPoint1,vertxPoint2,&vertxCount);//获得边的顶点
if (vertxPoint1[0] == vertxPoint2[0]&&vertxPoint1[1] == vertxPoint2[1]&& vertxPoint1[2] != vertxPoint2[2] )//获得竖直边
{
UF_MODL_put_list_item(verticalEdges,edges[m]->Tag());
}
}
UF_MODL_create_blend(radius,verticalEdges,0,0,0,0.001,&blendFeatureTag);
//假体求和
NXOpen::Features::BooleanFeature *nullNXOpen_Features_BooleanFeature(NULL);
NXOpen::Features::BooleanBuilder *booleanBuilder2;
booleanBuilder2 = workPart->Features()->CreateBooleanBuilderUsingCollector(nullNXOpen_Features_BooleanFeature);
booleanBuilder2->SetOperation(NXOpen::Features::Feature::BooleanTypeUnite);
booleanBuilder2->SetTarget(jbody1);//加入目标体
booleanBuilder2->SetTool(jbody2);//加入工具体
jfeature4 = booleanBuilder2->CommitFeature();
booleanBuilder2->Destroy();
}
el if (enumValue2==0)//无定位的杯头
{
Features::CylinderBuilder *cylinderBuilder4;
cylinderBuilder4 = workPart->Features()->CreateCylinderBuilder(null_cylinder_feature);香菜拌牛肉的做法
cylinderBuilder4->Height()->SetRightHandSide(kk1);
cylinderBuilder4->Diameter()->SetRightHandSide(diam1);
cylinderBuilder4->SetOrigin(point2);
cylinderBuilder4->SetDirection(vec);
女志全部
Features::Feature *jfeature3;
jfeature3=cylinderBuilder4->CommitFeature();
cylinderBuilder4->Destroy();
Features::BodyFeature* jbodyFeat3 = dynamic_cast<Features::BodyFeature *>(jfeature3);
表白送什么花
std::vector<NXOpen::Body *> jbodies3 = jbodyFeat3->GetBodies();//feature to body(vector)
NXOpen::Body *jbody2=dynamic_cast<NXOpen::Body *>(jbodies3[0]); //从vector中转出body
NXOpen::Features::BooleanFeature *nullNXOpen_Features_BooleanFeature(NULL);
NXOpen::Features::BooleanBuilder *booleanBuilder2;
booleanBuilder2 = workPart->Features()->CreateBooleanBuilderUsingCollector(nullNXOpen_Features_BooleanFeature);
booleanBuilder2->SetOperation(NXOpen::Features::Feature::BooleanTypeUnite);
booleanBuilder2->SetTarget(jbody1);//加入目标体
booleanBuilder2->SetTool(jbody2);//加入工具体
jfeature4 = booleanBuilder2->CommitFeature();
booleanBuilder2->Destroy();
}
//将假体特征转换成实体,为设置颜色作准备
Features::BodyFeature* jbodyFeat_color = dynamic_cast<Features::BodyFeature *>(jfeature4);
腰背肌功能锻炼std::vector<NXOpen::Body *> jbodies_color = jbodyFeat_color->GetBodies();//feature to body(vector)
NXOpen::Body *jbody_color=dynamic_cast<NXOpen::Body *>(jbodies_color[0]);//从vector中转出body
//设置顶针假体颜色
NXOpen::DisplayModification *displayModification2;
displayModification2 = theSession->DisplayManager()->NewDisplayModification();
displayModification2->SetNewColor(186);
std::vector<NXOpen::DisplayableObject *> objects2(1);
objects2[0] = jbody_color;
displayModification2->Apply(objects2);
delete displayModification2;

本文发布于:2023-06-13 00:15:23,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/940935.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:假体   获得   创建   顶针   杯头   设置   加入   颜色
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图