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

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

[复制链接]

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

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

admin 楼主

2015-1-9 09:20:48

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

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

x
  b( s  M9 T4 H* x' V2 o/ ?
% j, X7 a  e" j- L) A6 q

: r1 M6 q! w6 d创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!
, x2 d0 x, f* a, b# K0 X8 w1 m; v* m5 k' J
Session *theSession = Session::GetSession();
5 Z; t, y$ v3 m        UI         *theUI = UI        ::GetUI();
8 \. y' g  h3 f        Part *workPart (theSession->Parts()->Work());
- U( P8 j: V# E! @5 k. f0 M, @0 |9 {) D  k* u0 q1 i
        // initialize the select
. f4 g" e& W4 P, ]. x        std::vector <Selection::MaskTriple> masks(1);/ p% i9 M% H) P5 L
        Selection::MaskTriple mask;
1 x; H0 M7 _& }* L# C! L* U  Q: H        mask.Type=UF_feature_type;& F0 F& }8 H% Q# Y
        mask.Subtype =0;9 l$ s5 d7 G( O- v
        mask.SolidBodySubtype=0;
. v9 V8 E/ t; z! b9 z# S        masks.push_back(mask);* ~) ]! Z4 C8 H
        //masks[0] = {{UF_feature_type,0,0}};
8 _- _/ H) K0 M( x/ M" U7 f, R        TaggedObject *object;
: `+ q- C1 B+ t        std::stringstream ss;
  G* v0 e$ Z) h+ U9 ~1 D1 y        Point3d cursor;
. \' b/ O. k! F, H2 {3 `( K6 `3 M        Selection::SelectionScope scope =  Selection::SelectionScopeUseDefault;) G% w5 t6 I. N/ ]  t2 p' n: g* j
        Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;5 G5 P  L4 {2 W: b7 u
        Selection::Response res;& v0 C$ D! x$ {2 w/ ~6 }
        Features::Feature * getFeature = NULL;
2 v  z" P% b. D- L  y' r        res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);
' \6 z9 V  F  P        if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)+ _6 }% b5 E) S
                {
. c  P, z' j7 f! U                        // get the information
/ R+ h  a1 K, a; ~. J$ n, g. K. r; U                         getFeature = dynamic_cast<Features::Feature *>(object);. ~) q& b/ Q8 g9 `
; ^; @# {9 e7 W3 Q) |' |  e
          theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");  L; u, D4 }% c2 \: h8 P8 D7 B
' F9 s, P" A& v, K' }- [( X1 e) z
                 if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))! n4 J3 F% Q' Z3 d8 S, D0 _. y, `
                 {
  n, m. I/ U  X. k2 S3 o& f" W                         Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);
3 g1 W" v+ V. ]$ K9 N6 ~+ v                         std::vector<Expression *> exp =  getSphere->GetExpressions();5 |; |; q  d2 h( M& P
                         ss << exp.size() <<endl;
4 R6 i/ Y( L# X; ]4 z: ^- x                         theSession->ListingWindow()->WriteLine("the expression number is : "  + ss.str() );
- m9 j& |* X9 J9 {% d! ~. V                         for(unsigned int i =0 ; i< exp.size();i++)
1 a$ N) z3 I$ p: o- x- F                         {   ) Y# v* I4 z5 k' K7 ?8 T
                                  theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");
9 Z0 M5 f5 ]+ Q7 N. h                         }
* Y5 ^7 x) p2 ?$ K& X2 I                         Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");
, f  ^9 K, s: x$ _                         exp[0]->SetRightHandSide("400");# N5 `0 C6 c- H( l  Q9 @$ ^
                         theSession->UpdateManager()->DoUpdate(undomark);
1 @( j0 N/ N# z  ]                         theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");
6 Q$ A' b6 G1 f7 U                 }
' _- c# Q! v5 C( ^9 y          }
3 Q4 P# N! G  P) G9 o1 ~. p- Y+ l/ N5 C

: K2 l, c- M, }: p7 v
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了