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

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

  [复制链接]

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

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

秋爱 楼主

2015-8-15 09:15:43

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

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

x
, Y8 _( f* e& {9 b
void selectedge::initialize_cb()
. X& p! y7 N3 Z; Y# e{% G, d9 a! p5 H1 ]* Y* ]: d; j$ N5 {
    try/ _; I$ s7 e# P
    {

& ^8 k- `. e9 l+ ?3 h        group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));% d& r4 K% d- h0 p2 ]8 F1 Y$ \
        edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()-             >FindBlock("edge_select0"));
' G: Y8 F2 ^) c3 v% c7 w        expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()-       >FindBlock("expression0"));}
/ J+ K4 M( a5 j    caTCh(exception& ex)
! {8 y$ f8 E5 `; n. h8 i' ?& k    {
6 B9 T5 e% c/ t8 u% l        //---- Enter your exception handling code here -----" P8 L6 h* d5 E, s0 d2 }
        selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());6 }, I2 |- U" u
    }8 {* n# L& ~9 V, b; h6 I
}
7 p0 b2 a" r1 ~6 E; d
+ m: J/ ^- y6 c1 uint selectedge::apply_cb()
  C0 G0 V! ^; t- r  U/ O# o7 t{
, B; W9 N2 D# _1 _, V9 w' a% k* a    int errorCode = 0;
; g0 V$ |4 ]# l" j+ J$ ~    try: X+ J7 R) c* {3 f
    {% e8 Q0 u/ I' b* o8 u
        //---- Enter your callback code here -----
* G; A8 E8 V. R- r
3 g: b5 P/ V: G) g9 K7 |
' Q! H6 I& J" g$ G4 w: }" ~

! g7 t8 O2 y& Q1 @2 a                Session *theSession = Session::GetSession();
% b7 y# [; a7 b6 Q9 y( p: Q4 {% x) c                Part *workPart(theSession->Parts()->Work());
4 a7 u* B7 b7 N! O/ j( G                Part *displayPart(theSession->Parts()->Display());
! y9 j7 U3 T  {' L9 b' f- P
4 R% [8 I! L$ @# s

+ D. C( g% s8 ]& v                Features::Feature *nullFeatures_Feature(NULL);% N$ J# b2 x9 B7 N( Y8 i) o
                Features::EdgeBlendBuilder *edgeBlendBuilder1;
5 m# P6 C  m! T: ]" R( H                edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);
: }( g: f! |+ }7 u0 s( C. ?; h" W, a! m8 g; F; Q; ~+ X8 l

% }* R9 i) O" h' r+ U6 N% A* A: N                ScCollector *scCollector1;. J& K/ n; X: N
                scCollector1 = workPart->ScCollectors()->CreateCollector();
9 e  K7 O( V! q7 N5 g7 V: O+ Z; i3 r

1 N" X6 |* o1 ]! u( X( J                std::vector<Edge *> seedEdges;& A7 L( h6 K& K8 }! \% J4 ]
               
3 j4 [1 n6 A) x; f; R% L& v                std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects();       //获取选择的对象
% L. f$ c& G' Y2 ^                for (int i=0;i<selectob.size();i++)# ]" F8 z6 m$ q  T
                {
& e5 _/ y* G/ ~9 D. m* a                        seedEdges.push_back(dynamic_cast<Edge*>(selectob));
  w+ G( Z1 f2 {: t) e  A& N  }- t# k6 K+ y" B
1 \: T5 e5 m2 z) L6 p
  double dia = expression0->Value();            //获取表达式的值
: @5 o# {% _, b; H+ i                stringstream DIA;' I4 }) v. w1 G' K  G* i, s$ J
                DIA << dia;7 J; |$ z0 v; j7 q
+ w' U* [: i- s% a( |& e9 Y

5 u! j# S( I% I# E8 X) z                EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;" ]; l; K7 o4 m+ x
                edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);  S+ y9 m5 e- d# h0 y! v+ C  j+ e
2 x. V- H5 S# B, `/ D& o8 J

5 v1 h0 F- V1 Z  A                std::vector<SelectionIntentRule *> rules1(1);
  x# n& @. _, q8 o+ w" |                rules1[0] = edgeMultipleSeedTangentRule1;) x8 T: P) s& m6 U: E" M* z6 t! y
                scCollector1->ReplaceRules(rules1, false);  h" V1 W$ s$ D) W0 }9 ^

. `- N7 _. T2 r0 d5 S/ v9 z
( r9 H# ]6 f$ g1 o# Z" x" D& V
                edgeBlendBuilder1->SetTolerance(0.001);* @1 b6 v, }8 y; Q* N: x" F* A

; N6 K) w2 P2 d/ p: t! D+ C

" a5 _9 m9 ~! ]$ k+ l2 ^* f                edgeBlendBuilder1->SetAllInstancesOption(false);9 W6 T2 _9 p/ f: Q- Z6 t& O
2 \  |- j) J5 q
: n) E  T/ _+ \3 e0 a8 I4 G" L4 _- f9 e
                edgeBlendBuilder1->SetRemoveSelfIntersection(true);
% e. @6 g1 Y, _3 ?4 t* F5 k
  {2 F( e1 U4 y& K% f1 }, q: m7 j

5 j2 J+ g5 H5 e9 I. ?                edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);
; r' N0 I3 l. W7 v
( x  \' O4 Y6 g" A  Q

$ L: s& S/ K. c+ _4 t                edgeBlendBuilder1->SetLimitFailingAreas(true);& N6 \( K6 I% `
) c5 H8 L% c0 }5 A

