|
|
秋爱
发表于 2015-8-15 09:15:43
|阅读模式
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
! b S$ p* f3 g6 _: f& w) J- @5 C
void selectedge::initialize_cb()
\, x8 F1 A$ o{+ c/ s6 W. ?3 E2 p; {/ \
try2 O) {" x3 V% p
{; F% e# X' w. K' w
group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));
& R, o0 E7 c5 i( {/ w, y$ o edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()- >FindBlock("edge_select0"));$ f/ E1 `, [( o
expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()- >FindBlock("expression0"));}
* Z! y; _5 D% J; B* c caTCh(exception& ex)
3 g% b9 N- o9 a& H, D3 U0 S! f2 j {
e" J& R; a2 m8 }$ u- N$ K" O9 j //---- Enter your exception handling code here -----
y: ^+ S! @9 I, f selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());
~% s7 e* Y. q/ x& x+ i }
+ n- |" V/ u+ r}5 T) a3 y9 N8 G- K* p# a+ ]
( d/ ?* U+ |, I- ?. P. [' Iint selectedge::apply_cb()
: R* g1 ?8 F7 h% `$ ^{% g. Z) o$ b2 Q k5 n
int errorCode = 0;6 W' N% T [( J" H5 q9 K
try# H- B/ h, q! c! m% v& c
{4 L5 H3 o" |% f2 X- |/ }
//---- Enter your callback code here -----8 F+ p% e! L+ z' L1 P
9 u% R3 K' } ~+ ~& X& j
. [3 q5 w9 u- K3 P) n+ L. a6 `- z' }
Session *theSession = Session::GetSession();8 \! F8 J1 b/ a* q0 u
Part *workPart(theSession->Parts()->Work());6 ]5 a* m7 O% h
Part *displayPart(theSession->Parts()->Display());
* V, l7 A% ^, U* z( |5 z7 l
2 P- U9 H& [7 v& J' I4 X4 w5 z t {2 p6 [
Features::Feature *nullFeatures_Feature(NULL);
2 M5 U- i, B O, A3 a9 D% ^& N Features::EdgeBlendBuilder *edgeBlendBuilder1;
+ e) v" @, I# { edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);
4 N* d2 j' e, o+ Z) |0 z- L" H. b" ~( ~- U$ f$ G4 x2 K/ q
& `/ a" B/ A3 ?6 M) J/ C
ScCollector *scCollector1;
* @4 S p! @/ \8 ^% P scCollector1 = workPart->ScCollectors()->CreateCollector();
5 w9 G3 f6 d# x+ l' H% }( {) }" t+ ?& e9 P0 Q9 w
0 a" W4 a, h1 {: @2 z& B6 H6 P
std::vector<Edge *> seedEdges;- f8 P9 U8 y* E2 f$ x
4 r. H; B; M4 b H
std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects(); //获取选择的对象
8 G8 \3 b# c( f$ L* Q% t for (int i=0;i<selectob.size();i++)
5 J& K I+ w4 k3 v9 t5 G' R {
( G, ]: _4 y. ?4 h+ G5 o seedEdges.push_back(dynamic_cast<Edge*>(selectob));
2 f, |) t" T3 h3 ?) [ }4 I A8 h& l& z" [2 O- c! s U
+ P! ?* @ G$ Z7 T/ Y# t4 C! j
double dia = expression0->Value(); //获取表达式的值
& C- d% ]% w% p" q stringstream DIA;
( T' `4 n! Q. Z3 o0 i0 k DIA << dia; L/ H& Y+ j! V' Q
' }$ P8 C6 s" ?# M+ J
: _+ R2 `+ R1 a* s' q; r EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;
5 [& p: u% q# {7 b! X3 i edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);! d" }. r" Q7 K `, i
% T/ G9 X/ B: `4 |, {" k; I( h+ G- _0 B7 u% T0 @. `
std::vector<SelectionIntentRule *> rules1(1);
8 d; U( o7 y8 j* E) @. D% g& h* P! q rules1[0] = edgeMultipleSeedTangentRule1;
7 Z5 f) @0 O, p* U. V3 D/ i8 o# {/ c scCollector1->ReplaceRules(rules1, false);( U1 S/ b$ r& F4 |2 z4 L
2 `1 Z; x# ?0 n
) |0 `+ o- b0 Q$ v' y3 L6 S1 u edgeBlendBuilder1->SetTolerance(0.001);
+ M5 `/ m) m7 m
- {2 R4 u) c1 n! I
# S: ]8 m3 k3 e8 G- L9 A+ h edgeBlendBuilder1->SetAllInstancesOption(false);
4 v4 b% H1 X- [6 \+ ~, T/ m4 F) W" v$ j
6 z0 X |! Z/ |5 [" ]9 U* P/ R% y
edgeBlendBuilder1->SetRemoveSelfIntersection(true);
* f3 h+ }$ x" i
/ F) k3 p9 l" a" x' p; L' {4 K! e' j/ Y/ [9 q
edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);
7 B2 A9 r E3 M- Z/ @, m: z" M
9 B4 {9 A8 S- E, g1 A* c
* I0 g$ o$ T, }# o8 y edgeBlendBuilder1->SetLimitFailingAreas(true);
5 ~- D2 `) p0 G
! M4 _9 B; f: q6 B4 c; V$ O+ a5 x! ^2 V
edgeBlendBuilder1->SetConvexConcaveY(false);
- t+ P4 U; C) ^4 O( u8 j/ Z! ` [& [# F* G
1 P. s8 X6 Q+ C: f! E) N edgeBlendBuilder1->SetRollOverSmoothEdge(true);$ |, x9 j! S( N" p2 z* Q6 Q
' i# s3 t/ i+ J1 }
: r: C" w! ]& r edgeBlendBuilder1->SetRollOntoEdge(true);
8 c8 c+ S" o: D1 }
( c3 _; m" }+ _. o# c5 n6 [3 |# w4 v& c" I1 j3 m! b5 x" M, [
edgeBlendBuilder1->SetMoveSharpEdge(true);0 y1 E, L0 k; F" f A/ W! w
& w# K6 u. o% F* L0 E9 V
% E( z# H! f v8 r" C/ F+ J8 } edgeBlendBuilder1->SetTrimmingOption(false);
( h S: w. F& ^, [) J9 x' I
6 d: V1 O, | a- a: \6 i% W, Z) y5 j; R9 @3 W
edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);5 X2 B6 m9 y8 H R
/ x. q9 W* z, V$ u' `; E
+ A" Y" R2 d+ J$ D; y5 W4 G! m+ y- I edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);
( t+ H v( N/ D
7 K3 l2 ?3 @! e& K0 x F$ g0 t
4 T7 O$ ~+ {; `/ T9 L edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);; _0 u" ?3 R$ x
0 f- m" ^3 g& h( f
. `9 @* n$ r$ r4 j& J( v int csIndex1;
0 Q* q* @1 _$ N8 U: m G3 s- B) z csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());
. k$ |$ S! |, ~+ |# b+ e$ P& k7 F, {& B/ \2 g9 C9 N
# U/ d3 q8 A) g/ i4 H, G6 r
Features::Feature *feature1;
! P' s( O9 {1 @) A( T$ K" Z feature1 = edgeBlendBuilder1->CommitFeature();
2 o, h' ~0 @# u. z: {3 ?. a7 B/ w" @
* m4 n4 A; O1 r3 ^8 h4 ]/ P+ m5 ]
edgeBlendBuilder1->Destroy();/ z% |9 W# R" l' j, M& b$ b) M: {& Z
+ i( s: z0 c7 _% X }
5 W" i! l+ D* n; U9 ?7 h7 p catch(exception& ex)
9 y4 k1 ]% @0 n; \% ? {. Q# }; Q. [' ~& D& m
//---- Enter your exception handling code here -----# ?4 @' M# [- g$ `/ O9 d
errorCode = 1;
9 T; c7 ], B# ]6 M8 J# Y9 c selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());- c4 V" U% s k. H9 H1 u
}+ x# n3 K, f7 a' m( v
return errorCode;
% ]; S. J# v8 {: N: f}1 m9 s/ u8 j1 l3 ?
j4 b& k& ~9 h
说明:因为字数有限制,这里只贴出关键代码。
7 ^1 ] |+ J$ F! Q+ D; q+ o5 P- X0 O* g! S4 s
( W% e! y0 W$ Q8 F4 {
9 |6 ]3 y1 O w, [$ \ |
-
评分
-
查看全部评分
|