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

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

[复制链接]

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

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

admin 楼主

2015-1-9 09:20:48

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

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

x
% ^' C$ P7 O+ [" U! u6 b$ J

% ^$ Q6 x# ~7 I2 T- [3 s* v7 T8 Y
创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!, j" R4 i( `' U- @

& }6 g) e% F9 ASession *theSession = Session::GetSession();  y- ?- X9 k  j$ E2 S
        UI         *theUI = UI        ::GetUI();; m9 V9 q! V( |: w  o) B/ d
        Part *workPart (theSession->Parts()->Work());
( N/ R+ x8 A3 q/ n( D' n( r8 t; }0 A+ v: j/ z
        // initialize the select
  m* c! y) ^" ?$ z, y        std::vector <Selection::MaskTriple> masks(1);
( G3 a4 a3 m0 ^' }% C        Selection::MaskTriple mask;7 p! Z, ~9 K# I, s8 t/ W1 Y
        mask.Type=UF_feature_type;
! R, F4 G, {5 K& c        mask.Subtype =0;
8 }# P& N1 I2 E" e6 L8 x, b8 w- y        mask.SolidBodySubtype=0;
# G) k; I8 f% s8 W        masks.push_back(mask);# R5 k( \* f7 C6 k4 y
        //masks[0] = {{UF_feature_type,0,0}};0 W/ j) x- l3 C8 }. e
        TaggedObject *object;& B* r/ o5 W4 {- T% N0 k  M" P
        std::stringstream ss;
0 v' f# N, z# ^1 q5 ]        Point3d cursor;3 Z, C, [8 d+ e3 R" ?# i( f7 |
        Selection::SelectionScope scope =  Selection::SelectionScopeUseDefault;; T6 @' s( }  L/ l- J( I+ V/ k4 F8 P  |2 V
        Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
6 C) ?5 X- l6 v        Selection::Response res;
: C, b& l6 q2 f; V2 d3 W+ e        Features::Feature * getFeature = NULL;
9 @# |2 v4 b. o( f$ b7 R        res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);
( l, ]9 C& @) [        if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)
! S% U0 n8 \. b1 @1 D# q# r                {4 _4 X' A7 _! E- d) S
                        // get the information) k: n# b  a! U9 V
                         getFeature = dynamic_cast<Features::Feature *>(object);
3 }0 I9 `9 I. h7 v" e  G- k5 s. w
          theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");
0 f" V4 L+ a) y$ g2 _  q$ `0 Q; M# ]( k6 {' _  X* Y" S$ `0 ]
                 if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE")); C/ o) _2 ^7 w5 p! {8 _3 O5 t9 P
                 {, a0 v" D1 O/ E2 c
                         Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);8 s- w8 h& y, M3 A
                         std::vector<Expression *> exp =  getSphere->GetExpressions();* U0 }! |. T2 E2 t( R* a1 q# S
                         ss << exp.size() <<endl;: v0 ]6 Y$ \% G; p6 _
                         theSession->ListingWindow()->WriteLine("the expression number is : "  + ss.str() );
7 O  Z9 T* R' {  U                         for(unsigned int i =0 ; i< exp.size();i++)) v9 Q6 g, d& F. u
                         {   
+ ]; h, @& d' Q                                  theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");2 k1 E6 \1 Z+ }0 v7 ^4 r# ]
                         }# @! @1 \& Y" j# q- o
                         Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");
- y' i% X8 @+ G1 ]                         exp[0]->SetRightHandSide("400");6 [" n7 M0 s6 m: B7 F
                         theSession->UpdateManager()->DoUpdate(undomark);
% _5 E2 W/ v, u( O: z                         theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");
1 B( U! X( W: J7 d- @# z                 }
! T7 b" @6 i9 @  F3 x          }
) T% W' H( N0 T! z3 @1 ?' ]! d8 {! U! E  Z; h

4 k+ k4 Q! H( o2 f" }# Y. ~% G8 ^
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了