PLM之家PLMHome-工业软件与AI结合践行者

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

[复制链接]

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

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

admin 楼主

2015-1-9 09:20:48

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

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

x
/ \1 z2 y: D. H! w, m

* ?$ V! W! y: |, B$ l
! \: x5 {0 v+ |# Q4 y创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!7 e# B2 _5 l8 n0 }

1 \# K, J0 K4 J1 N6 OSession *theSession = Session::GetSession();
+ B7 e+ |( K6 h  C  q- s        UI         *theUI = UI        ::GetUI();
& Q7 c% v- v; Q0 h        Part *workPart (theSession->Parts()->Work());2 Q& f% L; q) n) x: Y& C7 T

3 |. c% N: ^2 m; T* z& I1 ^        // initialize the select 4 T6 z4 x- l, r/ j
        std::vector <Selection::MaskTriple> masks(1);5 k) l/ F- n2 \4 ]! Z( u: [1 d
        Selection::MaskTriple mask;, P: \. X- H7 B; I: x
        mask.Type=UF_feature_type;( i- ]- {: m2 T& a
        mask.Subtype =0;4 ^' h7 X/ Q8 X
        mask.SolidBodySubtype=0;
8 w2 p2 r+ y' z5 l; c1 z4 f, y% D; R        masks.push_back(mask);8 t7 K1 {' V, N) i2 U- j, k
        //masks[0] = {{UF_feature_type,0,0}};& l+ E4 @5 O4 ]) L* z" ]) D
        TaggedObject *object;0 B, w* U7 G4 U9 n& j0 g+ m
        std::stringstream ss;" }* \9 q4 E% [
        Point3d cursor;% G5 s8 z$ N/ G' e" {
        Selection::SelectionScope scope =  Selection::SelectionScopeUseDefault;
, l. g  x: U( x$ [: y8 T        Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;* O7 J# d: f2 Q: x5 G3 {
        Selection::Response res;$ i& M. |0 E& Z2 x2 L( ~5 V3 P; V4 q
        Features::Feature * getFeature = NULL;" V8 Y& E5 y% @' L, Y& O2 W; Y
        res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);
' x, x4 _/ F+ G7 _! R4 E, c        if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)
" v8 w/ P7 d5 `                {
; C- I7 l' z/ Y0 {1 q" u7 `7 C! b3 T                        // get the information
. }( x6 ^& B; s: z6 K- `  u  |                         getFeature = dynamic_cast<Features::Feature *>(object);' L+ e$ D% f; w
- y! I" O. H! l0 ^6 ]1 t8 X0 `
          theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");( b, H$ b/ X) r" h6 {0 J

0 K3 |! m( t: w) I9 ]! {                 if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE")), f+ P7 w6 V8 w' }
                 {
# `: j' A! G) u$ y" G. }                         Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);
2 _4 u/ ?- }1 V                         std::vector<Expression *> exp =  getSphere->GetExpressions();
$ F4 d" j% T! ^" R" k% |$ \( w                         ss << exp.size() <<endl;
- C' z8 p) v8 s- i. ~, x' l$ M                         theSession->ListingWindow()->WriteLine("the expression number is : "  + ss.str() );1 z$ C  I0 |) q3 ]  `9 w/ u
                         for(unsigned int i =0 ; i< exp.size();i++)$ \- N+ c% }5 D* s$ V
                         {   : o9 g9 @. d  m. X
                                  theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");8 I  c7 n" U8 s
                         }
0 E7 d2 T1 W% {4 W3 z0 i1 W2 \                         Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");
4 Q! U: ], d0 _+ e( e$ N                         exp[0]->SetRightHandSide("400");
) ?' F6 n* r; A" k" z3 S* O4 Y                         theSession->UpdateManager()->DoUpdate(undomark);2 b) g7 o& L; N6 Q$ _6 g
                         theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");4 {! V/ S3 u8 z' [  n/ W+ \+ I
                 }( Y( D/ P( i/ o/ [  V) p
          }
3 a  ~* b  B( I" t) h
4 [% N* e6 M* B3 n/ `& _; {  r" L9 T* Z* ^. j. }
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了