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

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

  [复制链接]

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

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

秋爱 楼主

2015-8-15 09:15:43

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

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

x
8 t0 v- A8 `+ ?' Z6 q1 D
void selectedge::initialize_cb()% [% f. `8 V" m2 L
{! e$ Z% y1 m) {' B8 d1 Y: W
    try9 P: o( n% {; l7 \! a
    {
1 u( @& Y( s/ }! |  s4 Q
        group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));7 M" K9 z/ D6 [
        edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()-             >FindBlock("edge_select0"));
" Z# e4 N6 W% }2 n; R+ B        expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()-       >FindBlock("expression0"));}
+ `+ A. Q' O% A. J0 p    caTCh(exception& ex)0 t. {; g9 e( W3 O. U
    {
; V8 [# y+ X+ u" u  Y        //---- Enter your exception handling code here -----2 d+ j3 p3 i5 K6 t5 @5 q
        selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());4 u, a+ Q3 }; E5 Z! P" R' v% A
    }
  n' }8 A' ]/ Z5 p' A5 q}$ t; Y( z# _- K% N0 k

8 b7 `) O; `- y1 N0 bint selectedge::apply_cb()
3 j3 w; @1 c+ j  i3 G  S4 s3 A{" X7 @4 N  I6 C* J; F2 `$ b0 s
    int errorCode = 0;& h+ A5 g! U) z! Q; ]/ `$ x4 G
    try0 B9 a/ [1 X% z+ g
    {
: c+ q; n' j; Z* y* }3 q        //---- Enter your callback code here -----/ ?4 ~0 l( e0 U9 n

  g; @4 {% {$ u, Z5 Y% q) r& |( O  d' e

9 N2 f5 T$ J' ~. c                Session *theSession = Session::GetSession();
' L. w! f: b# ~                Part *workPart(theSession->Parts()->Work());7 c8 Q( p( q1 p" e
                Part *displayPart(theSession->Parts()->Display());
/ P$ W) k2 S  ?0 c
; F6 u" D) L' U! u
1 a1 h3 k" U6 ?2 O4 I) V4 m
                Features::Feature *nullFeatures_Feature(NULL);
. |3 ?. g/ k# B( }3 z* d                Features::EdgeBlendBuilder *edgeBlendBuilder1;* K6 r9 J" f9 x$ d$ n' Q/ k
                edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);
4 X5 t# ?1 Q+ t/ \& \; K
* [' d& J5 m2 o8 e
' J; _5 r/ g* _+ g; Y5 H' T, i
                ScCollector *scCollector1;
+ d; f3 P+ x' u" _. z; e                scCollector1 = workPart->ScCollectors()->CreateCollector();
9 ?7 U$ T. T# i! T6 \1 i- s0 D
2 v! `! X$ X: D; m6 F
2 z0 e( e9 ^- y# Z7 K
                std::vector<Edge *> seedEdges;
5 ]1 ^" ~% o) h9 j- F9 |, y: k* P               
' O' y9 A) U% F# s: S+ x" n& s                std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects();       //获取选择的对象+ K7 J; I! D1 S) Y, w
                for (int i=0;i<selectob.size();i++)- R/ f. I4 Q4 ?( ]/ \
                {' x1 R/ ~. b3 P  w* i% [
                        seedEdges.push_back(dynamic_cast<Edge*>(selectob));- K  X3 q4 y4 K- I9 Q
  }$ {! F4 {" z. Y2 Y$ w- R
: X" p+ Q# d+ I) i; S- Q/ Z% o0 r5 \
  double dia = expression0->Value();            //获取表达式的值
5 h2 S" R2 e+ f* P, w6 s( z                stringstream DIA;; W3 Y3 \5 D, {, C1 W
                DIA << dia;
/ s4 H0 k  s- r! I3 A
/ U2 g7 L6 h! u1 W/ n! }
# S/ F) |, L# t7 P; g
                EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;
" ^2 ]1 O& U3 B                edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);  r' _5 b9 W% N5 Y

0 Y( I6 [& Y/ Z
1 q! b+ U1 O; q, Y! U8 q; J
                std::vector<SelectionIntentRule *> rules1(1);' [+ l/ O: T& d7 P  t$ K' T4 {9 k
                rules1[0] = edgeMultipleSeedTangentRule1;
4 V. V" b6 M9 O* a7 A2 M                scCollector1->ReplaceRules(rules1, false);
; I' K7 a0 m# X5 t9 q- N
# W% ?/ w# v" R3 S9 g
7 U- }" X% p  L5 G2 k3 W
                edgeBlendBuilder1->SetTolerance(0.001);
) K5 R8 E/ ?; \( d" c( O& y3 a, H3 D& |9 i! V6 a' v/ P: [3 x) y6 T
: n2 ^8 p9 K" G" N; y( v; ]
                edgeBlendBuilder1->SetAllInstancesOption(false);
6 [& V/ K4 t. ~) ~. T6 L9 X
. r% z( q) M& w8 K

. |" ^, C$ _2 r+ U3 V" O" N                edgeBlendBuilder1->SetRemoveSelfIntersection(true);/ h) s8 S1 q9 ]3 g( ]
2 ]+ S: a/ h& T# x% ~5 l! @- s

' [' g$ S  A  ~2 M                edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);2 K- }, \: u" t

