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

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

[复制链接]

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

2470

主题

1275

回帖

8万

积分

管理员

PLM之家站长

积分
82162
QQ
发表于 2015-1-9 09:20:48 | 显示全部楼层 |阅读模式

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

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

x

# b2 r. |/ z3 l0 {/ J0 A4 Z7 L- T/ [- @

# c  m! F  {6 K+ \3 @- I; y2 M4 T创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!/ R- N3 x1 ~+ V0 a7 W% t2 d6 x3 ]5 T
+ J2 |9 K; D, D( r9 K3 w, y
Session *theSession = Session::GetSession();: G- f% a& {3 C8 m+ H0 b: Y
        UI         *theUI = UI        ::GetUI();* j7 z+ u2 {& N9 d1 ^& {
        Part *workPart (theSession->Parts()->Work());. }3 \6 y4 T( e. d* J! F+ Y. k1 x
* I5 s1 z5 h' Q9 a1 s$ D8 u) I
        // initialize the select
& w7 O2 Y  n/ [0 ]; A3 U        std::vector <Selection::MaskTriple> masks(1);
$ L4 G% R) C" F        Selection::MaskTriple mask;
  C2 }5 f" N3 q; A8 d        mask.Type=UF_feature_type;
3 F: D' r; j9 [% [9 W5 i        mask.Subtype =0;
. V$ C: W; d& I. A        mask.SolidBodySubtype=0;
% ^" R# w6 v$ ^" @        masks.push_back(mask);, @6 ]# M9 Z9 V' [. z
        //masks[0] = {{UF_feature_type,0,0}};1 Z5 N% x9 s* p% \2 z7 S6 c; L
        TaggedObject *object;' ?: T. Q! _# ^* D% E
        std::stringstream ss;$ F0 I& R  R0 ~% g  p% c& j
        Point3d cursor;
; {  p7 T3 |  c2 O3 F2 h9 {+ [        Selection::SelectionScope scope =  Selection::SelectionScopeUseDefault;
. @9 y) f9 G4 d  j! g        Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
/ s3 \' `& m/ W' u  Z7 |9 n        Selection::Response res;4 {/ @4 r# V6 c/ U4 V
        Features::Feature * getFeature = NULL;
: G# d4 ?' W" O( I/ s/ R  A        res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);
- z8 h& {4 K- f0 d        if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)7 Q( S6 n: B+ e8 ?8 I" Q
                {
1 F( O9 S) j" H                        // get the information$ t7 k5 C+ B4 U& ^8 J) P
                         getFeature = dynamic_cast<Features::Feature *>(object);
% b  i+ M! }/ P( R. k* O$ _) |' ^) x; N
          theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");+ Y3 i+ {8 [; E5 L2 m
/ l( A* Z: b9 `
                 if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))
5 P: U9 t: n0 v6 K3 V& E6 t& W                 {
1 L' ]. |) P/ z! H                         Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);$ x) w0 d1 E1 i. y1 Y0 _
                         std::vector<Expression *> exp =  getSphere->GetExpressions();
2 v8 K* Q& A7 F3 B% {2 b/ O9 D3 ?                         ss << exp.size() <<endl;" M6 f- [" V0 q+ t" R4 y8 q: C
                         theSession->ListingWindow()->WriteLine("the expression number is : "  + ss.str() );+ s1 ?) Y" a( P2 ^8 m
                         for(unsigned int i =0 ; i< exp.size();i++)
& u+ @7 V1 f6 H, [& v/ ]                         {   
" M* Z+ b" F/ z# w; J                                  theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");4 v5 G1 K) G9 Y7 ], e
                         }) y' X  ~9 k8 `: N
                         Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");8 X; d/ X4 w: p) `
                         exp[0]->SetRightHandSide("400");
2 T, m* K( z! m3 i                         theSession->UpdateManager()->DoUpdate(undomark);
5 G0 K( e& E. b2 Y; _1 x: N5 f4 X                         theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");
/ K# }* h. r; @2 A5 l1 z" p                 }: N/ j; A! {3 }2 B' {. w
          }
: {9 {, S# L8 G- j+ B
( U% N4 N, M- M  k% z7 l1 ^5 C# j% i" X: _$ t
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了