|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
选择方式包括通过mask过滤,通过type选择,或者通过选择所有的对象。+ n5 `1 c- L) `3 @" y
, Z9 n& P! s; b' Y( K
/------------------------------------------------------------------------------; w" H8 w" a* P x, ]) a9 b" s" f5 v) x
// Selection with mask; ^, A1 [9 G, ^9 o+ D" v
//------------------------------------------------------------------------------
" i6 c8 S. x+ f4 W5 A7 N |TaggedObject* MyClass::select_by_mask()! r+ i$ o$ M" |
{
2 j# {5 B1 `3 x6 C) Y1 }, yNXString message("Select an object by mask:");
" X2 F7 @9 I3 _/ \NXString title("Select object");( Z5 Z3 X. M/ a" K, t
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;* R$ s9 O" }1 T
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
; F3 h) J, ^( l4 q9 nbool include_features = 0;$ @0 f4 R1 v+ K- E: P0 B0 Q3 P
bool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.
, T6 _( e4 h9 w( L, Z0 f/ C// Uncomment or combine the desired mask triples2 ?( L- D+ A0 f& v! ^7 |8 J5 W
std::vector<Selection::MaskTriple> maskArray(1);+ |4 z6 k7 e' J
maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_solid_body_subtype, 0 ); // Bodies( F4 w) Q( s, ~" p- Y7 ~
/*
( S% V2 z" b: T. J M9 X V6 CmaskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_FACE); // Faces
) ]! @, v( | m1 o( ?& imaskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_EDGE); // Edges
" e" _% W6 c7 @0 @maskArray[0] = Selection::MaskTriple( UF_component_type, 0, 0 ); // Components3 A, ~/ E. I- |' {$ B- O" `8 u5 R
maskArray[0] = Selection::MaskTriple( UF_line_type, 0, 0 ); // Lines6 H* x/ ]( U) h9 v
maskArray[0] = Selection::MaskTriple( UF_drafting_entity_type, 0, 0 ); // Drafting objects* _& w; ~3 s3 R6 _* R! N
*/
7 W2 O: _$ d+ jPoint3d cursor;& J# r* c& j7 U3 P9 R4 S
TaggedObject *object; // Select objects using filter defined by maskArray triples0 ?3 _! m$ ~; q1 A7 E% R
Selection::Response res = selmgr->SelectTaggedObject(
# o3 V' e% N/ a0 S; R- n$ v message, title, scope, action, include_features,) x4 |, [8 X( M
keep_highlighted, maskArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )& S# U1 _7 O# p" W- B. y
{
% J' c- N5 b% H4 q& O' H return object;
4 `# ^4 f1 m5 A! G$ i5 q}
% S, o) w) {) _( d. [return 0;) K; r7 L' C, J, |! E# |
}//------------------------------------------------------------------------------
9 v% S6 F( ^9 d$ F- \+ P// Selection with type array
5 N d; D, D6 [& r//------------------------------------------------------------------------------
1 U) b- |) _6 F, d6 A7 ]/ QTaggedObject* MyClass::select_by_type()5 m% y1 I% s8 z7 D' @# W
{
4 m o3 o. l+ J* dNXString message("Select an object by type:");3 [" P5 y1 i- `0 M4 b( m7 ]
NXString title("Select object");5 K+ m p' T# |5 ^( Q
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
% w: f& }$ r/ U* Qbool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.% W& _; g6 f! ]. L0 Y
// Uncomment or combine the desired types1 d3 C: Y* w$ W7 c) P7 b) ]
std::vector<Selection::SelectionType> typeArray(1);
* f! P" F9 g8 j T- B& D! CtypeArray[0] = Selection::SelectionTypeAll;" N( u' A+ i- r1 u7 L1 G0 D
/*
- }( R+ P4 {) W) V$ W3 p8 l" H" A5 jtypeArray[0] = Selection::SelectionTypeFeatures;5 K7 _3 B& u; d) J
typeArray[0] = Selection::SelectionTypeCurves;
7 U" N% h3 M) l5 j& `# |) JtypeArray[0] = Selection::SelectionTypeFaces;
) f% }* ], \- U" a6 EtypeArray[0] = Selection::SelectionTypeEdges;
: r, f$ i( A! s4 [, @4 d4 {; ]% A5 stypeArray[0] = Selection::SelectionTypeCurvesAndEdges;
& y$ b4 T- q4 w: Q: V*/! ?& }5 S+ ?* E
Point3d cursor;# s; a% r0 {; F3 W& _
TaggedObject *object; // Select objects using filter defined by type array( D5 d1 o7 S9 ?
Selection::Response res = selmgr->SelectTaggedObject(2 m3 V% T9 `8 A! |
message, title, scope, keep_highlighted,
! M. }" {8 D" @6 s6 _ typeArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )
4 j; u6 P* |! T3 [{; S0 U/ k+ h2 _5 W
return object;
Z# B' K3 V' j% L}
# h5 J+ F* O9 b, nreturn 0;
/ E4 B% x1 G) \}//------------------------------------------------------------------------------: I& P m% }( J, o3 p& _" t
// Selection any objects
' O% D8 r0 ?2 J: R) C+ T5 n//------------------------------------------------------------------------------
: ^1 O& D* n+ Q& u! Fstd::vector< NXOpen::TaggedObject * > MyClass::select_any_objects()
8 f1 |0 R, M, }4 y{, ^; H5 a1 G F( |' h
NXString message("Select any objects:");
9 Y5 [! Q+ l- o7 y6 D; [) e; ANXString title("Select objects");
( a- E, G2 N; {) h) j; LSelection::SelectionScope scope = Selection::SelectionScopeUseDefault;7 p. y1 f( L( {$ D& v1 N
bool include_features = 0; ! y( h- }- l7 }% Z. p
bool keep_highlighted = 0;. b3 _4 n! R% N/ N% A- Z
std::vector< NXOpen::TaggedObject * > objectArray; // Select any object array
7 H) N$ \. _3 C4 z" z/ R3 QSelection::Response res = selmgr->SelectTaggedObjects(
$ f% D. {6 T6 G! _0 ~ message, title, scope, include_features, 4 T3 V7 s" j' K C; E& G
keep_highlighted, objectArray ); return objectArray;3 x: B4 z7 _" r- T
}0 D& S+ Y9 `' u( ^9 o4 a
* t t- `/ o7 @2 {+ A! [1 e
" X1 D9 ^- G. y9 b; K, {
% C4 m. i: k! P. D0 r) n( p |
|