|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
选择方式包括通过mask过滤,通过type选择,或者通过选择所有的对象。
- v9 V r4 h! r- N) ]* h6 }5 [! R& Y$ D B; T+ \+ Y
/------------------------------------------------------------------------------8 s) n! `& S; Z8 P+ [4 e$ \& v: P- n
// Selection with mask
9 J9 P# t# q5 M, Y. v* p8 L//------------------------------------------------------------------------------: N6 ^) _0 `1 Q6 v* U9 ]3 [2 a; [
TaggedObject* MyClass::select_by_mask()# A) T6 E2 _3 D) ?: ^+ N2 ~
{
/ D9 S, I8 z0 ?: K! y, J# @, b# INXString message("Select an object by mask:");$ T& p; a! Q% j) b4 e4 \
NXString title("Select object");
. p9 [ [9 B" z v# mSelection::SelectionScope scope = Selection::SelectionScopeUseDefault;
: x8 n& o; j2 [9 MSelection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;/ q; l& L: F" o; n- T
bool include_features = 0;
a1 u5 u: [$ B9 M4 I, m/ t- B1 qbool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.
5 o9 c" ?7 G# ~$ z0 `5 y8 W// Uncomment or combine the desired mask triples6 \( j% r' F* C% H. _) C
std::vector<Selection::MaskTriple> maskArray(1);
c: \2 ?: j# u. @ LmaskArray[0] = Selection::MaskTriple( UF_solid_type, UF_solid_body_subtype, 0 ); // Bodies- j% A6 K9 ]( `5 X
/*5 A; F3 V9 g) W
maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_FACE); // Faces2 k- W8 e- W0 u8 \ Z' K
maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_EDGE); // Edges3 P e7 z; Z5 H$ D! u8 C o
maskArray[0] = Selection::MaskTriple( UF_component_type, 0, 0 ); // Components9 v% c4 @9 S J Q( ?. ^+ A0 |+ d
maskArray[0] = Selection::MaskTriple( UF_line_type, 0, 0 ); // Lines2 m3 \" x0 e5 K7 z, {
maskArray[0] = Selection::MaskTriple( UF_drafting_entity_type, 0, 0 ); // Drafting objects
, j! p# ]2 {: e; `* a) N# b*/
( z/ H6 r9 w) M) B) ePoint3d cursor;
& n4 N+ c) K6 @) Q5 vTaggedObject *object; // Select objects using filter defined by maskArray triples$ v. V% p" c& H$ B, \9 e; \
Selection::Response res = selmgr->SelectTaggedObject(6 L9 K" C4 L# C6 r, o
message, title, scope, action, include_features,
' b: f5 S" _ z! G, ]2 Q$ ?$ w+ ~- b keep_highlighted, maskArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )
! |4 Q* C7 {/ r p' w{
& I( m8 R5 i$ A4 P& e return object;/ D4 c3 E! z o1 P# u' O9 }7 J
}
, p7 Q% m% Y/ A# rreturn 0;
+ \) k- Z2 G7 ~7 S}//------------------------------------------------------------------------------( a0 b" i7 S% J9 {) P
// Selection with type array
" v# ^8 a+ a, g' d( G//------------------------------------------------------------------------------
# T( j" W* r; [' s- m7 Q7 [1 L- NTaggedObject* MyClass::select_by_type()
! |/ |4 |3 B( l @{
% Q5 e% \3 I1 DNXString message("Select an object by type:");
$ ^' i6 Q* e ~4 CNXString title("Select object");1 i0 t( D) P+ L- P* L5 a3 g
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
$ q, {, g6 U/ Pbool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h., n; n E6 \2 r
// Uncomment or combine the desired types6 f4 d4 _1 {4 F" q: ~: ^
std::vector<Selection::SelectionType> typeArray(1);
9 A9 T6 p$ D4 D; W" v- v4 [typeArray[0] = Selection::SelectionTypeAll;6 ~7 Q' V1 J. ^1 \
/*1 y7 b4 o( Z. ^ M0 ^6 G
typeArray[0] = Selection::SelectionTypeFeatures;
/ O; q9 \3 W: y7 rtypeArray[0] = Selection::SelectionTypeCurves;
9 m4 v9 [# O- I/ u# r$ btypeArray[0] = Selection::SelectionTypeFaces;
* i8 U% f. m i) f+ q4 NtypeArray[0] = Selection::SelectionTypeEdges;7 s, n" T: T4 m9 Q0 t2 S
typeArray[0] = Selection::SelectionTypeCurvesAndEdges;2 i( u* t( l8 P h8 r$ c, C
*/9 N8 y. n8 D+ K
Point3d cursor;
7 |- O8 T% J( w5 X9 s6 y- zTaggedObject *object; // Select objects using filter defined by type array8 W$ k3 ?4 f) R6 m
Selection::Response res = selmgr->SelectTaggedObject(
$ D* C" N; Z2 V. a1 J message, title, scope, keep_highlighted, 2 w0 n# o- s1 ?+ A' t
typeArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )3 D* h# w6 U% v) p# T" ~, s
{: n: f* r6 ]! J# q1 K7 H
return object;
, N% y& K5 O" r}5 M+ I; G6 w' [) O. k
return 0;2 W" a6 O! p/ S- v9 s( x8 L% r
}//------------------------------------------------------------------------------- x8 D' ^- @5 y' K' f
// Selection any objects7 m/ A8 G( w( d
//------------------------------------------------------------------------------; S0 ]* G6 E3 E- [ p5 S! b
std::vector< NXOpen::TaggedObject * > MyClass::select_any_objects()
5 t: } \) F, z" {1 F& G( R" k{
$ j8 |2 H/ d! x5 i4 MNXString message("Select any objects:");
7 ~2 j/ e5 D. e1 l9 GNXString title("Select objects");
, N2 w5 g# G) M1 ZSelection::SelectionScope scope = Selection::SelectionScopeUseDefault;$ O" T9 R& |: C# P! ^
bool include_features = 0;
' Y1 Q9 ~4 T! X4 x. u C7 A; M: Rbool keep_highlighted = 0; l" h- s8 H9 V! X
std::vector< NXOpen::TaggedObject * > objectArray; // Select any object array% M# D& F' D2 p& K) D0 r2 M
Selection::Response res = selmgr->SelectTaggedObjects(
9 j# h( h% l' S& Q9 q message, title, scope, include_features, 5 P, N1 q/ n9 s/ e
keep_highlighted, objectArray ); return objectArray;# @( A F3 B+ e# v2 D. m* W3 c" b2 O
}! P) S1 \: e6 X. X% v4 Z# F
: b( T7 n$ ^; j9 I$ y, ~
: U! K- h9 a [/ f7 }, |0 }$ \
8 X) k7 h3 y! P- K, L, d7 G/ v |
|