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

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

  [复制链接]

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

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

秋爱 楼主

2015-8-15 09:15:43

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

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

x

" {3 O) Z; V5 F3 avoid selectedge::initialize_cb()& h+ d& M6 |- r8 ?) i7 E! z/ p
{( v6 q% A' o' R+ E
    try
  j0 [- F0 u: v* a& Q9 \    {

& r, m1 e& a. I) F$ T' c# J/ m# W0 E) L( A        group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));( j( z( J+ i2 a& m% e- b- K! u
        edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()-             >FindBlock("edge_select0"));
- Z6 k% N% v, j' E0 j- ~5 N        expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()-       >FindBlock("expression0"));}
! C1 y9 u# h$ u  o, V5 @+ L    caTCh(exception& ex)1 w+ c+ M$ ]' o
    {
, }# y# j2 R% L$ t- m& C: a        //---- Enter your exception handling code here -----* g8 Q: q2 C; Z8 x6 C0 N% E
        selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());1 X  h% {6 A$ F# g2 ^: t
    }
  Y  e& N* @9 b& b}" |8 b- O6 j4 n8 \* |% ~; S- [4 ^
. P$ r% T3 P: `4 c6 c' W. `
int selectedge::apply_cb()
$ x8 G2 v" S2 z2 |) C, s, J; K{7 [, V* i- i$ i# \( Y* D0 c# S
    int errorCode = 0;
: I  h' a) y. O( w    try# x8 J) o; w1 f& m# K; O- C
    {! l! {/ Z" X0 h! E& J' l. m
        //---- Enter your callback code here -----: U- w* i* F7 F6 N

$ z$ v* e. ^9 k/ l0 [4 f- s* _+ ?1 Y( U, ]$ Q* l: h8 D
. x) D' M2 o( W$ n- C1 x- D
                Session *theSession = Session::GetSession();
: t( Q* |% E7 m1 F' C7 W1 J                Part *workPart(theSession->Parts()->Work());
) M8 W( f, _5 F3 b& d                Part *displayPart(theSession->Parts()->Display());
- g* L2 a! _6 b
' z. \/ I! P) ~  f' t' Q" ^

$ m- ]% S1 m6 F* f0 c                Features::Feature *nullFeatures_Feature(NULL);
3 a* O3 U' a6 y1 b: J" e                Features::EdgeBlendBuilder *edgeBlendBuilder1;
# l' j' O0 @; X6 w2 d7 {2 O/ e                edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);
" Z0 r0 E# Z  c% Q' l" M3 F4 K7 t5 z/ ^$ w/ s/ n; w9 f" |
, A6 w* m8 i; p! Y; r
                ScCollector *scCollector1;
6 }  @8 V/ V. P* o8 x/ l                scCollector1 = workPart->ScCollectors()->CreateCollector();3 F' X7 O2 P- g  t# r

; U. J$ A9 g$ s! U4 @
3 |% A4 v' B" R) L3 a
                std::vector<Edge *> seedEdges;
6 w1 h; p" A# S" e               
6 J' J4 l& k1 P2 @                std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects();       //获取选择的对象  g- v" I" _3 \/ K5 w  p8 ^
                for (int i=0;i<selectob.size();i++)
+ }) R6 K8 {) _# T+ q# V9 P1 U                {) f. W8 h( O; H( W# t
                        seedEdges.push_back(dynamic_cast<Edge*>(selectob));
( d$ B* ]' @8 }$ s3 i  }% D* s4 ~# `+ `$ |* Z) M* H7 L# C1 _

9 a: h1 n* C3 G" _0 I! @  double dia = expression0->Value();            //获取表达式的值
. D& Y/ D& w- D- ]$ h. x1 ^                stringstream DIA;, \0 o: y: \- n( n& r* _
                DIA << dia;- f" s  K  C  E' A" r
; @  T1 ?6 y% S9 B! u. q. [
+ v2 q$ j" |  v; F' k
                EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;
7 ]2 o, r+ T- t/ j9 t- t1 w                edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);
4 d- T9 ]+ E  H3 a8 `( D6 L
) R* B! e+ H2 J, J! m

6 Q! n" t: t5 i! |2 ~, W4 r                std::vector<SelectionIntentRule *> rules1(1);1 d; J* q# m( `& W
                rules1[0] = edgeMultipleSeedTangentRule1;
/ A" p# ?4 e+ L' g! L% t9 A                scCollector1->ReplaceRules(rules1, false);( j: v5 N$ a' T3 s+ r
9 P* I, r# g4 b! f

