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

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

[复制链接]

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

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

admin 楼主

2015-1-9 09:20:48

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

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

x
# k% I0 U, ?( i

" n3 j8 A; k: U
: l4 H7 z9 _; g创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!$ R- C  v! l5 c. U" @

4 {; z% A% p) SSession *theSession = Session::GetSession();
8 l- _" G. y% ]4 O& W. |0 K        UI         *theUI = UI        ::GetUI();, [: a2 H' }( H$ c8 D* B/ H: A8 j, u
        Part *workPart (theSession->Parts()->Work());7 }% t! z- f8 C4 N- n; i( l
/ M- C9 V2 Y7 P# f! D# }+ l0 W
        // initialize the select
. p2 A1 ?% M' L" U0 t        std::vector <Selection::MaskTriple> masks(1);
+ L7 G& d% c) _6 o, F        Selection::MaskTriple mask;
; b, x# K3 ~+ z4 H        mask.Type=UF_feature_type;3 `7 b" R3 ]' |
        mask.Subtype =0;, |$ r5 P8 Q8 a
        mask.SolidBodySubtype=0;
7 [+ e8 Q7 h; d  z        masks.push_back(mask);2 ]7 D! V' U& I( Q
        //masks[0] = {{UF_feature_type,0,0}};
9 J/ B  N+ A! Y/ l( ^7 W4 [# R- J: V7 d        TaggedObject *object;
3 h+ d5 y1 a" G! F# d        std::stringstream ss;9 q0 w# d% |; w! h
        Point3d cursor;
/ X; e- `- D4 a& a3 t$ ?3 s4 y  w        Selection::SelectionScope scope =  Selection::SelectionScopeUseDefault;
! }  U( Y4 Z# s6 V        Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
( k/ _  E1 k2 W) \. o* @0 j/ Z        Selection::Response res;3 _% j5 R* w, g/ a3 M
        Features::Feature * getFeature = NULL;
1 w$ Y' a* }' B# h' T- r        res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);/ a% W: \4 V5 p( ~* M
        if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)/ j8 k$ a- X3 b/ s$ B- ^. b) K7 L
                {
" l8 j/ k4 H2 ]5 c6 F                        // get the information3 K7 D( n2 t7 `
                         getFeature = dynamic_cast<Features::Feature *>(object);
1 n1 X( I% W# ]4 g8 B" a2 t# ^- S$ U  e' U. l0 C" }7 ]
          theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");
2 v# U+ T2 y2 M) k( a& K$ V
6 x1 k- T  V& s! i                 if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))9 x5 I2 V& P6 i" f" [% I( E  j, {. o
                 {
4 d+ I. F  F7 V5 }9 d3 v% u6 P7 F                         Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);4 u. L' W0 q, N  ]1 ?
                         std::vector<Expression *> exp =  getSphere->GetExpressions();4 z" i6 F# s$ p4 ?
                         ss << exp.size() <<endl;/ w1 x1 B0 ^6 @7 n) h
                         theSession->ListingWindow()->WriteLine("the expression number is : "  + ss.str() );7 q  a! {8 ]" v" z  `2 @
                         for(unsigned int i =0 ; i< exp.size();i++)
0 {8 _9 j! r# k0 v- V                         {   6 x& p$ g8 L% }6 |3 z/ F( I% W
                                  theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");$ G: s4 P& J( X
                         }
& I! o4 o" h! l& o5 N7 W# ?                         Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");
7 Q* x( w( g7 e7 c0 c$ ^                         exp[0]->SetRightHandSide("400");. C& ]6 N  e4 {' O
                         theSession->UpdateManager()->DoUpdate(undomark);2 t7 w8 {' ?: [) @9 ]
                         theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");
% I0 j; U1 \/ P: c                 }
7 Y1 e' b, F5 ]# I2 t# O          }
* k0 w5 X8 ?6 U9 Y
5 t$ `2 e0 g" b1 R; o  K* ]5 K. [% h9 T  A! s
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了