% H9 H0 [4 g  l; ?5 ~2 J8 L                edgeBlendBuilder1->SetConvexConcaveY(false);& l7 M# ]9 B* H- x) X

: h' D( G& c& N

+ I% m. O/ o' s3 H7 Z3 \/ M+ a                edgeBlendBuilder1->SetRollOverSmoothEdge(true);5 G( X' U& A0 q' I
7 I6 E; l6 N/ W0 L% E: l
) ]& z) U! f( P2 a  k% ^
                edgeBlendBuilder1->SetRollOntoEdge(true);
- N, c# u( M9 G5 l* d5 ?' n
" O, \1 ^* Y  v, y* F+ {

) Z8 p- r6 g- j* W5 @3 S2 ?                edgeBlendBuilder1->SetMoveSharpEdge(true);1 s8 X7 e) G0 `

, A8 L. ~5 K: N! o

+ n! k+ \: j. d3 v6 W8 M9 e7 c. P                edgeBlendBuilder1->SetTrimmingOption(false);  V% T. ~1 ?0 n
7 C) f" {7 x& G4 D

+ r' C9 X' I6 z& u/ `2 I6 ~                edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);
( a1 t( f4 j& Y# F8 _! @$ C$ H6 E- n3 X0 |, K
! H; p2 _: g/ u4 f, L- w" O
                edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);3 y3 M( `* }( E+ u6 K& m2 T
, ^3 y9 Z+ g8 L& s4 ]; D1 P3 [

' W4 r# N/ ]$ M! m7 p                edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);( s* H2 P* m2 R: Q8 m
% o/ X4 M: y0 |+ X' A4 h1 O# _
3 M: B. E8 X+ E3 h, c8 F
                int csIndex1;4 o7 c2 O7 J, y9 g! h
                csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());
( V( X+ `) G/ v5 F- B4 q. {" W3 n
9 K3 e9 j+ A$ `; ?) }' i/ ?
                Features::Feature *feature1;6 x& v! B! f6 h
                feature1 = edgeBlendBuilder1->CommitFeature();
8 R7 m  U2 g+ P4 c* P- d/ c9 ]
! E2 E3 v* S9 t

1 N5 a5 |7 l! A                edgeBlendBuilder1->Destroy();& p) f5 e: V$ b' ~  l

; i: I1 Z4 C- f. x    }
+ x1 j0 k2 l; o, c$ O    catch(exception& ex)( F: b1 J% p8 @/ _0 V1 N
    {3 T/ Q- \7 L- f3 t
        //---- Enter your exception handling code here -----, j3 o" o3 G6 [8 q
        errorCode = 1;% D' e& q- p- k5 X) q* @2 i' Y# C
        selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
; @+ P* d3 ~  g* ^, l7 n5 p    }9 W6 n" S- X! E% V4 f
    return errorCode;
6 U0 Q8 }2 _! V! j}
0 q7 M: ]  m9 ~( d! B9 t+ G( Y' Q( w
# H' a7 |" e9 }1 s* O
说明:因为字数有限制,这里只贴出关键代码。
+ C7 h! F% X. f' q
2 C; _& R4 @4 R0 @7 }( ^  t6 g; [
! s: |, ~' u: b1 O) ?/ k& z
* a5 ~  v0 `. s
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二次开发专题模块培训报名开始啦

    我知道了