PLM之家PLMHome-工业软件践行者

[资料分享] NX二次开发培训源码分享: 通过选择指定特征,修改特征...

[复制链接]

2015-1-9 09:20:48 3035 0

admin 发表于 2015-1-9 09:20:48 |阅读模式

admin 楼主

2015-1-9 09:20:48

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

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

x
2 @# i3 ~3 T$ s% U5 H, w( P0 R- p
; D( a/ @+ Y% r' h8 X" G

  q! q* _* y. p9 C/ z( c创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!% x. T8 x; p- |7 \6 S$ G, h
4 n* O* {/ L! U- M
Session *theSession = Session::GetSession();4 S, X4 {9 {" U3 x- ?  J
        UI         *theUI = UI        ::GetUI();
0 |: F7 F. Y1 }. p        Part *workPart (theSession->Parts()->Work());
# V/ H: v) p) n  R3 S9 i
$ G6 M; Y: @. E* h) v        // initialize the select 4 k3 {* o7 i& Z, L- @, M4 s: ?
        std::vector <Selection::MaskTriple> masks(1);
+ R6 Z: y  f: @( j        Selection::MaskTriple mask;! Y6 B: z% r- X( o
        mask.Type=UF_feature_type;
% P2 [0 V/ N3 Z( W6 P* A        mask.Subtype =0;& t) d( `3 [  D6 E) y" {3 H0 y
        mask.SolidBodySubtype=0;: \) t6 w/ A3 F
        masks.push_back(mask);
2 G* k% x* f  R8 W! c( ]6 o        //masks[0] = {{UF_feature_type,0,0}};
% x8 {9 G2 N3 W# \4 q: {        TaggedObject *object;7 r1 `3 V% t: ]7 Q
        std::stringstream ss;. t0 ~6 P6 C2 `- c, M# M  d
        Point3d cursor;; n" Y/ T5 c9 U: N5 A
        Selection::SelectionScope scope =  Selection::SelectionScopeUseDefault;' L3 w8 U& E# y# z0 ^/ W
        Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
% L! T' N) u  M( j  n1 B$ \        Selection::Response res;
1 ?, S" x% I/ R) r9 n5 F5 T$ z        Features::Feature * getFeature = NULL;
  k$ o' G  T+ U0 C% {* k        res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);
; F1 o1 _* I$ i6 J. c9 }4 g# |        if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName); Z7 s2 T& q7 {: I6 ?- `; d
                {
7 ]9 O4 w( v3 R! c. K, B& \                        // get the information
+ V# }# M' w! b" n& S$ q+ P                         getFeature = dynamic_cast<Features::Feature *>(object);
2 d0 l) F  b1 r% i  Y
: z5 v; y4 Q6 x) u6 T          theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");5 s' A* d, s# f( Z
9 }  I$ b7 \# @4 h( `" p& w, `4 Y
                 if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))
. f! {2 G4 S, W7 ]                 {' V' i- M0 J) L. X
                         Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);: P4 P& K. J9 {: @. D; q# E+ V( b
                         std::vector<Expression *> exp =  getSphere->GetExpressions();
5 e! F2 d3 k4 b- M7 v9 c/ [                         ss << exp.size() <<endl;" c5 W3 O; [3 A1 U+ o! X
                         theSession->ListingWindow()->WriteLine("the expression number is : "  + ss.str() );% z+ B3 k2 i! p0 e$ I6 l6 ?
                         for(unsigned int i =0 ; i< exp.size();i++)
3 W+ ]- h- ]/ q3 c                         {   + Y+ Q( M2 S$ d4 p# q
                                  theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");- ]" G- {' W2 w/ \) N8 X
                         }, `! E# N# F2 M% Y5 b) V( t
                         Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");" x) U0 K+ X. ?
                         exp[0]->SetRightHandSide("400");
# s- u0 l( L/ D4 Z                         theSession->UpdateManager()->DoUpdate(undomark);
; U% l1 w+ T% g2 J7 N& `% {                         theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");6 T. n9 t( Q! ~9 P" c$ Z
                 }
6 h5 V1 Q6 m, L7 x8 z% ?. d  D          }
) n9 N2 ~, [3 `/ z7 j" ?6 m: b* y& z' l. O' N1 V
; E' D, w" r/ j$ d: k0 E
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了