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

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

  [复制链接]

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

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

秋爱 楼主

2015-8-15 09:15:43

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

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

x
' M+ [8 K  d1 I3 y9 A  F: i
void selectedge::initialize_cb()$ C# M& p3 f8 B% Y
{
  \$ c6 I! Z# k# ?    try+ M: m( f( u, ?0 @+ c' E* [+ L2 ~
    {
' S0 W# `( `" P, N0 G) I
        group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));/ R' L1 w( h! D# d# F
        edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()-             >FindBlock("edge_select0"));
+ K, u3 W7 ^/ ]* g        expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()-       >FindBlock("expression0"));}# V9 V5 T+ z* \' Z' ~
    caTCh(exception& ex)
9 }) Q# G+ B( B* E0 H' x; Z    {
; ?# ]* L% D' q: T9 j        //---- Enter your exception handling code here -----# m: _9 |% v3 _
        selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());
7 K7 g8 X7 }) z0 P' A" \. Y    }/ _. H8 A  B8 `
}- F( K) ^6 E6 G2 Z9 d

+ s- g2 a$ g4 ^, Pint selectedge::apply_cb()) D6 J- t/ B& [0 e/ }
{
& b) Z: s3 b& ~9 ^6 ~    int errorCode = 0;
0 a$ t! C4 o) H# ]; a    try
% R" J% q# |" p1 B* C; Z) K( [    {
% d8 G  m3 A, n9 h4 w        //---- Enter your callback code here -----& K) [9 e/ ]( S" N. a* h& X

& s4 f+ W' x  @0 d9 ^0 z9 @5 B- q% z! }: t- r* \* w4 x5 d

% \5 q8 @7 M- Y& X4 E! ^                Session *theSession = Session::GetSession();
2 d+ M; m; N* Y9 n                Part *workPart(theSession->Parts()->Work());* Q! ~1 y3 P  d. L8 ]
                Part *displayPart(theSession->Parts()->Display());
% w6 F# P: W  K( Y5 ~6 ?( e9 E( N/ W5 s" @! n# Q! D
( j0 B3 Q+ \3 f: C( W
                Features::Feature *nullFeatures_Feature(NULL);6 R# g7 ~, e% E% }' _# T3 _# M( u0 E4 Y
                Features::EdgeBlendBuilder *edgeBlendBuilder1;
" j, w! i" n/ p1 e; L                edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);# V/ U4 r  M! R0 j
- R+ O% Y. @: A4 c9 z

2 T9 Y( f- V% p$ Z3 b! Y                ScCollector *scCollector1;
* f: m+ k5 y, z) c* i' }                scCollector1 = workPart->ScCollectors()->CreateCollector();- Y) A* j* I( C: }3 ~& r
5 y+ k3 R9 o- ]/ J
! U6 }! ^/ l8 Z( q2 V
                std::vector<Edge *> seedEdges;
( C# s; M$ a$ e- g                & q+ r# d3 ^7 H) W: u1 K/ b* I
                std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects();       //获取选择的对象; X6 o/ x- {- w% |
                for (int i=0;i<selectob.size();i++)4 y4 _7 \6 ]7 R6 a% f& V* D7 `
                {2 X, r3 ~) M: l3 X2 T
                        seedEdges.push_back(dynamic_cast<Edge*>(selectob));3 q2 N3 F( v" m( ]5 `
  }3 }3 _2 g; x' n2 t" p0 G) U; Y
8 C2 l, M5 O# n
  double dia = expression0->Value();            //获取表达式的值& P. ~+ i1 v/ u: C
                stringstream DIA;
0 i3 m; _, Q$ w  K                DIA << dia;! ?* t9 D9 m" A$ {+ Z2 j
+ ^" d8 U+ v; F& Q4 {8 S% Y
' y! W- s5 O" `4 ]* _
                EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;6 h$ _* J& L& M' Y/ g7 b9 ~) S
                edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);5 ~; w7 L) {7 V) p' ^* Y( |0 v
1 M7 s7 u; G# g$ O; X- `

, n4 X! u2 h( u7 W' X* _2 l* X! G/ i                std::vector<SelectionIntentRule *> rules1(1);
0 w1 f0 F9 m; K& v5 I/ ?                rules1[0] = edgeMultipleSeedTangentRule1;- J+ h9 O* ]' N$ ?; |3 ~* `7 d
                scCollector1->ReplaceRules(rules1, false);
