|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
选择方式包括通过mask过滤,通过type选择,或者通过选择所有的对象。9 v5 q) A- Q6 g* Q( r9 F
9 ~( c* {* n; ~7 y% W
/------------------------------------------------------------------------------
+ K6 }& @3 I2 W: Z1 b0 V6 {. a// Selection with mask t2 U! [0 F. T( i- b
//------------------------------------------------------------------------------
! L6 p$ G3 |) K$ I. n0 {TaggedObject* MyClass::select_by_mask()
! f0 x9 j* A* T& E% T4 c1 H{0 i: O% E& n3 O9 l0 P
NXString message("Select an object by mask:");9 c3 P# O# q3 b
NXString title("Select object");
. V3 e0 F, I- h" i1 {- dSelection::SelectionScope scope = Selection::SelectionScopeUseDefault;
; s; x1 Y& F. j, C; i6 c. ~( ~# N# |Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;9 B. }8 w0 D8 q9 f o
bool include_features = 0;( q0 H9 i7 I$ k: `; _9 r
bool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.% T9 D7 |7 O" T! @1 Q
// Uncomment or combine the desired mask triples3 v8 Z6 n1 r; | T1 Z
std::vector<Selection::MaskTriple> maskArray(1);; F" z/ q& J# _) U8 B
maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_solid_body_subtype, 0 ); // Bodies
0 P" ?1 n( t+ S% Y+ C8 r3 Q/*
- k# M" `" L# r. R8 Z% UmaskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_FACE); // Faces
% G! q! o- q6 S- I7 z' j4 ymaskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_EDGE); // Edges
! Z J7 M8 ]5 emaskArray[0] = Selection::MaskTriple( UF_component_type, 0, 0 ); // Components/ p" V: s' M5 j7 s, T
maskArray[0] = Selection::MaskTriple( UF_line_type, 0, 0 ); // Lines
: y" z5 k$ K2 Y# l+ A4 d+ o0 I. nmaskArray[0] = Selection::MaskTriple( UF_drafting_entity_type, 0, 0 ); // Drafting objects, [3 Y! b3 h+ T# Q
*/+ _+ u" I n% K5 a4 t
Point3d cursor;5 y% N: a, q9 K$ S6 l
TaggedObject *object; // Select objects using filter defined by maskArray triples7 G+ K* q+ s& Q- v6 D+ x6 \
Selection::Response res = selmgr->SelectTaggedObject(5 F- c1 }' C: e" E! B/ B1 a( a
message, title, scope, action, include_features,9 W, l" a( r+ d
keep_highlighted, maskArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )
* M8 _6 t3 |$ E) C. V{
+ I; y" z: {2 ^$ m6 M return object;
n I7 Q$ r1 L8 s1 Y}
8 _" i4 M$ S1 ~+ H) wreturn 0;' a( O- Q. [# c( g# p! L
}//------------------------------------------------------------------------------
* r9 ^% d& D6 N' f8 e. L! j: I/ ]$ e5 e// Selection with type array
, |8 ^ j# [. V P* X1 @0 U& h0 e//------------------------------------------------------------------------------1 ~+ B% m) r+ ]! E9 _1 d
TaggedObject* MyClass::select_by_type(). ~) J# }# p d" t7 |
{
. T- H) n, ~: S) k, _( y8 CNXString message("Select an object by type:");' z2 J+ H$ t o8 u
NXString title("Select object");
$ m' o- ` z6 h+ r* rSelection::SelectionScope scope = Selection::SelectionScopeUseDefault;0 M, k5 d; [, q$ [
bool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.
8 e% n) |% a' }1 ~// Uncomment or combine the desired types% T" t& Q9 U. A( l
std::vector<Selection::SelectionType> typeArray(1);0 b/ L- m3 [3 C/ o0 Y" v% G
typeArray[0] = Selection::SelectionTypeAll;
" r9 n; a4 E9 p& [/*
; I# ]% J1 t z% _5 c3 y9 f+ stypeArray[0] = Selection::SelectionTypeFeatures;- C" ~8 Y( R4 ]8 A* V
typeArray[0] = Selection::SelectionTypeCurves;* J9 ^/ y3 k& ?& A
typeArray[0] = Selection::SelectionTypeFaces;: `# M V: W0 @, a+ `7 _; Y
typeArray[0] = Selection::SelectionTypeEdges;0 P6 \; @! }+ Q# e
typeArray[0] = Selection::SelectionTypeCurvesAndEdges;( D/ z- o5 C! J+ B6 X/ t
*/
! V) B; V' _" l0 [' Q) z0 zPoint3d cursor;
1 i9 d. k; Z+ x. ZTaggedObject *object; // Select objects using filter defined by type array
' J' b+ f' {1 O8 f: ^1 mSelection::Response res = selmgr->SelectTaggedObject(
! _' R* C9 S% y; i$ r% O message, title, scope, keep_highlighted,
, S, |' Z1 b+ A typeArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )& w& i0 @0 g, a0 m* m. a
{
& U, ]8 j/ @8 q( C) k+ Y0 W return object;# P/ R9 C$ r! B; i5 I
}' q# r6 p4 w' p( n/ ~+ N0 i' [
return 0;; f1 p" `, W! e u
}//------------------------------------------------------------------------------
/ x) b, ^7 i/ c# I% r5 M// Selection any objects
3 ?2 @/ j$ o+ t% G& v0 z+ I//------------------------------------------------------------------------------
+ K r2 H* Y! H8 z+ v( Bstd::vector< NXOpen::TaggedObject * > MyClass::select_any_objects()
5 z y/ Z& E m& H& a{
! o; w a3 K" D z: yNXString message("Select any objects:");4 L0 W' I O6 P& s+ R* {
NXString title("Select objects");8 F" G6 U7 Y% ]# r% v" U
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
5 L/ r: ~ b5 obool include_features = 0; $ q! f F+ [$ f# f& i; X
bool keep_highlighted = 0;
+ I! [ v2 a& _std::vector< NXOpen::TaggedObject * > objectArray; // Select any object array) _9 }1 z# E: W2 h
Selection::Response res = selmgr->SelectTaggedObjects(' S7 Q. D5 }) J2 [
message, title, scope, include_features, ! n* z S3 o3 E" \' U' l% O
keep_highlighted, objectArray ); return objectArray;6 Y6 y. A/ ~9 n# N* S7 O
} a) x! u" n# X% w: e& r" t
X. ?& Y |$ m7 V% T! z0 q! G
; h& M8 Y: T5 z$ j
+ `; ~% d" q$ ]6 p/ a: i/ K7 y |
|