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

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

  [复制链接]

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

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

秋爱 楼主

2015-8-15 09:15:43

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

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

x
  T# A4 `7 s7 T: _
void selectedge::initialize_cb()
, g$ b) P/ U" q1 l; w  k* t{0 ~8 q8 R. Z: C$ x: v
    try
  u! ^4 v0 }/ ^; V5 N    {
. g" b' l9 K# N, O+ y+ A* k' _
        group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));% t9 `% r, C, [& b
        edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()-             >FindBlock("edge_select0"));. x7 U0 u' _' j. |: n, [) L/ g
        expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()-       >FindBlock("expression0"));}( u/ M  Z) c' X* {7 F
    caTCh(exception& ex)
- P; W; _% `6 m" U2 ^    {
* C( k: N- [! p" N1 z! _        //---- Enter your exception handling code here -----8 J# G! e1 R7 i8 d2 t" o9 U5 Q7 r( [5 S
        selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());: b) V; R* p7 r. B( q' {2 ]5 \
    }
0 P& s' w% ^6 a# B( W; l1 h2 ?}9 @: L" [; Z' `: w: [" ~

; S' i5 D& n: x: Gint selectedge::apply_cb()) A& y6 f' d+ b1 D
{
. H4 L/ T2 |4 {5 U3 S! Y2 J    int errorCode = 0;2 D4 _$ H2 W+ h% I6 N; q
    try
$ }/ ~/ `. J% h: L    {
" D1 \; b3 W8 f+ i9 ~; X% ]        //---- Enter your callback code here -----$ `$ t9 \. Q! C

0 L9 E% k/ X6 T# I6 i
0 h5 a9 \$ ~! d& _

' S; W# Y, V# [- T" A; |9 Y                Session *theSession = Session::GetSession();
# c: v% g/ h. c0 L$ E3 d                Part *workPart(theSession->Parts()->Work());
" {8 f5 S3 c+ i2 @1 J1 [                Part *displayPart(theSession->Parts()->Display());$ I: A0 v$ Y2 c. Q; R+ y0 S1 A

, }+ M* e. D  h$ ^/ G

' ?6 S% H" r# a! k7 I                Features::Feature *nullFeatures_Feature(NULL);
2 [9 M* a3 h2 e" o/ g7 ^                Features::EdgeBlendBuilder *edgeBlendBuilder1;
& f0 ?0 x+ J2 A  C                edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);2 B% m+ H# |! y+ u

" c; K- c; u9 q

; U# H/ F* E0 d6 R                ScCollector *scCollector1;9 `: Y) R9 t* k/ f2 G" j7 @( h
                scCollector1 = workPart->ScCollectors()->CreateCollector();
) c( S+ {% `) ~5 w7 f6 L* d' Q& ~7 @. t* [7 k( c

: c# o8 K+ e1 Y5 R; m' C                std::vector<Edge *> seedEdges;$ V: b4 c% f3 ~  H1 T4 S
               
3 y3 ]  E' v8 s& z# T1 M" H8 W                std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects();       //获取选择的对象, C9 j# ^0 Z% J4 f/ e3 k0 r
                for (int i=0;i<selectob.size();i++)
# T6 ?+ E" `  [9 U( Q0 g                {: g  _. M; {1 I) Z. m+ d, ^% d( z( U
                        seedEdges.push_back(dynamic_cast<Edge*>(selectob));
- \+ R7 P# t  d' O; r% Y8 e  }
8 f# P$ y2 S/ W4 x: m- T1 l; E+ j
  double dia = expression0->Value();            //获取表达式的值: ]8 w/ @: n( M: s. F
                stringstream DIA;
3 |+ h0 M5 `8 \" j                DIA << dia;
8 O" i! L4 }- o  w, u( B- W* j
  C0 f8 D  m% R2 O1 t

/ D; H7 \/ V' J( N                EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;# Z' b8 T! H  M- m$ }
                edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);
! E/ {" V1 U3 a% k" ^7 E2 I0 Q$ s* \* l/ H( S

- @6 l- K& M& Y# U                std::vector<SelectionIntentRule *> rules1(1);- R& D3 a8 A) E; l# \; H% D' P* k+ R
                rules1[0] = edgeMultipleSeedTangentRule1;
1 V2 I: {1 H$ ]                scCollector1->ReplaceRules(rules1, false);
$ l4 K3 X1 s6 ]( S# m: U* S2 Z  A) e7 B7 e1 B( k% G

  i0 B+ o. w$ }7 g* D. e9 z                edgeBlendBuilder1->SetTolerance(0.001);1 x$ e& N6 K9 y! ]) x! a- q2 S, y) m
3 v2 ^/ I) Q' N0 S& U0 t
3 R4 W$ T# A0 ]1 d  o( Y6 V
                edgeBlendBuilder1->SetAllInstancesOption(false);
9 ~6 r& a( K# h
& \8 B' {6 E6 P5 d2 v" U

  O5 J0 `9 o( F) u" Y                edgeBlendBuilder1->SetRemoveSelfIntersection(true);7 H# d! R% t. d

1 R, R9 z% C* K2 A4 n6 |8 v

' b- q1 I" K: {8 W0 m7 X' y                edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);, G, |/ U& A5 V0 J9 W$ u& z, @

4 A- Y" @0 D" H6 u7 d
# |$ b0 n! e) R
                edgeBlendBuilder1->SetLimitFailingAreas(true);
3 F1 n' Q: n$ [1 e0 T( N8 C( I& U) c/ Z3 y1 f, o0 y

* o$ U/ M2 N1 [- x% {! j                edgeBlendBuilder1->SetConvexConcaveY(false);
: {/ w( v1 v& i$ P, a0 G) \
( l* M, _0 ~% p" y: D) c
! }+ @" ]: S2 C5 r$ I4 u- I
                edgeBlendBuilder1->SetRollOverSmoothEdge(true);
5 P- Y/ g. y0 j( a) @+ {( l9 T0 g
) n* o8 R9 n- L
! ~/ Z$ ?+ m: I
                edgeBlendBuilder1->SetRollOntoEdge(true);
2 Q  \  ]$ m+ C( m( s
6 u6 d8 @9 n! e9 y8 D/ f
( J" g# p, b+ P) r7 _% H6 R" O) Y
                edgeBlendBuilder1->SetMoveSharpEdge(true);
- m$ Z$ _- p; L4 b/ R% Z% Z: Y5 V, w2 G

9 o2 S9 I: m1 Q2 Q                edgeBlendBuilder1->SetTrimmingOption(false);
% s" ?- e- E5 V: g
, T0 {; w- f) U% a4 A2 i' u$ B
! U6 ~' X$ H2 S
                edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);
, |; @5 m2 Y' L3 i4 i
) p- j; N0 r, V

" ^* M2 x& g" u: [                edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);; K" X5 w& o6 S5 `% w

1 {0 l/ K( A8 w( Q: O: S

4 h$ z3 m8 s, L3 k: c                edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);* h9 s) n# u1 ~, F$ b2 _: z
9 T; |5 C: b4 W( M; t  b  q9 r. t1 \

( S1 y  y; F7 V' X3 f                int csIndex1;. n/ d7 l2 b; _9 `0 `5 b* U
                csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());
0 y5 A* q- ^1 [# o0 F0 y+ J! B( E. H" u9 Q  Z
5 _8 U) W; X5 g/ ?% s0 H' x
                Features::Feature *feature1;
0 e$ X% O, M3 i9 D' q1 ~* u                feature1 = edgeBlendBuilder1->CommitFeature();
* i' b) g+ b4 k! f1 a& b
% o3 O. F# c$ t# y$ u5 m

9 `' l/ P$ L% j                edgeBlendBuilder1->Destroy();* f/ v4 r9 |% i; {- Q8 A+ W& e
) P, B7 \/ x& O+ d+ C2 F
    }
$ O5 @8 }0 P! S% j8 s# s; j    catch(exception& ex)
" B+ F0 G7 c, k& L8 r    {
  D+ @/ l% @. \# N        //---- Enter your exception handling code here -----  W* L# R/ ?1 ]7 @' Z4 P
        errorCode = 1;8 A! ^4 u+ w* \% R5 X4 ~% _
        selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());5 d! ~, q- [7 c( B  g
    }
# B# k- y9 z8 m% q* f3 @' i    return errorCode;0 x8 u  w8 G# i+ F5 W  P
}
0 ?8 ~1 Q, B. i. Y! W

4 U2 x: C, R# c$ g说明:因为字数有限制,这里只贴出关键代码。
1 t: a0 x2 }! h7 N* D1 A% s
* H/ g* ]4 b. {* s3 U1 m, q7 l( f5 Q; _4 V  P4 y9 Q2 W

* I. u+ Q- |. {
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二次开发专题模块培训报名开始啦

    我知道了