|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
5 [) ^1 J% m5 f
+ f; _! X" i M9 G3 j5 d( f
4 C" @7 o( [; v. v5 _' I. f" ~
创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!
6 g8 u+ T0 [$ ~2 U$ N* y' N1 j2 I( u1 ]$ L- y+ v6 ~& w6 M$ z
Session *theSession = Session::GetSession();
- t9 ~- b- i; I5 E; U UI *theUI = UI ::GetUI();3 i. Q8 U3 a; R! r
Part *workPart (theSession->Parts()->Work());
5 d' L% n* W: p( \5 g9 n& @& V
% T: ^8 g3 R1 n# X" b& u7 k // initialize the select
G. p+ Q4 Z$ ] v* t std::vector <Selection::MaskTriple> masks(1);: Y" q. E" n# d2 {( A
Selection::MaskTriple mask;- G* A# Y5 `8 a7 T2 q/ }
mask.Type=UF_feature_type;
# d1 K+ ~( B8 Q) r+ B7 H+ R mask.Subtype =0;
8 t" ^; z/ A1 H6 |# s. A0 s8 s1 |( Z mask.SolidBodySubtype=0;2 A y. w# f N. l' p$ ^4 z
masks.push_back(mask);
8 w3 L3 B$ T0 I W" U //masks[0] = {{UF_feature_type,0,0}};
5 u+ g$ [7 a, [: u TaggedObject *object;; Y s" [; S4 M5 R
std::stringstream ss;
5 [3 h+ X$ r& P; i, P0 a Z Point3d cursor;
+ P, M% ^; o: G8 g: v Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
# S( L' q$ g6 g0 ~3 p Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;) A3 t* P" A- X) W
Selection::Response res;
; r" [4 \, B- E: ^ Features::Feature * getFeature = NULL;
8 { t2 d8 f$ h& d. S res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);
( j( i- e( d, i4 w7 w. ^% O' v; ? if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)
" B W1 c5 h: y. |+ q6 a {
# X0 v. Y0 z0 i# A4 T // get the information: H$ e p- h6 L+ j. d1 {: ^2 x
getFeature = dynamic_cast<Features::Feature *>(object);0 g9 b! M8 r) W
: s# M% O# h; t- W theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");% q& D$ t" D- t1 [) b3 C# M0 @; d
2 A; V1 b9 t4 z; c3 M. _" Y if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))9 [$ r! j& ?9 N+ U
{
) s) ^& Z# W0 y3 s3 T4 U. Y Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);
" n( R- E1 c1 \+ y _ std::vector<Expression *> exp = getSphere->GetExpressions();
. n4 l( g8 t7 q! D$ s& { ss << exp.size() <<endl;. A- D# s8 e4 Z8 [) t# @% a4 ^
theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );* I! s J: B3 y7 c6 c" g
for(unsigned int i =0 ; i< exp.size();i++)/ o/ A0 [, V: o+ g! Z7 N" z9 {
{ / x4 g6 ~- y3 ]# K$ `' |$ ]/ a
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");) K( M+ y( W3 v8 B! w2 H* d
}
" ~. M8 c5 }; `" M8 o/ { Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");1 y+ E2 V4 } M, D e, M# c0 C
exp[0]->SetRightHandSide("400");
7 e4 z3 o4 X6 \; H theSession->UpdateManager()->DoUpdate(undomark);
2 A" { V4 }* e) h* P theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");1 U7 f, e- T7 t2 b/ {* [
}
' H2 z1 j* K; u. ^$ J6 Y! W6 K }9 w" U3 F( ~. n) n
6 E! _( i5 D# A9 y" d' R' E0 j
, N& O/ M, [. _ ] |
|