|
秋爱
发表于 2015-8-15 09:15:43
|阅读模式
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
. T! ]( r |) e5 @0 U2 jvoid selectedge::initialize_cb()
( [! `: u3 `- a{
& ~. |; k: ]; ?' _) g try; U Z( `; m: w" I& D
{, Z$ |6 Z! C6 o- N
group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));
/ U: y# l) O# B* K$ ^% ` edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()- >FindBlock("edge_select0"));8 H8 g! R2 S2 y* y9 @5 I9 }4 i
expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()- >FindBlock("expression0"));}8 ~7 F# L+ F6 f$ Z1 o3 t" [' k
caTCh(exception& ex)
5 C$ s$ }, |7 `0 ^ {
' C: I6 X1 Y5 y1 B //---- Enter your exception handling code here -----( u6 S% j& j, \3 B
selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());) G) O' l$ A: d! f+ v' \" z
}
# G; D$ }$ v8 f4 A}5 g$ c% O; T5 ?% U
. `* {: [! |3 J0 N
int selectedge::apply_cb()* D( w6 I% T9 ] g
{6 `: s# _* W5 |1 G
int errorCode = 0;. L# Q# i6 f8 o
try/ v* n# |, f, _7 F9 _% w
{5 h- U- p# K/ p Y- D4 t
//---- Enter your callback code here -----
0 B4 {/ E) c& I2 t9 L1 k
) A/ i3 H4 S, T! ?0 S) r8 G l& e" ^
& `! D# Y0 s" C
Session *theSession = Session::GetSession();" S+ @3 t8 x$ i
Part *workPart(theSession->Parts()->Work());
+ u: n' d/ Z& m2 J7 Q* L! ^+ I Part *displayPart(theSession->Parts()->Display());' W3 ?( T* e# s! m8 e
& T# D% B; r# J. k) y* C/ B; Y: o
Features::Feature *nullFeatures_Feature(NULL);
& s% n( p; S& O7 I O8 \$ L Features::EdgeBlendBuilder *edgeBlendBuilder1;
" C; g# o6 }4 M6 D6 w/ P edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);
) g; U8 u. Y6 d u/ o' z' I9 g- e; o
2 w6 |7 f- n$ S2 C9 Q3 H4 R( e* s
ScCollector *scCollector1;. m3 z+ o$ F# Q
scCollector1 = workPart->ScCollectors()->CreateCollector();# I# ]0 p" E: j$ I
. c$ g' F" h' d- s) b; k
/ X( ]% L0 T6 E& Q std::vector<Edge *> seedEdges;! C( I; W7 ], Q( V6 |( Z5 y9 |
6 O8 I: R) S O3 c9 E) o std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects(); //获取选择的对象
! o- T: A( S e1 J2 |: { _ for (int i=0;i<selectob.size();i++). z! `# r+ s$ X2 _/ ^
{
5 l3 u& h8 y# W seedEdges.push_back(dynamic_cast<Edge*>(selectob));3 ^. j% c" _2 y3 h; r- x# G
}! K9 v8 H$ B$ d" ~, k
% X; O2 \* n4 X5 G# c* q4 y double dia = expression0->Value(); //获取表达式的值
. D8 g% i% F9 i/ \. p stringstream DIA;4 ]8 _7 [3 r# A" C+ U
DIA << dia;
+ t( m# T! N0 P& M, s& H. o
. V1 E" a4 b, s( C) s% ^1 G, n) z5 A6 _
EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;- ~& H% @- B) q; X1 h4 `
edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);1 n2 X( v" i& Z
1 \4 ^" b8 p9 A" n9 l2 r/ D4 M. R5 E6 d7 F5 K
std::vector<SelectionIntentRule *> rules1(1);1 b$ o' e% N0 _. ]2 p* v
rules1[0] = edgeMultipleSeedTangentRule1;1 i! V( w i3 @& I2 X8 H" i
scCollector1->ReplaceRules(rules1, false);$ L: S0 p1 g1 p7 ~
2 `3 @- Y+ D+ o& A: h. Y' t: N
% l; A$ m( S8 [7 V5 g: U
edgeBlendBuilder1->SetTolerance(0.001);
x5 u3 s4 Q$ Y' { |6 i0 l: f
% I. P# v# ]5 i' P
4 ] ^8 j* K& U6 ^9 l edgeBlendBuilder1->SetAllInstancesOption(false);
! X8 R/ F2 g; H' [$ w# z
; m+ j/ P/ W& e* p$ C
( T, r; }; x9 v, k) c edgeBlendBuilder1->SetRemoveSelfIntersection(true);
0 T& U6 o3 L# k* x; G" x
, j0 {% k9 c& N" ?8 ^: k) Y
# M ~4 M) Z3 F( P1 [ edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);: `: A3 a0 I* | v2 `0 _6 u L# C
+ U# h8 N7 _) m( l7 n x3 ~; ^
0 f1 G6 V5 m) \2 N! [ edgeBlendBuilder1->SetLimitFailingAreas(true);( E7 N. U( J, s
/ t3 Y" W- q0 ]. N% Z
8 s, s, J. Q% R" A edgeBlendBuilder1->SetConvexConcaveY(false);) f1 f, k2 D Y
5 ~7 K; q( [5 @9 }- O0 ^- H5 M+ z7 q( u. q! V
edgeBlendBuilder1->SetRollOverSmoothEdge(true);
* [) c+ S( t3 j+ _
! R1 u# Y2 G# X3 W7 L7 b3 p! x. N9 H$ B V# w9 l, W' e
edgeBlendBuilder1->SetRollOntoEdge(true);# I2 `+ x/ L+ A- J; p
6 s1 r7 X. \! @2 D; \/ y- z- V
& [( G$ v! p6 b. }" i- L0 Y edgeBlendBuilder1->SetMoveSharpEdge(true);# ?( Y) J# _5 O. M# c9 ~$ L! M
6 Y. L' o# e% L. }! N' ^, O
! }% _0 v2 h4 q. v# ]3 ?# u edgeBlendBuilder1->SetTrimmingOption(false);, o! t3 b) F3 @- C$ g
3 v4 |- i' P& n
! ~. C" ]+ }) s( f8 a, L/ n* M edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);
2 N! _( Z$ c) e' O
0 u; L4 U" {5 s: n) u. o0 H5 d* E; |% x( r4 j8 |" x
edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);4 a0 X- c2 L/ h; X5 K6 b
. M ` _2 Y$ u2 n1 U
7 R! F, q1 X/ E( C1 f+ v4 H# t edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);
' b g) i4 W8 S/ o$ h
; t' A! z* r4 _% j! u# k: l8 y1 H4 c
int csIndex1;
# q1 [( i2 e" u; f6 w* a6 N csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());
- f7 o& Y, x. z' O& C1 Q- U. F. p" y: I+ O; Q$ \
" g. L" |2 E4 y Features::Feature *feature1;2 V" |/ m+ [7 n+ L: \
feature1 = edgeBlendBuilder1->CommitFeature();
4 O9 a8 g6 n x3 `6 p+ i `$ u8 W, V3 x7 J3 {" X2 t# Y
: Q; d' U: `) C; b7 k
edgeBlendBuilder1->Destroy();
6 a& W) M& q6 u5 Q9 s2 V. {# S6 Y0 m8 q; R' A
}
2 T# ^7 n% p p4 z3 ] catch(exception& ex)5 ]8 y& ~, s, w: U6 h7 U
{
0 ~" p& e4 J4 M1 D& n' I% C //---- Enter your exception handling code here -----
$ n7 f6 `% H+ Y6 T, U. _5 a errorCode = 1;
4 Z! F: J+ w$ c }/ ?$ r selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
- N& d" z7 t. ?% r% p- `1 _ }4 R& T7 q9 ?7 L$ Q& e7 {; F4 w& [! Z5 C
return errorCode;
7 o' ?9 f, o: s, F: `}& S" W! u& T+ E& x# O, D( c! J% k( A
! D) U, D8 A6 I0 |) ?! x
说明:因为字数有限制,这里只贴出关键代码。
5 l( x0 Q, e [! ~& s
" S x: x9 E+ n# z: K3 m2 g% O2 ?9 u6 J9 I7 R
* L3 |0 x0 u5 s) t |
-
评分
-
查看全部评分
|