|
|
秋爱
发表于 2015-8-15 09:15:43
|阅读模式
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
7 k' ^2 u" c7 g8 A" s6 z4 A- c
void selectedge::initialize_cb()
4 u2 H3 P5 _3 U2 W! o3 ]) O* ?{; n% J" G9 t1 O# d0 Q
try
, g' n6 d( J$ j( z$ c J {
5 F4 N+ P& s6 R5 e' N5 t# W group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));
; G l) Q9 P- H; L7 a' d/ w* V% } edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()- >FindBlock("edge_select0"));
/ g2 J0 l5 Z b$ i expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()- >FindBlock("expression0"));}
1 _, N( V: L v1 N9 ? caTCh(exception& ex)
& v5 @" Z6 y& q7 y/ v. U4 h {, N$ I: C$ F; m2 p0 v/ n- F
//---- Enter your exception handling code here -----
. _ }& G* M# W. m; g4 k6 w selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());
, @4 W; D) W) R( J2 y }
$ M4 [& j9 K6 Z}
2 h" x2 x+ }' u/ n. ?5 `7 n, X# R4 l; u0 z
int selectedge::apply_cb()0 Q' u+ ?" y2 u) \" r
{
) e/ ~% c/ T1 J( I6 {+ F* @0 a int errorCode = 0;# a" w% X2 W4 c( m
try
' p) q$ r; H) V2 U, |1 I {
& W" F. I, y* \ //---- Enter your callback code here -----
: k0 h' b1 ]% R1 C5 J; O' v0 y
, z- e# h( E3 n p! i& w& S& x# j4 ?3 W) r: x7 @
7 d0 Z9 e7 Y9 J$ O4 V* w( I Session *theSession = Session::GetSession();
: h7 N. H) K7 l! G Part *workPart(theSession->Parts()->Work());" k: H0 W! w ?* X% Z8 T# [1 k
Part *displayPart(theSession->Parts()->Display());5 n; ^; z$ _9 x. Q
1 u3 C+ r( m- u8 j3 F# ?
4 t: Q4 x' f+ w$ q. f) W; d8 p
Features::Feature *nullFeatures_Feature(NULL);" X$ b5 J+ S) g- `, d( h) r
Features::EdgeBlendBuilder *edgeBlendBuilder1;
1 H: |1 J" J% z! [9 N1 T edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);
) @1 U4 K I Y7 c1 ]
: H1 B; U* ^+ }+ E( _7 \, `# t
8 L! U3 x( b2 T ScCollector *scCollector1;
5 ?' l: b3 f+ A" [- Q, y. k scCollector1 = workPart->ScCollectors()->CreateCollector();
$ r V) J5 i3 Y( j/ X" S3 [% \% L3 K) [& y
3 _( p7 r5 {6 e std::vector<Edge *> seedEdges;
0 W. W5 N9 `7 ?6 B! b
# A2 h+ W) P. z4 o std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects(); //获取选择的对象
9 \& [- z/ e3 r* e for (int i=0;i<selectob.size();i++)
; P3 E$ `$ O* X( S {4 [8 U/ E% d- |' }, w4 a
seedEdges.push_back(dynamic_cast<Edge*>(selectob)); \& Q5 q" K$ Z5 ^7 R: p5 J
}
! x4 q% \: S' N- R+ q% q# b
; E/ V9 {! J# h; m/ C double dia = expression0->Value(); //获取表达式的值
6 H3 G0 R3 w& P# g stringstream DIA;! N, e3 }( x' V( P$ q
DIA << dia; g" X- s1 T c: e2 J* ^; p
+ B) p+ M& Y w- v% Q, ]) s6 {
5 x) d$ ?( @4 t4 ~ EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;
) L/ l: K4 X% Q" j4 J edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);! e! s l/ K) |0 C4 |# @
! k; |) l5 @) G# u% ?
1 Y0 [0 T; r2 d% p# @/ k std::vector<SelectionIntentRule *> rules1(1); A5 W! d% k. S& {& B
rules1[0] = edgeMultipleSeedTangentRule1;+ h( n' V- p. p! m8 J$ D0 n% p
scCollector1->ReplaceRules(rules1, false);% ~. w3 P/ p& J! t0 `3 S( {
, L4 Z8 {$ E/ u" f6 F; q' U6 ~* D9 \" e- L" P5 W" C L
edgeBlendBuilder1->SetTolerance(0.001);0 m" D/ m5 j7 K8 _0 n+ z; h# n6 z; N
. i" o4 P' d* H3 x" I' B
9 i+ b) Y3 x( C1 Q6 G2 s4 }! I edgeBlendBuilder1->SetAllInstancesOption(false);* h# s& w P1 O4 t
, {- W9 O K" D2 G! R; T2 H4 j Q' n- f* i3 m
edgeBlendBuilder1->SetRemoveSelfIntersection(true);8 X, z# w! f4 S7 e
1 T% H( T; k) a2 p+ k+ q
7 g! m+ w8 c" y5 r% ?1 i6 X edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);
0 C. ~, X; I& B! y; h4 ^9 v6 ]4 L# G
6 X. r/ O: p. }7 Y. N" k; `% d/ R6 l! f& Q: Z4 B+ ]& \' \
edgeBlendBuilder1->SetLimitFailingAreas(true);9 T7 j4 T; B* k* | Y( C3 V
# C3 t. [0 p4 v9 k7 `9 x5 K4 @4 L, }; V7 u' t
edgeBlendBuilder1->SetConvexConcaveY(false);
9 E7 ]) H w* X4 Y' Z, ~) B
( K* E2 L( I. b7 @# D1 @
p& s. {+ ?0 O g edgeBlendBuilder1->SetRollOverSmoothEdge(true);" j2 S1 M# s5 M1 q L3 g
8 T% r+ o& m5 z% M. F$ j: @+ d" p
. u# x3 ^' `8 P8 s9 w+ A' I# C edgeBlendBuilder1->SetRollOntoEdge(true);6 l! r5 x. z0 d" `
- z5 j$ G( {& @4 s0 u: ~; j. g$ _" r! Q, q4 S
edgeBlendBuilder1->SetMoveSharpEdge(true);
3 N8 R# X: _9 u6 m0 n& q( ?
8 c; p1 C" w Z
5 U$ l- p! b0 V5 W( _* B* I$ y& K edgeBlendBuilder1->SetTrimmingOption(false);
8 ~$ R7 V% j. O; t/ e6 T' d2 b- X
: o* e, Q$ B6 _. \4 {% _3 i- h' t' [" m- p$ y4 E: n
edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);
1 \7 _9 A$ N" o0 M: l! H+ S: b" Q0 O k6 s( z" X) v) z1 k( ]
* \7 g, T0 |6 o9 l _
edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);1 j# v; l- ?( U- V% i. \
/ e* T& R9 G9 x' ^3 _
. N; _7 Z$ j9 \" d/ e+ \5 g7 t( M edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);
- ]- a4 o& @7 U' I; M/ Q6 R* S3 L
, ?8 J8 L6 ^- u9 o0 s# F5 b, ]( v+ }
& h7 f" G. K8 o) N* ?( A' _$ V2 ]- O0 t: B int csIndex1;
4 C: ?% h V0 R/ b5 W* Z' s, N csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());/ v1 w0 F8 h4 _1 g& \
, q2 c0 M1 n9 m, z3 I4 h5 o3 S( Z2 v4 g7 @
Features::Feature *feature1;( j" O$ p" W, X" z
feature1 = edgeBlendBuilder1->CommitFeature();/ X: q. R. B* N/ ^
9 ]( R5 ]- {7 k1 q; ~
, s3 @$ b6 g' N( v0 O' t- @" h; \ edgeBlendBuilder1->Destroy();
. Y/ O; r4 W( q6 W5 Q, O, V& ~+ x. c f5 z5 s) a0 a
}: J- G, j9 M I# I) r
catch(exception& ex)4 i, t5 J& ?, r2 H0 |7 P
{3 q i1 s" Q' i: e) ]
//---- Enter your exception handling code here -----
% t2 {$ y4 C. M& B B- E errorCode = 1;: }( M0 X/ F( i) s" Q
selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());. [! V% K; J7 L- n% Q
}6 `* @" s+ P% G* h C5 V
return errorCode;
$ b; k, P4 t9 G2 M5 H}" I5 j5 O5 x% `* ~: i
- B; A& Y' _' \8 h8 {4 X
说明:因为字数有限制,这里只贴出关键代码。8 S" S# |" p7 C8 o
3 K; z1 F% l% r8 U
7 G$ c% M& E/ ]: c
7 N$ L' I: K% }4 S6 f O0 n0 D |
-
评分
-
查看全部评分
|