PLM之家PLMHome-国产软件践行者

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

[复制链接]

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

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

admin 楼主

2015-1-9 09:20:48

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

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

x
, D1 f& x3 q, C2 x

' H% H+ A/ P* d: f/ a
+ G5 y2 F; O/ @+ y7 c9 j9 e创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!
. k/ r. D% ^, Y/ A7 b* J6 @: T& A; W, q1 T' u
Session *theSession = Session::GetSession();1 r/ a3 V7 a5 e* \! X5 Q! t
        UI         *theUI = UI        ::GetUI();7 {- V: @, _) |8 J4 u4 l. ?/ O: [
        Part *workPart (theSession->Parts()->Work());8 W# m- [& h( u
0 p1 {8 H2 L* o! E$ V1 Q1 }9 \
        // initialize the select
6 y$ u+ `; x% q! @) j3 V  y        std::vector <Selection::MaskTriple> masks(1);
: l. K: Q1 _% Y1 @        Selection::MaskTriple mask;3 `1 l& P. R: l+ i
        mask.Type=UF_feature_type;
! E! u- Y6 ^: j% M1 E" g( o        mask.Subtype =0;
8 {" ]! ~6 z! K( S        mask.SolidBodySubtype=0;4 v, v; Q3 E; o% F! T
        masks.push_back(mask);
- I4 r" \* I6 R: ~- M" k0 X+ h        //masks[0] = {{UF_feature_type,0,0}};
' J- B1 H" U  X. }- ^/ a' E        TaggedObject *object;
/ v+ f; E; }* e# @        std::stringstream ss;
/ V1 h! ?7 F6 _- Z* }# U; f( x6 f        Point3d cursor;
7 I1 q& v' C- ^. C! R        Selection::SelectionScope scope =  Selection::SelectionScopeUseDefault;4 T+ k! k1 B6 A. M: z
        Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;; y% ]9 X* Q% U0 |2 I
        Selection::Response res;
/ ~5 F, L8 q" u. b        Features::Feature * getFeature = NULL;
1 n7 Q1 i& M: V% w        res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);
/ w+ R) H9 v2 r; ^* u        if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)
5 [5 Q8 I6 e  Y$ ~# v& S                {0 h* d" P/ M8 H9 w+ M% a
                        // get the information! C. c' Z" w" a5 \( b' b3 F$ R
                         getFeature = dynamic_cast<Features::Feature *>(object);
: H  |  ?- G  [( b" K  e) f1 U; x  [. m8 s! H2 R5 d
          theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");
% H. n  S* C. ~0 ^( \
" C0 ^/ k( b' d/ f                 if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))+ G5 u: O7 ?, b% `
                 {
7 K( z0 R* {, N8 Q                         Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);
+ p/ [8 f- |* e0 L( z6 D                         std::vector<Expression *> exp =  getSphere->GetExpressions();9 R6 J' o+ N9 g& d/ F& _2 r
                         ss << exp.size() <<endl;
; D2 |) y& r( g# g9 x                         theSession->ListingWindow()->WriteLine("the expression number is : "  + ss.str() );+ Y7 K: Q  ?: I2 _. ~* N" L# J5 R# U4 u
                         for(unsigned int i =0 ; i< exp.size();i++)
% U5 @% J" y8 A$ \                         {   
5 O7 H! _1 O0 Z' R) k+ e" @                                  theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");
5 t: L7 P* J9 S; S8 t- W/ y                         }
- v/ I# o! O- G6 N1 P: ]                         Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");% A7 f# Q4 z) G9 g# T" ?9 x4 O
                         exp[0]->SetRightHandSide("400");& h. |4 r6 Y5 i! X" l. Z
                         theSession->UpdateManager()->DoUpdate(undomark);
+ ], p0 _' S. O% L5 v                         theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");* \9 f% w/ ^' f; f. b- N
                 }; G) P* l6 }. a# f" ^
          }0 Z, r4 Q* k2 K$ v+ |1 J
  B. q' O$ c) E3 ~# `+ X) l( V
% c, E% j3 [4 q0 M5 k
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了