|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
选择方式包括通过mask过滤,通过type选择,或者通过选择所有的对象。
" N$ e J+ E$ }# ]
4 K( g- P' n. P U# B* r; x/------------------------------------------------------------------------------
7 W8 L, E/ [9 Y h1 E0 a// Selection with mask
6 o/ i% V; e! v* _! w//------------------------------------------------------------------------------; o" V; r+ h* M4 J, n2 n
TaggedObject* MyClass::select_by_mask()
! S$ p) I: f& S! b7 H6 |8 q, S{! D$ |7 a! n8 _3 [
NXString message("Select an object by mask:");
! d! t" U# X2 w9 R% S3 QNXString title("Select object");
# G0 U, C+ v7 p- ~7 \Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;4 t/ D9 e' s& B
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
5 p; z! m0 r: v( h$ Sbool include_features = 0;1 d# y9 m9 n4 A- [
bool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.
4 R* r) G5 B# z$ O. g. I// Uncomment or combine the desired mask triples! x6 K- e/ f' o" L2 T; ^5 N! a4 P
std::vector<Selection::MaskTriple> maskArray(1);
7 h! P/ E4 F+ d: d2 `0 u% B: r; pmaskArray[0] = Selection::MaskTriple( UF_solid_type, UF_solid_body_subtype, 0 ); // Bodies
4 g/ T( M# E( F9 t6 H+ d/ }/*7 @0 n8 i5 C( `3 i/ s" X+ a* A
maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_FACE); // Faces+ r) q/ ]2 p& ?; e
maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_EDGE); // Edges% w8 [) @" T) B$ |! v
maskArray[0] = Selection::MaskTriple( UF_component_type, 0, 0 ); // Components
$ i8 J: @6 p8 r( NmaskArray[0] = Selection::MaskTriple( UF_line_type, 0, 0 ); // Lines2 O+ v3 _3 t: X, @* n
maskArray[0] = Selection::MaskTriple( UF_drafting_entity_type, 0, 0 ); // Drafting objects3 t5 H6 N6 n2 y- N0 [% e
*/
7 x9 ]) D, }* }* C+ U# S/ ~/ f2 TPoint3d cursor;
0 ]9 T$ T- {! L" H4 qTaggedObject *object; // Select objects using filter defined by maskArray triples% J; w' Z- \* S/ ~: H
Selection::Response res = selmgr->SelectTaggedObject(% f; q5 G; z9 F# a' U# L
message, title, scope, action, include_features,
/ e1 P2 s4 n. \- s keep_highlighted, maskArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )
$ R; q) I, W5 C& Z F& Z{: L- r5 L. m! `* V% a
return object;
3 s# ~- G/ a/ n. I" N5 `& G( N}
* _7 B! u0 M2 {: K% `7 \! _" ?, dreturn 0;
* U7 U: r4 r6 A# k# R, h: F}//------------------------------------------------------------------------------( V3 j6 p$ L, a8 f4 V
// Selection with type array
( I2 x2 r) ~1 r# G//------------------------------------------------------------------------------
+ v- G8 ]! H, J4 T2 s( u0 G" XTaggedObject* MyClass::select_by_type()
: W0 I: w, g) g/ t3 ?2 F9 C{
: ?% h) D# j( ONXString message("Select an object by type:");$ r- n% M+ _1 M( r' [
NXString title("Select object");: H/ D$ t* \* k" p
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;2 h- R L: _8 {$ b, G8 r6 a
bool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.
5 X# Z. E5 D) R// Uncomment or combine the desired types
1 ~$ Q' C+ Q5 r: K/ k. I7 \/ bstd::vector<Selection::SelectionType> typeArray(1);$ v+ G/ i. i& C: u! J8 M
typeArray[0] = Selection::SelectionTypeAll;
) A# A! ?9 G5 Y9 W) O9 k: E/*
& _) g ^% S, t1 v( |. KtypeArray[0] = Selection::SelectionTypeFeatures;2 N0 e5 \* @# \3 D$ R9 f& w+ o
typeArray[0] = Selection::SelectionTypeCurves;
" R; h) |/ F' V+ ~4 j/ ?* j0 _6 {typeArray[0] = Selection::SelectionTypeFaces;, P4 ~) D% O" K( F# e' }
typeArray[0] = Selection::SelectionTypeEdges;
6 Q' t- M& H0 @3 h! k1 ]0 W) T# ~typeArray[0] = Selection::SelectionTypeCurvesAndEdges;
! `: S/ A/ E/ t*/) D) a1 X$ m7 \9 E$ X7 j6 r
Point3d cursor;
4 I( S/ T/ O2 Z! A6 ITaggedObject *object; // Select objects using filter defined by type array8 m. I9 h7 N$ G7 }* O
Selection::Response res = selmgr->SelectTaggedObject(/ p# t4 Z4 ~; J9 m* p5 Q7 I P
message, title, scope, keep_highlighted,
) e z& _- c4 p0 u typeArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )* s( t/ ~, l6 w# a" P
{
; J$ C: A7 K3 |- S8 n return object;
& ?+ a/ \4 M- w% P) F; u1 x}
/ |# F$ L3 ]2 H: I7 T5 l9 D: W Breturn 0;
; [7 S5 s& k- c4 Y( C" i2 C}//------------------------------------------------------------------------------; T) F! X% L! T; h% V Z5 l
// Selection any objects7 q* ?% T9 `; j4 N% f2 ^
//------------------------------------------------------------------------------) e$ t9 C9 M5 T0 s, K
std::vector< NXOpen::TaggedObject * > MyClass::select_any_objects()5 C2 t; o* C0 [8 [, Y
{0 r q/ E- t: V9 k" M- {7 _
NXString message("Select any objects:");( n7 z4 Z' `% e K4 o- v
NXString title("Select objects");" O" D- V. w \$ ?2 S! R& a
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;2 n1 V, ~7 `4 h% o$ F
bool include_features = 0; 2 ]: e+ V% N2 k9 _8 _* C: E8 i; m
bool keep_highlighted = 0;
; ?* t1 B) r- z% p9 g0 D# Y7 _# Pstd::vector< NXOpen::TaggedObject * > objectArray; // Select any object array0 w' e+ c1 z a) D
Selection::Response res = selmgr->SelectTaggedObjects(8 v0 w( p# n0 ^! u" J" ~
message, title, scope, include_features,
3 N$ X- V3 w/ t+ l. I0 K keep_highlighted, objectArray ); return objectArray;$ [. g: f! R$ v7 ~9 u3 J
}
' l$ |+ k, L( e! ~* @8 @, e) N; V: y% }# Q3 ?/ O, n. T% ^
% ~+ P+ n2 L/ }: n5 b$ x
8 q1 p" d" t0 n; ~
|
|