|
|
秋爱
发表于 2015-8-15 09:15:43
|阅读模式
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
- y' Y' M4 F# t# W4 Z. M- F# j4 gvoid selectedge::initialize_cb()
P* Z( h! q/ c/ E{# A0 T8 X' Z4 H
try# x: T" N# X# p; |& @, G
{
5 J, r# e8 a/ p2 x group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));. n" P" Q$ } l+ V: n2 y
edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()- >FindBlock("edge_select0"));' u6 o" {) ^7 x) {; I
expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()- >FindBlock("expression0"));} L, ^7 X6 f9 P9 |/ i# W1 v
caTCh(exception& ex)
7 X& F6 z+ G& E. x4 Q" M; Y {
4 d0 f' ~7 a6 V //---- Enter your exception handling code here -----
Z! H+ e1 ^; ?+ |4 j+ @ selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());
' }* [. ?# S, R, N1 g1 {5 ^ }$ }, W; B+ G$ H2 b* J$ _5 b
}( P2 \4 ]! e. o' t# s( l1 C6 r: ?
5 M3 T6 \. S( ?5 I9 w+ A' n4 X. L
int selectedge::apply_cb()* r. o7 C+ e9 |8 Z& m/ Q
{& R8 c: s! j4 h. p0 Q" s$ l" E1 p
int errorCode = 0;8 {( T, a7 O9 D3 o; u% L' q! x
try
, p* f; f) d9 d {5 |( E# E3 y4 O- T G/ s
//---- Enter your callback code here -----
) A1 p$ A: m: {8 _: M0 Z
2 G/ X# J9 ]3 G0 ?6 t* O5 t' \, K) X) O4 _" C
8 k( w" e0 k) p% Y Session *theSession = Session::GetSession();
- t8 \7 H9 R; ]3 P, w6 A Part *workPart(theSession->Parts()->Work());. c0 U0 w% O# T9 d1 D! f
Part *displayPart(theSession->Parts()->Display());$ Y' ?9 j2 y3 _3 f, O! _% M U
/ v# O! q5 R' \4 ?$ Z M6 q! p8 l/ n' G. w
Features::Feature *nullFeatures_Feature(NULL);+ k; T% a, k8 E6 H
Features::EdgeBlendBuilder *edgeBlendBuilder1;% g" v( p( X7 P1 h+ t9 S
edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);
: v0 V& w. {* K, D1 N
) ~0 O! N' j& F) T. P/ d+ M6 Z" q* D5 Q0 M
ScCollector *scCollector1; Y" F* `/ J- o$ g: R2 _
scCollector1 = workPart->ScCollectors()->CreateCollector();
D7 S5 q3 u7 l
9 [0 B% [* q: q; L# G& M: P6 s4 M8 N# X# p C) w# v
std::vector<Edge *> seedEdges;" j5 q- G v: }1 _: ?* B
$ D' `2 w% g3 [* Q% }
std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects(); //获取选择的对象6 |" @/ Y" L, q% J
for (int i=0;i<selectob.size();i++)
6 S: G; f5 k1 P {
/ v: g: q8 n% C; A/ I- {2 R seedEdges.push_back(dynamic_cast<Edge*>(selectob));% C) K$ q ~8 d4 I" }3 V
}
) ^( h( E! V4 N' F! A9 t! S o3 q6 C4 C+ J8 F. W
double dia = expression0->Value(); //获取表达式的值
# G) ]0 u! A# A( a stringstream DIA;
# ~3 w, t* f6 T0 y) M DIA << dia;% s( h: E# i5 Y3 {3 F
) }% Q# A" r8 G8 m6 r+ Q0 C4 J2 L$ D# L- `$ M1 i
EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;- h9 I) T( v! |! r9 t0 t
edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);
; `$ X( a) F8 I( C
6 b* i$ n# p& V8 l# e; s1 ]! j
' w7 w1 Q- K8 F* Q. d/ j: @ std::vector<SelectionIntentRule *> rules1(1);
2 V! U0 Q8 T) _; n5 Q rules1[0] = edgeMultipleSeedTangentRule1;$ ]* R7 S( h0 j7 ~
scCollector1->ReplaceRules(rules1, false);
7 Z/ g: r, v" E
* l! m8 G, \9 [8 r, Q' c: g' X G0 L1 \0 Y8 G
edgeBlendBuilder1->SetTolerance(0.001);
) E I2 c1 Y4 F' W- f" n% w- P* Z' w7 ~7 ]$ W) r7 J
! O- \8 O: g7 Z6 j8 Z# m6 D- m
edgeBlendBuilder1->SetAllInstancesOption(false);
. ]0 c" \& B, I; [0 |7 O) H$ D. t! q2 E; c+ X$ ]0 J! F
* e/ B+ ?9 t/ w# P* u edgeBlendBuilder1->SetRemoveSelfIntersection(true);6 y' X/ k' O& P' I
8 o ^3 G1 e8 L; x
/ p- f3 g0 F) \7 G$ X/ `
edgeBlendBuilder1->SetPatchComplexGeometryAreas(true); j6 A2 q+ s7 R/ ~7 T
" F2 X+ J" ?% h+ @; j) L2 y* m
" d+ i/ q5 G. U4 }! U& N+ J i edgeBlendBuilder1->SetLimitFailingAreas(true);: a$ f. R I" G3 P) k3 c* F3 V
, P/ q; d( L; E$ y* n
5 K- U% n+ O" I8 x% X! G edgeBlendBuilder1->SetConvexConcaveY(false);
k2 T( I3 i# m5 f3 w/ g1 X9 T8 W
! e8 @4 J5 V) n! f7 z( h
edgeBlendBuilder1->SetRollOverSmoothEdge(true);2 O# ?6 g& U+ ?( e
, X" v' x' v5 S( }6 q, X( t# A
X4 R) d* [( l1 b( R
edgeBlendBuilder1->SetRollOntoEdge(true);: h4 U: p' D5 ~) a3 [* Z3 f& y6 y O
# q6 A2 x4 s* h$ _
# z$ e3 K) I. ?& z" |$ ]1 {3 C
edgeBlendBuilder1->SetMoveSharpEdge(true);
( a1 ]6 \5 u! s5 q4 {
3 b) T* k! J8 k F6 G3 Q( {) q2 n) s9 k# L4 M/ R( h
edgeBlendBuilder1->SetTrimmingOption(false);' ^7 S; ]: x7 Q. `$ }5 a7 u
) I% ^* k! w0 Z8 S, V9 \$ O3 z( C: f* B8 T+ [
edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);5 Y) N0 C3 n% X) g( [
W7 d2 Q- \# h* c9 F6 b! e9 U
4 p3 l+ O+ Z8 p* ^# E
edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);4 l& e5 Q$ K. {
, w! d# t0 J ?
" b% R X. w6 s& p
edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);
/ a1 S n4 L- ~0 f& f( S& Z) k% v
+ w4 Y5 V; `5 R$ @2 B1 p
% d2 E+ S) K( ?6 C2 b int csIndex1;
$ j1 x( x. v8 i' f6 B csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());
) E- Y8 v" X j" N/ D7 R. Z3 V5 d$ g9 r
0 t1 f+ P6 p* U
Features::Feature *feature1;: \5 b6 |7 x) Z7 O h
feature1 = edgeBlendBuilder1->CommitFeature();
1 t ?# B$ D3 T! E/ q: y; H. h* V A5 U) V
6 C7 j& m4 }# [% I1 Z edgeBlendBuilder1->Destroy();
% l! O" k. R$ O' ], k, @0 T2 E
7 x% h6 y! t# e" R+ n; p I' V& D }) `2 T4 F5 F2 E& k1 D
catch(exception& ex)% `8 Z7 w7 Q, c( \7 x
{% I& W' j0 z; s
//---- Enter your exception handling code here -----
3 P+ @+ k1 A2 Z2 Q4 f errorCode = 1;
# _6 j- r; N7 m- k8 d; y# V selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
6 e" i0 W! U+ a8 ^9 j }
0 x' X5 t7 g2 i+ J7 B return errorCode;
: U4 V& h3 X) K1 i# `3 V$ `}
' z9 P) }# |& |' h8 r
3 v' K1 a2 C7 D- g; B说明:因为字数有限制,这里只贴出关键代码。
. |0 l) T2 L' W) ~1 z( W
W. a2 H/ C* o# v1 E, c4 T. r9 e7 \7 x* D. c1 O1 m& R
; p8 o$ {$ |- x D* @
|
-
评分
-
查看全部评分
|