|
|
秋爱
发表于 2015-8-15 09:15:43
|阅读模式
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
/ k2 O4 h2 d$ p c" B
void selectedge::initialize_cb()5 u& p! I0 `7 `$ a
{
& f& E* n3 y s3 N. e try& ^# l1 }; Z/ R. R1 L9 K
{4 Y5 Q" u7 x4 h7 _- Z8 D- A
group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));
! I2 a# y5 M h) p. ~- q' Z Y edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()- >FindBlock("edge_select0"));
4 L: @6 W& h/ U+ T3 K3 I expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()- >FindBlock("expression0"));}
C M& \' x; p) }5 y- p caTCh(exception& ex)
7 c( E2 X- M1 |. q* k" e. s {: W5 r4 d- y7 G
//---- Enter your exception handling code here -----
! x% j3 p9 }8 ?+ J+ L selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());/ K) n9 [; P9 s/ _4 }' \" s
}! |% V% r1 U1 F1 }: p
}5 n3 p% S5 e0 k& s1 n% X4 P, G
2 b" p$ p% Y: t L* I
int selectedge::apply_cb()$ o9 o; Z! Z4 l8 Z1 [9 W2 V
{
0 ]) X1 x0 e6 ~( a& @ int errorCode = 0;, H9 G7 K& p# D
try
3 r0 q4 t, R5 x: Q- R3 f {
5 Y% V- T2 D3 \* G( o# A //---- Enter your callback code here -----; v% X' Z) S; R3 N4 d7 F- g
& O7 x9 Q4 \ G% y! u: e5 S# [3 D+ ^3 m
! a# e% m" e$ |$ v. |9 ? Session *theSession = Session::GetSession();
- ?; A& B# v4 F- S, k; u: J Part *workPart(theSession->Parts()->Work());: r) f' P, {/ f' a
Part *displayPart(theSession->Parts()->Display());
; t$ t: P) M q) L; R- E, m" s- s5 n P# f4 B" {6 ?( t) Z' a
5 _4 Z, x4 j6 k
Features::Feature *nullFeatures_Feature(NULL);
% [) U/ B, P* R( p4 \ Features::EdgeBlendBuilder *edgeBlendBuilder1;
( {% y0 {5 u H& r4 v edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);
8 G! S+ r- y2 X, Z. \0 |- H l) N7 V1 p4 B; J$ R5 S
& @: G: u' r t& F6 s ScCollector *scCollector1;
) O3 w, L# F1 ~$ Z) |3 `& r scCollector1 = workPart->ScCollectors()->CreateCollector();" u3 ^9 |" C8 B& e: Z* s4 j
, f8 a' v6 r% A$ i. B1 C9 i, P5 q6 O- b6 _ d
std::vector<Edge *> seedEdges;+ E4 D1 O4 e- Y- {. _ ^
! d$ \/ A$ y: B std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects(); //获取选择的对象. P) Y# Y, O, F
for (int i=0;i<selectob.size();i++)
. z+ U" `; x1 l; c) p {1 G7 N; J/ D0 I
seedEdges.push_back(dynamic_cast<Edge*>(selectob));
8 N: v( i" H: n& g5 ]" L8 F. v6 s }. G& X6 \' S/ f3 k
0 X) ]) F) i! [$ l+ c+ E
double dia = expression0->Value(); //获取表达式的值
- v& |" i0 {% r3 }# { stringstream DIA;" I9 V. v2 H% I% S1 l9 S; z4 \5 u; b2 Q; J
DIA << dia;$ m/ s o* a$ k! \; T4 t* q8 w
* c- a+ U% p7 d: e, g
' C- F5 A" N4 W EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;7 f" e3 z2 `2 l5 K l4 h- S2 x
edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);8 p% u$ E" \- z* Y
$ ^/ j5 s9 f: E) u/ n
) H6 Q. x. L" p" _6 V
std::vector<SelectionIntentRule *> rules1(1); }& Y- j% [0 T2 R% O S
rules1[0] = edgeMultipleSeedTangentRule1;9 |, E7 @9 x, J6 ?
scCollector1->ReplaceRules(rules1, false);
, q1 V D2 l; n/ G6 O/ L; y6 Q( @' c/ v+ ]' `
7 [) \, O% A6 ?, W! @- Q' ^
edgeBlendBuilder1->SetTolerance(0.001);
; L: u, K/ }% V. a5 J+ c6 W
* l: y% }" ?9 W3 w) x7 W T4 t2 k/ F. `+ T( a7 \
edgeBlendBuilder1->SetAllInstancesOption(false);
3 l9 r) U! a5 C& t# P. c! X1 g6 g. h8 s7 w {5 J
+ T" V/ p3 Q" Q5 h$ s% T edgeBlendBuilder1->SetRemoveSelfIntersection(true);
, H% K6 B! E4 q% x) n: C. N/ E( a" H9 J3 q$ z' i
7 b9 |; w# u3 y7 y0 ]; @* R# h7 q
edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);
/ Y2 B0 F1 m3 ]8 R
8 c: j( p. n4 g: b& u& r9 ?: f R H4 K5 F% }" U- f. U& g& w
edgeBlendBuilder1->SetLimitFailingAreas(true);- n3 w3 N* c! L. ]9 L# t( V
9 Z& `" p( C: n, D d( v) z3 F, b% C8 m; x. X/ e
edgeBlendBuilder1->SetConvexConcaveY(false);) @; |! U( |3 h! E$ @
# _ D& ?2 x3 x; b! x" e
2 b) [4 J$ N- O9 p4 _% e' a8 I) x edgeBlendBuilder1->SetRollOverSmoothEdge(true);+ G3 J' b8 {2 r
2 i6 E/ _- M" o# H9 Y
- h1 Q% }/ A8 W3 H' e
edgeBlendBuilder1->SetRollOntoEdge(true);
6 c- J$ t- |& q% T5 p8 u
8 R6 F' @. B1 ]9 }5 K5 T2 `8 ?
; D1 K+ \2 e3 T6 l: j edgeBlendBuilder1->SetMoveSharpEdge(true);
: j/ G2 M4 P4 l4 d7 `. B2 w4 C; ^& V0 D1 W, p8 n
: E' U: d$ @' r, {6 k8 K
edgeBlendBuilder1->SetTrimmingOption(false);2 L. |' l; j; w$ b
$ F. q1 n/ k; z5 g" S/ k
' r! ]1 G! P- B edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);1 s) s) P: ?! K# j6 H) i) V. g
( [6 x2 J. ^ f/ q
0 Z3 @6 I |" h$ R& g" D edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);
" C% y! T" m; Z- B9 {" d9 `" V) Z
4 _/ X2 P0 n7 ?3 r. k3 p. ^; R5 O# ~+ M' p6 e2 K
edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);
) }0 m) a# [" `4 k& v6 {+ N" E1 ^5 I. {) |+ W
' b& d& _. a/ }, d9 T8 _0 {; |% \ int csIndex1;5 p9 u! ]5 _: o6 e
csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());+ v8 J2 B( k4 g {* h3 Z
w1 N5 c5 g6 r- f6 e R7 p+ Q
# G( ]. l$ L% ], q: Z# {* a' m. y
Features::Feature *feature1;4 A# M7 `$ {$ b7 y* j$ Z; g
feature1 = edgeBlendBuilder1->CommitFeature();7 g3 w8 N! A' I2 ^9 p( ~- s
9 {# |5 R. E, T9 h4 v% i/ f& q( i# N! _3 r. O: L" T% u8 a2 ?
edgeBlendBuilder1->Destroy();1 [- v! F" L, f/ m8 P8 I& [
4 R# {% r1 U Q5 K$ N2 a }6 H& q; P! E4 e# O, B0 M* X9 ?$ B
catch(exception& ex)* v2 G6 `# v1 n$ W# ~
{+ n4 q. h! H/ J5 c' c# ~ w
//---- Enter your exception handling code here -----4 ` F+ e8 v* O! L
errorCode = 1;* Z* l( p, Q0 p: L9 E
selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
/ H, ^! Y% P% q! z }% r6 {! i0 u5 b& T3 b
return errorCode;
s( E4 Q/ T& A) j}( ~) p; a% G' K \% [( L2 s) B5 T
0 Z& `- z' T% @9 B
说明:因为字数有限制,这里只贴出关键代码。
/ l% ^% z {5 ]: Y, U$ J
/ `3 s9 e) ^4 ]; w6 A+ v
M. D8 h2 o! `% _
* \6 D- i$ j( ~5 e, c |
-
评分
-
查看全部评分
|