|
|
秋爱
发表于 2015-8-15 09:15:43
|阅读模式
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
' U7 k" c; O0 T" `: b; O
void selectedge::initialize_cb()
$ z$ g+ g1 `5 t; d7 |% L6 \0 q2 T* z{
# I$ Y$ L, w) Q# r2 w5 J$ T* } try
* @' r, g/ j2 l2 Z4 B7 D l+ P {
3 w, X9 m6 E0 ?* J9 U* J+ E group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));7 W9 m$ \ X% v) E0 r
edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()- >FindBlock("edge_select0"));
2 h$ T4 ~, q3 O9 g expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()- >FindBlock("expression0"));}; J! ^$ }9 V* ]# u$ C# _ b
caTCh(exception& ex)5 j$ r" {. E% W' u4 b6 |, z3 i
{
& w- [' j! \' G6 ]; X$ d //---- Enter your exception handling code here ------ B7 Q7 x( l9 r0 L8 R# X
selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());9 n# _! o+ e( a3 d" E0 S
}
9 M d# G; ~1 A}
9 \$ \# ~& E- e. F1 @! V4 |3 ^, T2 Y. _; I! _! l
int selectedge::apply_cb()! S7 j8 B: Q V
{
. [ g! C( k' q int errorCode = 0;
6 F8 C, q) P2 R try) n9 \! g* o; G$ T6 v4 j- M# q
{
V3 A e0 }2 Q7 l //---- Enter your callback code here -----# j2 C% l& c; l7 E, ]+ N2 |: h+ [, m
o; Y) u, s [9 q2 r! X
7 K' g* x: T- w7 M
" K; }4 h, I* i$ g2 M. ~! s2 T0 \
Session *theSession = Session::GetSession();6 U7 J; h* g: H) S% _; Q+ m
Part *workPart(theSession->Parts()->Work());
; A& w ~5 x6 Y; H Part *displayPart(theSession->Parts()->Display());
7 t% c/ a8 \$ M
) ^7 @9 i: T* _2 K* n _
7 R; K7 _, z: p1 x& a: u% n Features::Feature *nullFeatures_Feature(NULL);
$ H9 S( m |8 U/ o7 ^9 [ Features::EdgeBlendBuilder *edgeBlendBuilder1;
: m4 e6 T; l7 O% n o edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);4 f+ o0 ~; i! E5 J3 D: o
4 V8 x z- ?7 T9 f/ z* f8 s: v
7 {9 ~2 y" `. z& F3 _$ ~ ScCollector *scCollector1;
5 D/ b4 u: h) Q scCollector1 = workPart->ScCollectors()->CreateCollector();3 }6 T$ i& T: `
% g. q1 z& J/ t& J8 s) n
* @( z e# ?* y& V6 |1 w5 S std::vector<Edge *> seedEdges;
+ D7 z( e- [9 p; p3 }! w ( y% u& L. ]) G% x+ Q6 u9 p
std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects(); //获取选择的对象
* w3 A) Z3 i* q+ Y0 \) ~ for (int i=0;i<selectob.size();i++)
. s* N- ~2 b3 o- g4 n {6 c( v) B& a6 d# k3 Z3 }
seedEdges.push_back(dynamic_cast<Edge*>(selectob));% B7 w& ^ R$ r2 g% l! R
}
+ R# @" u0 F4 @
6 y( S# |+ ~5 s$ T/ B" i: T a double dia = expression0->Value(); //获取表达式的值7 R! w( m) |- g! k0 b$ S; l$ N4 i
stringstream DIA;
' L @# r" ?% N4 ^ DIA << dia;
, R+ v% W0 P3 d& W' s
6 l8 }: J- o+ S6 u/ s! i9 v) [/ `$ O5 ^, d& x; M
EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;5 v3 b! t9 c0 Q& f
edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true); Q2 @$ D; y# q+ w" ]" S B
Z1 ?: z, }* R# R) S6 I( y
% b5 K" x+ `# q* d std::vector<SelectionIntentRule *> rules1(1);+ Z7 @; N$ @+ Z
rules1[0] = edgeMultipleSeedTangentRule1; S; D+ D6 a1 n) I
scCollector1->ReplaceRules(rules1, false);
' S \3 I, S% x @& i6 B/ U T( m4 n& F1 P9 o j
: \) E9 K: Y3 r4 P1 Q edgeBlendBuilder1->SetTolerance(0.001);6 @$ ~3 }4 e; E1 a
# U* W# O; |0 I/ z. }# P
# X6 z& L* M" R# d edgeBlendBuilder1->SetAllInstancesOption(false);
* s R: R$ z! Q. {0 A- x z7 f" H+ ?3 U& Y `& U4 F- x5 Y
, h. U: F6 A7 K3 l% G# ?
edgeBlendBuilder1->SetRemoveSelfIntersection(true);* I) a# C6 z; @: T
; Y0 I: u/ Q h3 [3 d3 A% P% F4 S3 F2 u D$ U2 ]6 j
edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);! @4 C! V @9 n; y( T8 Q
1 ~ a* H) w5 [! F8 n
5 G+ c) ]7 A. e# K. e( }/ ? edgeBlendBuilder1->SetLimitFailingAreas(true);1 k" i0 h# t: {' b3 z
- b4 B! V6 \9 |& T
+ _7 t1 K0 s9 f* k* b6 E
edgeBlendBuilder1->SetConvexConcaveY(false);
; A/ |6 n4 p5 c G4 W+ ~' }* {+ o& H5 y- P4 r
3 @0 F2 d/ E6 r& u- W. @( _
edgeBlendBuilder1->SetRollOverSmoothEdge(true);
: ]1 e- q( e' p& N6 x: Q/ d9 R. a) e6 B
$ m% M* t+ \0 w, {1 z
edgeBlendBuilder1->SetRollOntoEdge(true);
V5 \: { R0 G% T# a4 h
# ]( Q& @3 ]/ t: e* @. G
/ v& j3 J7 W Q% Q9 J/ s7 L8 s3 W edgeBlendBuilder1->SetMoveSharpEdge(true);# v2 ?7 i+ M# p4 Q: R& m
; O0 P; S/ P6 l X# i3 ~! @
8 G( A4 [- i) V" }- @: ~* E8 d: w edgeBlendBuilder1->SetTrimmingOption(false);% ^0 q* T& m- L
% b6 o' w# j; ^; D2 ^' Y2 f( D. z( H2 v0 x" t7 }
edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);
+ ?* `7 Y3 e* [9 e3 W! J. K J. g( {" s R0 y, ?, o
$ D0 @$ A, u4 ?0 [: A edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);$ |; n0 j" l k7 t
/ i, C9 ]0 z1 D7 A
3 f o; b0 o0 J5 X* C edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);( Z6 B7 T& y0 X( K
4 t2 {0 V" o: ~! x+ l8 |* ^) y
9 J( Q! d8 [: ?6 ~2 z! V
int csIndex1;
1 o2 l2 D, _ {. B9 N: w7 k csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());7 z, Y5 ?+ b( k% D
7 @8 T9 j6 }( O8 q
% O+ W% ] R5 \) |# J. n/ x0 D
Features::Feature *feature1;
2 q. J" c( m4 s" U4 {) G) y feature1 = edgeBlendBuilder1->CommitFeature();
* v w# {! T4 d
1 h3 G0 [( F& Y: D; l2 H. J2 u" d
9 Z! @+ E5 c& X) p) d edgeBlendBuilder1->Destroy();
( ~: `& [. F$ @
! v+ x# M' u' ^) k0 { }" Z1 G# W5 E5 }; ?1 L5 I! p" k
catch(exception& ex): |! x# h. |# D# z
{+ v; s- q i6 U9 Z# A" t `1 \
//---- Enter your exception handling code here -----
" f& w1 w b& s errorCode = 1;- K( a J \9 q8 F- C
selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
4 u% x7 e, j6 N }2 E: p g# p0 k6 i
return errorCode;* Z7 E+ R7 B! o7 X8 `
}
) C7 Z& s( ?! J7 N+ z' a
7 L% h( X w* g4 ~# N& p6 _说明:因为字数有限制,这里只贴出关键代码。
+ O! A- d" Q% N; l* I: r' ^- Y- i3 j( X# }) i: ?
/ D" u# t4 M9 o, q! _" ?8 ~
3 t$ _' f9 S% ]+ n0 A |
-
评分
-
查看全部评分
|