|
列子
8 i1 J. k! [- w" c. }2 [( F7 J. [ a8 g8 \& E# o: w' ]8 q
————————————————————————————————————————————
+ U3 |, N# A9 B2 W" ]$ a————————————————————————————————————————————; b, T8 D2 E# d' ]3 Q
咧子:只选择 实体边缘 直线和圆弧
; S; \0 E8 n e( c3 f# v d" K Q, B3 A8 W6 `; w9 @
initialize_cb() 初始化里加代码 可进行对象选择过滤
I7 ?6 i( J& n! E6 ^7 U, @- m. t: }8 \* X l* \, N z
selection0->GetProperties()->SetEnum("SelectMode",1);//多选模式! i9 _1 R5 ^4 U! x) E% q8 D
selection0->GetProperties()->SetString("LabelString","选择边缘");//只选择 实体边缘 直线和圆弧
# ^/ P& i9 b; W* H) x, X+ R4 @% f std::vector< NXOpen::Selection::MaskTriple > maskTriple;& U7 d+ z9 C4 U2 t i2 M- \! e
Selection::MaskTriple mask1(UF_solid_type,UF_solid_edge_subtype,2);
9 F. R! ]4 ]/ k3 [# t3 D4 Z. D5 Z Selection::MaskTriple mask2(UF_solid_type,UF_solid_edge_subtype,3);
- p3 S4 e" d: S! E* a) c; e maskTriple.push_back(mask1);
& s% W" U% l/ d! L+ X! m maskTriple.push_back(mask2);
5 K0 J9 N' z3 `# e. L selection0->GetProperties()->SetSelectionFilter("SelectionFilter", Selection::SelectionAction::SelectionActionEnableSpecific ,maskTriple); \: @1 X5 P& Y6 ^& z
/ V2 q$ x1 S5 a. S# ]/ B//过滤无效的边缘
. q' k8 y# h$ |; b. D& g. \1 _int ML_NX001::filter_cb(NXOpen::BlockStyler::UIBlock* block, NXOpen::TaggedObject* selectObject)
4 R2 X* ~. R% O6 \* P1 y- J5 g+ t{ : L% U; }* A3 d2 `9 ~: _0 S( X+ P
tag_t obj=NULL_TAG;7 E! |/ ^! [! Q6 i* v
UF_MODL_ask_edge_body(selectObject->Tag(),&obj);' B4 @! T% c! m5 F$ L
if (obj==NULL_TAG) return(UF_UI_SEL_REJECT); //不加入到对象预览列表4 Y+ l8 M r; r" [8 {2 F: y
return(UF_UI_SEL_ACCEPT); //加入到对象预览列表
" |+ H) g, G E: ^- J1 K: o}6 B/ W. d& i8 |
————————————————————————————————————————————2 b, l; T- }8 B2 V3 d# U- L. v7 ^ r
————————————————————————————————————————————
3 r/ H. a/ ?7 G! N5 ^. T3 v c咧子:通过枚举控件选项来 时实 分别过滤 边缘、表面、实体7 C3 e; w$ x3 d, a: }3 b
, l, q- r0 ?( N
int enumValue = this->enum01->GetProperties()->GetEnum("Value");9 K2 v) Q' I" D5 [
if (enumValue==0) # k: ~- C" ^% r' O* ~5 f6 M; ~
{
: ]: L/ a% Y+ k- p selection0->GetProperties()->SetString("LabelString","选择边缘");4 t0 l3 X; X5 w! a! o! J
std::vector< NXOpen::Selection::MaskTriple > maskTriple;
3 J6 h. W/ n' \. x- Q) T4 S Selection::MaskTriple mask1(UF_solid_type,UF_solid_edge_subtype,2);
; t5 a h" }* Y( ]; J3 M& a: m Selection::MaskTriple mask2(UF_solid_type,UF_solid_edge_subtype,3);
7 T# u9 j# r1 s; b: r maskTriple.push_back(mask1);/ }2 C0 W, v# A+ x$ M4 t' f
maskTriple.push_back(mask2);/ W, L/ h" l' s: K
selection0->GetProperties()->SetSelectionFilter("SelectionFilter", Selection::SelectionAction::SelectionActionEnableSpecific ,maskTriple);% x1 x; A5 A: ? ~
}
6 f5 _/ X5 j- D |! c0 Y if (enumValue==1)
9 M# w7 g+ \2 ?8 _: b {7 _) g4 k, m! }: k3 M6 Z' \7 t
selection0->GetProperties()->SetString("LabelString","选择表面");
5 J: X$ E3 F( S; t" t std::vector< NXOpen::Selection::MaskTriple > maskTriple;
- Q& b ~- {1 X% N, C2 h Selection::MaskTriple mask1(UF_face_type,0,0);
7 A, `" I, Q3 z! r maskTriple.push_back(mask1);1 s# S% x4 q7 j* r1 C7 r
selection0->GetProperties()->SetSelectionFilter("SelectionFilter", Selection::SelectionAction::SelectionActionEnableSpecific ,maskTriple);
7 A2 H8 n* ~6 j) V }
$ R; z6 ]/ Q5 t4 H2 {+ o+ h if (enumValue==2) Q( z% j0 i8 O7 F! K0 w( }
{ " e0 w' ]. ?5 v; ]
selection0->GetProperties()->SetString("LabelString","选择实体");( M# i( ~* i7 T1 V8 [$ D
std::vector< NXOpen::Selection::MaskTriple > maskTriple;0 |* b8 t: s: E, F
Selection::MaskTriple mask1(UF_solid_type,0,0);. @, `7 a* m: a0 T
maskTriple.push_back(mask1);
& u! a" N3 X# \# U% r selection0->GetProperties()->SetSelectionFilter("SelectionFilter", Selection::SelectionAction::SelectionActionEnableSpecific ,maskTriple);* ]. S$ a F& o2 g$ b
}
2 Y/ b% r+ o) B; u. i7 }% B! @: |+ s+ }( v! W1 k9 Z
# @& d% [7 i$ C% q8 \//------------------------------------------------------------------------------
0 @: w& }& F% u' G1 ?5 I, s% y4 I//Callback Name: filter_cb 过滤不符合对象
/ M, S: z' x5 }& Z. c/ P x//------------------------------------------------------------------------------, S4 C$ n4 K$ \+ u# |1 L) n
int ML_NX001::filter_cb(NXOpen::BlockStyler::UIBlock* block, NXOpen::TaggedObject* selectObject)8 w0 j4 z C( S5 @; O
{* x6 ?$ o& N P% W$ N! F5 I2 d
8 E" O- l( i! j
int enumValue = this->enum01->GetProperties()->GetEnum("Value");; b& Z) G' @+ U
if (enumValue ==0)3 k* L5 Y' G4 O( V2 w. T3 Y. i
{+ N8 z& N. `5 g5 u
tag_t obj=NULL_TAG;2 w* f& \) E8 g {
int err=UF_MODL_ask_edge_body(selectObject->Tag(),&obj);7 Q; I ^5 P" T7 \5 [5 c5 a
if (err!=0 && obj==NULL_TAG)
; g1 |" _- e, C+ ?8 B return(UF_UI_SEL_REJECT); //不加入到对象预览列表
: Y" A/ r& }8 ^( H: P! Q: [8 o }# d2 p( s$ ]* R- D/ l
else if (enumValue ==1)
3 l5 k$ ~& H& J3 Q/ { {* M2 o9 u) K* F2 ]: }9 a3 e) l
int type=-1;
& k1 H. E5 p, v% g# L int err=UF_MODL_ask_face_type(selectObject->Tag(),&type);$ H5 |' t5 Z8 N2 K1 U& _
if (err!=0 || type==-1)
3 ^+ U$ ]5 f6 n% |4 o return(UF_UI_SEL_REJECT); //不加入到对象预览列表
0 Z! @6 L+ P9 g! D }
. @( p0 n! J& |3 i. q5 @ else if (enumValue ==2)
& Z# _, z! A( S/ S @ {" N! t, O- e4 W( f: _
int type=-1; f1 p2 j2 b5 N E+ j
int err=UF_MODL_ask_body_type(selectObject->Tag(),&type);3 Q" D6 g2 J% Z1 t. u
if (err!=0 || type==-1)
+ a& M4 c: e9 V5 {8 | return(UF_UI_SEL_REJECT); //不加入到对象预览列表+ s6 j6 \) r. ?9 \7 `7 \
}
9 G$ K1 z1 |. q1 y
" D. k3 [: M, q& l6 ~ return(UF_UI_SEL_ACCEPT); //加入到对象预览列表, a1 v* l0 P0 N9 ^
}
" z- _; E0 c( L/ T8 K |
|