PLM之家PLMHome-工业软件与AI结合践行者

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

  [复制链接]

2015-11-23 16:33:40 4242 3

秋爱 发表于 2015-8-15 09:15:43 |阅读模式

秋爱 楼主

2015-8-15 09:15:43

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

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

x

/ r$ f% V; n" T% r0 I5 mvoid selectedge::initialize_cb()
# U: L1 `( h" D/ ]{2 \" o2 _/ a4 K5 n' `( X5 ]6 t& u
    try) ?% y9 [5 @1 z2 X9 z
    {
% a" h5 d& M( ?1 c6 [5 D/ h# N
        group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));$ M* Z7 C! }' Q' O2 X
        edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()-             >FindBlock("edge_select0"));
" F2 ]$ V( H7 K, J7 @+ C+ R, ]7 z7 U- K        expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()-       >FindBlock("expression0"));}/ U+ u1 b5 r* n; k8 O$ ?. p4 J( T
    caTCh(exception& ex)7 E8 {# j) b  i
    {
* o: V) I5 P0 O+ W5 g        //---- Enter your exception handling code here -----
# K5 r! S8 z0 n; H        selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());
( k4 p- I* s: U' W; s. N    }& r# }) U% g3 k, B' B9 o! y
}: f9 p' y) C5 a# I* W7 r; f# a. i

/ d* }+ i6 W7 ]7 ~' tint selectedge::apply_cb()
# d, y6 ^) \  r& d; ]  o- Y) M{
  i/ a( X" @$ i& W# |5 L; E    int errorCode = 0;: K6 J' \$ ~: f9 l7 t  r" H; ~
    try
) d( W- P! c0 A  P: L+ d3 I3 K; l    {
! \" J& f% m/ _        //---- Enter your callback code here -----4 b) M  K0 n. p, H
" [" e% q( Q+ B/ \1 A

; C) d8 F% \9 T5 P+ W/ n
# E. R- P8 l: ?) k% x' A5 {
                Session *theSession = Session::GetSession();( n5 e3 @+ Z( G
                Part *workPart(theSession->Parts()->Work());
2 O( g0 }3 g3 f                Part *displayPart(theSession->Parts()->Display());, T- D; y: h4 n0 R- P

, x* ^3 N5 W0 ~& R
: T5 }3 V" l& H, U
                Features::Feature *nullFeatures_Feature(NULL);1 h! T' i# m9 D; k. x  o% _
                Features::EdgeBlendBuilder *edgeBlendBuilder1;
+ P0 `2 |/ q  ]/ l; T9 ?2 Y( n                edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);+ A+ h9 @- h6 \+ ~- u% E
" b. ?# ^. N9 B/ X: W! }: y: T
2 h/ n, H9 h. M: f
                ScCollector *scCollector1;
7 N; p2 ^. D  w! C                scCollector1 = workPart->ScCollectors()->CreateCollector();
7 l/ V6 q* n7 J& d% S) w. s8 S8 ~" D1 A( j5 {
# A" v5 L( s# v- }; _
                std::vector<Edge *> seedEdges;6 I+ m+ {8 f3 ]/ t
                3 Y1 ~1 [8 |, z- P3 |
                std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects();       //获取选择的对象% ]7 D& \: R1 a. i% H
                for (int i=0;i<selectob.size();i++)
3 D) o4 w' n& ?1 F+ f6 p4 r0 h                {
' g- _2 Z. Y2 T' v6 ^4 E                        seedEdges.push_back(dynamic_cast<Edge*>(selectob));
5 X* A$ o8 I  e  }
2 Q% ~/ w3 f+ |7 z3 I, N: b$ x7 o2 z. H6 y" e7 ~9 \
  double dia = expression0->Value();            //获取表达式的值
( j" S. V: M0 K- P                stringstream DIA;
- e% x" c, C8 |& H" W                DIA << dia;
' m; g! z2 K! N$ j2 O( B8 Z' d# `; x7 d, _0 B- i+ |4 `! k1 J
& x7 M4 v, w/ c+ G
                EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;: O5 j' h+ a1 a* g7 F; N2 a
                edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);
0 z( I- }/ u) k9 z' E1 {( @' y* ?
0 E/ C: [$ b% x- R  Y3 p, X6 N& |/ {
( B# t, r. w- f) d6 ]
                std::vector<SelectionIntentRule *> rules1(1);
. d) H9 p! s  t" h                rules1[0] = edgeMultipleSeedTangentRule1;
6 u: ^  u& C0 L& n, I: A                scCollector1->ReplaceRules(rules1, false);) [5 \- L; U9 g$ U- w. f6 k

" J. ~0 e( k! C* \
) w2 i- j# u) o8 B% F4 C! X
                edgeBlendBuilder1->SetTolerance(0.001);
3 @1 \6 k# J  W7 w; D0 M5 ?4 K  `3 u
2 l; [+ p( {- ?( l! H9 b3 E

  m9 Z* q2 g1 o4 o$ b$ y                edgeBlendBuilder1->SetAllInstancesOption(false);
, ^) \6 R8 p5 f2 ~0 G
7 M. r( ~2 y) ?8 P
' r* ?  D9 }# ^9 W" j/ U
                edgeBlendBuilder1->SetRemoveSelfIntersection(true);: N4 k9 W& P. H) W) N* B1 j

/ i; |( f  _& y6 r7 t

# \# z1 G9 G& c                edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);/ D4 G8 z' e6 _* n" X6 J& ~

& v3 M2 M3 x4 r3 K- c$ i! i$ R

' f5 \7 l4 z$ w- m                edgeBlendBuilder1->SetLimitFailingAreas(true);
) x- ^" Z0 Y2 d7 ]+ n& H* g6 _1 O5 x2 W  O/ p
  p8 t4 S; `7 y) c
                edgeBlendBuilder1->SetConvexConcaveY(false);
4 E: U9 `# F: D  H
3 `0 b5 i* B- `. |

; d; n8 i) O- J" j                edgeBlendBuilder1->SetRollOverSmoothEdge(true);
& d6 d* n( a! w% i2 f& T# g1 y# Q" C  Y5 d) t# |

. s7 T  H8 I0 W                edgeBlendBuilder1->SetRollOntoEdge(true);2 j2 a$ I/ R5 ~% B
5 p: H1 k8 J9 p; j. d

8 Q" N# w9 |' z; @4 }0 h5 z                edgeBlendBuilder1->SetMoveSharpEdge(true);
. Z" M1 k$ X; v. t0 R
2 {0 a; |; y8 z1 p/ }9 I0 g
* ^# f' U  i0 l" ]. \
                edgeBlendBuilder1->SetTrimmingOption(false);0 k  C5 t- y" s' a

& b: f( n( l, ?1 M$ D
" o. c* G1 ^7 m  W* c3 D. U
                edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);
0 w1 }( i8 Z6 n/ y4 t& s4 }/ R$ i( i
& c% m; ^  u0 H  g; v
                edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);
# G, F9 v# O, S1 }1 D3 v" z4 H& Y2 f  K: l% _: Q5 V
* |, Q$ }. ^2 `& y4 f) T
                edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);/ p2 G! i- e. n% T2 [$ e
( |' L9 p% t! ?) I8 N2 J; V6 r$ B

! j4 [; X2 e& {" f4 ?2 z  _( o8 R                int csIndex1;
/ _. {: ~% L; ?3 n" v$ q                csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());) Z! G5 s; p( q3 K: |+ _. f
! J- [  A! i: `0 S# ~1 }

- n; U/ k" n* ^  F! n5 L                Features::Feature *feature1;
1 n1 f6 o2 k8 v1 W                feature1 = edgeBlendBuilder1->CommitFeature();" p  [9 M3 q- \, X% Z

8 y& h; G) P8 h$ ]( b5 S! u
+ v2 I. G* ^! O4 w) x( W
                edgeBlendBuilder1->Destroy();
/ P+ }# n; L3 O% f$ y% a6 N$ H) ?: \4 ^& m9 `
    }( Z1 N* o5 |7 k- o9 x
    catch(exception& ex)
* u0 S; J7 J1 K: C    {: a. H) t6 {; M$ }' _: Q/ W/ V+ @
        //---- Enter your exception handling code here -----
7 a7 w' i. K" B7 n6 m3 M        errorCode = 1;7 [% B" S$ |/ |. s) z
        selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());2 r3 G9 e% v3 ^
    }# N" ?1 W2 {- l! a5 \
    return errorCode;' ^. j& q4 \9 p, X
}
$ Z! n4 \2 G6 w. x( C: `' n/ A' S
+ V( K& U2 t! c$ C$ J% G
说明:因为字数有限制,这里只贴出关键代码。& ^) n' a' r! j
& I/ a# q$ U+ u6 M( `
3 i; z  Z/ v" j& G3 I$ i

$ b. U* j8 S0 K7 W% `
QQ图片20150814180022.png

评分

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

查看全部评分

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

使用道具 举报

全部回复3

heromo 发表于 2015-11-4 11:12:18 PLM之家手机频道

heromo 板凳

2015-11-4 11:12:18

如果我选择是一个实体,怎么自动将所有的边倒圆角呢?
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复 支持 反对

使用道具 举报

秋爱 发表于 2015-11-23 16:33:40

秋爱 地板

2015-11-23 16:33:40

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

使用道具 举报

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了