|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
* C: k, U& U) |0 f! P
! i" V' ` G* }& u: s
" [# `0 z% k0 W% E0 M
创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!
# `) ?2 n F2 E% k/ s( b6 G! Y8 T0 @$ `3 V) O& U# y2 t
Session *theSession = Session::GetSession();0 a8 \4 m V+ L2 d. L( g3 ~
UI *theUI = UI ::GetUI(); R9 n$ u# d" F) ?% \* r/ v% a# V
Part *workPart (theSession->Parts()->Work());
8 A- C. |/ i$ \/ _, D7 B
# C4 R8 V( l. ~1 V0 h3 q // initialize the select
* y7 a# |% i, n# i& {7 e std::vector <Selection::MaskTriple> masks(1);% v% t" y S! r/ P/ |
Selection::MaskTriple mask;
% |% j. O: b7 _. i+ l& U# ~ mask.Type=UF_feature_type;2 ~8 o9 l1 N/ y+ y' n0 d. {; v
mask.Subtype =0;
) v. p" p3 P$ t. n. \: d" J mask.SolidBodySubtype=0;
7 h8 D% y* Y; F4 M7 d+ I masks.push_back(mask);$ y. [" V; \* h) T, H& W* w' P
//masks[0] = {{UF_feature_type,0,0}};& P5 ~( f p& k8 F0 g- h
TaggedObject *object;
# N2 t, |/ y/ o c; Y std::stringstream ss;0 q, ^6 `0 J z S/ C t4 E3 I
Point3d cursor;; W. s8 m. I6 g+ H9 z: E
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
- A3 p+ q L* @ Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;% |- T# Z7 W" z T. Z0 K- {/ n
Selection::Response res;
& I( h: B$ k( Q6 O Features::Feature * getFeature = NULL;9 b$ c6 \" e/ O( J- B5 t
res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);
# b' R) c7 V$ Q7 v; T if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)9 z+ \# f+ c. u8 \0 q- h. ^! m
{5 [& p* [3 Z) ~, `5 M/ {9 r
// get the information2 V0 i; { g& I* }' I0 s! U- z6 D
getFeature = dynamic_cast<Features::Feature *>(object);
0 e3 c( E2 ~4 A9 x( j! ]& e+ t* ~' r, o$ p5 [. J
theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");4 Q+ a. B4 H3 k" S/ h* t; t
3 i, [3 y3 ^" M, S
if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))5 x* ?: p* m& j$ ?# x5 x7 c9 r
{
8 [& ]% h& P& ?% u# v0 Q& u4 Y6 \) w Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);
) [( d- t; \, z1 {& o std::vector<Expression *> exp = getSphere->GetExpressions();
" Z3 Z4 d( B: y, {" w' Y ss << exp.size() <<endl;' @$ Y2 j& K( s6 V
theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );& a- j5 |1 a N5 j1 x2 K: k
for(unsigned int i =0 ; i< exp.size();i++), } f0 g- c* p" q! C
{
3 j/ F$ y: Y* o. a" P theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");
' {' B6 v. e* Q Z' } }) K w1 z+ J: C c6 [; w
Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");) Z4 w5 L' h% H, K( Y
exp[0]->SetRightHandSide("400");: f/ s3 F9 d, A# t+ \! k' K
theSession->UpdateManager()->DoUpdate(undomark);2 e9 b" Y# o9 }; c
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");
5 K) c5 O, C; T }
1 A6 I" p* C; g5 s8 V2 `# C }' p% V6 e6 P9 J+ }8 F2 b6 ^$ {4 b
: X0 M0 j! N. n- ^! ]% i
# b# F6 x u7 y1 [
|
|