|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
选择方式包括通过mask过滤,通过type选择,或者通过选择所有的对象。
' h4 x- R' T: f3 p
2 s/ r. d7 Y e/------------------------------------------------------------------------------
8 U) p. \. v' V// Selection with mask* e; ?7 Q# p P; B3 X
//------------------------------------------------------------------------------% K5 e$ `4 w4 K
TaggedObject* MyClass::select_by_mask()
# S, U. m' ]# G{3 r1 }% |0 y# f1 p! v/ @; J1 B
NXString message("Select an object by mask:");
% E6 N; Z! |) c9 Z$ ~ {NXString title("Select object");4 d+ |7 [2 V' c- C0 j
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
. ~8 B9 n7 Q8 uSelection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
% ^/ V: \# _2 m# e+ a, \# Jbool include_features = 0;* I5 [& r' O% P c
bool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.
5 I7 M. @! D% I* D% W// Uncomment or combine the desired mask triples
/ b% I" k! }. t) @4 cstd::vector<Selection::MaskTriple> maskArray(1);# G! _5 o9 J) B F3 p
maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_solid_body_subtype, 0 ); // Bodies. Q! @, p# E' @, ]. L) E
/*
N ^# G+ j% w& dmaskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_FACE); // Faces. n: G* M2 b! g! G) T
maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_EDGE); // Edges
3 e. w1 U* Y UmaskArray[0] = Selection::MaskTriple( UF_component_type, 0, 0 ); // Components- N* @- I. r% f/ E$ g9 _
maskArray[0] = Selection::MaskTriple( UF_line_type, 0, 0 ); // Lines" n) o# }& H: s8 Z" v2 r) z
maskArray[0] = Selection::MaskTriple( UF_drafting_entity_type, 0, 0 ); // Drafting objects
7 A7 C3 ~3 }3 v; [*/
9 G" `& V6 ?' m6 R; z) r) }0 k% u/ iPoint3d cursor;
0 i0 j7 S. q& n% @% OTaggedObject *object; // Select objects using filter defined by maskArray triples
* D/ R& \) n7 g& v7 p0 RSelection::Response res = selmgr->SelectTaggedObject(
% c( s# G; v# U8 n7 f, ^8 | message, title, scope, action, include_features,/ e# h) ^) o7 d- }1 \' y
keep_highlighted, maskArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )
- L- j* c- O0 A. S. y3 Z: ?& L/ \+ w{2 R# d3 t1 S$ C# t- h- Q( z" H
return object;8 B. \ y6 S- s
}
* _0 R5 C$ U* b3 \5 Z: W0 `5 G1 \return 0;
" r. R- t1 K" }( D- N: ?}//------------------------------------------------------------------------------0 ^0 s n6 T& y. f1 s4 b1 Z$ x
// Selection with type array
( l1 D6 H1 G% E//------------------------------------------------------------------------------2 Q( f+ ?1 a: A) i: S
TaggedObject* MyClass::select_by_type()- i2 P# F' b6 n I9 n
{6 g/ h0 A& n* y* }) l
NXString message("Select an object by type:");1 z1 f! O9 R" d9 ~0 L+ d# h" h
NXString title("Select object");) @$ p3 p) H" J
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
% [4 ~% t m0 bbool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.* z. l% g( F% n# Z6 N7 V J# P
// Uncomment or combine the desired types1 c$ F4 Q$ F2 G& [3 r6 w
std::vector<Selection::SelectionType> typeArray(1);
) q0 P# c% s( f# o5 dtypeArray[0] = Selection::SelectionTypeAll;
. M6 d2 ?& x- T1 C/*7 D9 [; w% A2 j! l. k- r
typeArray[0] = Selection::SelectionTypeFeatures;
7 z* @! y$ w( @4 W, X( h3 ntypeArray[0] = Selection::SelectionTypeCurves;
$ i9 ~2 Y, H4 L' T. v2 K/ etypeArray[0] = Selection::SelectionTypeFaces;
4 O0 E2 f C2 I9 F! R, s8 ztypeArray[0] = Selection::SelectionTypeEdges;
/ O# t' b$ P( b3 ctypeArray[0] = Selection::SelectionTypeCurvesAndEdges;4 P! ~1 W$ M9 F/ v; k h# R/ t
*/
, u) O1 o9 y" b; d ~7 pPoint3d cursor;
( E; K* P& w# I$ k. xTaggedObject *object; // Select objects using filter defined by type array9 l: ^5 M; i( o2 `9 ^7 c
Selection::Response res = selmgr->SelectTaggedObject(
! S' E' g% Y9 Z/ R/ S9 g message, title, scope, keep_highlighted,
+ R& P, Z' p8 C* u: Y+ h typeArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )
( y+ v# n# E2 X7 N! U{! D9 D( i6 s/ E5 T a
return object;
0 n# W5 L" R8 A% k4 S! x}
4 G5 Z$ r: `) @/ G5 sreturn 0;9 Z2 X- Y* c7 f* H, e; O1 u
}//------------------------------------------------------------------------------4 k5 X% Y4 f* J/ I
// Selection any objects
, L6 W! v0 b G& |3 p//------------------------------------------------------------------------------
' x8 D0 ]1 }' `9 z1 c/ ^std::vector< NXOpen::TaggedObject * > MyClass::select_any_objects()& {! ]7 h6 X d5 k- h
{
0 `. g# z: Z0 U' I) o; S9 g$ g' Q/ sNXString message("Select any objects:");
' u9 K; Z2 B6 A$ E0 pNXString title("Select objects");
+ c; q: M2 d$ {# xSelection::SelectionScope scope = Selection::SelectionScopeUseDefault;
+ g* M- q8 \0 w; B* Xbool include_features = 0;
/ u% |! w" P: P6 J6 D" nbool keep_highlighted = 0;
. t7 P; j9 Q& I/ p6 Y3 M& R5 Qstd::vector< NXOpen::TaggedObject * > objectArray; // Select any object array ^0 ?8 h2 |7 v: ]
Selection::Response res = selmgr->SelectTaggedObjects(
9 p' ], s; s' ?1 Q' N( v( b message, title, scope, include_features,
; ~7 b$ k v' C3 U3 F keep_highlighted, objectArray ); return objectArray;! D( ?- G. V& P% I. J# A
}" _$ O# U% c5 s: U/ G: y8 `3 y
% `9 a" b8 c2 x( J1 e% k# h
0 n4 d2 m' }' _0 b! h/ H. |8 p
* n$ i" R* b% C# [ |
|