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

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

  [复制链接]

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

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

秋爱 楼主

2015-8-15 09:15:43

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

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

x

% e7 F6 c/ e% a7 kvoid selectedge::initialize_cb()  P# h6 `5 @7 u7 J9 {
{
! M; p  j) L+ F    try6 o; _% B6 w6 y* v( |& e
    {

$ J% a/ e1 O# _6 z        group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));
: p, K. a. }# ~0 y        edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()-             >FindBlock("edge_select0"));( R9 ~1 r( s" ^8 @" a' B
        expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()-       >FindBlock("expression0"));}
/ X( z0 n; C  r- l7 N1 D  s    caTCh(exception& ex)
1 g6 a0 l% w6 e. P$ k' l* b    {6 |4 W. A/ @/ Y: a1 c) v. r, f
        //---- Enter your exception handling code here -----' d: k: b, L7 o
        selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());
9 J2 U4 M9 Z2 W( @    }
1 U! m# t' L4 i5 \/ k, P}+ Y+ _+ ]# S$ J0 U0 w( T, Q
7 G, g" y$ f7 ]$ U3 h7 d4 O
int selectedge::apply_cb()
2 }' R: G2 w, k$ E& w{
+ Y: j: q0 K8 s- L) Z    int errorCode = 0;+ Y" }- {' }$ `( J
    try
: N: h& V7 T' t& s5 N% ^    {/ c( @! R; C4 e/ U7 \, s: `' ?
        //---- Enter your callback code here -----$ A5 u( u5 r0 {3 X1 h5 P

- F* ]1 C; C# s! u* W9 I5 y1 H( A* {6 Y: d; ]% L& e# b
; A/ p; U& i1 Z; {6 F
                Session *theSession = Session::GetSession();3 G% P: D4 E, N0 S
                Part *workPart(theSession->Parts()->Work());
% I; L0 M1 y  ^5 s% Q4 m                Part *displayPart(theSession->Parts()->Display());
: p1 i4 U; ?, o6 ]0 g
5 K# s; n- h; z) w/ y  u

& J  X9 `$ u7 {                Features::Feature *nullFeatures_Feature(NULL);
: `/ n% X+ L/ b2 m  q! t( E                Features::EdgeBlendBuilder *edgeBlendBuilder1;
' G/ K$ f6 ]; T7 \. f1 L; |                edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);, ~, E1 }  A% @9 k. p
. m/ t7 M% Z0 w3 g% M0 ~. R

* @3 t! ?9 h& _' T                ScCollector *scCollector1;
3 H0 t+ S" j1 b( E7 y4 P3 }8 @                scCollector1 = workPart->ScCollectors()->CreateCollector();
0 z# ^! S" i) _1 L1 C$ @# m3 [9 V  U3 `) X  X3 j& a* Z% W6 g) b
2 V: L) A( }8 |8 L/ |" {
                std::vector<Edge *> seedEdges;: w, e1 c* r- l; `* n# x, e. V! L
               
( u4 K. ^7 W; q/ x8 W7 C                std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects();       //获取选择的对象
) X, \2 N1 b% U                for (int i=0;i<selectob.size();i++)
" p  K2 l" f' u! c                {' G- f0 |6 N; I- W  E6 |
                        seedEdges.push_back(dynamic_cast<Edge*>(selectob));
; Y: W4 p8 U9 R& r# P  }  c" v; v& L  s- d0 _& ?9 k7 O
% j  l! c* W' ~7 T3 S$ Q
  double dia = expression0->Value();            //获取表达式的值: H2 a6 h5 n& N; C8 M* H
                stringstream DIA;- ^9 v) l/ T: P9 R* v  [: K& ]/ T5 h5 a
                DIA << dia;
3 O, \$ i) y1 D1 u, m' u) z
( S3 H- v% \$ C, y
7 }" _1 R! T/ `& N4 _) r4 J4 T: `
                EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;
7 A/ C# O- D+ A% d                edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);  J: {; s" Z* o$ J* k
$ e7 W7 n# r0 r+ h. L
7 o# |! w$ j9 j- u5 ]& d0 ~
                std::vector<SelectionIntentRule *> rules1(1);1 A; m! s: N+ r9 p6 b" M- G! I: t. G
                rules1[0] = edgeMultipleSeedTangentRule1;7 Y: u4 j( m, n+ x* E7 s5 r% f7 d
                scCollector1->ReplaceRules(rules1, false);
4 W8 U7 q  |9 u5 e! }% j7 e2 L5 T; ~

, W8 }* R5 L% \$ q                edgeBlendBuilder1->SetTolerance(0.001);
% a, n6 @0 h4 e% u, |4 J; ]& f" |* {- m, Z" E
1 K9 l# j! ^0 c8 }
                edgeBlendBuilder1->SetAllInstancesOption(false);3 }% |& P! I. p( r
6 G  ]0 I' |4 R6 ^# a) N% Y
, ^; G; r4 b5 d: l  c* t, j# M
                edgeBlendBuilder1->SetRemoveSelfIntersection(true);4 \+ m* B$ b) s

& h  }  ^0 N" t) |8 ~" w

3 v( R" c+ |: Z8 Z+ o                edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);
3 [& B) `4 i) F
5 s7 ^; w% P. J% q: R$ I5 _0 _7 J- l
9 _5 T) q- L! q
                edgeBlendBuilder1->SetLimitFailingAreas(true);+ @1 q* Y1 N0 q9 m/ j
