|
|
秋爱
发表于 2015-8-15 09:15:43
|阅读模式
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
! K B+ S. T6 q4 b
void selectedge::initialize_cb()0 W0 C* Y0 a# o+ Z+ f
{
+ U5 ^( j& d- I try. U4 J* \" b& V( e2 ]
{
& ~3 n( Z, L0 p group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1")); \% G( z& E2 F' H+ |! n; E
edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()- >FindBlock("edge_select0"));
. O+ i: w D$ G1 b; w2 A6 i expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()- >FindBlock("expression0"));}
$ V5 \$ o/ a5 z caTCh(exception& ex)9 {0 J: |! D" \1 Y0 @/ N+ o) X
{
- d. F1 ? H( o6 t" z$ F; p //---- Enter your exception handling code here -----
' E- s2 d, I, p+ C; Z selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());
) c3 W" [7 |. q5 G7 j }8 c% t( \+ A/ i% @) g0 q) e+ Z6 s
}
! u# t- L& [; v# v% z& z6 S
# [9 v4 q! X8 C! Y& A" o1 N/ \int selectedge::apply_cb()" C( p9 b5 B. V
{8 K1 r- s4 K% g# ~* ^: ~
int errorCode = 0;# T; t2 _! h- `0 m$ d1 e3 C
try
" Z3 j1 R \, S$ J0 f {
; H! N+ b8 B" C' u4 ~$ h //---- Enter your callback code here -----
, D6 v+ K- B% g# ~
/ N8 p: C, w" f T' Q
# W+ E, \. a, s( F* M- A0 ~# I+ h/ r% j$ ^. ?0 I
Session *theSession = Session::GetSession();
4 \& T' X$ ?, y1 |0 m& C3 Z/ ` Part *workPart(theSession->Parts()->Work());' y& D5 ~$ n, {/ j" \
Part *displayPart(theSession->Parts()->Display());# A, |0 k! R$ B* S
5 _6 F" u, @/ R4 T: |- _2 o1 H
+ h) J1 w3 j, Q, w, {# j { Features::Feature *nullFeatures_Feature(NULL);
% ^* _; t3 \/ P Features::EdgeBlendBuilder *edgeBlendBuilder1;
( N; s& j& J! {1 ]: m% h edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);
5 E! t& r* T6 |
/ q4 l6 O2 s/ {8 [
& H* `% ] Z& z7 j+ P0 f, I& G6 O9 \ ScCollector *scCollector1;
- ?5 I! E- Y3 \. D+ K scCollector1 = workPart->ScCollectors()->CreateCollector();' P0 K# M" t9 B( P z( V
+ f2 v9 q6 B0 h- k8 @# y" b, M1 m" m- @0 F- g6 D- |/ p
std::vector<Edge *> seedEdges;6 B4 |2 l7 Z; ~4 Q) P. ` {$ \
$ S |1 |& ^$ [" O0 [- Z6 e std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects(); //获取选择的对象% b) h# r0 X) l$ w$ k+ r' R; \4 O! |
for (int i=0;i<selectob.size();i++)1 F: |, i1 M4 Z6 }& Z
{3 X( h% F a- F' b
seedEdges.push_back(dynamic_cast<Edge*>(selectob)); M$ k6 P2 W5 S9 Y
}2 ?! j* a8 _& e/ n. z) [
0 r2 h8 k: }% B/ \( o! g
double dia = expression0->Value(); //获取表达式的值
; s9 N' y! P4 J' t stringstream DIA;
2 u7 g% z* n% @+ s+ _+ g) o DIA << dia;, {7 X" z- a. S& G/ S
/ S% l( ^+ g3 M/ `( H! n* K
+ t6 K3 r" j) x) W: i& [
EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;
$ I! }1 D. d9 k \) V7 ` edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);
. N8 Y- W; D6 {
& D( o0 O7 u o& Y! D" n. s
9 `4 q: `5 F- c2 V* ]& ~ std::vector<SelectionIntentRule *> rules1(1);
: C* ~0 ]. q8 o" M- I3 ^; k rules1[0] = edgeMultipleSeedTangentRule1;: f* U; Q0 Q) l; F4 k
scCollector1->ReplaceRules(rules1, false);+ A S# `" J# _+ h. W% g; S( f
8 J" O6 N; q& U4 T2 H0 O5 \5 L3 O
5 s& F% R0 }6 w" w% \
edgeBlendBuilder1->SetTolerance(0.001);( U* X0 X, I2 ^) l
$ ?" E. r- s9 V$ s" y, |. Y$ N/ s, i" [" R! t8 E' N- E) v
edgeBlendBuilder1->SetAllInstancesOption(false);3 r5 V$ g- W0 O; b
( g7 F8 N# O; g |5 J
2 f) Z9 K& j0 g edgeBlendBuilder1->SetRemoveSelfIntersection(true);0 Z5 t- ~: j1 h$ K" f6 e( e
! B m- u# x: p ]* k; k% G
2 q5 N7 k# A) T+ O A( K8 O+ j
edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);
6 V) G' K6 X) |+ L, B* H4 f. {' c4 ]; `
0 F% n4 q8 _" R edgeBlendBuilder1->SetLimitFailingAreas(true);' D0 |" W5 n; a3 x0 N5 l* Q& z; [) S
/ q2 v2 U- r+ ]- U# H5 Y
+ C" D7 D, Z. V% h. }% B# `. H edgeBlendBuilder1->SetConvexConcaveY(false);" z% x& e! I) {
* y' C: p6 p* s. ?
7 Y I, U$ ~; ^' ` edgeBlendBuilder1->SetRollOverSmoothEdge(true);& V% J! T/ T& K8 @: U, i$ R
) x# g: d$ G: r
r5 n! C' g5 G; ] edgeBlendBuilder1->SetRollOntoEdge(true);
# Z) Z' O7 Y2 C& ~6 z& N8 e5 X$ F$ s0 F- R! W; L
; Y% r c* H4 [9 ]- o7 u
edgeBlendBuilder1->SetMoveSharpEdge(true);
2 g" t& }5 J& U6 ^' q0 t# U: k: W' f M
( ^' v% t# z8 ]- W* A edgeBlendBuilder1->SetTrimmingOption(false);* u6 y+ h$ \9 p: O
) D- i* ]; M' z' W& {8 T
- i$ \/ X$ j. a8 G' s edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);/ h( M" L# a X1 W, i
0 ]) a( G2 F+ d+ v* B! D; K
- x; G2 V+ Z* `' q+ ?6 g edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);3 t0 N& y+ i0 Z% X# Y8 W
) V% S) @1 }" [/ L' k3 J; x u) u& J8 P3 C3 T1 {
edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);
. s2 N5 J* w8 ~$ {2 I% L, D& H& W2 ?' ^7 S. U
; M; k3 M: n+ x3 ]4 E. K( e" { int csIndex1;2 Y! w# C1 h2 k8 b6 P! ~% ~
csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str()); u& z; m- k7 W) p
: s% R) p1 Z) }; Y5 Z; O3 `+ G0 v' Q+ G( B2 F! w) N
Features::Feature *feature1;; M' t+ M! r n0 W ^( Q
feature1 = edgeBlendBuilder1->CommitFeature();+ j4 B, n i0 E$ t, O. S. ], M
! ^* H. G" F2 P' Q4 J0 k8 T: q! n; r
edgeBlendBuilder1->Destroy();
. K! ~5 S6 J* H; F+ R! u, }* l3 {! V6 }/ U) g/ \3 D& f
}
+ ?$ g# `; w) S# U2 _7 ~ catch(exception& ex)& ~+ M# \2 p, m M& C! n Q
{
8 {- F d0 \& x+ B& j //---- Enter your exception handling code here -----
# f- z- ~% {% c7 w errorCode = 1;
3 W9 l. @7 E9 W/ c selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());# {# C3 ~: t' G) P4 c
}/ a! F% ^5 R$ s
return errorCode;
' G e- |8 U# A# H}$ G9 |& B9 u5 |, \" k% o, c
" s$ U" E( B' P. ]+ s3 q
说明:因为字数有限制,这里只贴出关键代码。
: o! `% Q* W/ l5 V6 d8 t" R" ]
! v. {2 W) j }$ `
0 ]; n* c0 u8 l" h
+ f# m' ?# D* y& q |
-
评分
-
查看全部评分
|