|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
选择方式包括通过mask过滤,通过type选择,或者通过选择所有的对象。
" X) _( j6 `/ F" n: ^! ^$ F: E" ?2 e z; g) r8 ?" h* T y7 s
/------------------------------------------------------------------------------9 T( h& j# o* c, c$ W/ h2 c( z
// Selection with mask
6 \; J+ j: Z! e' X9 B0 H, M: t& q4 R//------------------------------------------------------------------------------1 v, w8 p% Q2 n/ G
TaggedObject* MyClass::select_by_mask(): y! T8 \+ s) T; R
{
* e4 ?$ r& R, C4 q- M, Q; _NXString message("Select an object by mask:"); [+ o$ `8 a! @" F T
NXString title("Select object");
+ _8 m" E% t: a: j( `. |Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
$ e" [) K W; H3 M4 eSelection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
+ j# B$ |1 k# }7 \) c& ?bool include_features = 0;
- a+ z, ^- q2 hbool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.- N* y7 j* {- g+ T4 _
// Uncomment or combine the desired mask triples
B4 k2 T) ]" i' K2 kstd::vector<Selection::MaskTriple> maskArray(1);
! q, F" L4 F! J4 @ qmaskArray[0] = Selection::MaskTriple( UF_solid_type, UF_solid_body_subtype, 0 ); // Bodies3 i o3 j* s/ G6 F. j
/*
* o0 G N( @2 W3 rmaskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_FACE); // Faces7 M& L4 }* P5 G& O
maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_EDGE); // Edges
, o5 b1 Z$ m: U. _5 SmaskArray[0] = Selection::MaskTriple( UF_component_type, 0, 0 ); // Components
- m2 B4 r' `1 L) e: x' Q" D8 p. hmaskArray[0] = Selection::MaskTriple( UF_line_type, 0, 0 ); // Lines
7 u( N: G# z) s( @/ B7 a2 kmaskArray[0] = Selection::MaskTriple( UF_drafting_entity_type, 0, 0 ); // Drafting objects1 i+ n: p4 P; D) a3 E. j6 ?0 a( y
*/! W" A1 a; t7 S" C) i% i; L+ s
Point3d cursor;
2 ~8 V" o) L, B7 N; J" wTaggedObject *object; // Select objects using filter defined by maskArray triples% @( N' @2 J% J" `
Selection::Response res = selmgr->SelectTaggedObject(8 t( r0 E' ?# M' Y( ]% U
message, title, scope, action, include_features," ]# B; F# B, o7 ?% H8 G6 v; k
keep_highlighted, maskArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )( X8 f; I1 w' ?: }: @
{
% `/ F: M$ ]( w b return object;* X. z" }+ t) e" i9 u6 ~
}* v; x# B' Q# X. w7 [9 v1 p
return 0;3 Z+ h) R X% S
}//------------------------------------------------------------------------------
" _% M! u- Z F8 ?+ `; J8 Z// Selection with type array
5 K, h! @6 {& G' M! r* P//------------------------------------------------------------------------------
4 `& Z. o6 d" I4 R0 NTaggedObject* MyClass::select_by_type()$ c* I& W& `: X" `
{9 z6 X' d" ~7 M3 I& w8 m0 K. p
NXString message("Select an object by type:");
8 Z! K& }& ~. F' L. a' mNXString title("Select object");6 f% m! K# l5 o
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
{& v$ R2 o8 P* Nbool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.- P2 u+ x- P. M) W# \( x- L+ @. `
// Uncomment or combine the desired types) T! ^2 ^% N0 i4 }7 L6 q) m" d
std::vector<Selection::SelectionType> typeArray(1);
/ l6 g. K& K6 TtypeArray[0] = Selection::SelectionTypeAll;" j2 R' ~; @6 I& w* w
/*
6 }( Y+ X8 w$ F/ W# N0 \ qtypeArray[0] = Selection::SelectionTypeFeatures;
; f8 W$ u, p; n2 atypeArray[0] = Selection::SelectionTypeCurves;: v9 s" }! k+ v5 E l$ x
typeArray[0] = Selection::SelectionTypeFaces;. o9 V0 o) A! v9 [2 F$ ]
typeArray[0] = Selection::SelectionTypeEdges;
8 ]& K4 S2 w9 v, htypeArray[0] = Selection::SelectionTypeCurvesAndEdges;
/ w- ~# `- x- J*/" s5 {* y& P% S4 s7 K1 U, Q5 |0 j4 Z
Point3d cursor;
) ?2 y0 w% p. Q1 f( g) vTaggedObject *object; // Select objects using filter defined by type array, }! V/ y* \! k4 i
Selection::Response res = selmgr->SelectTaggedObject(* h& c& f9 E% o9 r' c, d
message, title, scope, keep_highlighted, 4 p! C5 _6 u& m( W8 H! v
typeArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )
8 j. a% q3 x8 |{
$ M9 a6 B8 b# r2 C8 o. B- B0 n return object;
4 c0 P1 y/ W$ z3 R" }7 o4 L}
k' Q1 L% w- a yreturn 0;/ y) V* m/ m' y, K
}//------------------------------------------------------------------------------9 W9 a; K8 A3 n" t
// Selection any objects& D# u8 O1 d) u- |$ Z% K
//------------------------------------------------------------------------------
5 S J* X7 R' @6 ^1 ~std::vector< NXOpen::TaggedObject * > MyClass::select_any_objects()
- C' h; O$ V4 t* N! D( m{8 N2 U+ G6 B2 I, }: C' {" C
NXString message("Select any objects:");1 g; ^1 W; X- V/ _1 | L
NXString title("Select objects");
$ y" v& D6 @8 w# {1 s/ Y- fSelection::SelectionScope scope = Selection::SelectionScopeUseDefault;# g7 z( e! {* O( F3 l1 z$ Q6 i
bool include_features = 0; ( M4 \8 Q1 [1 I0 O, l
bool keep_highlighted = 0;2 T6 C) u7 }) x6 o& x: Y$ c1 ]6 i
std::vector< NXOpen::TaggedObject * > objectArray; // Select any object array
) q9 @( a# Z j$ P2 Y) }Selection::Response res = selmgr->SelectTaggedObjects(
+ J e8 w6 C: Z, E) n) e4 i message, title, scope, include_features,
! z! E: I3 s/ v& ?/ x B, h& l5 x keep_highlighted, objectArray ); return objectArray;* x; g) F4 F) B, `- W
}
! U# e: K+ m6 J: m
d$ I; ^+ g4 I0 k9 Z, P8 E3 |- O3 |2 [2 y% c
6 k% L1 i K" k
|
|