点击查看详细介绍

OPEN C++对面的类型进行判断,并针对不同的面进行颜色设置-代码示例

nxopen 11年前 7108 25

购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008  QQ号:85585969  


通过OPEN C++迭代查找当前工作部件下,所有的实体表面,对面的类型进行判断,针对不同的面,进行颜色设置

以下是核心代码:

static void changeColor(std::vector<NXOpen::DisplayableObject *>displayobjects,int color)

{ Session *theSession = Session::GetSession();

//Part *workPart = theSession->Parts()->Work();

DisplayModification *displaymodification = theSession->DisplayManager()->NewDisplayModification();

displaymodification->ApplyToAllFaces();

displaymodification->SetNewColor(color);

displaymodification->Apply(displayobjects);

delete displaymodification;

}

static void do_UGopen_api()

{

Session *theSession = Session::GetSession();

Part *workPart = theSession->Parts()->Work();

BodyCollection *bc = workPart->Bodies();

ListingWindow *lw = theSession->ListingWindow();

int cylindercount=0,plannarcount = 0 ;

vector<DisplayableObject*> cylinderfaces;

vector<DisplayableObject*> plannarfaces;

// get the body then to get the faces


●●●请先 登陆注册 后查看●●●

{

Body *body = (*it);

// get faces

std::vector<Face*> faces = body->GetFaces();

for(int j =0 ; j <faces.size();j++)

{

Face *face = faces[j];

if ( face->SolidFaceType()==Face::FaceTypeCylindrical)

{

cylindercount++;

cylinderfaces.push_back(dynamic_cast<DisplayableObject*>(face));

}

if( face->SolidFaceType()==Face::FaceTypePlanar)

{

plannarcount++;

plannarfaces.push_back(dynamic_cast<DisplayableObject*>(face));

}

}

}

// change color

changeColor(cylinderfaces,186);

changeColor(plannarfaces,6);

lw->Open();

char msg[133];

sprintf(msg,"The Cylinder faces count is :%d\n",cylindercount);

lw->WriteLine(msg);

sprintf(msg,"The Plannar faces count is :%d\n",plannarcount);

lw->WriteLine(msg);

}

//核心代码结束

3

最新回复 (25)
  • kevin 11年前
    1

    我要银元啊,发表回复有奖励!

  • 木易三世 11年前
    2

    我没钱看,怎么获得银元呢?

  • 风中劲草 11年前
    3

    寻找着呢 刚刚好啊 多谢楼主了

  • 风中劲草 11年前
    4

    没看清原来是NXOPEN,不是UF

  • eisuou 11年前
    5

    很好的内容,只是没有钱,怎么看那

  • limingmc 10年前
    6

    学习 了顶!!!!!

  • limingmc 10年前
    7

    正有这个需要 呵呵 谢谢了

  • xl137731 10年前
    8

    正有这个需要 呵呵 谢谢了

  • yangshizhan 10年前
    9

    这个要看看是不是对我有用的东西

  • 88hwp 10年前
    10

    謝謝大大用心的整理

  • hare_yan 10年前
    11

    这个要看看是不是对我有用的东西

  • gczg VIP会员 10年前
    12

    谢谢楼主, 谢谢楼主,

  • wfliuhuiping 9年前
    13

    我看看看很好

  • jimk 9年前
    14

    謝謝大大用心的整理

  • application 9年前
    15

    顶顶顶顶顶

请登录后发表新帖