|
|
秋爱
发表于 2015-8-15 09:15:43
|阅读模式
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
9 r; J! ], z- {" g
void selectedge::initialize_cb()% p; a2 V, A" q3 n2 @% c- `
{
6 ]9 R# F2 z+ H" i9 q: F try
3 B2 G0 A" {, G {9 J" V& C3 b7 w! l3 ~$ P
group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));' I+ o! c4 x" _
edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()- >FindBlock("edge_select0")); P1 R& k) ]' Q \) J# G' {
expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()- >FindBlock("expression0"));}1 [- Z; n" T* Z" L+ G4 c- z
caTCh(exception& ex)
8 d% M2 _9 T1 B' R7 H b. q1 `+ f {
6 ?/ ^' a' P8 t! X& h0 v! J5 @ //---- Enter your exception handling code here -----
" a* O) l6 o* J" O ~# s selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());9 ~' e* G$ b% ?2 d
}/ g h6 R1 o: ?$ y" q
}
& i! G) _) I4 c# Y
% ?. z$ }9 N% G( {7 n0 g/ Gint selectedge::apply_cb(): F4 B4 l# n1 v* I0 w: q- B
{; H9 R' r# b6 h1 Y; Q, a2 |
int errorCode = 0;! ?3 |) \4 K; `& m; f6 R
try" j- M7 h9 J# e2 P& ?
{* E" m3 Z4 K+ @4 U- N
//---- Enter your callback code here -----
+ e* \ D( `+ Z. `9 G: Z1 B! u: J" C) W+ [( q: }: C/ F, [
+ G8 d* w$ e$ W2 j( c
* h8 ?2 H9 c9 L/ |( M- l
Session *theSession = Session::GetSession();7 d$ ]; i: k; I4 W- q& a
Part *workPart(theSession->Parts()->Work());
8 |- p* r" F1 C! o3 _5 J. I- \ Part *displayPart(theSession->Parts()->Display());
3 v0 y/ \7 g+ p$ y" Z- b: u: X9 r- ~& i5 e! A" Z: e! Z0 u
) S9 ~6 R3 \+ Q, l$ t( a& s Features::Feature *nullFeatures_Feature(NULL);
, e7 [! k' j2 p- u" C Features::EdgeBlendBuilder *edgeBlendBuilder1;/ p7 n6 K9 P+ t, L: Y# |
edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);
- O/ W) V% P; F1 |# ] y m& ~6 N+ D/ p! c: v1 v& I
3 f2 N2 C3 y0 c( J- p ScCollector *scCollector1;
; d) Q/ O0 t Q3 @; |: l/ k scCollector1 = workPart->ScCollectors()->CreateCollector();4 J4 x: N! h# Y1 i0 j$ w
$ G' n8 y/ j- h
' [2 b# X* w0 b# X8 I! t std::vector<Edge *> seedEdges;
% S1 R+ @; N. a2 {, P; H& } : h2 m% R% T' h3 e( |
std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects(); //获取选择的对象
* `, I7 D' _& m3 S( g! i6 y+ P for (int i=0;i<selectob.size();i++)" p9 o7 Z1 g% g- g/ D8 X( S
{
$ \0 f# X. I9 Z4 v6 x- O! J seedEdges.push_back(dynamic_cast<Edge*>(selectob));
) o8 m+ r6 v% _3 [ }
/ l; M$ F) p1 [2 ]$ L9 J0 P& Z# Y3 Y( T8 G0 [
double dia = expression0->Value(); //获取表达式的值3 K$ H; z; G6 w3 U4 \
stringstream DIA;
; p$ _/ `$ u' r DIA << dia;& Q* E: [# K( x! Y
( G/ g- B4 C; n. d8 M$ N( @, i( w
- R/ B0 w7 h% q4 W( \ E EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;; Y1 _3 T8 Y3 e- v' Q. ?8 t, ]! |* G
edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);
% W; {% s; \7 N2 e
. K% r1 u; ?3 J6 Z, m y
# @. Q( |' `2 g1 l) r+ k6 _; X std::vector<SelectionIntentRule *> rules1(1);/ V2 c8 R5 j- D: P4 }# R' Z
rules1[0] = edgeMultipleSeedTangentRule1;% o* o- V, B4 i; o o' w; f( b
scCollector1->ReplaceRules(rules1, false);& x8 W+ r; {0 l& E) A+ \
+ r0 @* p# s: B
1 y% K- z4 j$ T6 V# u- c8 v edgeBlendBuilder1->SetTolerance(0.001);8 x$ l# r; u/ z! u% S% t. G
+ i' t9 b% k1 x1 z
! E% N2 f; c: K edgeBlendBuilder1->SetAllInstancesOption(false);; k" [3 ?4 x( m. }5 U* H
0 d4 N6 M; G8 _: _, Z( U3 p7 F
7 f* M! i8 T0 t" Y$ P) `/ K edgeBlendBuilder1->SetRemoveSelfIntersection(true);* u) s( k+ U/ ^$ n) B U p
( C4 v& v0 i" j4 ]' c" D5 E$ i+ [$ R
edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);
, X' y% G' }" Y: K% y1 B! F: h m n7 G6 H( _8 A
" a) t* ~0 | Y1 t( g' Q
edgeBlendBuilder1->SetLimitFailingAreas(true);
% P% x' y$ Q) j/ Z
6 x3 z t ^# n) U
& a5 e/ X: W- S/ h$ M) _ edgeBlendBuilder1->SetConvexConcaveY(false);
' _, j' |+ @( N: n
! Z6 e* [0 d) ~) e) p. m5 Z% Y2 ^' z! D$ N4 H3 Z
edgeBlendBuilder1->SetRollOverSmoothEdge(true);
. T5 Y' ~4 Q K8 C6 ]
# m+ c% J' B- N- Z# {( A$ p* m* W- a6 I; |, R2 n' a* {
edgeBlendBuilder1->SetRollOntoEdge(true);
8 w7 N: W; {+ [8 I, _8 }. `5 Q* p9 S L9 I0 }0 e: n% X# F
% u6 d& L* J! t' ^. A edgeBlendBuilder1->SetMoveSharpEdge(true);" ?- M/ J% J" A
, r& l6 N# A" {/ r3 A ~+ B& }" C) o$ ?' s
edgeBlendBuilder1->SetTrimmingOption(false); n" |/ z6 c& P% z/ ?
' W7 ~: f# l) W/ [* ^% J0 |. g3 K. _, r% t B A
edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);! |7 b3 b/ s' ?- [ t' G$ \3 P: |
' \9 N H+ N3 S& } A
. E1 N6 ~: o" v# \- v7 L* `0 Y
edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);: i, x X, c( V* k6 t, Y! `
9 z6 v: m# D1 S! x+ V/ X. a1 b+ ^) b0 ^* H. C9 \- r, ^
edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);
2 x- E, _: x* {6 w& T, s. T* t( U9 J0 Y, {
9 r8 }8 a/ g: z% k! T- G! Z: y int csIndex1; Q" @" P9 p9 h- k2 F) {% l5 E& i
csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());
; ]# j0 K; T$ {) |- M0 S8 A3 Y
( F3 J4 [2 S* D5 g# I: T! f- {; Y# Z
Features::Feature *feature1; _$ F! C6 k' m8 A# M3 c
feature1 = edgeBlendBuilder1->CommitFeature();
1 z0 G4 [! e* X
' }. T6 v4 X3 f5 {0 ~+ B& i8 N) F# b
! T* \# j5 q( [: `( R edgeBlendBuilder1->Destroy();2 A( l/ b3 }* j% F% \& @
" g4 x1 F! A8 Z3 h6 u }- b0 w7 r3 l6 v0 K# Y
catch(exception& ex)
4 T6 ^$ A7 m5 X/ m) Y j6 \ {* n+ |. v% ?! v, m$ n+ Y" W
//---- Enter your exception handling code here -----
! R0 F( K* i" @3 L8 k; @# z errorCode = 1;
& Z, F+ g8 S: ?* { selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());, G" [: \1 A( O9 U# Z$ d
}
! M. u, E9 l J0 m( Q" T' W return errorCode;
- l0 G1 T2 X5 ^* A: `}
) |9 S' V% Y0 _: @$ q! d1 ^ |$ k& R9 E7 k4 {! j- H& U n% I
说明:因为字数有限制,这里只贴出关键代码。
( b( N# T4 F3 s( g" I0 U* J( y
/ Y+ O8 ^! h( J" A8 w! W
! q! o2 n/ u* h3 Q
' E5 y: @6 j. j5 V* [! c |
-
评分
-
查看全部评分
|