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

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

[复制链接]

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

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

admin 楼主

2015-1-9 09:20:48

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

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

x
: v) \( m7 |  j' ], ^
8 R5 ~& i, ^/ R% Y- x3 ^8 u6 Z5 I) D

* V, Q$ R: t9 _$ t创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!
2 _- Y- P( f9 ~" H$ p0 u
3 W/ Z6 c7 b/ h0 CSession *theSession = Session::GetSession();
6 k3 k5 t% W9 l6 k        UI         *theUI = UI        ::GetUI();9 R- _9 x3 r: z5 i) V( [! a
        Part *workPart (theSession->Parts()->Work());( l- N& t7 P0 s, P& G
: i! r& i+ r  q% b
        // initialize the select
- E3 [: t: W1 `1 `        std::vector <Selection::MaskTriple> masks(1);& K1 V8 v! R1 ^" N" s
        Selection::MaskTriple mask;
' s. J( R9 m/ \5 B3 h' G* `        mask.Type=UF_feature_type;8 V6 U5 t: o6 M4 R
        mask.Subtype =0;% W7 q) R$ i( i3 ^- D0 Z$ B
        mask.SolidBodySubtype=0;; H9 @- G) t/ H
        masks.push_back(mask);
5 ~1 N2 c6 o, P2 Z+ n) i  m( `        //masks[0] = {{UF_feature_type,0,0}};0 e- v1 P( l8 g" r" ^# u
        TaggedObject *object;" E) |4 g/ U1 `
        std::stringstream ss;
( C* l! e2 f7 X1 p) z: }        Point3d cursor;+ c. j5 A! a. H# o* o: F
        Selection::SelectionScope scope =  Selection::SelectionScopeUseDefault;* J1 `3 f( }5 C' J- N4 |; s
        Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;3 g# q9 q' o) s  S
        Selection::Response res;  r0 x9 e, f2 ]
        Features::Feature * getFeature = NULL;2 _( b' l: {; ^% t, J: |0 |
        res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);- s, Q" G5 {6 y# y) T: L
        if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)) B: s' m) j& _+ y$ a  M& ]
                {
, O+ S0 ^/ G* O' `/ O                        // get the information
0 W) Z+ s2 G4 ^5 h& ]                         getFeature = dynamic_cast<Features::Feature *>(object);  y" Y, `9 X# j

$ _3 k1 Q" {% W          theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");: |2 V  u* d8 r' B5 h
3 _+ a8 A; L/ S+ _  z0 G  J: Q
                 if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))
+ W9 k% i6 n# |9 u3 f  o* X4 x                 {
& Q# W) B4 a! R! t* f/ i                         Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);9 f! \6 z$ ~- L' r& j) t; o; K
                         std::vector<Expression *> exp =  getSphere->GetExpressions();
8 R1 t1 q( j' u$ i) D0 A* H                         ss << exp.size() <<endl;( m6 }1 I4 C/ U- R
                         theSession->ListingWindow()->WriteLine("the expression number is : "  + ss.str() );
% o0 ~: }# \; y1 |& F                         for(unsigned int i =0 ; i< exp.size();i++)( t. k6 @" d( ~5 G  x2 V$ G
                         {   ' Y, j7 j6 [" D8 y" l3 z! F
                                  theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");  e* m* t2 Y7 o; U$ q7 @$ f
                         }
3 `/ d# _, T, r$ a3 n                         Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");
/ L- G( K& R$ j                         exp[0]->SetRightHandSide("400");* E$ e  F( Q* I0 K: l
                         theSession->UpdateManager()->DoUpdate(undomark);! I, Y" U: L  a3 g; M- n# ?
                         theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");7 C0 x  R/ v9 ?; [/ v
                 }
9 k! J. K" p' Y) d          }
5 I4 v. X% n7 `& H
2 E/ h; h& B) H' j  I4 J/ f' J# w8 p, Z, C' |6 P
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了