|
|
秋爱
发表于 2015-8-15 09:15:43
|阅读模式
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
3 _+ Z; G# H& d3 Z0 g+ }1 B, ]/ qvoid selectedge::initialize_cb()
2 s q4 }( V: j* R7 c{) C: N' o% ?; E6 u6 k9 R& l
try
4 Q4 f4 |" T F/ U' u {5 d, ]- J# C7 X
group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));
) F) O0 ~2 {5 k* S% L8 {* A) n edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()- >FindBlock("edge_select0"));
9 e9 E6 _2 Y+ q' ^ _ expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()- >FindBlock("expression0"));}
; A' G9 N8 h! a- f1 u2 e caTCh(exception& ex)) _& J. M- L' G
{8 v& s% q! G+ Y" U. J& f
//---- Enter your exception handling code here -----
& _( P8 q! k# h1 l' x- E selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());
' r' k0 ` k3 R }/ A" r( m% F+ n1 e, S
}
: X& R. O7 i" m- s
3 @: s% `6 U" e8 B) r jint selectedge::apply_cb(): _+ n2 w' Q4 u y/ h& A
{
# P: L( w: `( s7 i# ^+ l' ?4 ]+ A int errorCode = 0;
( {! b J8 c% e+ A6 T2 N; O try* X( e: k E. F# \, V
{
# ^* \$ J! k" [" {7 @5 R% R //---- Enter your callback code here -----
4 j6 N: B7 U% L% u* m" U; r5 _7 H' E6 d s# ?1 F3 U! A
1 P% B; p( B* C, S4 f
7 i5 C$ T! j3 v3 `. {1 n
Session *theSession = Session::GetSession();+ K4 J9 c0 m2 X$ {
Part *workPart(theSession->Parts()->Work());% i% S8 I. N0 O* B6 H
Part *displayPart(theSession->Parts()->Display());4 K1 z+ s2 f7 j
& }4 c3 Y( P" E- m( q+ [
9 z* f0 l5 e( t/ `% E4 i
Features::Feature *nullFeatures_Feature(NULL);
6 x, e* v# b5 c8 d, Z! R9 _ Features::EdgeBlendBuilder *edgeBlendBuilder1;' m1 ]* X, G* c ~; P- f
edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);
+ @1 _ L9 A4 b# v s1 E
& v( U" |2 n4 ?! O
" n1 D# g4 H* M# A ScCollector *scCollector1;
8 ?9 s9 l/ Y4 j- ?7 X3 N scCollector1 = workPart->ScCollectors()->CreateCollector(); |0 U/ p8 q* _- A/ n
3 T7 ^% m2 c& a1 E3 E
0 T3 B; h# ]* j( [! I, F
std::vector<Edge *> seedEdges;, O0 R9 P+ x" Q! n+ \) e7 j) n
2 i0 U$ G- \+ Q' \; ?( x1 Z std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects(); //获取选择的对象6 N. T- K4 F' i( T. u8 k
for (int i=0;i<selectob.size();i++)! g* V3 @2 W7 J/ k' T
{
3 _$ l" I$ m$ Q/ e; y' H seedEdges.push_back(dynamic_cast<Edge*>(selectob));- i& F5 b" G1 j3 m
}
" W2 q" ^7 y( j! U2 X' t+ p2 F C, v5 E l* q1 ]! Q
double dia = expression0->Value(); //获取表达式的值* U1 j2 ~- H2 Y& l t9 H, H7 |
stringstream DIA;2 q! J8 l. y# _0 G) T
DIA << dia;3 r/ P `* G: u P) Z$ i
" S3 Y5 J( f# @% G8 S
9 _( F$ s! G8 b, k; `: S EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;( G% P0 f. i" O
edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);# e( @1 [, X/ H: g/ m
! {+ s# z' m$ i% M3 M% {( j
3 a" g- H3 M( m9 h std::vector<SelectionIntentRule *> rules1(1);
2 X& W9 H! L! P7 f' @; i. P rules1[0] = edgeMultipleSeedTangentRule1;
! [, y/ ^+ X$ G' R scCollector1->ReplaceRules(rules1, false);" |; f- ^4 l/ g, y+ d) G& G
0 K; ~. @& \! y, I+ l6 G- X
5 K3 ^2 G2 ? i edgeBlendBuilder1->SetTolerance(0.001);
) y! a% b+ _4 S" U/ B4 Q5 [: O- ?, J6 g; r4 g
7 r4 d5 z: r- b' | edgeBlendBuilder1->SetAllInstancesOption(false);3 j# r: p: p) }
7 g/ W( e- D& f) t% t, P8 [, R, w
& t1 p, D: u( x v8 V. a- n
edgeBlendBuilder1->SetRemoveSelfIntersection(true);# }6 \% O9 i; T$ F3 n
" H" Y# S7 M8 F% |) K& F7 k
7 ]; t' e1 k+ V' z1 o/ m edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);& s8 T( v" y o' T; R
0 ^1 ^0 y( g2 o6 A. F z# `, t
G3 I+ D/ [' j4 k6 z: v. W3 c edgeBlendBuilder1->SetLimitFailingAreas(true);
2 W8 R# r( w' ]% J/ H. n
. J$ `" [* |& x( q5 [
# I, U# c: Y! m5 }" ? edgeBlendBuilder1->SetConvexConcaveY(false);6 y0 M2 ^2 D+ u) l+ G
, G% S8 e) N1 I3 C5 g- a6 I. E# T2 i9 V$ o; @% _
edgeBlendBuilder1->SetRollOverSmoothEdge(true);7 Q3 e* i- h! O$ M3 D5 y4 Q
( ]2 R, Z) T! |$ Z5 e* l: q% R
+ v" Q7 h' @; k. I. \$ h edgeBlendBuilder1->SetRollOntoEdge(true);' y/ o8 ]8 D6 i2 H
4 d- Q+ {! g+ I/ C3 a3 @
) A& G. q+ M+ `! a edgeBlendBuilder1->SetMoveSharpEdge(true); L7 R) S! u$ C8 e1 W
8 b- X9 V" C0 N1 H# K8 P6 D6 D# c1 t' F# @# j k) X
edgeBlendBuilder1->SetTrimmingOption(false);. L8 x" _0 ?5 W* M7 D" V) H
! |$ v7 K7 P1 Z
8 g+ H% l6 R2 f, \5 V edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);2 V' c: @1 e) m9 b
1 l2 u7 N, z7 `" T. y [0 [2 v
+ y% o. i. x1 z* v* s
edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);
$ n1 }+ o4 H* p$ e. R( d6 W% b- |0 @, s7 N$ t s, y, R
; [$ A- ^1 n! `) A: f/ }# @0 j edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);' q! X3 c6 M, L) Z2 X! i' p
! f' y# q& x2 E2 g4 |0 W. y
! z& S* Z2 r. L4 F, j( t3 ~
int csIndex1;6 ~5 h$ _0 R+ [4 e
csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());
# O8 ^: [" V0 F$ b0 _5 L3 b
' m/ O3 |% ~6 H' y
# {: Y3 H i" R" v0 w; e Features::Feature *feature1;7 Z$ L$ {) m5 w0 G( l! I, A" \
feature1 = edgeBlendBuilder1->CommitFeature();
8 ?5 E+ N. j* |5 u9 R) K
; H' K: h) D& B* Z9 N. l: R) y
4 {1 D f- N- Y: Z1 ?6 ? edgeBlendBuilder1->Destroy();
+ s, C2 m& H' Z& k& N' `1 C- O. D& [
}3 R7 ]* i3 k& A' `
catch(exception& ex)
/ V8 }- U7 M, r: y& l {& d9 V, g* c- B8 ^
//---- Enter your exception handling code here ----- O, I( d3 l# O9 q
errorCode = 1;
) P/ J2 S' y+ d( y7 G+ S selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());' S2 f' L% u9 f# E2 z
}
! ?, G* w7 W% H return errorCode;5 D# W T% T9 h2 M! _1 Q/ c
}
0 w J3 e( C. ?) w/ c8 o" f' E j" n3 Z( e$ X5 e x
说明:因为字数有限制,这里只贴出关键代码。
* O( F- r' P' x& n/ x2 c7 V% A: X$ j( s2 R3 W0 P d
8 m3 N9 [9 `2 x9 A) f- L
" m! l: r, R$ K) ^9 p& _6 i |
-
评分
-
查看全部评分
|