|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
选择方式包括通过mask过滤,通过type选择,或者通过选择所有的对象。$ C$ n0 s- u+ l. i4 n
9 Y H! Y5 n8 S& q( R5 O
/------------------------------------------------------------------------------
! u" r7 D: z0 \// Selection with mask, q7 Q1 C( _% V9 K6 ]* P
//------------------------------------------------------------------------------ p5 P+ ]6 y7 K0 ?: b( S
TaggedObject* MyClass::select_by_mask()
! M) j& c4 D) ^4 r. _{
+ J% J, p# ]* a& CNXString message("Select an object by mask:");
$ j& ~2 s9 ?$ D- y: \0 N6 v. M% E2 pNXString title("Select object");
; U8 V& h$ C+ h3 K% ~+ k: `, {% hSelection::SelectionScope scope = Selection::SelectionScopeUseDefault;; P4 I! }0 q* U+ |+ p- K* g
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
. h0 z6 _7 L2 \: s7 z t% r4 K1 _bool include_features = 0;
- K- ?$ g) [, H2 g* m( ]+ h) dbool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h. k2 g7 S& a6 G4 L C( u& t
// Uncomment or combine the desired mask triples% R* G) a# B, l6 _2 g
std::vector<Selection::MaskTriple> maskArray(1);
4 O( y2 `+ K% X* X UmaskArray[0] = Selection::MaskTriple( UF_solid_type, UF_solid_body_subtype, 0 ); // Bodies' O) D* m1 }( U0 G9 c1 D
/*3 e* m3 S4 ~5 V3 W- {' g$ I
maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_FACE); // Faces
& H4 y0 a1 e2 _) i& p! p: ~maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_EDGE); // Edges
; D( Y+ ^( }8 {: \maskArray[0] = Selection::MaskTriple( UF_component_type, 0, 0 ); // Components/ S8 t% `, f/ G# Y* `( V1 d/ B
maskArray[0] = Selection::MaskTriple( UF_line_type, 0, 0 ); // Lines
0 ?$ O) h+ [8 ymaskArray[0] = Selection::MaskTriple( UF_drafting_entity_type, 0, 0 ); // Drafting objects$ T2 ?# m o# O3 Z
*/
& D. f! i# e+ o) ]7 \4 P: A7 O9 qPoint3d cursor;
0 ~: j; q+ A, X& w+ {) _. C. n1 ?TaggedObject *object; // Select objects using filter defined by maskArray triples, i1 A* o& v! {, x# M( r5 A
Selection::Response res = selmgr->SelectTaggedObject(
! r$ | J$ E5 F4 W+ f message, title, scope, action, include_features,' m- P0 h$ j+ ^, k1 x' C7 Z
keep_highlighted, maskArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )
* J8 _9 |7 J2 `+ d6 }4 n{
5 c( T: A% o/ v S3 e7 {0 _: ] return object;2 v- _/ m7 W% \: w& ^; y4 `
} s* |2 P7 P8 V
return 0;8 o" k* H& ~! n8 S l7 D. n
}//------------------------------------------------------------------------------3 x, @) m/ ~/ m1 K4 K/ Y( a
// Selection with type array+ U/ p0 i% t) g7 T7 n! d
//------------------------------------------------------------------------------- }4 e8 x! g( o: D3 F3 n9 U$ O
TaggedObject* MyClass::select_by_type()
; B b& x* D0 z; C; e{
2 R2 _! X0 `0 C7 F# H2 ]& |NXString message("Select an object by type:");
: u$ i% F6 O- q) B/ JNXString title("Select object");
6 r* T7 f+ K. c- i- [: j) c8 hSelection::SelectionScope scope = Selection::SelectionScopeUseDefault;' w" o( Y! ~$ ^
bool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.
5 r. q# Y% M0 F; S// Uncomment or combine the desired types
) L0 f* W- F: U+ lstd::vector<Selection::SelectionType> typeArray(1);; ?/ r6 C, _5 ]1 `, ]
typeArray[0] = Selection::SelectionTypeAll;8 E- \. X( z7 _. a! d$ F) d( z
/*
[) I/ b5 x! }5 \7 G0 x1 `9 LtypeArray[0] = Selection::SelectionTypeFeatures;. M% f O3 ]* D# c
typeArray[0] = Selection::SelectionTypeCurves;
% O; q, K9 `9 V0 ?, _0 s; D/ wtypeArray[0] = Selection::SelectionTypeFaces;
4 i# R( n6 ]& h4 f# T/ mtypeArray[0] = Selection::SelectionTypeEdges; i# o0 L. M* }* H" L) e
typeArray[0] = Selection::SelectionTypeCurvesAndEdges;
5 d2 A5 l3 Z$ J- Z8 D$ U* ?*/ r3 N n/ |0 P; g% m
Point3d cursor;
T# r& L3 B* r- L3 j' u% V% |; N OTaggedObject *object; // Select objects using filter defined by type array- X+ D$ t, |9 l- L" G: E$ p
Selection::Response res = selmgr->SelectTaggedObject(, I6 J( n, \1 V- v* T) l
message, title, scope, keep_highlighted,
! q3 s; S' L8 ? typeArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )3 {& j" v7 a- i. F( f3 e9 _
{' X! R9 f5 C! [3 ]2 n' v1 l& ~
return object;
% g, s" a+ s; R# x0 |}/ ~# M# ]# c& h# t+ m5 ^1 T: T8 z
return 0;3 r) i @4 |% p" l8 H
}//------------------------------------------------------------------------------
. Z. Z/ ]3 {& |$ ~// Selection any objects
! N, O. b4 l0 m; z; d: V- ^//------------------------------------------------------------------------------) f: T P# `8 n2 u1 `- K
std::vector< NXOpen::TaggedObject * > MyClass::select_any_objects()
/ d) I3 M3 X. h( U$ r{' {9 F3 d* I6 e/ ^* v( R; z" p
NXString message("Select any objects:");
9 C3 \/ ^6 x1 WNXString title("Select objects"); \+ r+ k- Z4 P3 \" w! H0 n0 i$ e# ~
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
/ i" h1 A& y3 W7 V7 b) C; \bool include_features = 0;
. k" W0 Q5 k* C/ y5 _0 L# Fbool keep_highlighted = 0;, ]9 n% \" ?# o$ P* e
std::vector< NXOpen::TaggedObject * > objectArray; // Select any object array8 q$ ?$ d6 y2 X
Selection::Response res = selmgr->SelectTaggedObjects(+ o4 `: Y- g% K# k2 d) o
message, title, scope, include_features,
V. E* C$ `0 z% {; D& N. P keep_highlighted, objectArray ); return objectArray;, J. l( r# h+ r7 R4 s
}
* l& q+ s) @, n+ t& Y3 P* {& _' J$ d; k) `; {! k
* j" }% C- _9 ?1 v
" D. Y; `$ I! }$ D& U& b
|
|