|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
选择方式包括通过mask过滤,通过type选择,或者通过选择所有的对象。
, _6 D5 D5 R1 B( y( S" _, d& G# J5 Y4 U
/------------------------------------------------------------------------------
. e5 r0 i, m7 |' u9 g// Selection with mask
) k( n0 U' M# s//------------------------------------------------------------------------------0 F) f: W; ~; a/ b u
TaggedObject* MyClass::select_by_mask()
' z2 Q: n h- h, M$ v* S+ s{$ e4 D U& U. B, G; G0 z' J
NXString message("Select an object by mask:");' p3 q. `/ z, `
NXString title("Select object");) J3 y, c p' e5 ^, i
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
' x; Z+ i! m+ |; K2 _7 |, ]2 w( HSelection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
* B- C% v' a. {& ^5 m6 E' nbool include_features = 0;- U- ^# Q8 g7 y. ], U
bool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.
& L: T% ?) b5 N- Z# P// Uncomment or combine the desired mask triples2 T! P* ^) m- i' ^; z
std::vector<Selection::MaskTriple> maskArray(1);9 D. |+ k5 f* q/ E7 E
maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_solid_body_subtype, 0 ); // Bodies& o5 U& _; ]3 L8 j2 n4 G- ^4 B
/*- x: e$ {4 V/ Y0 e8 a
maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_FACE); // Faces
: u- [ R' X9 OmaskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_EDGE); // Edges$ r7 q( r, k& \ n7 ]. m" [3 {
maskArray[0] = Selection::MaskTriple( UF_component_type, 0, 0 ); // Components
, ]/ J4 a7 U1 i! w4 I3 w- `9 Q* DmaskArray[0] = Selection::MaskTriple( UF_line_type, 0, 0 ); // Lines
3 O) Z! B: N& o$ t& N& MmaskArray[0] = Selection::MaskTriple( UF_drafting_entity_type, 0, 0 ); // Drafting objects
1 r/ J" n' O: e9 P% Y( u( `*/2 S7 t2 l$ K5 x
Point3d cursor;
5 G$ l0 [2 I/ S# A) x$ u2 GTaggedObject *object; // Select objects using filter defined by maskArray triples. V7 Y. i' q1 f+ n/ R! X S) M
Selection::Response res = selmgr->SelectTaggedObject(1 K& S0 g+ I1 ~2 N. C: S! m
message, title, scope, action, include_features,9 T6 @3 N% L5 i# u. m: F$ ^
keep_highlighted, maskArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )
, @7 v/ f' x7 m, Q/ T; Q{) j$ P3 H3 z3 v5 l, R8 }+ h* t7 J4 ?
return object;: Q X7 Y+ N9 X3 v; X2 W; [
}
0 s; z& I! b! L: Xreturn 0;
2 z3 O y! W0 s8 E( o}//------------------------------------------------------------------------------
7 o: Y, W: v5 h8 _6 s" a8 I// Selection with type array
& f2 O ^$ v7 k: `4 c//------------------------------------------------------------------------------+ {! P9 r$ `% D" ~
TaggedObject* MyClass::select_by_type()
: h( h/ C, E6 q9 y+ K" O{
: R6 Q2 h, j, B5 Q4 ONXString message("Select an object by type:");2 d5 Q* A. _" j' _- y) }1 O
NXString title("Select object");& g! B8 z6 S7 W) R
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
8 J. F- d* J# Z9 Pbool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.
: u" I8 W/ p7 Q( g8 i, y- S5 o// Uncomment or combine the desired types
9 |: J0 ~7 e% b( D! P& D, E6 Ystd::vector<Selection::SelectionType> typeArray(1);; W d% ~0 H6 p* f$ }8 z
typeArray[0] = Selection::SelectionTypeAll;
C3 r+ r3 X }% z+ S' s; S2 ^/*5 n/ M7 t1 T5 N- x
typeArray[0] = Selection::SelectionTypeFeatures;5 u; a! F; r8 i" W- j- z8 l2 Q
typeArray[0] = Selection::SelectionTypeCurves;- b, U g7 V* Q3 C/ l' `
typeArray[0] = Selection::SelectionTypeFaces;
, d& L" A3 f: ^- \& otypeArray[0] = Selection::SelectionTypeEdges;
# U8 L7 V- E- [* j8 g9 l0 s' b/ X: QtypeArray[0] = Selection::SelectionTypeCurvesAndEdges;
6 V' ^; ]8 H: E. H) J6 S1 t" s*/
# n" X) y3 [7 k8 OPoint3d cursor;
; I3 Q* z( z* e5 o. V9 p# a( {( ?TaggedObject *object; // Select objects using filter defined by type array4 I4 ?1 q/ Q; T" c# D+ Y/ H, f3 A
Selection::Response res = selmgr->SelectTaggedObject(2 B* s5 g ?! m
message, title, scope, keep_highlighted, 6 f( ?1 Y$ X- Q4 b+ q' e7 B) f) L7 }
typeArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )) [. G/ ~4 r& x( r* ~
{ [ C. t0 U4 X$ T7 E, v* n
return object;
# p' E$ z, R/ F; i* p! t/ K: R K}
; k$ K) O% b5 C y( Vreturn 0;$ @; e, T% |2 F% l- A: g* H+ f1 K
}//------------------------------------------------------------------------------
) H% j6 k3 I8 `% O! l// Selection any objects; G6 x+ c3 f. V6 q
//------------------------------------------------------------------------------7 p% `3 [7 Y4 r+ f: I6 ~: d
std::vector< NXOpen::TaggedObject * > MyClass::select_any_objects()
1 d3 v+ z( O5 x" g9 h{9 ?9 [: X. I k# d1 o/ f
NXString message("Select any objects:");
! m9 p' ?5 A8 r" l$ G6 XNXString title("Select objects");
7 X' {4 _, [; e7 s! i) M( \+ dSelection::SelectionScope scope = Selection::SelectionScopeUseDefault;
5 d5 k: l8 K$ ?& e$ Dbool include_features = 0;
, A$ X$ D" a% _; G2 Sbool keep_highlighted = 0;; y& g; E8 p0 J. f
std::vector< NXOpen::TaggedObject * > objectArray; // Select any object array4 z1 |9 {" f9 S0 D' j* d
Selection::Response res = selmgr->SelectTaggedObjects( u# A; m7 h" C# [" m
message, title, scope, include_features, + n* R9 \! I3 m) w' |2 J. i
keep_highlighted, objectArray ); return objectArray;* n$ r# ?& r7 ]3 p
}
: y+ F0 i9 Z& T8 x4 z* i7 Z2 l* j3 g9 d
$ E! Z- M1 M: _) K- ]; A# j
) S. B6 e# g$ ~, }# F |
|