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());
        }

    怡宁塑胶模具设计
  • 相关阅读:
    LeetCode 42. Trapping Rain Water
    LeetCode 209. Minimum Size Subarray Sum
    LeetCode 50. Pow(x, n)
    LeetCode 80. Remove Duplicates from Sorted Array II
    Window10 激活
    Premiere 关键帧缩放
    AE 「酷酷的藤」特效字幕制作方法
    51Talk第一天 培训系列1
    Premiere 视频转场
    Premiere 暴徒生活Thug Life
  • 原文地址:https://www.cnblogs.com/hqsalanhuang/p/14441944.html
Copyright © 2011-2022 走看看