|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
【PLM之家-NX9.0二次开发实例视频】8 Open C++ 对象选择功能
8 u8 ~" o) Y7 J B' R- B. K- Z& E& r. V5 z# [
4 b: f' w" k9 k7 @& P, ` o
内容:使用NXOpen 创建一个单选feature的功能,并输出选择feature的名称和类型!, q* X1 s4 n' `1 T1 ~. D( z: p
目的:熟悉使用Selection类功能!
& j9 i5 p) C% r0 N+ u( X
8 Open C++ 对象选择功能
, c9 z: m% f) m9 D* k
! ]) ^9 A& e% N" C7 n7 {6 C
8 V) w# b# _ C1 q: M7 q; k
5 I' D5 x @9 X' v# E: f. K" s: ^' _5 t7 K* \4 Q
Session *theSession = Session::GetSession();
- T* D8 h9 P- v) z9 r UI *theUI = UI::GetUI();2 \% b6 k- K8 m1 Y+ U* w2 s
// selection feature
+ q' |) C3 P; Z% n# M( o! Y( j5 V char *message = "select a feature";2 U- {. C. d+ f* E% x; x- B8 G
char *title = "single select ";7 C, V' F. K9 l& _; \. N/ A9 F0 B
Selection::SelectionScope scope = Selection::SelectionScopeWorkPart;, Q: a, J6 J* q1 R
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
6 i* T0 r! U& M2 v: {" R5 Q7 n# \7 f std::vector< NXOpen::Selection::MaskTriple > maskTriple(1);
3 x8 A/ _9 j% j- c Selection::MaskTriple mask1;
7 `% T5 U ~7 y. {6 ` mask1.Type =UF_feature_type;9 |8 I5 r; V2 f6 ~2 f" c2 w6 c
mask1.Subtype = UF_feature_subtype;
* e' W: X1 S9 d" L5 m8 Y. ~7 z' U mask1.SolidBodySubtype = 0;- `, f2 Y5 g0 ~' F' a: t( G
maskTriple.push_back(mask1);
/ C$ D# F1 s$ g! J6 {+ W9 g TaggedObject *object;
7 Q% I; W+ i) i% z6 Z Point3d cursor;
/ C; s3 ]% M0 v6 G Selection::Response res;, z" H" O% o% }0 l* Y3 R
res = theUI->SelectionManager()->SelectTaggedObject(message,title,scope,action,true,false,maskTriple,&object,&cursor);
/ N3 ^5 R- r* V, w if(Selection::ResponseObjectSelected == res)
7 Z9 M6 N- R/ E) C/ _7 e {6 f8 _) q$ Q/ r) c) h
Features::Feature *selectedFeature = dynamic_cast<Features::Feature*>(object);
; c, e$ f, @# _5 Y' Q9 r+ z theSession->ListingWindow()->Open();
+ r6 c% E3 A# c }* K& b& c8 Z3 n theSession->ListingWindow()->WriteLine("the slected feature name is:\n");; e1 {3 R1 d* R& J( ^* h- E& {; P
theSession->ListingWindow()->WriteLine(selectedFeature->GetFeatureName());
9 c! D# f" t6 A' h, o; d theSession->ListingWindow()->WriteLine("the slected feature Type is:\n");
- U3 y W) ?1 { A" x0 | theSession->ListingWindow()->WriteLine(selectedFeature->FeatureType());
3 T$ z p; S$ H2 Q( i. a: E$ j theSession->ListingWindow()->Close(); }1 T) o) ]2 V1 g( O8 [! ]( b
- E- i: f' P3 f! B! {$ `; o1 ^
}) P y5 E& F, j/ ?
9 k" T, d0 U. U
|
|