! q5 l) l2 t7 W4 E% R                edgeBlendBuilder1->SetTolerance(0.001);4 ^2 o0 [0 I4 m/ P6 H! R
& J3 U3 R$ T% M- p

) i2 Z: j2 w! d6 {( B6 C6 M                edgeBlendBuilder1->SetAllInstancesOption(false);
) O& |& {5 F  G3 i, r2 ^) G/ l( Q& V, ?* d( O% {
$ A4 ?( k7 [5 ?3 A0 F" c
                edgeBlendBuilder1->SetRemoveSelfIntersection(true);
) Z2 f, n, c/ i8 M1 a$ j
. x1 S& e* U! |8 E; Y2 z
, u: X% V  ]# g: _, f& |
                edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);
1 w9 f1 q  q/ m5 m  ^  X9 w) r5 u
2 a5 O$ W$ D$ I, ?( d0 x
  W8 x; \, G1 Z% d- z) ?
                edgeBlendBuilder1->SetLimitFailingAreas(true);
; U4 O2 T& Z1 K0 ?. ?2 l. ]9 Q% r: \% T  U9 b9 O
7 Y0 }* w& f1 y+ S* I
                edgeBlendBuilder1->SetConvexConcaveY(false);* L7 j4 V9 j% @9 f
+ y, [) p9 W* l8 r
- }3 l7 B; v' G% w, F0 [3 l
                edgeBlendBuilder1->SetRollOverSmoothEdge(true);2 r" K) X; Y) j* q
9 A4 I+ A5 I- R: R) |" b  i
' o' B- ~+ R: }# ?. ]' i1 A% f
                edgeBlendBuilder1->SetRollOntoEdge(true);- {0 K! [- V& y9 }9 O
7 r5 H: R& Z1 _4 l" `3 Q& G
1 T7 _3 D1 k& ^4 t
                edgeBlendBuilder1->SetMoveSharpEdge(true);
) F" ?+ \$ K" |. d+ o4 I9 r. D. `1 l0 S5 r/ C
6 ]# r. D; L7 W7 L
                edgeBlendBuilder1->SetTrimmingOption(false);3 G! T9 c# i. X4 m

1 P! p- }, L  N9 c( J$ p

- O2 t, g. z3 A9 {; B5 y' o$ j                edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);" b7 `- H0 L  i7 Z( Q5 o; n% ~

* x" X5 h  z1 ~( v7 R/ i2 q3 c
1 J' B& a$ K7 H3 J
                edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);
/ S# i3 x7 s( W0 `  ]) F
; a5 f/ L# \! F" b/ [

; a; |5 F1 a0 d; n                edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);
$ @8 _8 p/ [0 J7 K2 G! K, r* d) M5 @- H
% Q% z: t; W' H! k
                int csIndex1;2 k" W! f# w; Q2 P+ N. |
                csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());
, b& ]5 g4 @! z5 m" Q
8 y+ n2 t* a6 w2 E- \7 r
1 {6 `0 ]- \2 Q4 F" @5 W  A
                Features::Feature *feature1;
" t3 A9 [" G0 p- M( D( \                feature1 = edgeBlendBuilder1->CommitFeature();3 U) F  m$ }# Q
0 k/ a% i5 O8 v8 N6 k  S" x2 @7 ?

# m* f5 s$ _( q5 f/ ^- ]0 \( [                edgeBlendBuilder1->Destroy();# s+ y0 m7 m& h+ n. {& q, h0 `# E: ?
: Z$ X, C! b3 C8 X4 j; |# y
    }, S" V: O- R; n3 ?- O+ A
    catch(exception& ex)8 A4 x/ {1 M* D# w/ D4 b
    {
: ^( O" I; G2 ?        //---- Enter your exception handling code here -----
8 C9 q, r# O$ D/ w, \        errorCode = 1;
% j; L! t0 h! }4 x        selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
9 e2 m$ r; G: |1 p. w    }
) o% r/ Q1 _  X2 N    return errorCode;% C( p+ r% j) Z. Q# z
}

8 U, h7 g* o% V: }2 C& w6 Z# F
7 e% f% h2 C$ b; k9 |
说明:因为字数有限制,这里只贴出关键代码。
8 x- w6 O: `9 F
  G  P( ^3 G, t% y
+ _  s; p3 R7 X
0 G& B/ c' m% b& ?* K4 w. D6 h
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二次开发专题模块培训报名开始啦

    我知道了