|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
选择方式包括通过mask过滤,通过type选择,或者通过选择所有的对象。
, V. ~6 L) l% G6 a' z% v' I2 u. I* w3 q
/------------------------------------------------------------------------------1 [5 x Q$ M9 S( D" ^' B v
// Selection with mask; ]( z z% | l7 ]3 W
//------------------------------------------------------------------------------
" ?0 R- E$ f- y! jTaggedObject* MyClass::select_by_mask()
$ E( O. s4 N! X2 I{
+ w I$ p% x+ }; u9 {NXString message("Select an object by mask:");
; X$ G* n( ] p. lNXString title("Select object");9 ~6 e0 a+ N# E2 g3 B. s
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
4 W( \' x* q/ i. OSelection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;# ?: A$ q9 ~4 R
bool include_features = 0;
( Y0 U2 e) G* G6 G4 bbool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.
' `* W$ }1 B( g* {! ^7 f// Uncomment or combine the desired mask triples
/ s+ h G% }4 G/ kstd::vector<Selection::MaskTriple> maskArray(1);3 U0 Y6 {/ M' n4 j! E" A$ o% ^) R' I/ G
maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_solid_body_subtype, 0 ); // Bodies- A, \6 V H c( }' l5 W' d8 X9 n
/*
' W* I3 a8 {" v" K0 TmaskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_FACE); // Faces
- P5 N2 O$ D% Q6 B% q! l5 W2 umaskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_EDGE); // Edges
8 U! l8 {0 {) C, zmaskArray[0] = Selection::MaskTriple( UF_component_type, 0, 0 ); // Components9 b" R I$ e$ [" ]5 r1 W1 o
maskArray[0] = Selection::MaskTriple( UF_line_type, 0, 0 ); // Lines
; f- {3 r$ y$ Y% p: v7 ~3 W; AmaskArray[0] = Selection::MaskTriple( UF_drafting_entity_type, 0, 0 ); // Drafting objects ~: U. F: f- ^% ?& q- k) a
*/
$ Q0 Q/ P: R4 Z" }" |# l9 _Point3d cursor;4 @9 R) D8 R _8 G: t
TaggedObject *object; // Select objects using filter defined by maskArray triples; C7 ?) l+ ~+ X* W2 D$ Q0 y
Selection::Response res = selmgr->SelectTaggedObject(
) p5 h* S, g+ a& Q( d0 n' M. C message, title, scope, action, include_features,% w( ?9 }" s/ P/ x7 W1 G5 y- l8 t
keep_highlighted, maskArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )" R, z+ i8 ?# f4 L I2 `" A* t7 c& }
{
5 `% B) h& r7 s7 w$ G return object;7 J; V5 ^$ {0 u$ `6 ^: q5 T' H
}/ O2 A, b+ b+ Y" t& D" |
return 0;
M' M" o) `2 O}//------------------------------------------------------------------------------
' d8 s |' [4 V- |// Selection with type array
4 M6 E r, ^7 ^) H) U( k, @//------------------------------------------------------------------------------5 C% i+ i: q1 M8 O @* z- K
TaggedObject* MyClass::select_by_type()
9 I" v m9 S, ?. k) l+ r$ | Y/ Y{6 S; Q8 K% X$ q% V' L8 |
NXString message("Select an object by type:");6 g3 \. a" x: v. g+ N
NXString title("Select object");8 c6 c% @3 t B$ a# f, d+ Q
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
1 f0 U: V7 b) B# t$ jbool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.7 {# q/ _6 W1 O# c% ^* O6 O
// Uncomment or combine the desired types
- B8 H* [ V- E+ G: vstd::vector<Selection::SelectionType> typeArray(1);
0 z" s4 v- E+ T0 |2 J' ptypeArray[0] = Selection::SelectionTypeAll;' {! T8 j4 ?( f% B
/*( N# N% Y* o8 B- |7 T
typeArray[0] = Selection::SelectionTypeFeatures; T9 v2 w4 `( w9 s2 E
typeArray[0] = Selection::SelectionTypeCurves;
8 J. Z3 S( Z2 ]# L( C6 btypeArray[0] = Selection::SelectionTypeFaces;6 J% U6 n- V7 N2 `+ d
typeArray[0] = Selection::SelectionTypeEdges;
/ t h( e8 |) a& c1 }* l* etypeArray[0] = Selection::SelectionTypeCurvesAndEdges;6 ~2 d% W, `+ H5 t& _# O. v
*/
. L V5 h z. y1 Z) sPoint3d cursor;
0 @0 j, A+ L# C, N* m8 `TaggedObject *object; // Select objects using filter defined by type array
- t% `; U8 [- y0 tSelection::Response res = selmgr->SelectTaggedObject(( h+ e# ~+ j, m! l& p
message, title, scope, keep_highlighted,
& K- O0 V5 Y4 w) {. M: a" t" h typeArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )
; x7 i/ N! N( o3 q; a{
( C# y8 d# l; r( D- |- k3 O: w return object;
3 H% @8 N- A! O+ w D* s* p}9 Z5 X; }1 u& q! I9 L4 w
return 0;
. K8 U/ [$ X2 _& D, a}//------------------------------------------------------------------------------
* p0 O9 A/ P& Q3 b6 j; j' Z// Selection any objects& O$ P0 t+ |9 G
//------------------------------------------------------------------------------# d6 U2 A" f. d4 ~
std::vector< NXOpen::TaggedObject * > MyClass::select_any_objects()! i0 x8 Q. B/ w8 n4 v% L- d, t
{
, {1 |7 r( j5 I5 a+ u w1 DNXString message("Select any objects:");
" ]% R- V+ U/ J; ^. pNXString title("Select objects");9 t3 Q, L9 f: H' i! n9 C0 x) c Q
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;. Z5 S. Q7 A: t4 V; F
bool include_features = 0; 0 G9 r0 u P0 t( l& m, D
bool keep_highlighted = 0;0 Q$ L- o" C; E0 S. X$ b
std::vector< NXOpen::TaggedObject * > objectArray; // Select any object array
. g" y* _# `+ f6 JSelection::Response res = selmgr->SelectTaggedObjects(% G9 f: Q0 |. n
message, title, scope, include_features, _( c! f9 d% ^: z( B" u; e
keep_highlighted, objectArray ); return objectArray;
, e* X& S! L5 s& Y4 i}. z |: F' E# B6 u, `
* A7 d J n! c
+ X$ @6 I/ Q9 l, q0 d) Y
, Y5 K/ F5 Q, e/ |9 |; p: @
|
|