|
|
秋爱
发表于 2015-8-15 09:15:43
|阅读模式
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
! f" t/ h9 ]0 fvoid selectedge::initialize_cb()
+ c- y2 Q6 B3 i/ O{/ t1 ]+ f6 I1 ?& Y& a
try$ M% U4 ~2 f/ U3 H, n- e3 b# B
{
% X1 q! |* j# d% q& X R group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));$ E; B7 }2 Z) k
edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()- >FindBlock("edge_select0"));7 e7 Q2 |! f$ L( ^; u8 u) ~7 U
expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()- >FindBlock("expression0"));}
" v: R5 \; E1 n% I" [& O caTCh(exception& ex)' X0 T, j# b. f( K! I2 {
{2 D/ t) S8 i2 F# u% s* {0 U- I& O% X
//---- Enter your exception handling code here -----% T9 ~# F6 ~7 n6 T
selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());
9 X8 R& o3 ~/ w( I l& d% ~: [, f }
" V2 u" O9 J9 X B$ y; x1 T' J2 _}
D4 n2 [- Q4 Y
5 o% R: {' @& C, J8 T- f+ hint selectedge::apply_cb()
K7 X# f/ j$ [3 A1 y- I{
- Z5 n4 y1 _! `% p' B! H int errorCode = 0;3 ?& p/ j/ Z/ _* s
try/ Q# \1 g) r/ G1 ]4 g
{7 W6 d* A3 m+ C3 \
//---- Enter your callback code here -----
7 y% o1 O. H3 n
3 o* W2 B1 \# Z( ]
* N9 @& Z$ _4 N5 G
& G q: d9 Z# z& z( I+ m% Q9 J& S Session *theSession = Session::GetSession();
9 @5 X) {% e8 I' @) g' v! j7 G Part *workPart(theSession->Parts()->Work());# W n* G& }4 \. J
Part *displayPart(theSession->Parts()->Display());' h1 p! E- C* P, V4 u, }5 g7 D
# h, s [: \: G. M2 n7 n# B
) M' L# S/ c, l, ~, S& @5 u& r: g3 k
Features::Feature *nullFeatures_Feature(NULL);. y5 `3 a9 p9 @0 J g7 z
Features::EdgeBlendBuilder *edgeBlendBuilder1;
# P0 y/ E5 N* p! V edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);% M' G) N5 }/ H' ? I: f: ?
g# y' }" d g) h; h9 N7 u ^- L+ V* h0 u# l( o; S
ScCollector *scCollector1;' i. Z1 z" M! n4 ^" s
scCollector1 = workPart->ScCollectors()->CreateCollector();
- K- v6 Z( Y9 z+ `" |9 A; {" l! N M3 G8 }
3 u3 u e1 f9 C6 b, o( {
std::vector<Edge *> seedEdges;& c, M/ `+ ^+ h
+ h0 `0 o, f& ~: i1 T2 ]. r
std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects(); //获取选择的对象8 q& Q1 l/ _2 ~8 W2 S5 m+ U
for (int i=0;i<selectob.size();i++)
9 V! C& B* l4 X& b$ c {
8 M+ g6 U& n$ f+ X6 e seedEdges.push_back(dynamic_cast<Edge*>(selectob));0 J( g+ x, B9 ?4 L$ R
}2 j2 M. Z5 S8 B: q# \, b; X* C
/ P1 W$ V3 k1 S% Z6 b7 e M) }" T/ y
double dia = expression0->Value(); //获取表达式的值% H8 V4 `6 @, B5 W
stringstream DIA;
]" c, {( [5 u. a" } DIA << dia;
$ x* F% e2 Q7 t. X3 ~5 t
& H$ i, e. ~$ w2 b0 Q$ Z: P0 W1 X
/ ]$ j5 q& m- v) e$ R& Y EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;0 Z/ u, {/ d9 C
edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);' l4 G+ X0 b! j& T H/ R( K3 r
/ l9 a, U, L1 H: k6 `) }( s
2 n" w! U& n/ W3 q1 p% d2 @7 m# A
std::vector<SelectionIntentRule *> rules1(1);
( N8 }: x% W4 P/ Z* C& h rules1[0] = edgeMultipleSeedTangentRule1;0 a* g' F7 C6 x+ I. a2 F7 @
scCollector1->ReplaceRules(rules1, false);
$ k* [7 w3 r+ @9 w# t5 X% a6 h+ v/ Y2 {: i; D v
; u! w, o: m' u6 i5 o
edgeBlendBuilder1->SetTolerance(0.001);) q. p6 a! v! Q" \: ~/ n& {$ n
- j# h8 h3 h5 ^6 q) P: x8 Y3 @
2 h; f+ a0 I$ h edgeBlendBuilder1->SetAllInstancesOption(false);
2 y1 @6 }- o2 F8 T) W1 p2 n" @
3 J* l. ~8 X& |/ V7 O" K& H& ^5 F7 a1 h2 _! m" w9 V, p
edgeBlendBuilder1->SetRemoveSelfIntersection(true);# N& g7 H5 j& s: Q6 Q& ~( L6 q( ~
( y# Z3 O8 K( p
, D; Q( S: x9 D) J
edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);" D$ k6 y6 d" L; l5 z, k
6 L) ]( B; K/ C( H* ?2 T$ N) ?
: e: F+ N$ B3 i# |* s edgeBlendBuilder1->SetLimitFailingAreas(true);
* ?0 a% N0 @! V( Z' }; }' F2 Z3 ~& a- k1 W2 x
' b/ n! o4 a/ L# w* ]3 _" L edgeBlendBuilder1->SetConvexConcaveY(false);8 z/ T6 p& W9 M- |5 C! h; |5 E2 A! F0 I
/ T" ?; m3 O, D5 h& J! c
& O7 p: g7 `* ?' L4 _
edgeBlendBuilder1->SetRollOverSmoothEdge(true);/ O5 ]; g# `! N$ A% M
+ b4 J6 w* r, F8 X& `' s# {: S# T- w8 u) a1 A6 o
edgeBlendBuilder1->SetRollOntoEdge(true);9 z' O: l0 A+ ^& M
' i7 a" `# W+ I! U
$ B" N6 D$ e9 K: l, @! {8 s- s edgeBlendBuilder1->SetMoveSharpEdge(true);
0 v2 B8 D: x. N2 Q6 e5 ]) z8 B2 p7 \0 X; q3 W
4 q0 E" Z. F! B8 [
edgeBlendBuilder1->SetTrimmingOption(false);
, p) J6 o4 d X& X' ] s* P! O$ ]- r7 Q6 A7 z( C1 z
) }# r9 p9 X! ^ q; e edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);
6 c- [5 C+ P0 i) O( t2 f5 e. B: Y5 d
0 f( K% Z2 S3 Y2 n" w/ l edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);
# d! v" V# j6 ?) u8 v& c- Z2 R' A6 [) b6 o
0 m' w& i. O d @ edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);
9 _( T3 k/ m8 K* i, n# |6 @ _& Q9 _9 `- S( B
$ K: T. w, W* U2 f2 { j5 V4 F
int csIndex1;
; O) S \0 F: F8 Z2 r" I csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());7 D7 `) M7 o7 P4 F& A
% _5 E7 X! u' ]7 Q5 Y
* Y+ D7 V5 t6 \3 R Features::Feature *feature1;
% D: x* P0 B9 D: |3 W feature1 = edgeBlendBuilder1->CommitFeature();
- Q5 p" W: S$ V9 R. @5 U* q1 R D- `/ O ^8 f" \
5 R( M8 y$ w8 f C+ t edgeBlendBuilder1->Destroy();
[' v& u0 @4 o ]* v6 X0 x/ Y; }$ w1 u& S8 e
}' D! T7 V; g, ~* J0 N B7 C
catch(exception& ex)
P. p* H5 C/ u {7 ], g" }: ?- E$ P& p
//---- Enter your exception handling code here -----4 B/ c' |+ u2 D6 e: \) w# x1 h' Q
errorCode = 1;
% ^; A6 a) O! Z3 e3 G selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
; [3 E$ r! i% d; s; e }( o) y8 Y( F3 o/ U( m- x$ k+ h
return errorCode;
% Z q- m% \* e- R2 q5 D+ {}# D" e' ^' H3 y5 k
9 s, b% w2 E ^6 }
说明:因为字数有限制,这里只贴出关键代码。
: q/ J9 |1 u- d% m) k4 U) O( b5 I
0 ~& } C" w0 t) Q/ |9 b
9 v: x7 z' T6 w6 u
|
-
评分
-
查看全部评分
|