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

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

  [复制链接]

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

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

秋爱 楼主

2015-8-15 09:15:43

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

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

x
5 g+ X5 [, `# d$ Q1 R. }
void selectedge::initialize_cb()2 o: G+ M% P$ N) `- D- G3 p
{
% I& j1 Y/ {! k    try
3 Q# ]4 N+ o/ O    {

0 V2 a8 \" J' N" g  H        group1 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group1"));; D2 @- t, \! a9 t/ E( h" y5 H
        edge_select0 = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()-             >FindBlock("edge_select0"));
" B/ y" d: n# Q  s        expression0 = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()-       >FindBlock("expression0"));}
! |  D* g2 J( [" p! R$ X* w    caTCh(exception& ex); C' r8 K& [( k( k$ Z
    {, j) ^- j# Y0 y# S: C' H6 U: X6 c
        //---- Enter your exception handling code here -----
& l' K* u9 H, ~- R& J        selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox:dialogTypeError, ex.what());
9 z$ s$ f: E3 k+ E    }7 ?+ R( l7 T, I! c/ z  ]
}  ]; z/ o( m! ]+ A+ {
" J" d$ H9 [. `0 w; J9 J0 R- T5 e5 E
int selectedge::apply_cb()
8 Y' {" D* `7 R/ x3 ?  c8 y{7 n" ?: }( f& p* R  w
    int errorCode = 0;4 Y$ D5 Z8 s! G+ u2 w
    try) D4 B9 b: l4 T) M8 e( }
    {
7 h5 s0 W  E" R8 _2 j, ~% O        //---- Enter your callback code here -----
7 C8 K6 L5 t7 x3 ]" e, T+ R& I& M& ^5 n. ?5 I
* _5 w  W$ V+ P- F4 i

) J" S0 I/ \2 O/ i' R; R                Session *theSession = Session::GetSession();- t' u/ e2 r! H% H; [! s7 b
                Part *workPart(theSession->Parts()->Work());
& `2 ]* j8 S: [, U                Part *displayPart(theSession->Parts()->Display());5 R7 h" i+ L; b4 |, C( y  r& F

+ n" |+ L, |' m4 Z

* N$ {3 F7 B  p, ~                Features::Feature *nullFeatures_Feature(NULL);% N- ^2 M4 y; v& a- ]
                Features::EdgeBlendBuilder *edgeBlendBuilder1;
. u# [" U& W( L; J# H                edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);2 i; G+ I/ {' w: U8 q! _; |

" k  M! n3 x/ V2 J

2 S3 [+ R9 s5 e$ O( e: d                ScCollector *scCollector1;% x- W7 c3 a' n; y
                scCollector1 = workPart->ScCollectors()->CreateCollector();
) b$ C# T. c( G- V' {
# N5 c5 t( L  a7 Q; v+ o
/ E# O  X# S/ h) A/ h
                std::vector<Edge *> seedEdges;
' y6 Q0 Q; R: O+ \, w) T               
3 c  ?( N+ L1 j: H' {                std::vector<TaggedObject*>selectob = edge_select0->GetSelectedObjects();       //获取选择的对象
8 T' S7 _/ I$ x  s# Z' M8 z                for (int i=0;i<selectob.size();i++)( ?% a5 F/ ~. }) I
                {
" [; ]! b) z! }- M/ |                        seedEdges.push_back(dynamic_cast<Edge*>(selectob));
0 N& [& Z: d# k3 `) Z, D5 m" G  }
! g9 Q1 a. L8 h3 P0 U' R0 e3 V& s7 ]
  double dia = expression0->Value();            //获取表达式的值
, P! N* W5 n: i# N6 j                stringstream DIA;
5 k0 h- u* C: }$ v3 l. }  i                DIA << dia;( A" E. a0 Q6 E' w
2 S; ?2 M' N7 _' L( l
) o1 ^& m1 `5 X# S; I6 m
                EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;. Y8 l# v! ?3 q! A' D. j
                edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges, 0.05, true);/ S9 F! p, f; h, `3 t
. H$ V6 s! ?5 i6 }# D0 j

