|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
5 \/ ~& ^' ^4 J" Q
2 Q0 f& n' k: ?0 C+ i( w, h
# ]# F. f" |# \
创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!9 g+ ]/ R7 ~ J* z* d- e
" N( _; e- J( C) e) E5 W7 A4 cSession *theSession = Session::GetSession();
9 v. U+ C3 Y* f J8 X w5 X% X UI *theUI = UI ::GetUI();" ?) |' P1 U: w0 g
Part *workPart (theSession->Parts()->Work());
. P, `4 w# b. D* W; N) u- j" a& o9 }2 v/ A4 z( D- q5 y1 S
// initialize the select
. ]+ g) r) ?" U6 [& M( Y std::vector <Selection::MaskTriple> masks(1); o- \) k0 b9 L+ B4 s+ o% ~
Selection::MaskTriple mask;
: ?9 R2 O8 d: S/ l0 n1 X mask.Type=UF_feature_type;
6 z2 J. r8 b! i( v mask.Subtype =0;
- t8 Y+ O2 W, ]% M. D; d mask.SolidBodySubtype=0;
9 [: h) J. B+ b" K; X# G1 R& U% @ H masks.push_back(mask);$ y+ `* z' m. I* m8 `0 a# {0 n; K
//masks[0] = {{UF_feature_type,0,0}};
8 A2 m6 L0 I) [, B TaggedObject *object;
' A u ~8 R+ C! ~9 ?$ w4 l std::stringstream ss;7 f9 ]; K' m1 P2 a) L
Point3d cursor;. Z2 Y3 ], T' Q; I
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
+ }, F( `$ g+ J9 z& ^0 w# Z5 z Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;7 j2 y5 H4 F# R+ `
Selection::Response res;
2 w5 i+ O; i5 M+ [4 r4 r4 @ Features::Feature * getFeature = NULL;( i- Z/ F0 l. t- x" ~$ p
res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);6 ~+ p' {) @3 a0 e% Q( w
if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)
8 K0 I9 C- G, ?& A9 ?. n {/ x5 X9 e. b* S
// get the information
, o/ @1 ~- m; o8 O* `: |( T. O. a& O getFeature = dynamic_cast<Features::Feature *>(object);
8 q7 R. ]+ J! N% H' K
# |( ]- U$ g1 D# C+ c' E theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");& Z$ a. B/ n3 V- y: ~* K
- |+ B) x" }7 M; a if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))* q, g; q2 x& Y# m y
{& w7 g) c) G, s! v% W; l( t
Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);
0 |% n; F+ v- \# X std::vector<Expression *> exp = getSphere->GetExpressions();
6 K4 s7 X' e K( ^# V3 m- o- b( K ss << exp.size() <<endl;, T. \2 c0 o# A
theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );
& R1 M* o6 D. |5 B- {. \- m6 [ for(unsigned int i =0 ; i< exp.size();i++)3 w, j$ j( E% i6 T8 S, e$ k
{
2 X6 J. r/ x- w7 B" m1 a9 O5 i' r, @ theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");
9 m4 ^( Z5 o& b- s/ l }# l8 n3 g4 n; z9 I
Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");7 L ^$ Z, Y* w; x- c3 P4 y
exp[0]->SetRightHandSide("400");0 ^7 t4 j9 A0 l1 g$ R% ?1 [
theSession->UpdateManager()->DoUpdate(undomark);
3 ?& d: r- w1 u, V theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");
* e' t6 W3 u3 ?/ m7 G9 v6 U4 K9 q k }
/ W$ U$ q( u! q, g2 n }/ k; g- f" E$ C6 a
! z( H8 _3 u5 y0 f& |$ ]) a" z3 B$ [
|
|