|
|
秋爱
发表于 2015-8-15 09:15:43
|阅读模式
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
6 c8 ?* p! D ~+ }) T; u0 F6 k6 Jvoid selectedge::initialize_cb()
# `0 U8 y3 s6 g{% R( G1 H4 r( z8 o
try
i i% y* i* R! n {
; Q/ t, K+ g Z6 z; r* ~ group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));
3 w& U4 r! f4 y9 d; L' x( p* m edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()- >FindBlock("edge_select0"));) p0 U3 p4 g3 J+ r! k
expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()- >FindBlock("expression0"));}8 W/ M, s( Z" L" p
caTCh(exception& ex)
( E) o! i: |# d, [( l* S {( P/ m! \3 e$ i% E3 @+ ?0 L$ @6 Z6 ^
//---- Enter your exception handling code here -----
. r+ r% {8 R/ S" U/ } selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());
c. L3 j) F/ e9 A! n }
6 q, T- e( J9 S* s7 |}
: d6 l- e9 O+ j0 m" @* U0 ?& }3 l/ ~# f) v1 S, l0 Q
int selectedge::apply_cb()* A9 ]# @) _& f6 B+ p4 @0 B9 W: L
{
. I3 C; v+ a$ x% G* G! U1 M int errorCode = 0;
& n' X. u1 D7 l try
# N/ h) T5 W* m6 h5 D {
+ E% E+ L' |+ h7 h' u" ] //---- Enter your callback code here -----
( b" X+ i# r/ N3 b
, |4 X% k* s% u& s; K7 B& O
! _9 C+ s; G+ _3 d! a
3 n0 D1 Q9 g- H% C Session *theSession = Session::GetSession();
' k, I4 g3 {: p$ o+ p6 H* a Part *workPart(theSession->Parts()->Work());
" |& v+ [- W' S, G/ l7 U- L Part *displayPart(theSession->Parts()->Display());3 }' T) |% M5 a+ g
5 }( V$ w$ e# H! [( ^
; y# C; T3 Z& S& S6 p
Features::Feature *nullFeatures_Feature(NULL);
" H& g6 l/ \$ r; N0 E, o5 E5 D Features::EdgeBlendBuilder *edgeBlendBuilder1;, M. M, J; \1 p' }% W _' F' m' W
edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);
, @, X# A# q1 a" \5 R: `8 j8 c1 v2 ]/ a2 N+ i7 [3 Z
% K" {- {( J3 d: r, g
ScCollector *scCollector1;
+ v5 J% ~! V! w6 F- Z scCollector1 = workPart->ScCollectors()->CreateCollector();! H( i1 V& k* K( S& l' j; t
8 N/ s) s/ z5 B' Z2 t$ p
0 }$ Y6 H8 @4 \3 p std::vector<Edge *> seedEdges;
( k# l" u0 N) E% |! f: t4 h
/ o$ R( I9 z- n1 J std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects(); //获取选择的对象
% I( x6 a) b H8 @ for (int i=0;i<selectob.size();i++)
+ E: s5 ^1 U% k7 B. R% b {
9 G& p4 \2 }2 C1 A seedEdges.push_back(dynamic_cast<Edge*>(selectob));
5 A& m7 X5 a1 r a0 D1 P7 h. ? }" @. F- D9 V% H ]* r
# j- t/ [ C: ]* G8 f% x
double dia = expression0->Value(); //获取表达式的值
) ?3 x) k8 D- L8 ` stringstream DIA;& x/ z2 }4 }* s2 m) M+ c
DIA << dia;& x) Z; o5 d9 l/ s
* A, F; E8 `3 P: _# `
- W& k6 Q1 @8 h1 ]0 t- [
EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;* @. |2 ~& E" F+ y0 O( T0 Z) W
edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);
9 p% @4 A& \2 k ^6 n- q+ _1 M9 |
' w4 f2 a) L) X7 w0 e. z! c
9 b" M* R/ s7 | std::vector<SelectionIntentRule *> rules1(1);
! n9 L5 r- e$ ^/ U) Z! S rules1[0] = edgeMultipleSeedTangentRule1;, L# p. P2 K: I* X" ~9 B; ?
scCollector1->ReplaceRules(rules1, false);! A" j# _7 W. z7 T y2 D
3 w1 Q2 E! L$ X/ Z. ^- e
+ D3 w! n% j7 O. ~6 n' ~) u edgeBlendBuilder1->SetTolerance(0.001);
" i) _$ R9 s5 L- `4 h& r1 d7 c' \8 \& ~
% |8 ^( t# b3 |) G edgeBlendBuilder1->SetAllInstancesOption(false);+ _& A, H' g- L) u8 ~5 m. O
+ l+ q7 K( N. n# s: Z, g3 o* w" U0 f% c# ]4 G `) x3 u! W
edgeBlendBuilder1->SetRemoveSelfIntersection(true);
( R. {+ q9 n! u
5 O- W, }% t+ G) ]. ]# z; f# P8 @
( k" [* x& o M3 s edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);9 B; j( |/ i: e2 j' M4 B8 O. q
, v. W9 _9 p, x0 L* ?: O6 |7 l8 u: n( X# m9 V
edgeBlendBuilder1->SetLimitFailingAreas(true);3 e1 a6 e3 g2 k( `- W" N- \8 g
# w1 n" j- l3 L+ j V3 i9 Y+ R2 m: E
9 J: u I: T8 a! Z8 t4 n
edgeBlendBuilder1->SetConvexConcaveY(false);' H# ?# |9 Q$ d s% L {$ I% }
3 t: {) r! T5 _7 n9 z7 C7 F; b
2 o& M1 j$ b6 Q
edgeBlendBuilder1->SetRollOverSmoothEdge(true);4 B: F# K: L7 P! O2 a
" z: U y/ G4 {- D& M8 L, y( m: f% e6 o+ I$ w& Z0 L
edgeBlendBuilder1->SetRollOntoEdge(true);( ^% [. E$ i2 F3 h6 x0 `2 K% L# X/ W
8 Z t& m+ v6 N' V' G; y
8 L2 V9 w6 B" o0 g! |% x edgeBlendBuilder1->SetMoveSharpEdge(true);
4 L: H. Z7 F. i% H, p# V7 f! s
# r! I4 T8 Z3 i$ H5 q( ?. P3 f" ?- T, i! O. V* d
edgeBlendBuilder1->SetTrimmingOption(false);+ ~) @' u5 u9 N* y" D; H8 I
8 I0 x) }$ A/ }8 e' }) V
7 T2 r: v+ C5 ~% W/ X j7 s edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);
! m% K' J, }6 x5 ?/ R8 w3 m+ a* c3 [0 T
" ?: Z7 C- H! o6 @+ `" g0 @ edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);. q# e7 P) H7 ]) D5 A) [5 [
8 ~. H+ `& B9 ~4 i
( L) c! e" y1 G- @ A
edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);; _8 Q/ _* t# [; m$ l; p
" g* {6 N7 G) z
" l% v- c9 K! z int csIndex1;
' u! \9 U9 g' j* e9 k csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());) f8 f- R7 G$ C z& E/ i7 J9 ?4 e9 }- A
( M( [$ N* n- M) B" t7 i0 u* D( W8 q& Q. A
Features::Feature *feature1;
9 s; Y1 Y5 }/ T( w# ^2 J' v; V& P( p feature1 = edgeBlendBuilder1->CommitFeature();4 X! i- s6 S# Y, D4 A7 a
4 L! T# g8 c: ]1 P* f$ z7 ^
, n4 m. S. Z+ M! H/ E1 O edgeBlendBuilder1->Destroy();
8 e- n4 f7 X) v) L, N* @; x6 @& J/ q) q. @; f; N
}
" R6 u7 L5 ?" l" S/ j catch(exception& ex)
8 l7 w9 m* P, Z) ~: z. e& ^ {
7 W4 A- }) {- O //---- Enter your exception handling code here -----
9 ~9 @1 g$ b9 e- f" z" g errorCode = 1;
! m0 K, _' ~4 a- V5 W& H selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());7 w/ }$ B: A* I# m
}* c. G) y8 A* _ j k! ?1 f# L
return errorCode;3 I, {0 N, _* i ?0 C. g5 D. D
}& {) Y- L3 R$ M5 }+ [
7 ^: I6 ?$ u; L) ^( u1 x说明:因为字数有限制,这里只贴出关键代码。2 n- Z' i2 V- h" y
# d" n1 G. N s' C. Q7 |& L) @) r/ s4 d
, J5 g) {3 v! A4 c |
-
评分
-
查看全部评分
|