|
|
秋爱
发表于 2015-8-15 09:15:43
|阅读模式
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
8 M& t3 A5 I' D( K2 k, C+ nvoid selectedge::initialize_cb()
: l4 w) r, I: S& Z0 l" f* S' D{, Q0 f) J0 M7 |8 S, I2 p
try0 C' ?6 |9 ]$ ^! \3 M" c2 F
{
" x+ L' R$ d% p& a& e% B group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));
# D* p- q: H* L/ i, a, a edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()- >FindBlock("edge_select0"));$ f* a! a( T3 I/ b% _
expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()- >FindBlock("expression0"));}
* D8 P$ C1 ~0 a# ^! n caTCh(exception& ex)) Z# j1 G( H+ R. \6 `
{+ `4 {2 B8 N1 y- N
//---- Enter your exception handling code here -----
: q5 H( V3 F5 X- s selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());
6 B& c" M8 U# Q }4 f( X& n/ k' ~
}
/ g6 R/ ?/ W' H6 A
6 ]% r' K8 j/ tint selectedge::apply_cb()
& u5 h8 e- v, t* H$ n2 I{& d" y. }+ }4 x+ ]. b9 `; o
int errorCode = 0;
0 O S3 r" j, a$ q# v7 F7 w9 ? try/ B0 d: Z$ ], O/ O+ H
{
) p4 A7 o) Z( W! m //---- Enter your callback code here -----
4 J' @5 q5 I# ~* e5 ], F+ l+ k2 ?! V( ]$ P
' v6 Z! {3 h% i s
' g( k& Z5 \! i) p) B; O6 j7 l) n
Session *theSession = Session::GetSession();
( V5 @( A9 J# M/ h6 x Part *workPart(theSession->Parts()->Work());
7 W" m2 \8 W1 a8 T# {3 T Part *displayPart(theSession->Parts()->Display());3 p+ V7 x. a8 l- Y
! w9 X8 | o% V2 ?7 V
- T# z( M3 H# w: j7 N" V* d
Features::Feature *nullFeatures_Feature(NULL);
/ K$ U6 F8 l. Z# S( f! c Features::EdgeBlendBuilder *edgeBlendBuilder1;
: |0 a7 Q( h" r% k1 W4 ` edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);' e2 x2 C- }$ [# u
1 `8 z v9 ]' ]6 u+ d( R
* e3 N. X6 k- Y1 H4 `# D% k, A ScCollector *scCollector1;
+ ?! i% a. O, ^$ L2 c scCollector1 = workPart->ScCollectors()->CreateCollector();# J9 V$ C } o1 M: X+ ~4 W
5 D# v$ M1 j1 Z; m# g' v3 j: ]) h' q g& B
std::vector<Edge *> seedEdges;. B+ }; f, p& Y; k, b
$ d9 N9 m7 l8 [: R3 R std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects(); //获取选择的对象% t* Y0 L ]1 O+ y
for (int i=0;i<selectob.size();i++)( I! p# Z# k& ?$ P( c( T# E& ~
{. ?: I/ o: R/ Y5 A. d
seedEdges.push_back(dynamic_cast<Edge*>(selectob));! Q j# \5 H8 D3 n
}
R/ B" |+ W- e4 F# t! h. N( x1 k, r
9 ` G* w3 J3 M. i& O5 @ double dia = expression0->Value(); //获取表达式的值1 [# B3 j+ x; Z
stringstream DIA;
1 x: ]4 v& ~- Z, s- y1 \ DIA << dia;
7 w. H8 e' N9 N3 t& w6 F9 G3 F0 C
# F/ o/ P% b9 I1 B$ g
EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;( g9 J8 W: T1 N0 w8 W- s. o, x
edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);
0 y* u( I$ ?7 t' E$ [
! L" x6 V4 i7 S
/ ?+ E$ _$ C7 j. a4 b2 w std::vector<SelectionIntentRule *> rules1(1);8 y! W% `5 O% f! D7 O0 u' ^
rules1[0] = edgeMultipleSeedTangentRule1;7 H" L5 ]# E3 f+ h
scCollector1->ReplaceRules(rules1, false); {* s/ e9 b, \' m: P+ h7 e
$ w& E/ R6 p4 W, A
7 e: y8 D! w5 a
edgeBlendBuilder1->SetTolerance(0.001);
2 a- Y4 j2 J& L3 i; Q. b* c6 L+ E3 p0 O/ p* N% p) @. H% M( B, K
5 u* }& N) u% P' r8 T
edgeBlendBuilder1->SetAllInstancesOption(false);6 u/ ]$ w, M. E& t' {
5 T: ~: B* L* H8 D
' V6 H& f9 X* {
edgeBlendBuilder1->SetRemoveSelfIntersection(true);' B: Z& g) i' M. i% l7 U
' k4 L) Z$ E( V* {) I F+ E1 a- ^" F! S+ a& |. H3 ?# s
edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);$ ^. A) h b" a& l. k
4 H4 g; r! c3 D c$ A( I; w) O$ n1 L4 V
edgeBlendBuilder1->SetLimitFailingAreas(true);
5 c6 e5 a2 h2 c O4 R( Y( `- m6 l; H1 s- z
: A, @; i- i6 R# |# W edgeBlendBuilder1->SetConvexConcaveY(false);
# q& m% D# ?: u+ X# M
; p: y& |- g4 x% t6 I- M, I5 ^. Q0 W6 y7 C: K+ ^7 M0 ]) s( `
edgeBlendBuilder1->SetRollOverSmoothEdge(true);) m$ A h5 R0 B1 I# L
" \% n& B, Z& Z1 Z/ a2 P7 u; a1 n2 i2 W) I9 j
edgeBlendBuilder1->SetRollOntoEdge(true);
* B4 Z5 B8 a4 r8 z0 i g$ U8 g3 l4 D9 k9 C9 [ R5 Y: b Z
( ^/ ^! k% \3 y. a$ u9 E
edgeBlendBuilder1->SetMoveSharpEdge(true);
$ D# {; v# v8 j* B
+ c, V" p6 Z1 E, `3 m' T8 S. V
3 ]: G% Q: u: \; Z; J0 j* ~4 | edgeBlendBuilder1->SetTrimmingOption(false);- q- X+ Y: {7 x }
1 Y4 Q' L5 {) n) b% S8 }9 }# w5 M- Z5 Z2 x
edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);
3 x' r$ h1 P& d
- l" R: d' s7 J9 V: ?( ~8 b4 Z+ m7 ^2 f( {! y+ _& K
edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);
" N! D ` C% L7 O- `7 G- O
* S4 J% k; }+ O% N! Z& J* i! Q5 @! h6 V" h% q2 Y5 Y' @: V$ D
edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);8 ~3 E. f$ t( T: i$ U
9 f. @/ m/ Q8 q
* a0 s- x" W" B* K; U7 o" K int csIndex1;0 i P; x$ u" t: F. C
csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());
# e* a1 |8 m% R2 Z* @% z
7 u" p; P I: I" r- y. J$ c! Y! ^
Features::Feature *feature1;7 P7 O' x7 A ~& {' E. E$ W
feature1 = edgeBlendBuilder1->CommitFeature();
" A* O6 d3 b! s* E) |
9 X$ }" U1 w6 S7 _ E3 r, I( f' ~0 ~- A/ Q1 t9 l( F( P) V: U. b
edgeBlendBuilder1->Destroy();5 b/ @( N$ U: r2 W
' d" ] J( ]* ^' X; h
}
" F4 z2 S' I+ q+ H( n* o7 S catch(exception& ex)
+ [+ R; v* d* T" z; j {2 q, M# _; Q; L) \
//---- Enter your exception handling code here -----8 J. w3 Y2 k! P \, i0 N
errorCode = 1;
4 N/ H% D0 P% [8 @, Y selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
9 Y; Q: p% G! S5 r }
+ J$ } X- X' U2 x" s& z7 ~0 l( A return errorCode;
! u3 \: q+ f* s5 `& J}$ q3 X- C/ a( f6 N9 U, ]
: q% F- E* a; x2 U
说明:因为字数有限制,这里只贴出关键代码。$ v n* }8 k( I( j" G- R
d( E- y* A `/ E2 I) }! G
w) n8 @) T9 z+ N& ^# n8 u" O
7 f% z0 }2 P4 d! n3 X
|
-
评分
-
查看全部评分
|