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

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

[复制链接]

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

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

admin 楼主

2015-1-9 09:20:48

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

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

x
* v, P6 Q+ |" G" Q5 a: H3 f

4 V1 ~2 I! y: m. ?( e3 n# \0 ^5 s3 x& g" |. p$ ]' \3 ?; m
创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!3 X9 @9 T0 @. ~7 b. t, Y( q
. W$ l$ u. r, w7 b: \  v8 ^/ }' m
Session *theSession = Session::GetSession();
, ^% e& M* p2 y2 r& P7 x% I* O. ?5 T        UI         *theUI = UI        ::GetUI();! U( S  s/ U# e7 s6 H+ e" e
        Part *workPart (theSession->Parts()->Work());
9 \% e: ~7 A: r6 ^2 a% B9 j/ J6 r
5 ^& ~; k" S6 {) g' _1 e4 n        // initialize the select   V. ], n$ C( b6 m3 D
        std::vector <Selection::MaskTriple> masks(1);' t& R& x) l! j& F9 d" \
        Selection::MaskTriple mask;* Z1 k( p! X* w( [1 Y, [; H
        mask.Type=UF_feature_type;
5 l, V9 G/ r+ Q6 m        mask.Subtype =0;
. m( ?9 ?, d+ b& E1 ^7 @        mask.SolidBodySubtype=0;
9 s3 D. n5 b. S1 _. p        masks.push_back(mask);7 L+ P* X, e2 P
        //masks[0] = {{UF_feature_type,0,0}};
6 a$ F) w% V, c0 _# I5 u        TaggedObject *object;% g8 u7 F* w/ |) Y! p: u
        std::stringstream ss;
* z5 e) c/ G7 y, D) ]; w        Point3d cursor;+ T4 ~5 y9 l) A8 R/ b0 i
        Selection::SelectionScope scope =  Selection::SelectionScopeUseDefault;
$ |; A3 n6 v/ N6 O0 K        Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
# x1 I" H& A- X& _  z        Selection::Response res;$ {3 _$ X/ K  v# P
        Features::Feature * getFeature = NULL;
" H' L' k# O+ o, m6 s        res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);% g& k" i7 _, K0 C% }& `
        if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)7 u. J2 [( u& t' T' Y
                {- r( m$ l( z3 F/ O( q' L
                        // get the information2 G3 ~6 b( i0 I+ e) h
                         getFeature = dynamic_cast<Features::Feature *>(object);
- X% W; G" T& Z( y6 e
  P4 ^' ]9 M/ X) X* S& l8 l          theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");4 r% i: l1 T6 x/ I( H- S0 b
5 n6 F2 {4 P( L7 ~& G' _
                 if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))8 b/ Y5 W" e5 ?' K
                 {: f1 Q) c, N4 z7 k. v
                         Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);
! e. o! ^$ ]% A2 E2 V                         std::vector<Expression *> exp =  getSphere->GetExpressions();
. a0 O. d: d# x                         ss << exp.size() <<endl;
* G& E& K/ |) r1 p0 D/ F3 t                         theSession->ListingWindow()->WriteLine("the expression number is : "  + ss.str() );
6 Q/ T- N; X- X                         for(unsigned int i =0 ; i< exp.size();i++)
0 s- M. d0 T0 t3 H: j3 m" U                         {     `1 }+ r8 K% ~0 ~: k
                                  theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");3 [" u# i, T6 i" V+ }$ U
                         }
9 y3 I0 m1 F  S+ n3 r# h                         Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");
$ Z) e2 N: B7 w( a) n% x                         exp[0]->SetRightHandSide("400");" o% y+ o0 f+ O7 p" H
                         theSession->UpdateManager()->DoUpdate(undomark);
) a  a5 B( G, G5 K$ u9 @0 y                         theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");
2 u' Z) y) e& t6 s8 k                 }
! D: }  J# K: q. C6 ?; N; k9 I          }! p  z  |" K+ Z2 W: u3 N9 G

9 m0 O% C9 [* c) @2 Y( d4 N  \+ k5 [( }, [
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了