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

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

  [复制链接]

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

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

秋爱 楼主

2015-8-15 09:15:43

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

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

x

! V3 e  u' P0 U, Tvoid selectedge::initialize_cb()
5 n% u" Y3 ^# N2 J$ j# Z{
! b. g, d9 v' `2 h# p0 ~    try
/ t* l+ k" v- B2 A9 X    {
8 [6 @0 {" q  T5 b
        group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));
0 h  V5 c; _: Y        edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()-             >FindBlock("edge_select0"));+ |/ v1 j3 D& [$ a
        expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()-       >FindBlock("expression0"));}* I9 k: W4 r. S( W
    caTCh(exception& ex)2 A  F0 e, a0 K4 u
    {
" z- S. h2 B5 s( ^8 {8 E9 d        //---- Enter your exception handling code here -----; g' k( f2 g( D! a
        selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());
4 I! {7 q" ^' u    }7 {( K) T" n; t" {4 n( g
}  [. L& |8 i: {1 x, U; I, Q  e

, P* ~6 X1 j: z+ A1 K* j/ Oint selectedge::apply_cb()
% @9 ^* ]. t" J: w, h+ A{
, O+ N: K- |& Z" D* W' J    int errorCode = 0;
3 q; H$ H/ t9 v1 s0 B9 C! k, J    try2 S5 m  L! q7 [" ]
    {
" q$ W& K, ]# J/ U        //---- Enter your callback code here -----
/ t" E7 M' u& F6 O
9 I5 W) J. D' j8 L! |! D1 P4 F% K. C+ B
- l. k" p6 {- t3 L
9 g% B' c$ Y. V: ?: V$ n
                Session *theSession = Session::GetSession();
# [) H, X, S0 {7 F9 ]6 W& [3 j                Part *workPart(theSession->Parts()->Work());
; `8 w) d/ w4 e2 a                Part *displayPart(theSession->Parts()->Display());
$ ]; O6 P7 M- C/ r* [5 I/ |" i8 ]
% C  G! `! b5 r& u) O. x) G

% E; ~9 l; c6 I                Features::Feature *nullFeatures_Feature(NULL);. R7 g/ T+ p0 j$ M, ~
                Features::EdgeBlendBuilder *edgeBlendBuilder1;1 U& u( s: J! N" f/ D- a( i
                edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);
9 b4 H0 i- E1 Z: x" n6 l, D3 o1 K/ O; r* e6 o( s# P- `
6 o, m: b/ A6 j% x
                ScCollector *scCollector1;
7 ?! n& v  G3 Y/ P$ k$ G                scCollector1 = workPart->ScCollectors()->CreateCollector();! R* Z  }# G  i: U, ]
* {2 Z, n4 H( Y( J
8 o+ T2 @( i" H+ v9 `/ `
                std::vector<Edge *> seedEdges;8 h1 U0 y& J0 y9 M
               
+ `% @5 s& }* O; H2 u                std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects();       //获取选择的对象1 r& {3 }4 _4 J5 k8 a5 k
                for (int i=0;i<selectob.size();i++)
$ l: |  F2 X% ~3 }0 M! E) p                {
6 \3 f& X0 n8 \+ ~, w" _- }                        seedEdges.push_back(dynamic_cast<Edge*>(selectob));' q- n8 a8 E1 P) n
  }/ p/ e% g# l) z+ O3 m
% A+ B5 O$ Z# K$ H
  double dia = expression0->Value();            //获取表达式的值
  f& B. @4 d' o! s3 q                stringstream DIA;# d5 T$ d$ p- _: j! I6 J; T
                DIA << dia;
2 P% x! m& P/ r% |4 P. ]! a6 f
) ~# g2 Q+ `- A" E. u- s
  d, E8 \7 X5 o; l
                EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;2 j+ s  K- _; E8 d- y2 I
                edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);+ }5 [6 k/ \" o* s" F/ c

. [# Q" }( M# y* G* ^

& R. z; K# T- {0 u0 @                std::vector<SelectionIntentRule *> rules1(1);
) h5 R4 `2 a5 v                rules1[0] = edgeMultipleSeedTangentRule1;0 Y6 l( G; l; k1 t. ^! P* K4 f# n
                scCollector1->ReplaceRules(rules1, false);
" s* a* Y9 A& @
" i8 a! k* `5 H

. O. [" f( c$ A( r2 O                edgeBlendBuilder1->SetTolerance(0.001);
3 ?9 u  U- w* p
/ \7 H' {$ ?7 q% a
. Y5 _8 Z: K! d$ A
                edgeBlendBuilder1->SetAllInstancesOption(false);0 _# S  W2 k% b9 N# `  g

; C2 y# y/ J& A

% N3 Q3 `) i0 j/ Z- `4 G                edgeBlendBuilder1->SetRemoveSelfIntersection(true);
) _+ G8 U1 p6 }+ @- q" W& N
( W; K, F  y6 a6 z& A' I' K
2 ?. l- T5 t7 _* i+ `3 t2 b
                edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);
- q5 |5 A) n; {% b% x9 k  S5 t! ~/ C' n, T' p
# }6 N1 H' ^  B7 R
                edgeBlendBuilder1->SetLimitFailingAreas(true);  ~( G2 ^: ^- _/ ^2 _. c/ Y2 S1 ]+ i
+ H8 y+ L, V) v! H

) h$ o1 E1 [) G' S& o6 I6 D6 S1 }, r9 B                edgeBlendBuilder1->SetConvexConcaveY(false);7 U& T- o+ x# e+ s9 o, v2 ~8 t

5 t/ j# C. ]+ t0 L: s6 s) H+ f
, r0 n% _1 E8 ?9 H1 S  F3 {. ?7 J
                edgeBlendBuilder1->SetRollOverSmoothEdge(true);
+ @4 B; p' }6 J0 a" x; D8 m
' N# Y3 H$ g. I' V2 A

. n% D& b" W+ T: n5 I                edgeBlendBuilder1->SetRollOntoEdge(true);
: |* @& N. B  p
+ X  N" P1 ~, V: B( M' U

$ q; W; V) w. F4 @                edgeBlendBuilder1->SetMoveSharpEdge(true);: s' z- R. ?* N

1 b, d3 T" S+ x8 P6 ]4 x) w
0 C* I* @: o+ n! z( C
                edgeBlendBuilder1->SetTrimmingOption(false);; ]. f$ u2 [4 A( S2 h
& x; O& L6 x- d+ S1 ~. _7 t
0 l& P' c- P+ T$ n7 F
                edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);8 |6 G9 G3 ^  i( X- Q( P8 Z
8 i% k9 ]" b2 ?4 o) \2 N

5 p* h) I& Z6 R  M                edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);# n$ B6 R8 \( H& y: j

2 i' b/ p5 X" h# @0 f  V

. y5 u$ W. W1 J  a* ^4 G- l                edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);
! a" s( i5 Q- I4 ?$ ]  Q
+ d* }- @1 o4 `

/ ~5 i; E+ }, _; ]2 a, c, D1 g                int csIndex1;
! R+ I# E+ ^8 W                csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());# O2 s! s# B+ [  p$ M1 w9 q( s
1 ~" Y+ P1 ?4 M5 ]
  t+ E5 u+ K. e. t) }# x' F, y1 h$ t
                Features::Feature *feature1;2 _1 l6 Z8 ?' h0 x
                feature1 = edgeBlendBuilder1->CommitFeature();: R  i1 F& M# K' j& N2 e. u# f
# o7 ^/ o! B4 d9 c5 H( `! L# e
% |+ s6 @/ Z- u6 h
                edgeBlendBuilder1->Destroy();+ V5 i! H, {- o$ W" I
4 X/ |$ U( R& O* p( L' g/ Z
    }& [& c' g5 A8 J; R
    catch(exception& ex)
0 \, ]/ \% t2 ?7 a    {
: I! e3 s! V2 i2 }6 G        //---- Enter your exception handling code here -----( J4 ?( ?! @4 ^3 J) s" H# L
        errorCode = 1;  B/ F' ?% w6 e+ P& F7 M( y
        selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
: `5 `: l0 p" a' U/ G# v0 `3 p6 |    }, E2 x+ o3 A: z
    return errorCode;- x( H+ X3 ]$ V% }
}

. E% j* @, D1 Z! r

1 m8 v9 j" d; y. I. @- x. x( d说明:因为字数有限制,这里只贴出关键代码。/ |8 P- M. d/ ?
* P' K$ t2 e3 |  ?' Z
4 r, D/ h- z2 r$ T. K0 _

2 f5 J% P+ k- z+ V7 _7 |1 T
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二次开发专题模块培训报名开始啦

    我知道了