|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
选择方式包括通过mask过滤,通过type选择,或者通过选择所有的对象。
" u; D0 l6 \! F
$ q S, f+ S2 B/ S6 p2 J, o/------------------------------------------------------------------------------
$ L9 R9 s5 m1 }3 m// Selection with mask
( _3 R; l5 |% ^4 l* H( L//------------------------------------------------------------------------------$ L: h6 ~3 R2 S1 C' Z5 l. u$ j
TaggedObject* MyClass::select_by_mask()
& m9 d7 B% [- v& Y, g; _) J; a{. w# L7 Y" P' Z9 [2 u# O
NXString message("Select an object by mask:");$ `& l( i0 S/ ~: H5 V! f9 f
NXString title("Select object");
6 Z$ `: w. m' A0 [& USelection::SelectionScope scope = Selection::SelectionScopeUseDefault;
) H/ Y. ]% U0 I4 m& SSelection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
& c1 S1 E, ]+ _5 gbool include_features = 0;
( @# C2 P5 z2 E# @bool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.
1 j$ p s0 u5 }$ L0 e// Uncomment or combine the desired mask triples
$ t; |$ F1 g5 k( |, [4 pstd::vector<Selection::MaskTriple> maskArray(1);1 f' I- R; r7 `1 c9 z$ G* {2 ?
maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_solid_body_subtype, 0 ); // Bodies
- z$ q8 G3 ?* L& |. W& p/*% {4 D+ ?8 Z2 f( m" Y/ U% W
maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_FACE); // Faces/ A! c! r) `. }' g3 {
maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_EDGE); // Edges
- A9 r9 J7 A+ o! F* ~4 }: ~$ H8 `maskArray[0] = Selection::MaskTriple( UF_component_type, 0, 0 ); // Components6 N7 J7 z' d, O2 W1 c. j' L
maskArray[0] = Selection::MaskTriple( UF_line_type, 0, 0 ); // Lines! c# }$ Z( j2 k* T" S
maskArray[0] = Selection::MaskTriple( UF_drafting_entity_type, 0, 0 ); // Drafting objects9 H* p4 C; G/ S5 @) m l
*/: T! k: M( I5 c3 z8 k4 P2 V! O
Point3d cursor;
2 Z1 X+ i. M( U) DTaggedObject *object; // Select objects using filter defined by maskArray triples
6 C! I! O4 C3 U0 h( U3 jSelection::Response res = selmgr->SelectTaggedObject(
. ?. U$ I1 `5 f message, title, scope, action, include_features,
' N& G5 i- H7 b* V0 s, ] keep_highlighted, maskArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )
_, d2 e. l( j B{
( f. c# i; D w1 |$ i5 d" t return object;2 T8 I4 S4 X- e4 R9 b
}, E" \7 O$ F2 e; j' k
return 0;2 \9 s8 Q# B# p3 y: T$ T, Z% y
}//------------------------------------------------------------------------------1 a2 U, Z; a5 N) u) C, s
// Selection with type array
/ Q4 W3 |( `$ J* J% S6 E//------------------------------------------------------------------------------( v+ a: u) A) y0 d2 U& P
TaggedObject* MyClass::select_by_type()/ H6 F2 C/ f4 b' H* K* Q
{
" R5 I2 Z0 e6 @) k! ZNXString message("Select an object by type:");0 [& ?! |4 f- Q# |) E. Z' {
NXString title("Select object");
3 a% Y u1 t& R( v$ t! N4 fSelection::SelectionScope scope = Selection::SelectionScopeUseDefault;
9 I8 F( r1 M+ e" I( B6 wbool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.
6 r4 l# O2 `; G4 N4 U// Uncomment or combine the desired types; b( K' B- v7 Q' Z. L
std::vector<Selection::SelectionType> typeArray(1);9 t# x! A: b$ n* p' O
typeArray[0] = Selection::SelectionTypeAll;
$ E! D* |6 |+ @8 i4 a/*3 C; H) R) e$ J9 j; d) [6 w" k, |
typeArray[0] = Selection::SelectionTypeFeatures;
5 ?8 L( ]. V3 A a5 R7 Z' x0 Y7 MtypeArray[0] = Selection::SelectionTypeCurves;( K0 k$ |+ F8 ?: H |& Y" L
typeArray[0] = Selection::SelectionTypeFaces;/ T4 b* u* ~5 G3 v* z0 y. @
typeArray[0] = Selection::SelectionTypeEdges;
. d* U, w$ E$ ^typeArray[0] = Selection::SelectionTypeCurvesAndEdges;0 M! m9 s7 T1 ?; x" L# e- N
*/* u& u6 G" e* t9 G+ F- g
Point3d cursor;
( s7 _ B! L8 }6 U0 VTaggedObject *object; // Select objects using filter defined by type array; O$ \: _$ G$ p# O& j# C; X0 _
Selection::Response res = selmgr->SelectTaggedObject(3 L3 k9 k4 |- Q' _/ x
message, title, scope, keep_highlighted,
6 V5 Z& V5 N' \+ F8 M: s- w typeArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )9 T: `% h c a1 e/ U
{
' l" Z2 Q& z# P. m g1 ~ return object;- Y0 o7 Y8 d- B
}9 K; J8 k. c8 }4 R8 K; _
return 0;
/ p, T: n, D) m}//------------------------------------------------------------------------------
. D+ B: |" Q, X4 k( L c+ e- @; F// Selection any objects
1 O$ w/ t6 C' l5 n% X" b2 U//------------------------------------------------------------------------------; {5 J) K& a8 X0 P
std::vector< NXOpen::TaggedObject * > MyClass::select_any_objects()
2 W- y. h, G. F/ I{
8 _8 ?/ F( c& x5 T9 d1 }- e4 \NXString message("Select any objects:");* i8 M7 S+ G- J2 X0 j. g; ^
NXString title("Select objects");
8 ^2 g4 w, Y" K$ z9 LSelection::SelectionScope scope = Selection::SelectionScopeUseDefault;3 f6 l+ _" ^. ~9 t2 ?$ l
bool include_features = 0;
% @' A$ |9 a" V7 Ibool keep_highlighted = 0;7 M, s+ z& a" j" r% U
std::vector< NXOpen::TaggedObject * > objectArray; // Select any object array' D. p. `3 I( r
Selection::Response res = selmgr->SelectTaggedObjects(
( ^3 t: B$ t! L' l message, title, scope, include_features,
1 r( T* [% Q# ` keep_highlighted, objectArray ); return objectArray;! s' n1 n6 x& h7 A3 d' \) G, X
}+ \6 ?: p4 h- f9 S0 B
+ _+ j1 s. b4 T1 N9 o/ s! q- L2 \' s# `/ G) l1 Q- b
( u: N G# s+ ~
|
|