• NXOpen创建基准座标


    C++   2010

    HPP

    //用户头文件
    #include <NXOpen/Part.hxx>
    #include <NXOpen/PartCollection.hxx>
    #include <NXOpen/CartesianCoordinateSystem.hxx>
    #include <NXOpen/CoordinateSystem.hxx>
    #include <NXOpen/CoordinateSystemCollection.hxx>
    #include <NXOpen/Features_DatumCsysBuilder.hxx>
    #include <NXOpen/Features_FeatureCollection.hxx>
    #include <NXOpen/Xform.hxx>
    #include <NXOpen/XformCollection.hxx>
    #include <NXOpen/Builder.hxx>
    #include <NXOpen/Features_DatumCsys.hxx>
    #include <NXOpen/Features_DatumCsysBuilder.hxx>
    #include <NXOpen/Features_FeatureCollection.hxx>

     //用户代码
     Features::Feature * datumCsysfeature1;//定义基准座标
     void createdatumCsys();//创建基准座标
     void editdatumCsys();//编辑基准座标
     Part *workPart;
     bool isdatumCsysCreated;

    CPP

      //用户代码
      datumCsysfeature1 = NULL;
      isdatumCsysCreated =false ;
      workPart =  theSession->Parts()->Work();

    //创建基准座标

    void CreateWCS::createdatumCsys()
    {
        try
        {
      if (isdatumCsysCreated)
            {
       editdatumCsys();//编辑基准座标
                return;
            }


      Features::Feature *nullFeatures_Feature(NULL);
       
      Features::DatumCsysBuilder *datumCsysBuilder1;
      datumCsysBuilder1 = workPart->Features()->CreateDatumCsysBuilder(nullFeatures_Feature);
       
      Point3d origin1 = manip0->Origin();
      Vector3d xDirection1 = manip0->XAxis();
      Vector3d yDirection1 = manip0->YAxis();
      Xform *xform1;
      xform1 = workPart->Xforms()->CreateXform(origin1, xDirection1, yDirection1, SmartObject::UpdateOptionWithinModeling, 1.0);
       
      CartesianCoordinateSystem *cartesianCoordinateSystem1;
      cartesianCoordinateSystem1 = workPart->CoordinateSystems()->CreateCoordinateSystem(xform1, SmartObject::UpdateOptionWithinModeling);
      
      datumCsysBuilder1->SetCsys(cartesianCoordinateSystem1);
       
      datumCsysBuilder1->SetDisplayScaleFactor(1.25);

      datumCsysfeature1 = datumCsysBuilder1->CommitFeature();
       
      datumCsysBuilder1->Destroy();

      isdatumCsysCreated = true ;

        }
        catch(exception& ex)
        {
            //---- Enter your exception handling code here -----
            CreateWCS::theUI->NXMessageBox()->Show("创建基准座标", NXOpen::NXMessageBox::DialogTypeError, ex.what());
        }
    }

    //编辑基准座标

    void CreateWCS::editdatumCsys()
    {
        try
        {
       
      Features::DatumCsys *datumCsys1(dynamic_cast<Features::DatumCsys *>(workPart->Features()->FindObject(datumCsysfeature1->JournalIdentifier())));

      Features::DatumCsysBuilder *datumCsysBuilder2 = workPart->Features()->CreateDatumCsysBuilder(datumCsys1);

      Point3d origin1 = manip0->Origin();
      Vector3d xDirection1 = manip0->XAxis();
      Vector3d yDirection1 = manip0->YAxis();
      Xform *xform1;
      xform1 = workPart->Xforms()->CreateXform(origin1, xDirection1, yDirection1, SmartObject::UpdateOptionWithinModeling, 1.0);
       
      CartesianCoordinateSystem *cartesianCoordinateSystem1;
      cartesianCoordinateSystem1 = workPart->CoordinateSystems()->CreateCoordinateSystem(xform1, SmartObject::UpdateOptionWithinModeling);
      
      datumCsysBuilder2->SetCsys(cartesianCoordinateSystem1);
       
      datumCsysBuilder2->SetDisplayScaleFactor(1.25);
       
      datumCsysfeature1 = datumCsysBuilder2->CommitFeature();
       
      datumCsysBuilder2->Destroy();


        }
        catch(exception& ex)
        {
            //---- Enter your exception handling code here -----
            CreateWCS::theUI->NXMessageBox()->Show("编辑基准座标", NXOpen::NXMessageBox::DialogTypeError, ex.what());
        }

    怡宁塑胶模具设计
  • 相关阅读:
    C# linq lambda 分组获取最新的数据
    C# SQLite datetime 时间比较查询
    .net core webApi 上传附件
    ①、Vue学习
    阿里云单片上传、断点续传,上传到指定文件夹下面
    php设计模式之策略模式
    composer安装laravel
    php全局配置
    windows系统安装composer
    php设计模式之工厂模式
  • 原文地址:https://www.cnblogs.com/hqsalanhuang/p/14441944.html
Copyright © 2020-2023  润新知