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

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

[复制链接]

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

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

admin 楼主

2015-1-9 09:20:48

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

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

x

# G7 K3 o1 W1 q+ X
# ?  J9 g: E. F$ T# Z) r* ?3 {' m: v. o, Y
创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!
9 `; R5 c- U0 Y$ d' x2 ~7 _$ D7 b, X. W" D, O+ m' |- V* q* }
Session *theSession = Session::GetSession();
/ ]7 {# Z, |1 |! l- l1 n0 i3 ^# u        UI         *theUI = UI        ::GetUI();
/ ~; \7 J7 P; a1 H& J) [/ j, `        Part *workPart (theSession->Parts()->Work());5 h( B0 M1 V2 s# H' A

" ~; L+ H- J/ K2 S9 j/ @        // initialize the select * g" @8 F# D9 W- P" J/ a$ h
        std::vector <Selection::MaskTriple> masks(1);% y' S* p- @/ n0 d( ?# r" S8 B2 B; h
        Selection::MaskTriple mask;$ |5 Y, I6 g; G* [$ N# b' I0 p
        mask.Type=UF_feature_type;
( U9 b& G8 F. I+ G        mask.Subtype =0;
4 E3 e* G9 U% o0 w5 Z' Z        mask.SolidBodySubtype=0;
7 N- s/ j$ a. W; F* I7 F        masks.push_back(mask);/ `; z& u7 L: J, U+ V, }" {
        //masks[0] = {{UF_feature_type,0,0}};
7 V; a* k9 C  P2 \) x        TaggedObject *object;
, m+ `6 W! ]. V6 o        std::stringstream ss;4 M0 l/ m: q: q) r9 ?. G
        Point3d cursor;0 e" h9 u* |8 L( q+ |
        Selection::SelectionScope scope =  Selection::SelectionScopeUseDefault;
3 G& G! j& a% J) c( ?        Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;+ c, _. x$ R- P) i* [* w
        Selection::Response res;
8 n  b8 q# H4 P+ s; `% I8 B1 u        Features::Feature * getFeature = NULL;
* }# O# G9 c" q; m        res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);" E4 p! D; V5 W. ^" f1 w
        if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)8 F) C/ ^4 Y& j2 D
                {1 Q# T2 j0 c; y' ?# A$ M' ]
                        // get the information
& R/ j. k1 x3 J" z. N9 c0 d) P                         getFeature = dynamic_cast<Features::Feature *>(object);
) D$ e, i! ^6 r  J9 f& [' e" V& Z' p
          theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");
2 Y. s- H, W5 l
  d' [9 ?4 B) K8 W                 if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))
9 P( n! k/ M: F7 p; }& [# S2 u                 {
2 \/ I) o, E8 @3 @% l) d  m                         Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);- |% P. h6 U: M" E
                         std::vector<Expression *> exp =  getSphere->GetExpressions();
% f( h9 ^% f6 d" J% o0 t1 C+ c                         ss << exp.size() <<endl;
1 l5 N1 G, O, _: Z                         theSession->ListingWindow()->WriteLine("the expression number is : "  + ss.str() );0 j+ X+ w. Z  B
                         for(unsigned int i =0 ; i< exp.size();i++)
. k  Q& C$ l3 d) I2 ]& p) g% R% p7 r                         {   
. D( d: r* A: W! S* x3 f                                  theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");0 d5 I9 f4 N2 H3 u8 z
                         }: Z9 h/ k7 W8 S: g/ [: w6 i
                         Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");
" I9 {6 W5 y# J# S                         exp[0]->SetRightHandSide("400");3 Y) ]2 f, y) [& k. ]$ V. d# c- Q
                         theSession->UpdateManager()->DoUpdate(undomark);
8 S) s" i$ W+ G) I8 y                         theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");/ v8 }2 d7 L: _0 R$ p9 I: H& |
                 }
' T: S; b# w( E; F& w6 L$ [. W$ P          }
- h0 ~0 Q) G7 w& s' C3 X: N; m" S$ n5 f0 `
0 }$ r! k( i6 {
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了