查看: 4196|回复: 3

[交作业] 通过UI结合代码生成倒圆角功能,有成就感!

  [复制链接]

7

主题

9

回帖

228

积分

培训VIP会员

积分
228
发表于 2015-8-15 09:15:43 | 显示全部楼层 |阅读模式

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

×

& |+ |" b& F7 D" Avoid selectedge::initialize_cb()
/ D) L, s2 @* d- ]{
9 C' L) J2 b/ ~, I1 h3 N$ y    try, h5 e0 v  p/ F3 O
    {
4 W7 [+ t/ B5 c9 H% l0 J( e( c
        group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));
+ n/ ~$ Y+ A6 K% h0 H7 U        edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()-             >FindBlock("edge_select0"));
: D+ r% M; s2 `3 M" |        expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()-       >FindBlock("expression0"));}% Z  n3 t' c3 W; _
    caTCh(exception& ex)
5 i  f2 m! {0 u, R4 W    {; |: U" J8 f7 j
        //---- Enter your exception handling code here -----
9 Y5 C0 [  S( W, W  d        selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());$ Y- R+ A/ h+ |
    }
- Y; G$ U# e7 [1 D$ x- T- T}
& y! N% B" [0 e) L5 z2 Q" o$ Y+ h; n1 }" e* R
int selectedge::apply_cb()$ p+ ?& y4 Z' V3 `7 h
{
. T' d! B3 V* f% J3 i9 Q    int errorCode = 0;
' D9 {$ c0 d# |% \3 O    try: a# u' }! X. F) W4 G
    {; r8 c2 [# x9 u
        //---- Enter your callback code here -----
6 C" U0 }: E! {- L) B
  X% e6 N  n' G+ w; g8 V$ H0 m
3 J3 G4 y1 k. U  `" ~

# k. i, n: p9 A                Session *theSession = Session::GetSession();# m4 ~: m8 h9 [% i
                Part *workPart(theSession->Parts()->Work());0 z9 K: V" r: M1 {1 R1 R
                Part *displayPart(theSession->Parts()->Display());7 B0 Q4 |0 X' ^/ K' g0 U
8 T3 L; `" f7 [9 b# J
) Y0 f0 W) J% _/ }8 L* G& Y, e
                Features::Feature *nullFeatures_Feature(NULL);0 m0 V, ^* t# F8 Q# a
                Features::EdgeBlendBuilder *edgeBlendBuilder1;* h" U8 ~5 W6 q; k
                edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);0 C1 x" O* U5 _5 ^% }2 k& M
# W) a* L+ t' b$ W5 f9 g
: |: V& A4 d. e5 L; z5 d5 k
                ScCollector *scCollector1;
* N& ]! T) n1 \7 O' z: k: l                scCollector1 = workPart->ScCollectors()->CreateCollector();
1 j, `6 P% P- ?: x; _4 N* \0 v. i7 J: v: O, z
4 N  K5 F* K4 k
                std::vector<Edge *> seedEdges;% C* \. I: r( t, H
               
; D7 ^% l3 w- J, w; i                std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects();       //获取选择的对象! r; I% z3 K- V2 Q% I9 S
                for (int i=0;i<selectob.size();i++)
4 [" s  e9 Z" S, Q6 O  _                {
9 V2 H% U" I. Q+ u! {0 V                        seedEdges.push_back(dynamic_cast<Edge*>(selectob));
) H+ w9 i' G7 _' j& Q/ H( s! f  }5 v( L4 K* k1 T! C# D- P

+ r! Y, W& u' b0 H' b6 O  double dia = expression0->Value();            //获取表达式的值
4 p' E- I) W% \; ?0 Q                stringstream DIA;1 v1 X6 c5 w: f4 `6 y$ s
                DIA << dia;% m7 \9 y/ p2 N) L" e2 Y" M

