|
|
秋爱
发表于 2015-8-15 09:15:43
|阅读模式
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
# H& Y1 w* a4 ~. w" ~; C; |
void selectedge::initialize_cb()
$ R' D" J5 b" K1 E: g{ x5 f: s0 J( [% ^: W7 s, T/ U) ^$ [: ?
try
, o) N, P0 y( M4 w, f3 ~9 X1 L [ {
8 ~0 _' N0 U4 }' `, u# w* s2 A$ J) q group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));
( L9 e6 h1 Y0 R* q! L edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()- >FindBlock("edge_select0"));
' l T4 b" _2 g) A+ O* b expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()- >FindBlock("expression0"));}% E7 K- q3 ]* F0 w) X
caTCh(exception& ex)
( K* ]6 ?1 a0 _# ? {
7 P* W3 v! Y. ~2 L8 r //---- Enter your exception handling code here -----2 m+ T$ ]% H; E- R. f" }% h" ^
selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());
! v/ [" J* V' d. ?$ [7 ` }+ a) j% U, ~* b
}
( q6 ]( o% q7 L" s3 {$ ]5 s
+ f% R" n1 ^& ^$ Q& d/ {6 m) kint selectedge::apply_cb()7 q) V+ ?8 U0 L2 n
{0 }# J! c3 J' c' o; n# G6 h# l
int errorCode = 0;/ q! M( G5 K t$ Y% D
try
7 f* f) |. D; i) `8 n( n' C2 z1 G {* x, k4 k) R$ \$ ~7 A
//---- Enter your callback code here -----
6 z1 D8 L% A+ Y4 m8 @$ a8 d
+ t' V; G! z! J- w5 H, R$ O! k2 ? ^0 X+ C. r
# _/ E5 }" K' o) v# x! b% r Session *theSession = Session::GetSession();
$ F* a( u! Z: P( P6 f Part *workPart(theSession->Parts()->Work());/ \2 p5 F; h& I
Part *displayPart(theSession->Parts()->Display());& Y* Q8 v0 ^3 V9 P
, v+ v+ J" }5 g& D. k/ z Y* [# w5 j2 F
Features::Feature *nullFeatures_Feature(NULL);
. n" \3 d3 E% \4 C! S- |% Y Features::EdgeBlendBuilder *edgeBlendBuilder1;
, }: ~2 p+ W9 p3 h& y' E5 ? edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);7 J9 L8 U( g0 \+ q) L8 @% b
1 o: q3 Z" d& e C! u# E1 E7 t& Q. U; \4 q( e8 d& a4 _. g! I( X ~
ScCollector *scCollector1;: q% G& @3 _9 C( ?3 m
scCollector1 = workPart->ScCollectors()->CreateCollector();
: |2 g1 w; u# e" ^
6 n' K3 k5 N6 v: W8 O( L Q! a g5 D5 Y' b2 F' J1 ]9 x6 w! ?
std::vector<Edge *> seedEdges;2 s; i; V" a8 j) e* Y# s/ B
% |3 Z: j% S7 u% p0 m$ \( W! H std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects(); //获取选择的对象
) @ S, N: `$ D, V: H for (int i=0;i<selectob.size();i++)
" q! M! N: ^# u, Q9 s' | {
5 ]* \' {2 O( l. p: ^7 ]2 o9 U seedEdges.push_back(dynamic_cast<Edge*>(selectob));
+ y4 r! I- |- O% M1 C }
- }# x, e% U" l' [
$ g R* `9 ?0 G. v) J( { double dia = expression0->Value(); //获取表达式的值
& |: R8 E) B* b( _! w% D' X+ x stringstream DIA;5 O# l0 @8 U! N1 p/ j/ N
DIA << dia;
; K& [4 Q( H( E3 n- i1 f0 m8 z" H9 L( v
/ s3 k7 w# [# @7 Y6 Y' C3 ^ EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;- H+ Y1 y0 \/ `1 o/ s
edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);
8 O! V: f/ @6 E& ~6 t: c i) V3 n$ z. N K O3 H
( E0 v4 p7 g* f3 s, D( y% {4 F std::vector<SelectionIntentRule *> rules1(1);+ D- a+ W. S$ g8 l! Q: s; Q
rules1[0] = edgeMultipleSeedTangentRule1; W# _$ }; [3 p' b1 L
scCollector1->ReplaceRules(rules1, false);
9 D" X* x. }, y5 w$ \. |/ U6 a. \+ y
$ L/ m& G% W6 f) W+ G( F edgeBlendBuilder1->SetTolerance(0.001);. w* S! R. u' K5 g! l- y# x9 a- M O
4 M/ k3 }. S9 i
7 @3 K* G0 G R z edgeBlendBuilder1->SetAllInstancesOption(false);4 l4 S5 W. X/ H
9 P. }. y$ e. u: _- b! O0 M
* J5 Q0 w$ k! K: V1 w
edgeBlendBuilder1->SetRemoveSelfIntersection(true);
. A; n; D/ J4 x2 F* ~4 }% Q5 q* f2 R
* s, ?$ Q- y& G. v+ o$ T+ d1 h
edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);7 z. g. s! K9 }' Q" H
+ J# P0 x' k# ^ S9 [% G
: @* Q7 _- _- @* z3 f. _ v edgeBlendBuilder1->SetLimitFailingAreas(true);
' E4 ^, q L0 o4 A/ I; P5 M3 S
* z3 x, y" u' Q" r9 O) f
- l2 N/ m8 u3 y edgeBlendBuilder1->SetConvexConcaveY(false);
4 ^5 `* {" T% ?) z0 F/ b$ s' Z! w8 T- S* X- G3 D, v
+ o! c! {, b4 x+ x# P edgeBlendBuilder1->SetRollOverSmoothEdge(true);) f& ?; R3 s$ b, X( e
1 ^9 ^+ M% o& K! J& g3 h$ ^
7 s3 l! {, Q3 w) p9 f7 h edgeBlendBuilder1->SetRollOntoEdge(true);; } D. @9 K8 q
. N: k' N0 D0 @0 i! ]4 x! H
! M% U! h0 y. q8 Z3 g t edgeBlendBuilder1->SetMoveSharpEdge(true);
8 ?2 `* A ?6 g, S2 \, h2 s7 K" O8 a3 `( s+ A* V4 P
7 w x4 F0 z1 y5 S; Z; ?( L
edgeBlendBuilder1->SetTrimmingOption(false);, Y! u& F' |+ S: W' j5 f$ n6 F
3 z \ R& P* h6 [$ I6 J6 _
8 \" w- _5 G% Z0 { edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);
7 E! ?7 F( u1 D" @1 T8 @
9 n' i. f2 G' i. D) w6 N9 q e4 z" j% t6 J" p
edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);
( z/ J' U# o' a, R3 [. m
( h. C* c5 j1 H1 a1 `2 Q0 P% ]" [; l; G8 d" c" ~" O: K; r
edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);( b! u/ m0 @: f% e
( X8 L/ W1 v" X% s
% Q6 `! A( X1 a% L& l. V; u* Q; Y int csIndex1;" F* l) U0 l. O b2 f
csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());
% O6 A+ `- p m( J% }& Z; S
2 @' a1 A1 ~% u7 G, J
7 }: ~$ L3 X) H Features::Feature *feature1;' F5 _* f ], p0 b/ p& g/ }& o( ]
feature1 = edgeBlendBuilder1->CommitFeature();: B# {6 M( O+ i" l: H) {
& ?( }) @5 M/ k9 T b; T
* k6 `, n5 C0 E0 R edgeBlendBuilder1->Destroy();
) T4 l" v; n; Z8 r" |0 b1 M; p" d
}
, A6 g' z! Q; \6 a. j" X; f catch(exception& ex) J* J1 M1 N1 X' k7 W. O0 w' x) ^
{0 R- f' r/ p$ e
//---- Enter your exception handling code here -----
, j: f% z5 ~5 D# B$ w* N- r/ _2 _ errorCode = 1;
* k1 P8 t1 M# l# x7 q2 h selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
# r& N* l: a0 T) E }
( ^3 ~6 `7 T+ L; I5 z return errorCode;
: M F* A6 a# `+ \$ m2 Q}
+ C) Q6 b6 W; ?7 ]/ p( s" ~0 f2 }- t1 y7 R. ^+ O; t2 W
说明:因为字数有限制,这里只贴出关键代码。, S$ z7 x0 U; S1 Z5 M3 P! P
7 }4 a! l1 S1 b6 A3 }3 T- ^! G; w& h4 Y' [& m- S* C) T
2 I6 v6 ~/ J8 `# |1 r% `: B3 o
|
-
评分
-
查看全部评分
|