zoukankan      html  css  js  c++  java
  • NXOpen测量方位器Z方向到面的投影距离

    C++

    //得到面的TAG
    PropertyList *selection0Props = selection0->GetProperties();
    std::vector<NXOpen::TaggedObject*> theselection = selection0Props->GetTaggedObjectVector("SelectedObjects");
    delete selection0Props;
    selection0Props = NULL;
    tag_t faceTAG = theselection[0]->Tag();

    //测量manip0原点到面的距离
    NXObject *nullNXObject(NULL);
    MeasureDistanceBuilder *measureDistanceBuilder1;
    measureDistanceBuilder1 = workPart->MeasureManager()->CreateMeasureDistanceBuilder(nullNXObject);
    measureDistanceBuilder1->SetMtype(MeasureDistanceBuilder::MeasureTypeMinimum);//创建,类型为最近距离

    Point3d p1 = manip0->Origin();//获取manip0原点
    Vector3d manip0X = manip0->XAxis(); //获取方位器的X方向
    Vector3d manip0Y = manip0->YAxis(); //获取方位器的Y方向

    double ufun_X[3] = { manip0X.X, manip0X.Y, manip0X.Z }; //方位器X轴Vector3d类型转double型
    double ufun_Y[3] = { manip0Y.X, manip0Y.Y, manip0Y.Z }; //方位器Y轴Vector3d类型转double型
    double ufun_Z[3]; //定义ufun_Z轴
    UF_VEC3_cross( ufun_X, ufun_Y, ufun_Z ); //通过叉乘求Z轴
    Vector3d manip0Z ( ufun_Z[0], ufun_Z[1], ufun_Z[2] ); //Z轴double型转Vector3d


    NXOpen::Point3d Point1XYZ(p1.X,p1.Y,p1.Z);//创建点
    NXOpen::Point *p2 = workPart->Points()->CreatePoint(Point1XYZ);//Point3d转Point
    measureDistanceBuilder1->Object1()->SetValue(p2);//设置第一个对像
    Face *face1(dynamic_cast<Face *>(NXOpen::NXObjectManager::Get(theselection[0]->Tag())));
    measureDistanceBuilder1->Object2()->SetValue(face1);

    NXOpen::MeasureDistance *measureDistance1;
    Direction *direction1;
    direction1 = workPart->Directions()->CreateDirection(p1, manip0Z, SmartObject::UpdateOptionAfterModeling);
    measureDistance1 = workPart->MeasureManager()->NewDistance(NULL,p2, face1, direction1, MeasureManager::ProjectionTypeMinimum);//创建距离
    Distance = measureDistance1->Value();//获得距离
    delete measureDistance1;//释放measureDistance1
    measureDistanceBuilder1->Destroy();//释放measureDistanceBuilder1

    char msg[256];
    sprintf_s(msg, "%f", Distance);
    theSession->ListingWindow()->Open();
    theSession->ListingWindow()->WriteLine(msg);

    怡宁塑胶模具设计
  • 相关阅读:
    数据库连接字符串
    搭建消息队列
    Linux---江湖
    Bundle压缩JS和CSS
    DDD分层架构之仓储
    UI控件库
    图解Http协议 url长度限制
    JAVA jdbc(数据库连接池)学习笔记(转)
    领域驱动设计(DDD)部分核心概念的个人理解(转)
    怎样的中奖算法能让人信服(转)
  • 原文地址:https://www.cnblogs.com/hqsalanhuang/p/14217089.html
Copyright © 2011-2022 走看看