PLM之家精品课程培训

PLM之家精品课程培训

联系电话:18301858168   |   QQ咨询:939801026
NX二次开发培训

NX二次开发培训

UFUN/NXOpen C++和实战案例

适合初级入门或想深入了解二次开发的工程师,本培训结合ufun,NXOpen C++,大量的实例及官方内部的开发技术。
公众号二维码

关注公众号

点击扫描二维码免费在线高清教程

课程详情
Catia二次开发培训

Catia二次开发培训

市场需求大,掌握核心技术前景广阔

Catia二次开发的市场需求大,人才稀缺。掌握开发技能潜力巨大,随着经验积累将在汽车、航空等领域有所作为。
B站二维码

在线原创B站视频

点击关注工业软件传道士主页

课程详情
Teamcenter培训

Teamcenter培训

全方位培训,从基础应用到高级开发全覆盖

涵盖用户应用基础培训、管理员基础培训、管理员高级培训及二次开发培训等全方位内容,由多年经验讲师打造。
QQ群二维码

加入同行交流

点击扫描二维码加入QQ群

课程详情
×

PLM之家plmhome公众号

课程涵盖: PLM之家所有原创视频

×

关注B站视频

所有高清视频一览无余,全部在线播放学习

×

加入PLM之家QQ群

同行交流,疑问解答,更多互助

PLM之家PLMHome-国产软件践行者

NXOpen C++ CAM二次开发:获取workpiece的所有几何Tag值

[复制链接]

2018-8-23 08:32:50 4687 0

admin 发表于 2018-8-23 08:32:50 |阅读模式

admin 楼主

2018-8-23 08:32:50

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

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

x

% W3 D2 E; K2 @$ @' B# [$ L) TNXOpen C++ CAM二次开发:获取workpiece的所有几何Tag值
3 A: s9 o8 C0 @; i9 d4 ~5 |& x# L) h3 i. O2 G  i
; o, v# K: r% c& c8 f' y/ u9 E  `
static void do_it(void)
5 J6 \+ a# _) m# h; h, S' E{) W% g, C5 e$ _  I# N) A
    logical is_initialized;
# L6 l( S0 C( m( L    int object_count;- T! x, A# y( Y8 H; V
    int type;
& K: f; w  f! E/ ~, i) S( {    int subtype;
3 r2 t/ h  [4 s4 O    tag_t *objects;
) f+ j' O9 U. r/ I4 a8 x) n5 }! m+ k" e

. w9 _: v: m+ M. v3 y
7 |) R. P, q1 G( D& T9 h
/ M7 F3 U$ w/ g. M/ B
    char mesg[133];  v2 _$ E8 }0 U/ j" E
+ v8 n, F/ v6 D  H3 {9 u3 H' t3 D1 T

$ R# F+ b% M; o1 Q    // Get the work part
% }# C, W& r5 f# }    Session *theSession = Session::GetSession();
) t; u. B+ Q% ]% U  E) }4 @# O    Part *workPart(theSession->Parts()->Work());6 W6 o) l- `6 w" [; F& K; @0 H
    Part *displayPart(theSession->Parts()->Display());
& r  q* ~* A! F; a4 @9 a, ]
. w, N' r8 j, K' M$ w
( o% L8 g  A" l4 ?" Q% N7 y- O0 @

$ l% W$ p, u3 z8 q

/ L8 S. w: f/ O; n  ?1 p# A    if (UF_CALL(UF_CAM_is_session_initialized(&is_initialized)) || (is_initialized == FALSE)) return;6 Z5 h8 Q6 S5 `7 X/ Q; G
2 W1 t% m% m) a9 @# C

1 p5 [- Z$ W7 h: m& G    /* Get selected WORKPIECE object in ONT */
9 v7 p9 \' ^* j  c; i4 }    UF_CALL(UF_UI_ONT_ask_selected_nodes( &object_count, &objects ));9 O: P* J# \' n, m4 f6 S% u

  x) N) ~7 J" h$ ^
+ q0 v3 @/ y" E+ e$ W

