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

    怡宁塑胶模具设计
  • 相关阅读:
    webstorm 2017 激活破解
    落在纸上的思考
    Mysql数据库备份脚本
    asp.net c# 打开新页面或页面跳转
    转正专业考试
    关于mysql-5.7.23-winx64.msi的安装
    win server 2012 R2 你需要先安装 对应于 KB2919355 的更新
    零碎
    按钮
    猪猪公寓——冲刺第一天
  • 原文地址:https://www.cnblogs.com/hqsalanhuang/p/14441944.html
Copyright © 2011-2022 走看看