7 Q" M" X) ^$ ^4 A$ ?% u( t

% M" p% A+ K$ O) t: U                edgeBlendBuilder1->SetLimitFailingAreas(true);
; N. s' ~+ y0 q- u  p# H; m3 Q0 }# ~0 J- c  J

7 V/ O( P1 d5 q7 `! `% H                edgeBlendBuilder1->SetConvexConcaveY(false);
* [  ^7 m' ]9 ]) G# s) j% w$ \+ m. h2 [  `9 Y# w4 Z. `

8 W3 ~% Y+ E7 F4 {) Z                edgeBlendBuilder1->SetRollOverSmoothEdge(true);
, {# l8 U& `+ V
5 e5 P8 B) i3 |2 L+ d, ^5 I
' @8 q) j$ H7 W. b% }  s3 \: J
                edgeBlendBuilder1->SetRollOntoEdge(true);7 u$ z9 Q1 I  T; c

! A$ `5 f4 d) y' o
$ @" k0 o$ g$ K# [" S. b
                edgeBlendBuilder1->SetMoveSharpEdge(true);4 @" w6 i  a6 Q  [

# E9 c) F- T9 F, v

$ \, }2 \8 i& \) g+ ~/ d9 h/ m                edgeBlendBuilder1->SetTrimmingOption(false);
' y1 ^6 e: |! b6 ~$ C! Z% |7 k& [% ]8 Y' S7 n

9 E) n8 `+ |: J6 C                edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);6 N3 {9 \; |4 U0 E

) x3 K5 l- P: ]( P. l
* c& _" G5 ?/ _- I
                edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);' p# `9 {3 p3 Y" d4 x5 V
* e; y. K, d- [

' x! ]3 f+ k5 }4 p8 D% a                edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);- L/ G! n# i) q: W/ C+ R
2 z" [$ p9 y9 H4 s0 l$ r

% r% F+ |  C5 U0 b3 P8 u: s9 s2 m  [                int csIndex1;
" G$ u- l. r) V1 A) u7 S9 x7 c                csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());
8 d: b  R0 y$ |6 b+ J6 `
* O/ n4 @# {& R7 Z2 d9 t6 g

3 J7 u6 N6 M$ |! y4 Z3 `9 o' r                Features::Feature *feature1;* F. R. Z, N. \  l. H9 K4 I
                feature1 = edgeBlendBuilder1->CommitFeature();
) f' i# c9 q# X( }5 q! R, V4 T2 b9 x% j  q

" M! |  M! ]* z- u                edgeBlendBuilder1->Destroy();
  K8 S2 ]7 o: S6 y; V( U8 X. S: E# v, {" o; e$ N$ `
    }1 k. E5 u- c1 T$ F
    catch(exception& ex)
" J/ X1 e% L/ {, N4 ~- G4 M$ s2 p: A    {. s/ Y- V6 |8 f: R
        //---- Enter your exception handling code here -----0 W6 i. F8 L% O4 i. ~+ C
        errorCode = 1;
: q& f7 w7 W7 a- U5 \% q- s+ j        selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
# K! i5 T& |6 f8 g- u    }/ e" Q3 W" j2 ^
    return errorCode;
# n5 q+ w5 `) y- K. G9 y}
8 p1 S# L' W% t/ a, U7 `
/ F/ X6 Q/ }9 S1 ~* f& u' e2 g
说明:因为字数有限制,这里只贴出关键代码。
8 k' Z6 o0 w7 ?
7 {& Y" X& K: f% v1 Y* Y7 H( b/ ]5 B3 M! _' N
* F8 S, g6 j; Z) ]# `4 ^: j" w: A
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二次开发专题模块培训报名开始啦

    我知道了