|
|
秋爱
发表于 2015-8-15 09:15:43
|阅读模式
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
0 {% O% j5 N, E# ]
void selectedge::initialize_cb()" b8 L8 n) O3 e7 ], a6 J }* m4 u5 ?
{
- n! {2 |' H. e: k. E. } try
+ _: F/ ~+ Z4 t% Q {% Q( ^ q4 z/ y
group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));/ Q5 x) |6 i4 ?3 P3 }$ m, w( ]
edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()- >FindBlock("edge_select0"));
$ U" E: a G# k( z y, t) ]6 \8 O% q expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()- >FindBlock("expression0"));}
; d1 D m; K; ^ caTCh(exception& ex)
& a# }8 v2 d2 U. K m* t) S {0 D% s! g: [6 y& t# Q, F9 W: ~' J
//---- Enter your exception handling code here -----
" I6 w' y+ [/ j selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());
9 y; y6 V- ^% D' ?! x) {: [ }
; h, d. U3 @( G}
% q% v4 |2 a7 S9 |9 L3 E0 [
- u( x3 W `8 Z& hint selectedge::apply_cb()) `1 J" n# a. K* C6 P) W, ^
{* _3 u. P7 |% R8 E& x
int errorCode = 0;
4 p5 S+ W) S5 F+ l try
. f, I- i& f9 [/ W, G: z7 I) A- k {) L# X L1 M$ ?$ d7 t. n+ h1 H2 C% z
//---- Enter your callback code here -----
/ N( ` N, z) b( B! j- L
* l' p5 h$ Q- G' e% s* K- i
0 l6 r) q, |2 e% d/ K# m, w( p1 G4 [* J0 w m: n
Session *theSession = Session::GetSession();
+ l/ Y3 N- S4 q. O Part *workPart(theSession->Parts()->Work());' ~& S- _9 _2 q
Part *displayPart(theSession->Parts()->Display());6 j+ N6 l2 {8 X) P* q# G0 I* {9 @
/ D" L) C4 N8 b6 P6 ]& i
$ m' }1 L Z J! F) } Features::Feature *nullFeatures_Feature(NULL);
% H; c3 c- d8 X Features::EdgeBlendBuilder *edgeBlendBuilder1;
) s. |/ J% u% [' o& F6 H; } edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);. X; Y+ A+ A3 N1 n' d3 C
2 C1 j! ^9 l- h9 F& U- ?7 H
' J5 e+ D+ I- v# O" t$ w ScCollector *scCollector1;. ]) O1 D: C X8 u c9 D. K
scCollector1 = workPart->ScCollectors()->CreateCollector();& j; E4 x+ p+ u8 ~( r6 T
; r3 S% z# n* @+ y, y2 I
. L" x2 `. ?$ _$ v5 c7 I$ | std::vector<Edge *> seedEdges;
' O0 M5 e; ]8 H4 Y: U9 @+ Z6 K7 t 0 b" b" R; J- S2 _1 Q Q9 d. ?3 F
std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects(); //获取选择的对象
: x2 n# x6 T) H2 W3 m for (int i=0;i<selectob.size();i++)
+ f) J* a2 F2 q) b" B3 I1 Q {
) l8 R5 V& f" k& w seedEdges.push_back(dynamic_cast<Edge*>(selectob));
3 i4 Y% n4 A# N3 c! u5 ` }6 I& ~+ }4 a+ `# q4 q" ] n/ B( n
7 Q! b: ^" j1 P* O3 K5 f8 V4 [7 G* h
double dia = expression0->Value(); //获取表达式的值; ^' L, D/ s+ M: U$ O! B4 v
stringstream DIA;4 t/ C1 `$ j/ l% z8 z9 W( Y6 z ]; }
DIA << dia;
! K' Z* W8 Y7 G9 h% o+ x: v- o1 n- A s% O3 }: K
3 }, e" S6 P; U' ^) y& ]: a EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;
& W3 W3 o; [$ ~' O edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);
# g8 S' m8 s0 ?1 ]( K" v% q/ L( _4 U* O
7 L+ R; g/ q3 r& T, a8 K/ l! j
std::vector<SelectionIntentRule *> rules1(1);5 \6 v, X. y# C3 H0 }
rules1[0] = edgeMultipleSeedTangentRule1;
# j; H9 r" _. o- V9 V scCollector1->ReplaceRules(rules1, false);# @, i/ h% K. t# ^, x- E
7 I$ }% J+ O2 v- k1 V2 }: E/ e4 C
edgeBlendBuilder1->SetTolerance(0.001);
% S1 a8 Q3 T) g. A8 n- O7 C+ E# L+ X- o- d8 h1 f, l6 n9 } k
1 Y& |0 J9 k1 ~0 ?+ K- p edgeBlendBuilder1->SetAllInstancesOption(false);
9 U7 o& }2 F3 G' |
: _4 L; S# c' P" D
* t1 b/ ?7 _* E/ P' @% ]2 I edgeBlendBuilder1->SetRemoveSelfIntersection(true);
0 B9 b, h( v. Q6 k2 ?/ }3 @ G
9 H \2 l" p9 d" [ r4 t, a9 d. ?/ y4 r v2 d4 ^! r3 T$ K, W
edgeBlendBuilder1->SetPatchComplexGeometryAreas(true); J: ^2 W6 E+ |7 ]6 C; `. ^: p) a! d
3 p; p$ s7 m3 H9 h& A, c" U- ~8 ]0 Q+ J/ D* x. w- ~
edgeBlendBuilder1->SetLimitFailingAreas(true);
( `5 `- Y7 D. T4 j
3 p. J' L, n. ~: _2 _
9 P' y$ F! c) R3 r4 U Q7 Y+ n edgeBlendBuilder1->SetConvexConcaveY(false);
* c6 ?% e/ v: T5 N
- H2 r/ ?' O/ W) `4 J6 i4 }- J$ N
8 e; m+ }' D: P% m% L( S edgeBlendBuilder1->SetRollOverSmoothEdge(true);" }) r. f1 Z$ J" S4 J" O# o
- R; k# m3 x0 t! ^' c
5 i- W Z7 E. A" r! f edgeBlendBuilder1->SetRollOntoEdge(true);$ `- [) q4 l0 O* ?( y
7 v+ n6 I5 f8 U
) D& u b/ D2 q& z
edgeBlendBuilder1->SetMoveSharpEdge(true);
5 M# G2 m# _3 R# q' I8 t$ g3 V* A# `' n T4 c
p3 g% ~+ S8 T* }6 l- \+ N3 A, i) |
edgeBlendBuilder1->SetTrimmingOption(false);
# A0 x1 D/ w$ q( F# \: @- `+ E
: e3 {2 s3 ?' B( R5 I+ `6 Z/ M( x; k0 y+ |
edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);
; r# X# S- [1 Y3 `6 h7 ]8 z; V$ k4 {# v" V; H' Z
- |* ^! F, y6 V# u/ X6 P edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);+ A( l5 A# e% `
2 d* |( i4 e) J$ X2 z) I0 K4 ^9 y5 b: i; {) Q3 V- A+ L" U
edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);4 p9 G/ l% w1 r) h- [' |" b) x# u; Z! o
) l. N$ Z, L/ s
- z, c% i" K; } int csIndex1;' H4 a2 n3 l8 i
csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());0 b$ p; A! Q# ?; h' ~7 B2 e
& P# \) z8 K6 g+ e& y
( n# v1 `4 a& Z" P" A+ Q Features::Feature *feature1;) v" z- M& e1 {
feature1 = edgeBlendBuilder1->CommitFeature();
/ v$ y7 F, [7 Z3 S; @6 I6 J9 r" Q) W1 X/ n
* Q% O# \) x# L0 D7 p0 ~ edgeBlendBuilder1->Destroy();# b; g# f( Y0 \+ O
8 o- N' f$ c' K
}
) y0 v8 m0 H: O6 ?: l' @6 Y catch(exception& ex)
5 Z) K! k# w7 |$ Q7 x {& v d6 _. E" Y
//---- Enter your exception handling code here -----
& D8 M. s- g: N* n6 a errorCode = 1;
0 H7 M. E" ]2 v/ g- X selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());+ g a3 |0 k8 w) J0 u& t, H
}6 ?" V- m! _+ \* f
return errorCode;4 S3 ^1 [8 K$ v( D
}
- _: W. P( m. P, @3 e: Y( b; V+ l) h' @. k) P! @; T
说明:因为字数有限制,这里只贴出关键代码。* T; d9 E* Q4 L* O, A
2 G% J6 ` \8 m! \
c% p! v9 G/ X+ \7 B& r, h' B
+ f: E( w. t; l) J. N2 K! P ^ |
-
评分
-
查看全部评分
|