: x) d5 j& ^% [

4 D8 X8 @! T0 e! |0 N& W                EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;
( R6 _  r9 U5 T! U1 z                edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);
: j/ _9 Y( u6 l$ B- X( p6 x2 B( d: n3 a

- S7 F- [3 n( O) j8 L2 w, m& w                std::vector<SelectionIntentRule *> rules1(1);
3 ?. |( W! n, E                rules1[0] = edgeMultipleSeedTangentRule1;7 X) C2 Z, w/ ^! B# H: ]3 \2 h
                scCollector1->ReplaceRules(rules1, false);
# T! v+ u5 B0 I  V0 R
2 @" l2 {( Z9 N

! _9 L$ q3 j* e9 ^( p! ~& g6 ^                edgeBlendBuilder1->SetTolerance(0.001);8 h6 P9 d5 I3 a5 V# m
: Q: a+ e8 }# Q% }  G- p2 F7 v' ]

( d4 n! n: D6 e) R                edgeBlendBuilder1->SetAllInstancesOption(false);4 ~$ I- u+ k: H4 `+ X$ K5 u

; u: E. R" g: r. n
" V0 |& E1 b  c0 q% Q
                edgeBlendBuilder1->SetRemoveSelfIntersection(true);
+ O1 N( q$ E4 f- @3 ^8 a! {: U2 B8 }: ~

% K1 t7 J7 o- ?6 M# I                edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);
8 }6 \: [2 p: L$ C. A
9 x6 [( g% s& P, j
/ R8 E2 \# E4 D2 w
                edgeBlendBuilder1->SetLimitFailingAreas(true);( a; c  m# }; J+ ?

# ]1 u8 @  O/ N" N* `3 t
  s3 L9 z  c& s2 w0 ~/ O  |7 Z
                edgeBlendBuilder1->SetConvexConcaveY(false);, }; ^) i7 |) u$ U+ S1 _: B& t
# [( V6 o/ t% M

$ k0 G$ w$ t( H. r3 q: N7 }: C                edgeBlendBuilder1->SetRollOverSmoothEdge(true);7 G9 O" x6 L) Q* \3 f; Z

$ b$ y5 e6 \0 L& _

( ]- h' J) Z$ K' ?' q                edgeBlendBuilder1->SetRollOntoEdge(true);. v  X% |8 w1 h" e# }" q) x% I

! J' U: v$ L; b2 Z, a. E. P2 G

, G6 }' X- c+ f0 Z+ w/ Y                edgeBlendBuilder1->SetMoveSharpEdge(true);; G1 }* u( e2 p# B6 r2 c

+ T* Q1 s5 Q/ \4 Z. a$ o3 C" w8 o8 u
7 `. ?1 p( z+ M
                edgeBlendBuilder1->SetTrimmingOption(false);* n1 m" w2 L5 W. i+ F3 f
- D) W' M; d6 Z6 z- n
3 y8 l" V9 i1 J6 F. U$ W8 J& q
                edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);; L3 G# L$ e- ?; J6 c

  U: f7 \: w: g5 K2 [

& T, v) b( _! @9 p% q2 w1 x                edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);; Y6 D9 t! h/ T) p
4 b# G6 s) O" I* ~" Y3 G2 d

: u; F; p1 @0 \; _' s$ j) P                edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);
- G2 E! ?6 A2 Z0 r, [4 ?
3 C+ [' V) t7 E! A4 H/ Q
# g6 k7 o7 U1 V) h
                int csIndex1;9 m7 s- d; j  i2 {2 Q$ W
                csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());+ d% |4 F: X5 r4 s3 b" X
3 b: g2 F9 |7 Z+ l
2 B5 Q( |! \1 i& V
                Features::Feature *feature1;
3 C. U% W2 ?& @0 k! Z                feature1 = edgeBlendBuilder1->CommitFeature();
  t! O* L% H2 q9 P/ c
5 }' u8 h5 B, r( g
9 `' I' [5 h. d$ O% b% x/ B
                edgeBlendBuilder1->Destroy();
* K! A6 u( G% t. ?
$ k/ t& v% i0 n+ |    }
  [2 r+ f6 N4 Y/ h5 ]    catch(exception& ex)$ s# y4 A3 C7 N+ t: L7 A; z  `$ X( a- r' w
    {
9 K& ?- a3 J# i1 q' X) C        //---- Enter your exception handling code here -----& ~8 w& h- U3 c7 G( m
        errorCode = 1;7 j" G; |, k& d
        selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
* \/ |( G" c0 k3 O, U* }    }. U( v; e/ D* y2 P
    return errorCode;
+ }; ?, o, r1 L5 t9 r}
+ O/ N% t0 \; c3 \: N+ @
, R3 {4 |! s, Q* Z& ?% V0 {
说明:因为字数有限制,这里只贴出关键代码。
) M2 C# \( C3 P( T( {! |
9 G- c9 k3 `4 ?6 p. U7 ?% G3 P, R) v  ]! `0 W3 P! I) q

' {1 ?7 }- s6 g( Y% \. Y
QQ图片20150814180022.png

评分

参与人数 1PLM币 +5 收起 理由
admin + 5

查看全部评分

上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复

使用道具 举报

1

主题

10

回帖

125

积分

注册会员

积分
125
发表于 2015-11-4 11:12:18 来自手机 | 显示全部楼层
如果我选择是一个实体,怎么自动将所有的边倒圆角呢?
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复 支持 反对

使用道具 举报

7

主题

9

回帖

228

积分

培训VIP会员

积分
228
 楼主| 发表于 2015-11-23 16:33:40 | 显示全部楼层
遍历加判断
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

在本版发帖
关注公众号
QQ客服返回顶部