|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
选择方式包括通过mask过滤,通过type选择,或者通过选择所有的对象。
- j1 B) j4 Y: U$ U! e/ X. @6 k$ w
/------------------------------------------------------------------------------
2 ~* x( v0 l1 V7 N+ c// Selection with mask
4 @ J0 z9 W8 I. m! x" B//------------------------------------------------------------------------------+ z% u4 V+ P- H: i
TaggedObject* MyClass::select_by_mask(), y9 m ]! E+ Q8 H- d& Q# q) m3 \
{
$ K6 A$ g; l% x1 JNXString message("Select an object by mask:");7 t& u8 P3 l, T
NXString title("Select object");6 B# \: y" s2 M" F5 g, E' X2 K8 L
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
8 O& r0 t! v' W7 z* u5 [8 \9 \2 \Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
t5 N: x. U( obool include_features = 0;* a( t$ s0 S- B1 \
bool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.% T& b, N; ]- J! v
// Uncomment or combine the desired mask triples3 }9 H) |. o' g2 M+ U- P
std::vector<Selection::MaskTriple> maskArray(1);
- [2 P! M! A$ q: S* vmaskArray[0] = Selection::MaskTriple( UF_solid_type, UF_solid_body_subtype, 0 ); // Bodies3 r# B* j( i3 U
/*0 m0 H, B& f1 @/ F# {
maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_FACE); // Faces
! S" {1 b. C } h, z( ~maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_EDGE); // Edges6 N0 J. Y7 Q, K( u
maskArray[0] = Selection::MaskTriple( UF_component_type, 0, 0 ); // Components
2 T" Z2 e9 R& j, i8 I5 z0 Q. [ CmaskArray[0] = Selection::MaskTriple( UF_line_type, 0, 0 ); // Lines, \/ c0 }: ^ X3 R! j
maskArray[0] = Selection::MaskTriple( UF_drafting_entity_type, 0, 0 ); // Drafting objects
. c5 o+ j7 w6 s4 B3 R*// ?- z( ]; ~- s
Point3d cursor;& T) h4 {, H6 k4 r/ m
TaggedObject *object; // Select objects using filter defined by maskArray triples
1 J0 ~. c& E* iSelection::Response res = selmgr->SelectTaggedObject(
2 o3 X3 t$ Q/ f message, title, scope, action, include_features,+ J, J( W: R. A8 r' s/ m4 h
keep_highlighted, maskArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )# W4 x9 I# u8 F! f
{
7 `( a% F$ Y0 I1 q; o& Z1 u return object;; H9 Y1 l2 p- b2 E! v
}- G5 {! R6 v6 k d- W6 z8 s; F
return 0;
8 u2 M. }" T7 t+ M& c}//------------------------------------------------------------------------------4 ~1 D& |- P, n: m
// Selection with type array
5 A+ n8 |9 Y' U. K& g2 ~3 F, a//------------------------------------------------------------------------------( a5 O: }0 _3 x4 C* \
TaggedObject* MyClass::select_by_type()7 N+ i/ G; H/ l7 y, U. e4 o
{: C) G, W. v4 Y
NXString message("Select an object by type:");
Y& M X% [0 \' u8 w3 ?NXString title("Select object");" a& I* j# y" D3 i
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
; I7 r0 z9 W- P& s' M" ]8 Zbool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h. e M/ h" o6 t/ K: R
// Uncomment or combine the desired types$ [5 ]3 S7 J" t" X8 d' m
std::vector<Selection::SelectionType> typeArray(1); ^$ r$ W1 A+ q- @3 H1 B8 H% ~# N/ e* O
typeArray[0] = Selection::SelectionTypeAll;& f/ \6 `. O. v* v. H& b
/*2 y" t' H- z4 ~! ]
typeArray[0] = Selection::SelectionTypeFeatures;' z* Z8 |) ~$ Y O. D" }; }
typeArray[0] = Selection::SelectionTypeCurves;
$ w5 f; W& l( X: PtypeArray[0] = Selection::SelectionTypeFaces;( P" ]1 D( w& r& D9 d
typeArray[0] = Selection::SelectionTypeEdges;# p) i7 n( P; C
typeArray[0] = Selection::SelectionTypeCurvesAndEdges;
+ K8 Q; R( {9 i$ ^2 f*/) T5 A5 R2 m! g" }# X/ w
Point3d cursor; p0 J* c( @0 y& |. O3 Y) j
TaggedObject *object; // Select objects using filter defined by type array
# _) T" U! K0 N& |1 k; d. Z( oSelection::Response res = selmgr->SelectTaggedObject(
$ X, P' w, V3 G; v% K& ^* i message, title, scope, keep_highlighted, ! B( ~9 A. `: M9 y
typeArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )
- ~3 A/ z7 s \' v/ D{
2 h1 X* b) i" { return object;, O5 u/ b3 T$ R# L8 l4 s p( o8 t
}7 N7 H3 ^/ I3 l/ r' E
return 0;8 N% U3 [# Y" ]* a: G2 r7 ]
}//------------------------------------------------------------------------------/ I' F: b* h, Y' e" t7 G- |
// Selection any objects
( R8 M/ c3 @' B) @. _//------------------------------------------------------------------------------! _. ?6 ?, S$ k6 ?
std::vector< NXOpen::TaggedObject * > MyClass::select_any_objects()4 g X- R) |& L. @6 ^1 p
{, C6 `0 i( e ^ P6 }6 u/ D B
NXString message("Select any objects:");
; o8 q8 F. l5 d/ D9 a* Z# n. @( vNXString title("Select objects");# M+ h7 U7 p7 |1 [" A1 ?+ B* A
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
* P( `0 `1 U; t* H1 K K, lbool include_features = 0; 8 y, j1 \1 v% ]/ f* }8 e+ v0 W! O
bool keep_highlighted = 0;5 @ j' g' [8 B: z$ k$ m# ^
std::vector< NXOpen::TaggedObject * > objectArray; // Select any object array" C! M, D7 Q) w" p% S: R& f) c3 p4 G
Selection::Response res = selmgr->SelectTaggedObjects(0 i9 P7 C9 g6 d
message, title, scope, include_features,
+ B8 [6 W5 |" {! i+ m5 x+ d" r keep_highlighted, objectArray ); return objectArray;6 Q& F+ p2 k0 J/ z( Q3 y7 \
}, k1 P0 c; O7 n/ n
3 r% ?8 y( r1 I E5 e
+ l5 n% Q# O: V3 c" v
% W& O8 A; j' w6 k w |
|