$ U$ T) |) Z3 W" r$ |6 I9 y                std::vector<SelectionIntentRule *> rules1(1);
; F( a' t9 J8 n( z5 N4 [, T3 P. k/ u0 A                rules1[0] = edgeMultipleSeedTangentRule1;( |. ?& u6 n6 ?1 `
                scCollector1->ReplaceRules(rules1, false);
; J2 _- h& ?' x0 }, M/ `7 ^
, _4 U/ A& y. Z: O9 `9 o% x
9 Q. A2 f5 {+ f5 f1 @: P8 r4 q0 m- H
                edgeBlendBuilder1->SetTolerance(0.001);
! |7 P0 H! B/ W3 H3 C9 U: ?6 R
9 T+ V6 ^7 [( L  Z3 m; S
3 ?# N2 G9 ~2 w( c; u& n; X
                edgeBlendBuilder1->SetAllInstancesOption(false);
! W8 X' P/ x1 T  S8 e0 K6 Z! R8 S" s- S" q! f2 M1 h
  F" m2 R6 t, G2 X
                edgeBlendBuilder1->SetRemoveSelfIntersection(true);% T' {. Z/ t% q( N+ v) i. a

8 r; U- K# ?  ?/ E5 V* \! S
. c* f  ~' Q" B; E/ R5 z
                edgeBlendBuilder1->SetPatchComplexGeometryAreas(true);
4 @0 N8 ]  C7 A% N" k  ~2 C5 c- ~3 {6 `4 p5 C" ~0 |! R
9 i5 I; V. W+ v9 h7 u, p" X
                edgeBlendBuilder1->SetLimitFailingAreas(true);
+ W: z% q. Q, T! w# u( ^  H/ ?$ l$ `0 ]9 b& ?, P, n; \
3 d  \. a) O  I$ W1 w' H8 {9 T
                edgeBlendBuilder1->SetConvexConcaveY(false);
2 x/ I2 }/ p1 e7 T, g( U
/ D7 e' u4 R' Z" u8 P1 ]; o

+ c6 g: Z; z) v; o. D9 H3 K- ~, J: L                edgeBlendBuilder1->SetRollOverSmoothEdge(true);
3 o9 l$ n; U) U$ a! [1 V0 C7 ?7 u% m( \! z* f3 s
) U4 Z8 B- [0 i1 u( n* b: D
                edgeBlendBuilder1->SetRollOntoEdge(true);
. \3 w) U( q  q6 J9 O/ ~8 {: f3 v$ P# p0 w- ~7 j: J3 [3 O  k* x' H5 H
' V+ J6 O* c) R
                edgeBlendBuilder1->SetMoveSharpEdge(true);0 x% d* H5 d% T/ I$ a6 r

5 m( ]; P( A) y; W4 o% h

  z9 L3 b- C$ I  l) p                edgeBlendBuilder1->SetTrimmingOption(false);: c5 r! Q" `7 e8 i

7 @8 S5 m$ [- ?7 n

& s; a% f7 G' K2 w1 @- w                edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);( O; }: f0 Q+ w$ k4 t" d) s

! k. A; |2 I' t% ^3 a

5 _) H, C+ Z- {; [5 r) f% d" a; U                edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);2 `/ n2 Q1 x, h8 i' u

* ?. b2 U3 \5 V5 `0 r) x  [4 i
$ [% [, ?0 l/ m5 ?; q
                edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);
* ?8 k  c  g! P4 z8 R3 N
9 z( w4 a. r, R( F6 ~* J3 X
& l  a  |. ]" t; I, m  s' V2 c* [
                int csIndex1;
* d% v# Z3 I1 x                csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, DIA.str());
) w) n! @& \$ T2 ?$ m
4 Z* F1 L) }4 z: g5 a+ P
7 Z  I# q( b6 e2 j9 R9 Q
                Features::Feature *feature1;
0 Z) O) C4 Y5 L5 @                feature1 = edgeBlendBuilder1->CommitFeature();
% B# F2 U8 `/ u  u" m$ c- b2 e
, Z9 n7 O  s' }2 R0 O7 n% a
' U3 t; M! g# L  D& |
                edgeBlendBuilder1->Destroy();
5 _; o3 I, z9 u2 s" L9 m/ Q5 _2 A& B. _' m( x
    }
- X4 I( E6 [7 P3 i& k$ S, k    catch(exception& ex)8 O7 p- T2 v1 k. G7 g
    {
+ L' J6 [4 R. Y$ i. y4 f0 c; Y        //---- Enter your exception handling code here -----
4 m+ Z8 L5 X; |5 M4 r        errorCode = 1;
5 \( Y3 W0 z$ t' ]6 g2 Z* f        selectedge::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
+ V5 L: k0 o% x8 P9 D    }
, k5 e2 T; o. G/ a    return errorCode;
( Y. l+ ]- n' P}

/ W9 J+ D3 w# p
3 R, y! e" A6 d2 H: h. y
说明:因为字数有限制,这里只贴出关键代码。
" \3 n* a" A$ {. @4 O9 A$ {* G
+ p2 y/ J$ R) O5 r6 Q+ M+ ~* S$ u6 H
! f) w; v8 b8 B1 }. T% N0 z
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二次开发专题模块培训报名开始啦

    我知道了