|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
选择方式包括通过mask过滤,通过type选择,或者通过选择所有的对象。
0 V: i& ~' n h6 X; |% V8 F( t* W; B9 |' y5 W6 r: e+ i% L
/------------------------------------------------------------------------------9 T& c. s( I- j* k' ^
// Selection with mask
6 v- [! Z6 b+ w- G1 E//------------------------------------------------------------------------------% B b; ^4 n4 y) z6 k
TaggedObject* MyClass::select_by_mask()$ Q6 [ A$ N9 s& t) l' W+ |
{
9 d0 W! d* |" VNXString message("Select an object by mask:");
% i3 ]& m. I7 RNXString title("Select object");
* S! B, J; }5 }6 x. kSelection::SelectionScope scope = Selection::SelectionScopeUseDefault;: o2 |; m, R6 c( T# N* Z
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;' L) R- T# z. g3 h: _: o
bool include_features = 0;
1 q4 l1 D1 I; |% Ebool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.
9 C# J2 f0 T- C- @ ~) g& G0 l// Uncomment or combine the desired mask triples
: K3 e% a+ o' i3 Hstd::vector<Selection::MaskTriple> maskArray(1);
( V, U) |: _3 J5 \4 U: @4 |4 emaskArray[0] = Selection::MaskTriple( UF_solid_type, UF_solid_body_subtype, 0 ); // Bodies( E& e7 r8 v0 P$ c0 `) ?! g5 ]
/*9 P. t: y3 j& R6 d
maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_FACE); // Faces
$ m, K* T, J0 C9 W! ymaskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_EDGE); // Edges
1 X) [0 e8 @0 D) ]# omaskArray[0] = Selection::MaskTriple( UF_component_type, 0, 0 ); // Components7 M' J) c+ ]0 O, V" y
maskArray[0] = Selection::MaskTriple( UF_line_type, 0, 0 ); // Lines6 C. r8 `# N. p. G! V
maskArray[0] = Selection::MaskTriple( UF_drafting_entity_type, 0, 0 ); // Drafting objects! E. [5 t- F s) G
*/
4 I( Y) I- m, G# x1 |0 l5 HPoint3d cursor;
5 E' [# k/ I7 C/ J8 D: `" ?TaggedObject *object; // Select objects using filter defined by maskArray triples
/ g- T% X8 R* e SSelection::Response res = selmgr->SelectTaggedObject(- p% v7 O% h$ P4 s0 T; L$ H, }
message, title, scope, action, include_features,3 q* y9 T% B+ a+ C
keep_highlighted, maskArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )8 E: A8 g0 e3 G ]" T/ D& a- Y) S
{
/ i& e7 A6 q1 c' n& w return object;2 D3 i0 I! ^) |& c! t9 `) S
}7 p/ v i% [# }' q
return 0;
+ ?3 t$ m8 U$ t" B0 m}//------------------------------------------------------------------------------7 P0 x' Q* B- R" j
// Selection with type array
9 @" p0 D" e: j//------------------------------------------------------------------------------
4 \) H* U1 E4 p' K1 ]' j- OTaggedObject* MyClass::select_by_type(): F2 L! |0 o$ i( b/ h d
{2 q! \4 B; a- ~3 i4 z. R4 c+ `
NXString message("Select an object by type:");8 x/ n- H# a- n$ d
NXString title("Select object");
H1 F8 y( h* \Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
! @! ^$ s6 l5 V/ t( Nbool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.
* N6 x* C% E0 @// Uncomment or combine the desired types/ c5 Y# J" {) F2 M
std::vector<Selection::SelectionType> typeArray(1);
5 ~2 F$ o8 t' o0 E# [, U: vtypeArray[0] = Selection::SelectionTypeAll; @* {6 h2 v# G4 A0 X# V3 }
/*
) S' S% H6 k. S+ ]$ j) p( T, AtypeArray[0] = Selection::SelectionTypeFeatures;
) F8 d, p0 y8 b$ D6 U- S: m* WtypeArray[0] = Selection::SelectionTypeCurves;
3 [% n ], V- KtypeArray[0] = Selection::SelectionTypeFaces;
5 G# K N6 b$ M" Q1 _' qtypeArray[0] = Selection::SelectionTypeEdges;4 `, w B. K% U
typeArray[0] = Selection::SelectionTypeCurvesAndEdges;4 \8 Q2 z9 b' J" |2 M
*/
2 K+ l) A, A) z: p6 }Point3d cursor;
7 h) o3 ?5 O9 j2 _! p1 H" R( F' H6 s8 BTaggedObject *object; // Select objects using filter defined by type array/ q' S+ z' o% p% p1 p8 x: Y
Selection::Response res = selmgr->SelectTaggedObject(5 p& l7 w' `+ T$ o# ~& \- q
message, title, scope, keep_highlighted, - _* O9 `( v6 [9 }7 V7 T0 x F
typeArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )
$ n f% B: J1 o- Y. S3 Y{. U) a9 Y. r5 K j" D7 j
return object;
& b! X0 Q- |& ~' Q% f0 I/ i}( ` d @* @! x2 T
return 0;
: N3 K# W( A- Y}//------------------------------------------------------------------------------
]& ]7 C( K1 X6 _// Selection any objects
0 n+ }; x) \; _3 v2 o3 U//------------------------------------------------------------------------------
/ \& k2 i4 n- m8 n. o ]9 U Zstd::vector< NXOpen::TaggedObject * > MyClass::select_any_objects()
7 l9 d$ D/ Q) a4 R0 l{
, Q, n4 c. L! JNXString message("Select any objects:");
1 I) f' i, K7 R6 q" z; kNXString title("Select objects");
& `. d; F" }* sSelection::SelectionScope scope = Selection::SelectionScopeUseDefault;
9 h4 w" c& i; M& r* r' v" Ibool include_features = 0; " A) }2 ~2 q2 `- O0 K4 K
bool keep_highlighted = 0;4 n( R) z7 {$ Q; a1 N- C: h { n4 r! y
std::vector< NXOpen::TaggedObject * > objectArray; // Select any object array* P1 p6 k, f# D' j, N) f; l
Selection::Response res = selmgr->SelectTaggedObjects(
/ J8 V! `- i" x message, title, scope, include_features,
/ ~( U9 l' A# U, b# }0 C keep_highlighted, objectArray ); return objectArray;
* B/ D2 B7 Y' r6 y}
, [# F* D( i9 u, N
: y: b" |% a1 @3 _
( U* y: _1 o, M* w6 g9 |& `5 b8 b0 C" q: a* B# q: P
|
|