|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
【PLM之家-NX9.0二次开发实例视频】8 Open C++ 对象选择功能
) b7 Q$ o! w9 ^( i) L5 u& j3 O
c [8 M% F: b' N$ I2 Q; s) [" O2 q/ v z9 V# \ r
内容:使用NXOpen 创建一个单选feature的功能,并输出选择feature的名称和类型!
8 Y0 W$ T1 S1 v8 c- H1 x目的:熟悉使用Selection类功能!
# ^' \8 K, Y, L M P
8 Open C++ 对象选择功能
- y* |8 A# s1 z! c+ ^5 ^6 c" x+ s* O- F
8 I1 p$ z# q4 J# Q _, G, T
. G5 o, l B( A. j/ ?* \" K: N: S$ J5 J* `3 L, k) u
Session *theSession = Session::GetSession();+ A, \3 q4 [7 D7 l; \
UI *theUI = UI::GetUI();
; ?8 N& u0 ]! E // selection feature
8 h$ z( i! f9 E( E3 P6 p char *message = "select a feature";
" Z) F; Z' v2 @: E; ], N/ }) T char *title = "single select ";
# r; T( \! m/ q+ v/ g/ E Selection::SelectionScope scope = Selection::SelectionScopeWorkPart;8 I; H9 J/ `0 U6 N
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;; m0 ^# G+ k) r) S9 k7 ?" T A
std::vector< NXOpen::Selection::MaskTriple > maskTriple(1);& ~: ^) ^( N5 j
Selection::MaskTriple mask1;
. y2 P/ B! C. G mask1.Type =UF_feature_type;! s& b! N( a1 j7 w7 V/ z6 E$ x
mask1.Subtype = UF_feature_subtype;
2 w/ {% b% c* D! v. O mask1.SolidBodySubtype = 0;
! I1 K/ P# }" u- X* p: ^) j maskTriple.push_back(mask1);5 s3 {" Y" P5 S0 { Z
TaggedObject *object;8 Y' L- y9 O. a" p5 n2 W
Point3d cursor;
6 D" D3 g1 i" y/ l1 ? Selection::Response res;
7 y0 l( M7 h/ N& s/ H" g$ L res = theUI->SelectionManager()->SelectTaggedObject(message,title,scope,action,true,false,maskTriple,&object,&cursor);
* d" O+ l9 N1 w if(Selection::ResponseObjectSelected == res)
0 F$ A1 K: F/ g4 H! k, X {
3 z4 C, [6 U6 S, _ s Features::Feature *selectedFeature = dynamic_cast<Features::Feature*>(object);8 p' b* h) s, _3 q) q% E) R
theSession->ListingWindow()->Open();! }. {! }7 `2 Z0 e, f5 Z q
theSession->ListingWindow()->WriteLine("the slected feature name is:\n");
5 b4 ~8 y+ Y+ i# a theSession->ListingWindow()->WriteLine(selectedFeature->GetFeatureName());! U+ P2 c1 f. b
theSession->ListingWindow()->WriteLine("the slected feature Type is:\n");
' ?9 @4 Y. r$ e. @ theSession->ListingWindow()->WriteLine(selectedFeature->FeatureType());: S2 H; r& M7 _, G2 l9 ?4 I c1 v. M
theSession->ListingWindow()->Close(); }3 M0 M3 x" w# @" n+ K/ j/ J
3 H4 B5 m/ Y& t& ^. t/ a( T' q8 m5 ?: p+ q0 s
% V/ s6 Z# v/ n# o |
|