|
|
秋爱
发表于 2015-8-15 09:15:43
|阅读模式
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
8 [! J1 v0 z% uvoid selectedge::initialize_cb()
% M d- W: G" q! j{
& B. v/ k0 n9 g! z- |" c try# V5 r# A2 T. C, c( H
{
! X/ n& M, D: b2 Y& a4 l$ C group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));
# W/ e/ p) R; f% H* o5 O& ^6 G) G edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()- >FindBlock("edge_select0"));
; k& p/ b: ^$ _7 N' Y) o0 C2 D expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()- >FindBlock("expression0"));}, R: Y- \8 |; M0 ]8 b* p( D y( s4 |
caTCh(exception& ex)3 g* K: F1 [( Q) q) e
{
( a( L0 q( G% I+ J2 A //---- Enter your exception handling code here -----
) ~9 @9 Q+ m. T- X3 T/ x selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());5 x7 R' P) H& e* Q2 d8 V( u! M
}
! f, z1 T: T( C" j3 \}
5 ~; G' S, i* I5 p3 L' ?* |; R: S) b% q5 L" u4 K! X
int selectedge::apply_cb()
. p1 h. v! L* J5 [8 C$ N4 Z{
/ W% D+ a+ k% f' e( @ int errorCode = 0;+ a4 {- F9 q' m
try
' O" p9 M3 r; M: f1 r( Z6 F {
2 h' `! V' h4 m2 R5 a& n //---- Enter your callback code here -----3 k% D/ n4 |! H+ y/ u
! A8 Y; [" w" g. T; H- A- ~" C* Q' o
' S* y7 e4 P/ P( \2 u
Session *theSession = Session::GetSession();
/ M, v" _ l1 p1 P Part *workPart(theSession->Parts()->Work());
) f: @9 s: }2 \% |' b; U8 }$ K9 q Part *displayPart(theSession->Parts()->Display());! S/ |% p" z! e4 B' m( n" W$ V
% A! h: k4 @( q3 d, `' P) s7 [
' B3 J7 f" F$ t# Q' d# q2 o1 t9 N: { Features::Feature *nullFeatures_Feature(NULL);( _& q' E7 K `9 _% t# q6 v1 Z
Features::EdgeBlendBuilder *edgeBlendBuilder1;( q b, j7 ?$ K2 d6 E3 m* `
edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);
$ p3 |8 P7 x5 x9 c, ?
+ Z' o9 W* _8 q4 _! ^3 L5 [" d. ?% y
ScCollector *scCollector1;
; _9 C& S2 J& i8 i3 t, h scCollector1 = workPart->ScCollectors()->CreateCollector();( M" l9 T7 r3 C' L0 q' c4 `
- {0 r' [! k5 A* D# T; {
6 ]6 Z( ^+ s' G& b& p+ r; b std::vector<Edge *> seedEdges;/ Y4 }6 l$ H7 h* S% }; g! Y
4 H( V6 K& }- q/ b0 P/ E1 U" y std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects(); //获取选择的对象
( D+ m( p" ~1 i for (int i=0;i<selectob.size();i++)( _1 \( D5 G" X+ a# X0 m
{' j. ]8 j, R5 w& D* @! l
seedEdges.push_back(dynamic_cast<Edge*>(selectob));
$ r9 b/ @- x" f: C: b }
, |- `5 G# S/ o7 Y8 q9 K0 J i4 a; v9 v& s8 a4 B
double dia = expression0->Value(); //获取表达式的值
8 t* J6 p2 s9 Z6 U stringstream DIA;
0 J3 H6 H5 E4 N' r DIA << dia;
6 d* I6 o( ^' s( T3 v- J
. Z& ^4 X/ P' o' h% I9 m- f& L) y7 P% H
EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;: \6 z8 P: \0 k7 e+ K4 }
edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);
9 }, H7 y- p3 |+ g6 ]" b5 G& x' {9 A1 ]. t# g
! H1 R; D7 R6 i6 h& ~. t
std::vector<SelectionIntentRule *> rules1(1);/ z& T* ?0 m- G
rules1[0] = edgeMultipleSeedTangentRule1;4 C- Q3 [1 ~ Y5 `5 N# Z
scCollector1->ReplaceRules(rules1, false);+ u6 ~ N. f" A8 l
u! P0 P6 D. _( [
. V. d0 r* k/ x7 m0 B# [ edgeBlendBuilder1->SetTolerance(0.001);& c2 s V+ ` \- U9 B7 d! [; i9 O
5 ^/ s+ ]1 V7 L& {1 J$ r4 S% i4 L. @% m5 V A
edgeBlendBuilder1->SetAllInstancesOption(false);
: l4 K( J) u: T7 G6 S {# n) l, e5 N1 c: X4 \9 j* ?% B$ k% [
' Y; S. Z; W4 \. I; c0 c3 ] edgeBlendBuilder1->SetRemoveSelfIntersection(true);
7 U3 p& T6 k! t6 u& B! K$ T( w% m. d) l# x7 e" d% i- h3 U; @
: U2 S# \. p& y edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);$ i- X F$ B/ J$ Z% d* O7 ?- T) P8 B
' C: N* E% I9 n
* B' d0 T, n( x0 F E. w- L/ ~ edgeBlendBuilder1->SetLimitFailingAreas(true);0 h9 F: [7 p4 E! Z8 l
5 X* h2 T, V) t0 ]$ I- r8 v, {
6 }4 p, l. `% c2 {/ r! u* {
edgeBlendBuilder1->SetConvexConcaveY(false);
, p9 o' m# e( y& [$ j- Y a# q" [) U5 ?$ Q2 Q. p
& n f. g# `+ Q% r1 A: Z edgeBlendBuilder1->SetRollOverSmoothEdge(true);
* M& w# L6 f% G3 N& ~- U! E2 Y6 U5 u
9 x" A; [- d4 w$ O. o edgeBlendBuilder1->SetRollOntoEdge(true);
' M8 h& F+ Z" w( y) ^5 ^1 G! L5 G1 A8 n
! R& c# f, y2 A6 J& g% F! [+ v/ @
edgeBlendBuilder1->SetMoveSharpEdge(true);
) N9 o0 A4 v7 D. h2 Z h w
( L! [" O4 m! A6 U# o$ j I. |2 u+ [& |1 `
2 E4 Z' b; [- u3 Y( [. m+ } edgeBlendBuilder1->SetTrimmingOption(false);
4 P- l ]' G, G1 I( r9 q$ U. K; c |. k2 w; q' A8 S8 y8 C
* ?0 h ]* g. P8 Z$ c8 Q: {, P: O edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);
) f: l" T- Z$ [$ G" Z9 t2 F8 }$ v/ ^5 X5 y
' G- E( Z+ }" P0 }% D; ] edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);
0 H: B! c! |- S( m( @% @! Z+ c% A; ?
! _( h8 x X. Z! h4 U
edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);
* j3 t0 i3 C0 w3 M6 c( {; D9 z. p: N5 ^" P# i9 U) R) Q1 J" d
6 n2 y4 p8 B: T _
int csIndex1;
0 \6 k8 Y- v1 w- ~3 l csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str()); p6 U3 u8 P: J6 C/ U
" p C: s& c. c3 S" y5 a7 a# ]( i. {, j* y
Features::Feature *feature1;
' X: {& V/ V- X feature1 = edgeBlendBuilder1->CommitFeature();
) k& u% s( t& t$ W- p4 E8 c$ N5 k8 g! F% A
/ G0 U& @$ b J
edgeBlendBuilder1->Destroy();' Z S5 J( K8 ^0 B: v* L& c, h7 Z D
; x- D0 ?) m8 U# J
}/ }/ P& D2 h- F4 i1 q/ E1 Q
catch(exception& ex)3 s% y' `8 F7 w+ P! w
{6 \0 n: K! L. D4 }! S1 ]- ^, H& h r
//---- Enter your exception handling code here -----! o; B$ I z) _
errorCode = 1;6 ?+ }" `3 \* |) A% c# A
selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
: v$ u1 G' B* Y }# I) t0 V, F: N, h4 _
return errorCode;8 X# V& q; ?0 U ~- v* o. Z
}
8 r; |2 b- D/ Q: b* J; O% ~0 e" B/ X
! X; o& \( h9 _说明:因为字数有限制,这里只贴出关键代码。3 t! X8 H+ S* N: q% N/ l& y
2 O% f# e6 I6 H* E6 s, p% Q9 h% F& M" l( Z
, B. c/ R9 W1 e3 P O' d+ v |
-
评分
-
查看全部评分
|