|
|
秋爱
发表于 2015-8-15 09:15:43
|阅读模式
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
3 l+ Z! L' `+ ^# H* h
void selectedge::initialize_cb()
% `5 ^) f6 f9 X: ^+ j: o; |, b{
- u0 r g3 P/ O/ V2 d: ` b try
/ z7 z. a* X( }! N: @ {, G* }- U3 T& v7 m
group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));
0 q8 [3 Q" q0 \! T! r6 l edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()- >FindBlock("edge_select0"));: f! e* I$ X0 ]" {9 Q0 I- ?
expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()- >FindBlock("expression0"));}
4 Q/ T% c, l. h, J- m0 k! M caTCh(exception& ex)3 I) a8 a' P% l" O) M) I* E6 ]
{, O" i8 G( q, n6 }) ^3 o; Q
//---- Enter your exception handling code here -----; i) q x& r9 H& G6 _" a
selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());
% B* }( i$ Q8 v* E3 [5 C }0 B. d5 P" C5 ]" K( z1 F3 a
}$ ]/ @: }3 u# b! R
7 `0 q- j* G: t& E: g4 I
int selectedge::apply_cb()
( l$ U( f7 l* Z* x{
; \4 H" K& L1 B$ _6 d' A int errorCode = 0;+ @" j1 o' \- ~) G* v" T
try
. F2 B: I4 |8 B. j) o- h- ` {
& J2 ?3 h3 Y' ]5 g$ P, ]; X //---- Enter your callback code here ----- g) F* x, Z+ v3 ~- R0 b: R
. N5 d* [/ \! w+ K
) B7 ^& t6 ~" {
7 N) ~* O4 l1 t* ^( c Session *theSession = Session::GetSession();
, j. u% j8 r0 k" {# G+ ^ r, e9 |, b Part *workPart(theSession->Parts()->Work());
4 }& y$ F/ G, I9 ~0 X, K Part *displayPart(theSession->Parts()->Display());
/ V# a! g! W+ j& S2 z& ~! @& r7 l( T9 N8 {# ~
+ Y0 t% Z8 k/ S4 f9 W4 h4 F' r Features::Feature *nullFeatures_Feature(NULL);
0 U2 k4 [0 l0 {( Y! \7 N Features::EdgeBlendBuilder *edgeBlendBuilder1;
& N/ D% h0 f+ {8 q* Z1 J7 h1 }# i edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);
( x- o8 [# R: `1 m
9 r" d4 a9 j5 O- t( j" l' o
9 l3 f0 b0 l9 K$ \) g+ s% K) W ScCollector *scCollector1;2 c3 z _% C# n& _
scCollector1 = workPart->ScCollectors()->CreateCollector();
$ g: _1 y1 E, \- M1 D, q) ]* t Q; ]0 E7 @' O( R3 `
3 O, J0 ?% U0 k, U# P! H5 f) Q2 W
std::vector<Edge *> seedEdges;: Q, Z+ q9 U7 c! I% q
7 \+ D" q& P* }
std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects(); //获取选择的对象
% i8 \5 G. s9 D* d9 x5 P for (int i=0;i<selectob.size();i++)
6 } t7 y6 j( {+ Q2 @ {
& e- l, p( W. S! h! n/ w6 I seedEdges.push_back(dynamic_cast<Edge*>(selectob));
1 Z4 J5 p" L" D+ L# q8 y9 l. ~3 j }
) ~: Z2 x9 F7 |) Q6 d0 _0 A
" K1 g- j6 U5 r/ j. D double dia = expression0->Value(); //获取表达式的值
# P, d6 @+ `4 i c Y. q stringstream DIA;
' [5 s+ D% f* w% X DIA << dia;
$ T" s% U9 M, f# b5 k9 g$ f6 a$ V- `) ?: m( C0 p
9 Q3 M+ b) Q) _ EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;
8 P7 \" t! L0 h& p& [4 E edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);
* z) ^" k2 V* O) c' a+ S5 K6 H
) E: l3 N- N$ ^7 ]: b7 `; f% j8 D$ W' N' w, b% e
std::vector<SelectionIntentRule *> rules1(1);/ P. D' n2 |1 Y, L
rules1[0] = edgeMultipleSeedTangentRule1;" U7 }; @' T; o3 D$ [ n
scCollector1->ReplaceRules(rules1, false);
$ @9 W# C0 @1 w! r0 h7 a* U0 `. S
2 w, O: \4 k$ }, W. |# ]
edgeBlendBuilder1->SetTolerance(0.001);9 J% [7 Q: r) c. e8 ]1 H8 Z
- g+ h1 Z8 F* ?5 ?
, G8 X& N* l- F2 _6 D( t
edgeBlendBuilder1->SetAllInstancesOption(false);/ c9 v! O9 h2 M9 O5 c9 c
4 Y# S, R+ K( D" z( l+ X5 S0 Q0 x/ R' O7 Q4 w: g# D
edgeBlendBuilder1->SetRemoveSelfIntersection(true);. ], \4 A2 Q+ B& T6 @0 S. g; S
$ @3 ^/ H' t" m5 }: {$ O, ~# b% E9 j3 K! W$ B# d
edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);
# A$ p& H, @ l6 e! M# a+ X2 w, P. R2 } _5 ]8 g$ I; j
6 c( [8 U+ Q* Y* d0 B edgeBlendBuilder1->SetLimitFailingAreas(true);$ `1 ]% w$ |$ n1 M4 b0 c4 ~& ~
! m2 B1 P6 W8 I! q8 K! X- B$ l- }) C% L0 @4 h1 b# t2 n8 u
edgeBlendBuilder1->SetConvexConcaveY(false);
- T0 g4 w" E; r0 a& h) d) [; J' ^' m6 |& C- W' W2 [
! l+ I0 ?, i7 k+ Z: `8 U
edgeBlendBuilder1->SetRollOverSmoothEdge(true);
( A* N% ^+ x8 w3 |+ o5 y8 Q7 n2 P% ?; f
7 r2 _9 C8 H$ i; [9 e; M2 C6 b
edgeBlendBuilder1->SetRollOntoEdge(true);
/ u( i% ]) L4 s9 r5 T' ?9 {: W& D' [$ f9 J* H
" e( C2 p, F. I/ n2 }
edgeBlendBuilder1->SetMoveSharpEdge(true);
, i2 K+ P. G! g+ }% W. q {: C) v
: i& ~# Y1 c' [$ p4 g- z9 @0 p v j; a
edgeBlendBuilder1->SetTrimmingOption(false);
" j' g& Q: @* E& H3 K" W1 a; @/ \% h+ u% c
6 R1 W9 X2 }" ^! A. S& _' n6 L5 a edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);# u8 O Q8 D3 ^+ f9 h2 P# z2 ]
) u( k- I- L5 `" W% j; `3 X' P! r
- y3 u( u% L7 R edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);
( O8 Q* L+ x8 F' c9 Q8 O+ G
) E! ?; V5 z4 K' ]2 \& }
0 |2 h( ]+ q' ~7 s* J edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);( b4 k7 z t5 N3 a1 d# T* P' @
# n3 a, e) S: n! {2 [
* ?; S" M, j S4 K int csIndex1;
: E9 B. V! A5 K6 |2 L" n! T csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());% K/ n( F& a+ }1 n; e: S; z7 B
- s* f1 y: }, m! u- S$ Q1 v: O$ o
" g- j! H' q1 F7 m
Features::Feature *feature1;
7 Q1 |* B1 v9 e3 U- v8 D; x feature1 = edgeBlendBuilder1->CommitFeature();, b& q" z9 b( y; Z' ~
. r2 k& K) N, y- [. d0 k
, Q/ m8 _- B# B4 a' y. l3 e edgeBlendBuilder1->Destroy();$ K2 n" ~* x* t2 B+ {
$ ^$ i+ i, K; d M2 M, w
}
4 z2 ^3 G6 j$ P7 J8 P. @6 D catch(exception& ex)
4 h2 L1 {+ \% Q3 ^. e* T5 v9 [ {& J$ _( B( Y# T5 ^- k
//---- Enter your exception handling code here ------ a: `# t3 C% ]* _6 s6 Y( ^
errorCode = 1;
# z5 @& F+ a; ~2 N selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
2 K3 l) d; Z) U( s# M( m# _$ p }
. a$ l/ L0 z& C ~/ V) c; \ return errorCode;9 e4 n l6 p) R: @7 E
}
+ S4 ]) k& ]. N2 x& O' F0 [- `. ]1 o% w3 C# S) q" L
说明:因为字数有限制,这里只贴出关键代码。& `( b' h9 @3 ^3 L9 X
$ b A+ T4 _# k( O3 a
( o' |: o& \' H
6 o5 N U. i9 ^- p' e/ k2 u |
-
评分
-
查看全部评分
|