【NX二次开发】相切面封装函数(100米)

相切面,封装函数

 

 

 源码:

#include <NXOpen/Session.hxx>
#include <NXOpen/NXException.hxx>
#include <NXOpen/Session.hxx>
#include <NXOpen/UI.hxx>
#include <NXOpen/NXMessageBox.hxx>
#include <NXOpen/Callback.hxx>
#include <NXOpen/NXException.hxx>
#include <NXOpen/BlockStyler_UIBlock.hxx>
#include <NXOpen/BlockStyler_BlockDialog.hxx>
#include <NXOpen/BlockStyler_PropertyList.hxx>
#include <NXOpen/BlockStyler_Group.hxx>
#include <NXOpen/BlockStyler_FaceCollector.hxx>
#include <NXOpen/NXObjectManager.hxx>
#include <NXOpen/PartCollection.hxx>
#include <NXOpen/Face.hxx>
#include <NXOpen/FaceTangentRule.hxx>
#include <NXOpen/ScCollectorCollection.hxx>
#include <NXOpen/ScRuleFactory.hxx>

#include "me.hpp"

//输入一个面,输出所有相切面(包含输入的面)
int getTangentFace(tag_t tagFace,vector<tag_t> *vecTangentFace)
{
    NXOpen::Session *theSession = NXOpen::Session::GetSession();
    NXOpen::Part *workPart(theSession->Parts()->Work());
    NXOpen::Part *displayPart(theSession->Parts()->Display());

    NXOpen::Face *face1(dynamic_cast<NXOpen::Face *>(NXOpen::NXObjectManager::Get(tagFace)));

    //相切面规则
    std::vector<NXOpen::Face *> boundaryFaces1(0);
    NXOpen::FaceTangentRule *faceTangentRule1;
    faceTangentRule1 = workPart->ScRuleFactory()->CreateRuleFaceTangent(face1, boundaryFaces1, 0.01);
    std::vector<NXOpen::SelectionIntentRule *> rules1(1);
    rules1[0] = faceTangentRule1;

    NXOpen::ScCollector* scCollector1 = workPart->ScCollectors()->CreateCollector();
    scCollector1->ReplaceRules(rules1, false);

    std::vector<NXOpen::TaggedObject*> vecFaces = scCollector1->GetObjects();
    for (int i = 0; i < vecFaces.size(); i++)
    {
        (*vecTangentFace).push_back(vecFaces[i]->Tag());
    }
    return 0;
}


extern DllExport void ufusr(char *param, int *returnCode, int rlen)
{
    UF_initialize();
    
    tag_t tagFace = 68545;
    vector<tag_t> vecTangentFace;
    getTangentFace(tagFace,&vecTangentFace);
    for (int i = 0; i < vecTangentFace.size(); i++)
    {
        UF_OBJ_set_color(vecTangentFace[i], 6);
    }

    UF_terminate();
}

extern int ufusr_ask_unload(void)
{
    return (UF_UNLOAD_IMMEDIATELY);
}

 

帮助:

posted @ 2022-07-06 14:56  王牌飞行员_里海  阅读(59)  评论(0编辑  收藏  举报