admin 发表于 2018-6-20 18:50:29

NX二次开发源码分享: 创建 镜像 体


NX二次开发源码分享: 创建 镜像 体

默认的 JA 有个 bug,这里看看怎么处理的!!


int IR9027488::apply_cb()
{
    int errorCode = 0;
    try
    {
      // AIW - Begin
      tag_t body = selection0->GetSelectedObjects()->Tag();
      Plane *thePlane = dynamic_cast<Plane*>(plane0->GetSelectedObjects());

      NXOpen::Features::Feature *nullNXOpen_Features_Feature(NULL);
      NXOpen::Features::DatumPlaneBuilder *datumPlaneBuilder1;
      datumPlaneBuilder1 = theSession->Parts()->Work()->Features()->CreateDatumPlaneBuilder(nullNXOpen_Features_Feature);

      NXOpen::Plane *plane1;
      plane1 = datumPlaneBuilder1->GetPlane();

      plane1->SynchronizeToPlane(thePlane);// this is new in NX11.0.1
      plane1->Evaluate();

      NXOpen::Features::Feature *feature1;
      feature1 = datumPlaneBuilder1->CommitFeature();

      NXOpen::Features::DatumPlaneFeature *datumPlaneFeature1(dynamic_cast<NXOpen::Features::DatumPlaneFeature *>(feature1));
      NXOpen::DatumPlane *datumPlane1;
      datumPlane1 = datumPlaneFeature1->DatumPlane();

      tag_t mirror_feat;
      errorCode = UF_initialize();
      if (errorCode != 0) throw NXOpen::NXException::Create(errorCode);

      errorCode = UF_MODL_create_mirror_body(body, datumPlane1->Tag(), &mirror_feat);
      if (errorCode != 0) throw NXOpen::NXException::Create(errorCode);
      // AIW - End
    }
    catch(exception& ex)
    {
      //---- Enter your exception handling code here -----
      errorCode = 1;
      IR9027488::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
    }
    return errorCode;
}

licxsw 发表于 2020-9-26 21:49:38

为什么不能用OPEN 直接做镜像 需要赚UF呢?代码中OPen的作用是用来获取基准面吗?
页: [1]
查看完整版本: NX二次开发源码分享: 创建 镜像 体