|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
选择方式包括通过mask过滤,通过type选择,或者通过选择所有的对象。
( e* t5 y% i/ V+ |) ?# k$ y8 E' j r7 H" @# i, `
/------------------------------------------------------------------------------# ]3 B& ^, z0 D# d/ `7 ~$ _6 p O
// Selection with mask) u9 M% c7 c. P) t
//------------------------------------------------------------------------------8 z# h/ L# c$ _9 f+ C' s- p
TaggedObject* MyClass::select_by_mask()
. c4 t2 |9 y( i4 a$ E- n3 r+ B{0 \. J* A- ]: }) O2 T- E
NXString message("Select an object by mask:");6 \% A+ @5 O& \4 {/ @
NXString title("Select object");7 o5 i [% c4 C4 ^- ~8 R
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
n! f& }. b; Q/ p: ^6 t% fSelection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
! u4 e2 Z' n7 T/ x7 abool include_features = 0;
: F1 O& Z. W Z0 {bool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.
2 l1 b6 }; O$ A3 K// Uncomment or combine the desired mask triples
8 r2 i* Z5 n7 r1 |' p% a9 [std::vector<Selection::MaskTriple> maskArray(1);+ m( r! D5 k% E& g% |
maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_solid_body_subtype, 0 ); // Bodies
' j* a! H7 ], Q5 ~4 P H/*% S$ W4 r1 i0 x3 g$ J) Q
maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_FACE); // Faces
1 [% [5 G2 q! {- ~# UmaskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_EDGE); // Edges
# P7 K6 R1 S; k# s j$ Y1 Q" }maskArray[0] = Selection::MaskTriple( UF_component_type, 0, 0 ); // Components+ T( `9 h; N0 y$ @( N: [
maskArray[0] = Selection::MaskTriple( UF_line_type, 0, 0 ); // Lines
- b- z' B1 S- A0 i% H& n kmaskArray[0] = Selection::MaskTriple( UF_drafting_entity_type, 0, 0 ); // Drafting objects
2 l! d9 t1 l6 N; _3 K1 V6 _( J*/0 e) ^$ o8 J: k+ [' I
Point3d cursor;6 j: W4 x" V& u q
TaggedObject *object; // Select objects using filter defined by maskArray triples$ f+ `/ L/ k. f! T; l! a
Selection::Response res = selmgr->SelectTaggedObject(
! ], z+ @& a$ E- Z' `* C message, title, scope, action, include_features,8 O" z( ~! N0 b3 B1 L- D
keep_highlighted, maskArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )) ]( J* R2 R U2 K7 M: I
{0 M1 I# v% h! J% i3 Z
return object;
& }' y8 R5 v, B}9 k: H, }5 Q9 w8 [7 Z6 B1 o' V2 e
return 0;
a J K3 A/ J W}//------------------------------------------------------------------------------
4 y2 G8 v' i; B' u// Selection with type array
4 ]2 z- O* ~9 u% \, k//------------------------------------------------------------------------------
* I7 C+ ^* E/ p5 f5 h6 v; _* {TaggedObject* MyClass::select_by_type()
( N8 c1 _7 K. x% t7 X# z/ w{4 d5 g, Q G$ n u# L7 T
NXString message("Select an object by type:");
2 \8 n2 z9 `) n" [( U! s* GNXString title("Select object");
2 U6 d2 Z1 k+ H3 B* ]Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;; t3 a8 G7 E: a6 c; [0 D- ]2 @
bool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.- u- t( `2 v& h" p
// Uncomment or combine the desired types
) `0 L9 K6 U8 R) Pstd::vector<Selection::SelectionType> typeArray(1);
1 o0 o+ c; ]; L9 P6 M# DtypeArray[0] = Selection::SelectionTypeAll;( t* d* |1 ?1 W- e2 m9 [$ S& |
/*1 \, N0 G, h Q7 W8 s: ?
typeArray[0] = Selection::SelectionTypeFeatures;
' d! e$ u0 h' d6 i) _# @: Y2 |, `typeArray[0] = Selection::SelectionTypeCurves;
% j. g9 C" d2 g ltypeArray[0] = Selection::SelectionTypeFaces;3 Y {; X# l$ X8 Q3 x
typeArray[0] = Selection::SelectionTypeEdges;
2 N1 z5 _* a2 A3 j5 f$ r. ?# xtypeArray[0] = Selection::SelectionTypeCurvesAndEdges;) L1 ?% L% M r' P' h& @
*/2 S% D& b( H: y) [
Point3d cursor;# e9 }) G+ D" P- B4 s
TaggedObject *object; // Select objects using filter defined by type array7 N1 u2 j- E) X L3 J
Selection::Response res = selmgr->SelectTaggedObject(
" J+ u& s2 u" d! l4 F message, title, scope, keep_highlighted, 9 t- t) i$ w$ @
typeArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )
3 N- ]0 H, Z* D8 X{# \# `" w0 ~, ^& ]2 P& p, Y
return object;
# y) r) O- y4 @* O" [' t9 H1 w}
. r2 L! e l$ g: q" ?- wreturn 0;% A- C% N# }8 H
}//------------------------------------------------------------------------------: \2 V. M' d9 V5 B. C" h! d3 g) A
// Selection any objects$ J/ @& M% g3 Q) U. G) s. ]. w
//------------------------------------------------------------------------------8 c0 ^+ M+ N& Y) K1 |) W
std::vector< NXOpen::TaggedObject * > MyClass::select_any_objects()
4 i0 t7 f+ Z+ b{
( b; z; J5 a7 q! L5 i- {" B0 ~9 pNXString message("Select any objects:");1 V1 N! o' C. i
NXString title("Select objects");- G/ P5 e! {1 E& _% ?7 @! _2 ~) X
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
: w- m% O# X2 K3 _! v" B: cbool include_features = 0;
$ T* W6 D3 W, _; Xbool keep_highlighted = 0;
1 d# ^, L- j6 B, D+ m3 F. @std::vector< NXOpen::TaggedObject * > objectArray; // Select any object array! h6 Y) x" L" P) V `9 s! c3 x# a
Selection::Response res = selmgr->SelectTaggedObjects(
2 A# M8 {0 c* `9 c; } message, title, scope, include_features, , P3 Q2 S- a2 \, y; i
keep_highlighted, objectArray ); return objectArray;! W" D$ ~$ [* L- N6 a
}
0 {4 A7 d4 c% K. L7 S) v! D q! M3 `1 c
: S" J+ J' C9 b9 v9 \6 A1 u
+ T: o7 D7 ?1 ~+ a* }: Q7 d+ S
|
|