PLM之家PLMHome-工业软件践行者

[二次开发源码] 教你如何通过NXOpen C++通过session 找part,part找body,body找face...

[复制链接]

2014-3-18 16:55:13 3492 0

2470

主题

1275

回帖

8万

积分

管理员

PLM之家站长

积分
82162
QQ
发表于 2014-3-18 16:55:13 | 显示全部楼层 |阅读模式

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x
The examples show how to access the following relationships:
* ?# Q) T3 V2 Z& U/ V
  • NX session → list of parts
  • part → list of solid bodies
  • solid body → list of faces
    solid body → list of edges
  • face → list of associated edges
    face → solid body
  • edge → list of associated faces
    edge → solid body

    $ Y1 u3 e1 l2 ]/ C
7 e! A0 U0 z! X6 @. I! Y! {0 a; F
Bodies, Faces and Edges - Language Specific Details$ j1 }- C6 H$ A. S# r% r: }4 \# r
NX Open for C++
NX Open for .NET
NX Open for Java
1 {4 N( \% G& v3 y

5 Z* j2 Y9 \1 Q" n3 l$ @& _1 cNX Open for C++" }$ ]6 L- @, H8 T) ^+ C

* X  g  I/ W) R8 F% l9 }% P( T& W2 O5 d; K4 h2 j( t
NX session → list of parts
! i2 W% C- e2 ]2 X2 R5 w- I+ ?
To access all parts in an NX session, use the Parts property to access the Part Collection.  Then use the collection's iterator to access each part.
  Session *NXSession = Session::GetSession();   ParTCollection *partList = NXSession->Parts();  PartCollection::iterator itr;  for ( itr = partList->begin(); itr != partList->end(); ++itr )  {   processPart(*itr);  }
' I( L; K+ l) |" x3 h$ i  c% o0 B
- M4 Q' V; s5 }* R/ y$ j1 bpart → list of solid bodies7 z2 J& L" a1 v# o0 d5 E
To access all solid bodies in a part, use the Bodies property to access the Body Collection. Then use the collection's iterator to access each body.
void processPart(Part *partObject){   BodyCollection *bodyList = partObject->Bodies();   BodyCollection::iterator itr;   for (itr = bodyList->begin(); itr != bodyList->end(); ++itr)   {    processBodyFaces(*itr);    processBodyEdges(*itr);   }}$ m5 p# [  z) ~* v2 n" s. T
' b% g7 Q4 a+ z6 K0 a2 `- Q
solid body → list of faces3 ^  }7 C/ G, B& J8 ~: h+ g* Q2 S
To access the faces of a body use the GetFaces() method to return an array of faces.
void processBodyEdges(Body *bodyObject){    std::vector <Edge *> edgeArray = bodyObject->GetEdges();    for (int inx = 0;  inx < (int)edgeArray.size(); ++inx)          {                        processEdge(edgeArray[inx]);          }}
" o# K0 Q# q% R1 O4 t3 L. R9 B2 o$ b5 v1 T, j4 o5 X* C& s
solid body → list of edges
1 \2 H4 Y4 ~$ Z& d/ Z) x6 W: H$ J
To access the edges in a body use the GetEdges() method to return an array of edges.
void processBodyEdges(Body *bodyObject){    std::vector <Edge *> edgeArray = bodyObject->GetEdges();    for (int inx = 0;  inx < (int)edgeArray.size(); ++inx)    {    processEdge(edgeArray[inx]);    }} / D# h) t' t: ?- F$ U5 s, G' J

3 O. }6 B6 t* m- e; zface → list of associated edges
) N; H# c, f5 O. v: b! {2 ^, Q2 M' oface → solid body
8 v9 g& _5 G  L* H  A% w; i( A8 @
To access the edges for a face use the GetEdges() method to return an array of edges. To access the face's body use the GetBody() method.
void processFace(Face *faceObject){        std::vector<Edge *> edgeArray = faceObject->GetEdges();        for (int inx = 0;  inx < (int)edgeArray.size(); ++inx)        {                processEdge(edgeArray[inx]);        }        Body *bodyOfFace = faceObject->GetBody();} " s: T2 C+ Q* |* `; e+ V
6 G1 H! c* E9 b" b* _2 l
edge → list of associated faces* E8 N; ^: J2 ^" `. w
edge → solid body+ N& S+ I0 a- N
To access the faces associated with and edge use the GetFaces() method to return an array of faces. To access the edge's body use the GetBody() method.
void processEdge(Edge *edgeObject){        std::vector<Face *> faceArray = edgeObject->GetFaces();        for (int inx = 0;  inx < (int)faceArray.size(); ++inx)        {                processEdgeFace(faceArray[inx]);        }        Body *bodyOfEdge = edgeObject->GetBody();}
5 _" G3 b# x4 A! v# ^# _
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了