" Z  V$ ]! {' V6 R0 z' O
; Q) E" A. U/ `" O/ L! o+ K) z
                edgeBlendBuilder1->SetConvexConcaveY(false);7 L+ t7 X- ~! ]; x' M' r0 i
, V% K$ q  i) k  s  I
+ g2 S( o3 t/ d
                edgeBlendBuilder1->SetRollOverSmoothEdge(true);1 G& g* [2 P/ u. M

6 y  A4 G6 h  l' y

* d4 D) m* P- g  `! |5 `                edgeBlendBuilder1->SetRollOntoEdge(true);
: v- N6 S; @% ^- b7 m: `  V: Y% @( e8 ~: V7 `' L/ h  F
  W; S% `, z1 P$ L
                edgeBlendBuilder1->SetMoveSharpEdge(true);
1 x% s& A* E- z- |& L7 x
/ a) E( [5 U* T3 O" L# M5 m& X

  K- j! ]9 h& x4 b/ h                edgeBlendBuilder1->SetTrimmingOption(false);* u  p6 G5 l# c+ j$ }0 N
, r" v& O$ ]9 ^) J; [

! }9 s$ l( H; C/ E  R2 V                edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);
& u. M7 f4 `0 \, h9 ], w2 v, `; Z
' S2 I- ]: V% F% l# W# h. `5 O
                edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);
9 g0 F" j) M5 h; G/ r' }. P+ O
% R! E1 ~1 [6 D; a& \5 C- J5 Q

, {0 e% U8 W+ N                edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);
1 ?( ~' y/ d2 V9 D# T( x! S3 T# N+ b8 b$ W& k3 G

* h/ F) Y( V" Y- r                int csIndex1;1 S. q( q2 W+ M! C
                csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());0 T' m5 s* V6 [% u, P
- @1 j. r& ]  K0 N: C
, u- F- `/ o) D; d/ o
                Features::Feature *feature1;
% c. y' W4 l% u" n                feature1 = edgeBlendBuilder1->CommitFeature();
( Y- R% p; G6 ]  F6 H$ s
( `! A* C8 r1 y
- i( J, S4 x6 W7 x. w
                edgeBlendBuilder1->Destroy();
# X9 U- u3 f1 W: M, T* T% m5 j+ X
    }
3 A* q/ b  I: w8 B    catch(exception& ex)
2 \0 S. Z. @, B- d- p% {    {
$ F1 j- d8 d# @" M- J# L8 s        //---- Enter your exception handling code here -----
5 \) L! N' a( P0 y9 k) J0 L* r1 g        errorCode = 1;
  h( r, U* ^* @2 [( M& ]0 i4 K        selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());( j0 s) a! Q! r/ i" v: m
    }& G% ]+ z$ J0 ?- q/ z2 q8 W
    return errorCode;" ]: }% H3 u3 s
}
' A  |. Y: R$ ^
0 B0 `$ q. C& K% N
说明:因为字数有限制,这里只贴出关键代码。# s7 v6 v+ S2 b9 g1 n; F& O
2 G0 ~; @9 @' B! y4 e+ e1 y- q; Z
" d/ \: _) ^' k, E( H
1 g! X9 `/ N+ f
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二次开发专题模块培训报名开始啦

    我知道了