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

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

[复制链接]

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

2470

主题

1275

回帖

8万

积分

管理员

PLM之家站长

积分
82162
QQ
发表于 2015-1-9 09:20:48 | 显示全部楼层 |阅读模式

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

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

x

1 }+ f( @* D3 ^* y* X
; p/ J. w  @. K& G3 O: A" |" s7 Q  H9 s$ X
创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!
( R# l* w% g4 Y% U* K/ N( b- Z! y4 r5 U9 X9 f
Session *theSession = Session::GetSession();6 I5 a0 t& n' K/ n, U0 @3 d
        UI         *theUI = UI        ::GetUI();
7 c& o- ~4 g9 M        Part *workPart (theSession->Parts()->Work());) G6 r, {3 ^$ g6 {: j8 @5 V

+ M: [  D: t5 }- T" ^  C        // initialize the select
) K* \( K. r2 Y: Z        std::vector <Selection::MaskTriple> masks(1);
1 S5 {+ }# N! S; a1 b' a+ f( J        Selection::MaskTriple mask;
9 r3 Y  g2 {- m  [; A& q; Z        mask.Type=UF_feature_type;
! y! P' z; X$ A' e        mask.Subtype =0;' S- _/ C0 c. m: k% ]: E
        mask.SolidBodySubtype=0;5 P$ m7 ^# l7 c5 v
        masks.push_back(mask);% W8 b7 U7 z2 a/ j$ I8 w2 D
        //masks[0] = {{UF_feature_type,0,0}};: {( y" r$ A0 p- ~5 H
        TaggedObject *object;' G, H" n1 W8 ~2 M, J
        std::stringstream ss;
( w, e/ L9 t5 Y        Point3d cursor;: \+ E8 l; q/ v; {
        Selection::SelectionScope scope =  Selection::SelectionScopeUseDefault;8 K1 L& \( F" G: q
        Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
' ]$ L$ k# e! l3 O        Selection::Response res;
  G0 c! m% o8 |4 Y9 y        Features::Feature * getFeature = NULL;
3 p# l6 L. i' t+ {4 Z# ~7 m0 y# q        res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);
+ p8 n( ]1 G) i* m. w        if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)
) G% b& h( u8 A" E7 }                {: Y' [% P- n- G9 N2 d5 j
                        // get the information- A7 }3 n' r* B- U
                         getFeature = dynamic_cast<Features::Feature *>(object);- D& j$ D, [' _8 o/ f" b) m0 S; }

1 ?( }$ q8 @$ }          theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");
& n. \9 r  u5 a- A$ M8 G* Z9 d# b$ c  U
                 if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))
# t+ }. G& z) ~4 T                 {% x% v* S9 R6 ?$ {) z
                         Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);7 t: b3 M' u& W& {6 t1 z2 r2 q: G
                         std::vector<Expression *> exp =  getSphere->GetExpressions();9 l& b) [& _8 ]. N! X
                         ss << exp.size() <<endl;$ m: w$ ^4 `% W( s8 l4 b
                         theSession->ListingWindow()->WriteLine("the expression number is : "  + ss.str() );8 M1 D2 p8 b* a5 R% G
                         for(unsigned int i =0 ; i< exp.size();i++)# E3 X: t+ k5 ]" l
                         {   
' O( X6 \8 j% l5 {, M- R) K* g                                  theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");
! v: b2 z- t; h                         }+ r$ i, c/ j/ M4 s$ l5 V
                         Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");9 c* m2 B1 X1 H9 r5 J9 D2 E4 c
                         exp[0]->SetRightHandSide("400");3 o) M: ]7 J- r: x. H) D- |/ V9 l
                         theSession->UpdateManager()->DoUpdate(undomark);8 ?$ d+ A) M; ^: k1 P
                         theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");
6 B8 z' a/ @' r/ y                 }
' ]% {3 S+ s# Q) W3 p; u          }
0 u) `$ g* D6 S2 y# O/ Y  U! z/ T( O. E

/ {( f9 D+ N6 b! e7 U
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了