8 H  J' g6 A) i; J+ o* G
* j2 d; u$ W$ x/ L8 d* `7 p6 I
    if (object_count == 1) {5 {7 m+ L0 {* F7 c5 n+ ^6 j/ j
        UF_CALL(UF_OBJ_ask_type_and_subtype (objects[0],&type,&subtype));
. u: I2 y$ I+ }( Y0 G
/ r+ C! n9 o! D% s& U
. o0 d) a, Y* ]5 z# N3 t0 r, o

- R/ D4 r; S' Y. p
8 x1 R6 X- c# |* t
        if ((type == UF_machining_geometry_grp_type) && (subtype == UF_mill_geom_featr_subtype) ) {
8 h& {) o7 ]( G) g
( W4 s0 Y) O( x8 a8 P6 g$ t
3 Y2 i8 j, L6 d; h
            tag_t ObjectTag = NULL_TAG;: a- J+ \; q2 f& T* h
, O/ S4 V- N& U8 e8 N& V& U
8 k; G* |0 O" m7 ]* N; D
            // Get the object from the WORKPIECE tag
. t# u+ F* `1 W9 U0 f. e            CAM::FeatureGeometry *WP = (CAM::FeatureGeometry *)NXObjectManager::Get(objects[0]);2 o9 S- d, q( g- q4 j0 z$ S
9 ~; S% i+ x4 a0 o8 v! x0 w' r; t6 e9 Y

0 W  Q( a* K& d' P9 k4 }            CAM::MillGeomBuilder *millGeomBuilder1;" @/ [6 W* u; w: q; ~* \$ a$ O$ N
            millGeomBuilder1 = workPart->CAMSetup()->CAMGroupCollection()->CreateMillGeomBuilder(WP);7 E! E1 Z! L& s* p

9 A8 j* E0 e( {/ y4 O
5 X3 f% L6 B9 W1 |/ C: X8 o
            // Get geometry set list
3 j' D! S8 |) {* f" O* |1 _            CAM::GeometrySetList *pGeomSetList = millGeomBuilder1->PartGeometry()->GeometryList();! z8 i# \3 m# t! V8 @4 R, `9 K. [0 \
            std::vector<CAM::GeometrySet*> geomSetVec = pGeomSetList->GeTContents();2 e, n9 D: L3 o
+ M1 M  @% R' Q0 E$ n' A
0 ]9 X; \# @' x7 a1 f4 Y
            // get geometry set
+ B* Q0 s2 @: q0 \2 P            std::vector<CAM::GeometrySet*>::iterator iter;4 L# n3 L; K3 }8 v
            for ( iter=geomSetVec.begin(); iter != geomSetVec.end(); iter++ ). k4 _+ I, Y6 D% L
            {
  j' B3 A/ @- O+ f                CAM::GeometrySet* geomSet = dynamic_cast<CAM::GeometrySet*>(*iter);
8 \( y( c: r  j! }                ScCollector *scCollector = geomSet->ScCollector();            * O; T  k5 ]2 ?6 w$ X1 N6 l
                std::vector<SelectionIntentRule*> rules;
. W' I2 A' k& u                scCollector->GetRules(rules);
7 F% x4 X; k; t( |" `0 ~2 _' R5 u$ S& d! N+ f
7 _5 k. C0 z, Q0 ^3 ~) Z
                //get selection rule( @7 I& k5 u+ p
                std::vector<SelectionIntentRule*>::iterator ruleIter;
, \4 h7 t. S1 M. q, R  D% E                for ( ruleIter=rules.begin(); ruleIter != rules.end(); ruleIter++ )
% u; `- V3 R* i4 U/ k0 e                {
8 l* r1 \. k$ k: @2 a. Z                    SelectionIntentRule* selRule = dynamic_cast<SelectionIntentRule*>(*ruleIter);) J5 J8 _% y5 y: w# r
                    NXOpen::SelectionIntentRule::RuleType ruleType = selRule->Type();$ I: n7 d" N# \5 n
                    //there are different rule types, here just use body, face as sample
" p, B# P2 M# q; C. f! P: m                    switch ( ruleType )" ?( f& H. `" [% R; v1 V6 Y
                    {
6 D$ c/ N! T( }2 i: W7 b                        case NXOpen::SelectionIntentRule::RuleTypeBodyDumb:5 Z0 [/ K* n1 ?
                        {) `2 W) R, d5 H2 E. t; ~5 @, a
                            //get bodies ; E* P# o" ?0 i
                            NXOpen::BodyDumbRule *bodyRule = dynamic_cast<BodyDumbRule*>(selRule);5 g5 b, z. V# o- w
                            std::vector<Body*> bodies;
$ \) A! w+ ?0 _- l                            bodyRule->GetData(bodies);
* u: `* |1 r; n1 i6 ?; z- a: [                            std::vector<Body*>::iterator bIter;
6 Z. g" H/ |& x. x( h8 _! C                            int index = 1;* G" l9 j. q+ [6 ~: e
                            for (bIter=bodies.begin(); bIter!=bodies.end(); bIter++ )
) @5 B0 o+ T7 c. v* h" ~                            {
, P! s3 n4 ^. H" m- t3 _7 |0 {                                Body* body = dynamic_cast<Body*>(*bIter);
- z. g' W& N' P% b0 R* E8 M                                ObjectTag = body->GetTag();
, y; l& W3 c8 [2 B# k& E                                sprintf(mesg,"the geometry object type is body, the index is %d and the tag is %d\n",index, ObjectTag);                                ' W1 }  `8 e6 ~. |
                                WRITE(mesg);# a8 F( m: v' R) }, i, L
                                body->Highlight();7 |7 L- m0 X" M) V
                                index++;
- |; S. ~& e9 }  z# Y                            }
5 ?* P3 @$ t* J1 B0 m+ M                        }& d2 s: Q% I, V& k* Z. N1 K
                        break;: |, w6 A7 j( r0 |# A* F
8 N$ ?9 w9 u1 @+ }

! [8 [% P# w' j& A* X2 t                        case NXOpen::SelectionIntentRule::RuleTypeFaceDumb:
1 M3 t; o1 e, T6 N. [+ ?2 ~1 W                        {
% R  E) g% U4 V/ \                            //get faces
/ A1 n7 ~, F6 }$ q/ g$ a+ Z                            NXOpen::FaceDumbRule *faceRule = dynamic_cast<FaceDumbRule*>(selRule);5 Z$ B& y. f$ u% K. o6 f7 z
                            std::vector<Face*> faces;1 h" s" |; R$ D: r$ Y
                            faceRule->GetData(faces);
8 R8 _3 Z9 J2 X                            std::vector<Face*>::iterator fIter;- `. i" i% ?1 ^5 ]* `9 J3 w4 g
                            int index = 1;6 y- \% q$ _! s* N  K7 v" O( X
                            for (fIter=faces.begin(); fIter!=faces.end(); fIter++ )
' n" F$ e7 W" o+ b  e                            {
( |: _/ u$ b8 y7 K2 i                                Face* face = dynamic_cast<Face*>(*fIter);  Y: ~! u0 U: p
                                ObjectTag = face->GetTag();
7 ^. }4 w/ M% y8 ^1 S3 H7 }4 X                                sprintf(mesg,"the geometry object type is face, the index is %d and the tag is %d\n",index, ObjectTag);                                - t$ {* q) O/ I! E: O. o
                                WRITE(mesg);: \. |& J9 ~# ~1 O2 \
                                index++;7 a, r. S: ?3 e" d( i) p# d) I
                            }2 k8 b. j* f* z, P7 O
                        }
% T% e" V, x, \/ X/ T9 x                        break;
; S& k; U* c% K- B
, M' B4 z$ O/ U

% _% B7 d; c( b6 d                    default:( W. Q4 \  a! p; c6 @
                        break;# F' y7 q9 w0 b9 }+ F& `" W  Q: w8 z
                    }
5 Q) h+ ~  {0 w! _8 {  }( a+ \                }
0 k+ r- y" V# N& I4 P7 Z2 E+ n            }
2 N, D' s, _1 R5 G
) H' F7 j8 n. K! u& ?, ^# x

8 K( L8 a: B$ _7 b' z3 y. \' ]
5 `% m/ z, h- X/ P4 L

! I  Y& h' P5 {# G& g+ u3 Y  w9 I, L, w9 X" L+ s: s
. W2 r9 Q- w/ t, Y* {0 q2 a
            millGeomBuilder1->Destroy();+ V, B7 D$ C& U+ i) ]
" g$ t7 i1 X( x- G& t; O2 |+ \

' o# R2 D: ~' o        } else {5 L; D! C; v6 ~- I  B5 c
            WRITE("type is not UF_machining_geometry_grp_type");, `! n* K) ^" F9 i
            WRITE(" or UF_mill_geom_featr_subtype");, s! {4 j: ?2 K6 s5 L
        }3 F" b# K. j/ B% ^
        UF_free(objects);
; S- N. ]  |* g5 b7 m/ P' ?2 _
9 n0 i& S* M% N7 o
+ Q1 C' p  X3 t
    } else {
' c0 a) U6 _) R3 x8 N        WRITE("The number of selected objects in ONT must be 1.");
! H' \1 w3 a- ^  a& ^    }
) u! D' G6 G( T% _/ L4 a) l% m4 x( i, }# V7 @6 R+ L

! d7 F1 p) h0 n4 m# U2 X4 j! n* P# _}/ `* _6 S2 G3 n$ N: P
  m# `& L+ h& X# l- \
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复

使用道具 举报

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

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

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

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

    我知道了