, E5 m/ z$ y, D2 g  S6 @' D% M  b5 ?6 ?& U- D& m3 F# t

" X: u3 C/ m2 [1 q1 G4 O; j                edgeBlendBuilder1->SetTolerance(0.001);
) ?7 G7 R& d  f4 n' P0 E8 g4 }% C

. X. _4 k( n# m' C" S. ^% _1 I                edgeBlendBuilder1->SetAllInstancesOption(false);
5 R1 M$ S  y3 e. U# E" I8 {% x% g7 g( {) R0 y

9 I# F6 H: T* h$ m7 ]0 W                edgeBlendBuilder1->SetRemoveSelfIntersection(true);8 L5 d2 Q! \1 F
0 u( ?. J" {! h) @: r
6 M+ s- U  Y8 S, A, j9 H
                edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);# ~, ^' r. S. q( R3 B" q) o
9 {3 L# G1 v, d4 L. u/ l$ h: r
5 H5 T' [9 M, U2 U
                edgeBlendBuilder1->SetLimitFailingAreas(true);: e% y7 y. ^5 F8 f! |7 M

( w' k# M: E# ~4 j# b

/ W; n; @% X2 w: Q! r: p                edgeBlendBuilder1->SetConvexConcaveY(false);' j% ~" I, r, C% _$ D" r

; C4 g& X/ e6 Q3 f# K

' ^5 x1 i  n$ W. ?5 Q                edgeBlendBuilder1->SetRollOverSmoothEdge(true);7 ?1 q& Z8 l" t( z6 R

% F  h$ ?) h& s
6 ]% o3 J& T; {: b
                edgeBlendBuilder1->SetRollOntoEdge(true);
/ F; }- X0 E) i! z/ f- T
; ?; F& I/ ?4 b) a# d2 G( e

! v8 D) a- \+ i' M# ?7 k' T                edgeBlendBuilder1->SetMoveSharpEdge(true);
3 x' T+ B5 q/ P6 p3 v  b  |  {. Z. W, o% V# Q3 K/ q% l3 c2 r3 T! n
6 Y% C: _. P( B8 z; g  @
                edgeBlendBuilder1->SetTrimmingOption(false);
5 C5 S0 f/ x* L- x+ H0 t9 U3 i: y* e/ q' `9 ?8 q( q9 I: z

! ^% L4 ]$ p$ _9 \7 S                edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);
- d+ d- g5 l" Z+ I" m0 T
7 c" W$ c# q1 l* t! g

) S7 r: ~9 V! T# j                edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);1 K2 w) f  W* J) y

6 J9 R1 h8 E$ |1 w5 H

& u5 v' q. b6 a) f. j                edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);
1 ]: S  i& [- a% z: g9 n- F. z1 Z! M& g

) p* v+ }: e% D4 r2 M& r                int csIndex1;
9 w3 N& |  S8 \( D                csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());
6 c( N5 ^" V# a2 |0 P8 b
6 d- d# s4 T1 T# A5 V9 U/ S
. V2 P8 M) q" {7 A
                Features::Feature *feature1;3 W. C3 [5 I4 _0 L1 X6 ^0 r
                feature1 = edgeBlendBuilder1->CommitFeature();
, d) z4 x, _$ G
; h: @! _( V' z
. |8 g3 G2 ?. p% h- b
                edgeBlendBuilder1->Destroy();
7 B2 S) O3 j6 I3 _; X4 Y
) _/ j3 R0 y1 H& o: ~    }
. N2 `4 q# M- m1 ^  a2 v    catch(exception& ex)4 u7 ~; @0 Y5 U$ ^* W" s7 e% {$ F
    {
( s( g/ a; x/ _. Z        //---- Enter your exception handling code here -----# ?2 P' x# P/ W
        errorCode = 1;$ y/ s; L; y4 G* ^. V$ u
        selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
0 }1 c' k: b5 P1 S! [% y' l    }2 Y4 r" `6 _  p! g
    return errorCode;
- e. y, e) Z2 _( k" C}

# N- Z, y) ^) s/ U7 R" V; P6 _* ~
/ g9 N; H/ q; j$ W7 Z
说明:因为字数有限制,这里只贴出关键代码。% N; f2 g0 z+ {7 }8 I- y

: e0 ]6 X3 h: P7 f( Q5 e# N: C0 C. l6 U4 C" V0 S3 p# l

5 i. }. q# I. C
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二次开发专题模块培训报名开始啦

    我知道了