|
|
秋爱
发表于 2015-8-15 09:15:43
|阅读模式
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
. X. y' C3 D+ _% ]( M
void selectedge::initialize_cb() Y5 g( }7 F4 L* a/ L5 V
{* R% u& u) K+ U2 A
try
* {8 }9 H$ h. ^! c+ O& g) t Y {' t0 l+ F1 H* z% g
group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));6 ?8 x; E2 a) R0 p# N3 ]
edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()- >FindBlock("edge_select0"));
* T+ Q4 _% l( b expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()- >FindBlock("expression0"));}
, H: u3 C% Z( R9 f/ ? caTCh(exception& ex)! U- W8 M" h6 \+ h9 Q
{7 v* d r, X: r0 w- u
//---- Enter your exception handling code here -----" ~- p: v, E6 f4 B
selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());: G/ f' B0 f5 v
}
# n& U$ Z- V& p: n# x6 H}
. P( k8 \- D% l3 C5 q2 j: U; m! p- x5 \6 o1 ]
int selectedge::apply_cb()! z, g2 q G* _
{
6 J- J t* P. h int errorCode = 0;' O1 @7 @" d. p6 k7 l( ]
try8 i& H5 \+ D, a9 { m$ S, W
{/ i+ j3 g. n7 }/ r2 Q; U
//---- Enter your callback code here -----
s; H' z7 X# c* S) i8 G9 }* W9 l% \+ D$ \
' ~9 `, J' ~% ^+ ?" B
( \: }0 a8 H0 w Session *theSession = Session::GetSession();
8 v5 B/ l6 t7 {/ X0 a& {# W( N$ Z Part *workPart(theSession->Parts()->Work());, M$ _. O# A7 w
Part *displayPart(theSession->Parts()->Display());+ p- }4 o/ d1 s7 ?0 r
: ?( y; n$ v- K; k# U7 V2 O! y" f
* \$ A, f! @8 L P# Y; c Features::Feature *nullFeatures_Feature(NULL);& J: v. L" ?. z+ {6 V& G: z
Features::EdgeBlendBuilder *edgeBlendBuilder1;
8 ]+ {0 Y; r. U- _5 C edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature); E: e' z2 _+ n3 g; H7 {
) o$ {3 h* L" e! C* d
# B) P8 w H% {5 w; G% o, W; @ ScCollector *scCollector1;: ]* J3 m% ]" [- a4 U% h
scCollector1 = workPart->ScCollectors()->CreateCollector();
# q9 p6 y* o- z& {7 C9 t8 Y% T7 n$ h% a3 `7 N5 b8 ?
2 V9 L G8 \9 T/ _$ @! w- C std::vector<Edge *> seedEdges; R! ]7 P8 p F' {; F$ _
4 `5 c, h1 Z. A8 ~9 Y" {7 p
std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects(); //获取选择的对象
: F% h% F# `! ~# p/ a' w5 S6 i for (int i=0;i<selectob.size();i++)
; ~- S! B9 N6 ~8 b2 I {
9 d2 h& m) t4 P# S/ O; `" a3 Q3 w seedEdges.push_back(dynamic_cast<Edge*>(selectob));9 T$ l3 K8 C: q0 F2 h
}
+ f* g. e$ } c- I0 w7 Q1 s: E! x! n' {( Z
double dia = expression0->Value(); //获取表达式的值
, J! s$ B3 J% E/ k. T3 R3 {; ~ stringstream DIA;
' }8 e7 T/ M. t' K, v! a( }: t DIA << dia;
# B' h4 S; k8 } _1 C5 e+ B e4 m$ X$ z4 g
$ G4 E, \9 Y* S7 \( p% ?/ B1 h3 q: u. j
EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;+ f; y" O5 E5 }! R
edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);
0 H: e6 z' w0 c" s9 z2 \; J) Z. M2 K) I; |. V. p) X
& }3 [6 Z: @. ~2 j6 ^5 y
std::vector<SelectionIntentRule *> rules1(1);" S5 U/ |+ m1 j9 E; J' e/ N: c
rules1[0] = edgeMultipleSeedTangentRule1;
! Y$ u% k/ H0 U/ R scCollector1->ReplaceRules(rules1, false);
3 a9 h4 x0 O" g' z# R& H7 |) Y) G! R3 k& w% ]
' T4 P: B' Q- o edgeBlendBuilder1->SetTolerance(0.001);# T/ `1 }" [& E+ z
- c5 v, j, w3 g) P T
" g( F$ S: y4 m% |, Y' B& k; { edgeBlendBuilder1->SetAllInstancesOption(false);
* x; N0 y5 H$ g' ~/ P4 k2 p) h5 W7 {9 ?. g, @) U, z
" G2 s1 M8 I$ R0 ^& U# a% J edgeBlendBuilder1->SetRemoveSelfIntersection(true);
7 j# Y6 L* d: `* y0 Q3 s; K
8 C& _( } f: P8 `
4 s8 X `( ~; p& y edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);9 |) ]! O7 y( I
$ L: j' H) B( f* E) D8 L4 ]1 f4 k
1 m, s: x0 m. ~& C% C+ C; j edgeBlendBuilder1->SetLimitFailingAreas(true);* F' F& e6 H6 s2 Z! w
- _/ c: n7 m9 V2 V1 J0 ?& x
" N9 {! z q" ], D# y7 s5 t edgeBlendBuilder1->SetConvexConcaveY(false);
9 H* ~6 O! R" V
: P% O5 T) K* l7 f) I* S3 g
. n/ D1 {% }; X+ @ edgeBlendBuilder1->SetRollOverSmoothEdge(true);/ p. B3 {: a% q q
2 u+ v) x1 f( Q7 \7 H" c" J! ]
# b* }! s9 V3 T* G6 ~. {* Z5 B" I& z K
edgeBlendBuilder1->SetRollOntoEdge(true);! d; F b7 \) Z* y m
9 K7 g8 M( _% i
$ c) V! c% X) S. k" S4 h
edgeBlendBuilder1->SetMoveSharpEdge(true);
# n- Z3 O W' j( {' b0 k6 x3 J$ ^/ k+ D# w/ C
3 B; L4 k5 _: ^: O M; b1 N edgeBlendBuilder1->SetTrimmingOption(false);
* \0 |" p7 `! R8 m% i4 K, Y( N6 W. q2 F7 v
" }% v6 D/ ~* J7 Q edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);
8 Y y! l+ }1 N) x7 s9 k0 S3 a
" O) |4 S3 ]% _/ L
3 V7 z% m2 c+ G4 d- l% h9 X edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);
e8 ~# y2 b5 e" D* ?8 H% _ P
7 F. m: }' I6 C- o edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);/ \1 B' P' Y% {/ D
. T. T4 v" v; S1 ]1 f
0 s& p4 N5 D; ~7 N: f( R1 r int csIndex1;
. I$ W- O! J. t( o) A4 O: g8 { csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());
y* v' N2 z8 n0 r* G# s, Y" l; J5 W, K- p" P
3 G( e( j* O7 V2 R B% W& X Features::Feature *feature1;: j' K0 `% j- k# W5 u5 b7 l
feature1 = edgeBlendBuilder1->CommitFeature();
' x) a Y2 `( N
* B2 E/ m# |, R9 q. H& Q
# f! l+ h. ]$ `$ r" f+ m edgeBlendBuilder1->Destroy();
' M+ B; `+ z9 X1 l2 K4 g
( k* \0 e! t% M- O }
/ p: q& a0 p4 a* Y- O catch(exception& ex)! i6 W1 j I# @7 u& _, p* m. T
{
) I2 f2 @) a$ y# W1 A //---- Enter your exception handling code here -----+ x1 Z$ U# O H3 z/ O8 D
errorCode = 1;
& S' [. ?+ F; c( F2 Z selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
$ t* H3 h' H0 z& _* X }
R+ w+ X7 w3 d" a return errorCode;/ D0 {' h5 Q6 ~7 O$ c3 E5 p. H
}
6 @, Y/ l2 i% ^3 T3 a$ L
2 L" i' E4 L/ v& B说明:因为字数有限制,这里只贴出关键代码。( r5 | e2 E5 W+ O$ m$ H
4 V0 S( A/ w4 E$ y- a
2 x% T9 w3 Y$ a& |; W! T }
& l- B" H" [3 l, g, w/ ?5 b( b |
-
评分
-
查看全部评分
|