|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
选择方式包括通过mask过滤,通过type选择,或者通过选择所有的对象。
7 E! l$ s4 C- U. w) u9 j; ]# m
3 J7 \& q* F! R: Y9 j! ^/------------------------------------------------------------------------------- S8 u9 u) ?2 g; a2 u( e; |
// Selection with mask
# x% p5 D/ K6 z9 N//------------------------------------------------------------------------------; ]6 S! t" T/ F; U4 A8 J
TaggedObject* MyClass::select_by_mask()
) w- [5 `8 o/ m1 h# ~{
' [/ W, r1 H+ l) qNXString message("Select an object by mask:");7 P+ O2 B* X1 p5 E3 z5 F- h$ {
NXString title("Select object");/ p4 U2 k& \; l' F
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;/ D9 g6 I) E5 O8 o' z, p
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;3 W# u) C6 u" V- r9 u6 r
bool include_features = 0;
( ? r1 I* a. Q7 d+ O6 ubool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.- _* o9 C' p1 t- p
// Uncomment or combine the desired mask triples) h0 v$ Z. r2 N! z/ Y- C! J z3 T9 D
std::vector<Selection::MaskTriple> maskArray(1);
6 j% ^ @9 K6 J4 ?* Z: [maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_solid_body_subtype, 0 ); // Bodies
3 `5 s p& v2 G ^! q4 T/*
: l& a1 f1 I' q# _4 T' pmaskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_FACE); // Faces
& i3 P V3 c' Q1 o) SmaskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_EDGE); // Edges7 X# o6 m* D' [5 \4 p- b) Y: z
maskArray[0] = Selection::MaskTriple( UF_component_type, 0, 0 ); // Components
d) z* t2 H+ [4 ~maskArray[0] = Selection::MaskTriple( UF_line_type, 0, 0 ); // Lines
" y. ~$ n: o A8 C4 PmaskArray[0] = Selection::MaskTriple( UF_drafting_entity_type, 0, 0 ); // Drafting objects; S( N& u4 q7 w) E
*/8 J) E {1 u, G7 ?4 E0 U
Point3d cursor;9 C2 Y$ l5 _$ l+ L$ k" I
TaggedObject *object; // Select objects using filter defined by maskArray triples
: e3 R" d: J4 J/ r. S: P7 m$ FSelection::Response res = selmgr->SelectTaggedObject(' p2 {' U6 s M1 c% _
message, title, scope, action, include_features,+ z7 R3 @- V( T$ n. `5 }
keep_highlighted, maskArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )
& V7 a, o9 i8 e0 d{
" p' h5 M& A) \3 ]. Q8 J return object;
: p% t/ j) n: E# L8 y8 \}
Y6 y i$ d3 U n. O5 Kreturn 0;- n1 ]1 r O: g, r; ^. h$ \
}//------------------------------------------------------------------------------0 G6 T' V& o" _' V) P0 Q
// Selection with type array
: }5 I2 V- j6 o- `//------------------------------------------------------------------------------
5 M8 C+ M: h: ~$ C+ P* gTaggedObject* MyClass::select_by_type()! L2 |( E6 W7 F4 s/ Z
{
) G) c' c1 q7 P# p- H7 o$ D5 INXString message("Select an object by type:");
( s6 i# P# M, d$ rNXString title("Select object");
* b& ^4 r# p1 C: J) D, {/ ^2 xSelection::SelectionScope scope = Selection::SelectionScopeUseDefault;
$ Q0 b& n, t5 w, K, a. Wbool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.7 L5 x F) V* F) S" n/ t
// Uncomment or combine the desired types
8 f8 |7 ^; _+ C7 q: ~std::vector<Selection::SelectionType> typeArray(1);& \6 k9 m( h) D2 f t- X6 K: Y
typeArray[0] = Selection::SelectionTypeAll;1 k# e8 m, D ~) U; t
/*
. e+ v% q. X7 o, M5 _typeArray[0] = Selection::SelectionTypeFeatures;
* W( k( X6 N+ vtypeArray[0] = Selection::SelectionTypeCurves;
4 z1 } m0 ^ m7 `) B* `7 DtypeArray[0] = Selection::SelectionTypeFaces;
2 C5 a& @$ _( c8 Z* j( @6 a2 @typeArray[0] = Selection::SelectionTypeEdges;
8 S/ b4 n# E3 c7 utypeArray[0] = Selection::SelectionTypeCurvesAndEdges;
. h4 `% t9 I. t& l5 V" l0 C- X*/
; p% f; l& A ]" C* @, `Point3d cursor;
3 h4 I; T) J' T- b" H0 p' kTaggedObject *object; // Select objects using filter defined by type array0 U( g9 ~" p$ z/ V0 M
Selection::Response res = selmgr->SelectTaggedObject( O* _6 @( k& a5 T& f
message, title, scope, keep_highlighted,
3 Y" j6 i3 G2 s6 \ typeArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )
' V$ ~, j6 t! D6 H* S0 D{, n7 U7 r7 N: p6 k
return object;, u, j5 c+ G# M# j' W$ F% j$ z+ b
}
8 J# d- x- i, h0 ^return 0;
2 C: `- ^, i* }}//------------------------------------------------------------------------------. g) B3 n; [6 w. N, d" F
// Selection any objects
: _: ^: h, g" q( k" F8 s; _( W) q' g//------------------------------------------------------------------------------
& K m; w1 |# R J3 f# A) C8 \std::vector< NXOpen::TaggedObject * > MyClass::select_any_objects()2 }( b' n+ U4 W+ m7 f
{
5 S. O( O8 Y) Q9 {NXString message("Select any objects:");
, w4 j! o6 f9 ^NXString title("Select objects");9 B6 F& d0 n. H
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
$ G2 H0 w# [8 U" A W# y, pbool include_features = 0;
, }0 ?$ i7 G- Vbool keep_highlighted = 0;) ~5 ?" P( b3 `- u, s" k
std::vector< NXOpen::TaggedObject * > objectArray; // Select any object array
& b$ d, m7 W8 z; ^Selection::Response res = selmgr->SelectTaggedObjects(
# {2 _$ ^0 ]6 f( Q/ d) L3 w5 e message, title, scope, include_features,
5 C @- W# ~4 n1 O+ j' C# } keep_highlighted, objectArray ); return objectArray;
9 @; F4 x* C9 ^' {! K}, \$ N( E- O5 o6 N% d- o; P& _6 ?
; r m1 k& _5 `9 }3 ^! o
$ B+ @0 m; j4 i$ C4 g* v. h1 L4 h) \4 z7 G/ |8 z
|
|