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

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

[复制链接]

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

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

admin 楼主

2015-1-9 09:20:48

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

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

x

5 @- I+ |  b0 G# [# q- M$ }" c+ O* C7 v7 Z$ \
" @6 K( |" _/ A1 k! o$ e
创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!6 Q' z: P' M: g4 m; {" o8 x5 r# m

# f" Q' p7 W2 i8 USession *theSession = Session::GetSession();$ T$ I( `4 c9 `* t
        UI         *theUI = UI        ::GetUI();
% F8 q+ Z1 E+ x& L        Part *workPart (theSession->Parts()->Work());
6 T6 b" D; S* N- m8 W1 H" Y9 J
$ ^* t; _9 q* E8 P        // initialize the select
" t8 L- s$ o- U8 Q- m3 q        std::vector <Selection::MaskTriple> masks(1);
" f* L+ F* V/ B# h1 n        Selection::MaskTriple mask;
$ N' n8 ~4 z% w" H9 f& G0 K. s        mask.Type=UF_feature_type;, [8 G9 P! ?( T/ t8 y/ E" g$ r. B
        mask.Subtype =0;# i: S8 ^" l4 b9 T: A; j$ m% B& E" }# _
        mask.SolidBodySubtype=0;7 F6 P1 W5 Q8 }( v3 z
        masks.push_back(mask);
5 s0 u6 I8 S+ J) J5 z) j        //masks[0] = {{UF_feature_type,0,0}};
, C  W2 w3 q: x$ k        TaggedObject *object;
8 o' I, ?9 y. x        std::stringstream ss;" x) d5 W$ k  ?- O  H. V
        Point3d cursor;
0 }  l9 u( H* i5 L7 G6 C3 ^5 Q1 }        Selection::SelectionScope scope =  Selection::SelectionScopeUseDefault;) }* {4 b' v1 r* C( M
        Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;4 ?+ f% l% K- W( U- W" c0 y9 L$ |
        Selection::Response res;! C( x' [6 n0 E. V7 Q$ R
        Features::Feature * getFeature = NULL;9 v1 C  A* Q: k0 [$ O1 f! }
        res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);0 M0 e) h4 X- t0 n0 m
        if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)7 s$ c% P( ~, E5 r9 j0 `' K
                {
2 F* L3 r/ M% R- g% i1 q; X                        // get the information
2 y4 M# h* d, s% S. N                         getFeature = dynamic_cast<Features::Feature *>(object);
3 h  W) m, E  `. ]
% p  P' a6 v: S# }7 X: I          theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");1 R: A6 N" ^/ d9 ^1 i. X0 }

5 r4 D/ B7 _5 A, {* `  i                 if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))
' l* r8 p6 b0 @* v  `                 {* v# I3 L& T$ j
                         Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);
' i$ A% N. }2 G0 T3 A5 }3 v1 ]+ `                         std::vector<Expression *> exp =  getSphere->GetExpressions();+ c- ?% p( f: [' i1 o2 W
                         ss << exp.size() <<endl;
* n( T% ?+ l! \/ t- K) I! o; K                         theSession->ListingWindow()->WriteLine("the expression number is : "  + ss.str() );
$ Z7 d; \: A  l                         for(unsigned int i =0 ; i< exp.size();i++)
, C% `3 J0 [0 x! |- w8 L                         {   5 D6 ]  w( j9 h/ i; N
                                  theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");( J  R. j3 h8 \' b! D
                         }7 |8 X3 H0 j' w2 `+ e% Y" x. H. l' }
                         Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");
1 Q" k* L# ]& c7 x. y7 e                         exp[0]->SetRightHandSide("400");
  ?" ]- Y2 v$ ]: I' u% ?                         theSession->UpdateManager()->DoUpdate(undomark);' H7 I: I  v6 `# m" P
                         theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");7 e$ p" I+ `# e2 O  \
                 }
! h; ~1 g+ J3 d" K          }
9 A6 @2 h; o* U$ Q3 w7 \* c
5 a! }) O6 x' E" }% S  i$ d
+ A+ y9 d- h6 S" t/ Z
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了