zoukankan      html  css  js  c++  java
  • 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());
        }

    怡宁塑胶模具设计
  • 相关阅读:
    2019年6月英语四六级试题及答案和视频教程
    经典解压缩软件 WinRAR 5.90 sc 官方去广告版
    会动的边框
    萌萌达机器人
    背景图片跟随鼠标动
    烟花代码
    常用正则表达式
    计算器
    顶部下啦菜单
    ps用画笔工具设计水墨圆环
  • 原文地址:https://www.cnblogs.com/hqsalanhuang/p/14441944.html
Copyright © 2011-2022 走看看