马上注册登录,享用更多网站功能!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
经过几个月的业余学习,对OPEN C和NXOPEN C++作了对比,发现NX OPEN C++十分实用,通过UG内置的日志录取功能,可以很快速的找到功能的实现方法,结合BlockUI开发的界面,很容易的实现UG二次开发功能。
由于工作中要对一个移动面与固定的多个面进行重复布尔相交运算,并获取相交后的相交面的面积的功能,BlockUI 界面和布尔运算函数和求面积的函数都已经完成。但在获取相交面的过程中出现问题,根据布尔相交提交的结果,获取的NXObject * 对象,不能获取相交平面。(由于进行布尔运算相交的面的数量比较多,如果都通过遍历来得到相交面,我想效率是十分低的,所以放弃了), 但想想通过OPEN C 的UF_MODL_intersect_bodies_with_retained_options 命令都能轻松的获取tag_t 标识,为什么NX OPEN C++ 就这么困难呢? 这个问题纠结了我1个星期。
希望NX OPEN C++ 高手指点一下,如何获取布尔交后的Body *或Face *,感激不尽。
附上我自己做的实现布尔交和获取面积的函数。
Session *theSession = Session::GetSession();
Part *workPart(theSession->Parts()->Work());
//--------------------布尔交运算函数(保留目标和刀具)-----------------------
void bool_inter(Body* body01,Body* body02)
{
Features::BooleanFeature *nullFeatures_BooleanFeature(NULL);
Features::BooleanBuilder *booleanBuilder1;
booleanBuilder1 = workPart->Features()->CreateBooleanBuilderUsingCollector(nullFeatures_BooleanFeature);
ScCollector *scCollector1;
scCollector1 = booleanBuilder1->ToolBodyCollector();
booleanBuilder1->SetTolerance(0.001);
booleanBuilder1->SetCopyTargets(true);
booleanBuilder1->SetCopyTools(true);
booleanBuilder1->SetOperation(Features::Feature::BooleanTypeIntersect);
bool added1;
added1 = booleanBuilder1->Targets()->Add(body01);
ScCollector *scCollector2;
scCollector2 = workPart->ScCollectors()->CreateCollector();
std::vector<Body *> bodies1(1);
bodies1[0] = body02;
BodyDumbRule *bodyDumbRule1;
bodyDumbRule1 = workPart->ScRuleFactory()->CreateRuleBodyDumb(bodies1);
std::vector<SelectionIntentRule *> rules1(1);
rules1[0] = bodyDumbRule1;
scCollector2->ReplaceRules(rules1, false);
booleanBuilder1->SetToolBodyCollector(scCollector2);
NXObject *nXObject1;
nXObject1 = booleanBuilder1->Commit();
booleanBuilder1->Destroy();
}
//--------------------获取面的面积-----------------------
void area(Face* face01,double* AreaResult)
{
Unit *unit1(dynamic_cast<Unit *>(workPart->UnitCollection()->FindObject("SquareMilliMeter")));
Unit *unit2(dynamic_cast<Unit *>(workPart->UnitCollection()->FindObject("MilliMeter")));
std::vector<IParameterizedSurface *> objects1(1);
objects1[0] = face01;
MeasureFaces *measureFaces1;
measureFaces1 = workPart->MeasureManager()->NewFaceProperties(unit1, unit2, 0.99, objects1);
AreaResult [0] = measureFaces1->Area();
delete measureFaces1;
}
|