|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
2 s2 Y3 H0 g" P
5 [+ s4 ^" b# t5 s6 {0 _$ d( r: s/ E
1 R. V8 b" H1 V$ u h; A$ c0 [) K8 `创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!5 U; w9 D: _6 r. A3 `
% c8 O' ^2 g4 p+ i% OSession *theSession = Session::GetSession();5 u7 Z# W+ t0 o
UI *theUI = UI ::GetUI();
1 O* O& r j$ q9 n$ ~( _$ a, z Part *workPart (theSession->Parts()->Work());
3 F2 `, P G2 f# B
- H2 k" W/ I- Z% s // initialize the select * b/ u% q: E" L; Y8 o, Y! U
std::vector <Selection::MaskTriple> masks(1);
5 g) P5 B; q5 u4 G6 r* I. T+ L Selection::MaskTriple mask;
; E' s, C# F. w2 G mask.Type=UF_feature_type;, R! Y( {7 E) M& H7 M+ O; y/ V, F, j
mask.Subtype =0;
& t* Y. x: |( P- F& }: k mask.SolidBodySubtype=0;6 g: W ?: b( t0 z
masks.push_back(mask);+ ]3 F/ Q1 T9 {
//masks[0] = {{UF_feature_type,0,0}};! B$ D4 P4 z/ m8 J, c8 Q/ ^( x
TaggedObject *object;/ ?: p& D7 g: i3 G
std::stringstream ss;) b; C' _7 t7 g" `7 l
Point3d cursor;- g( r- N- Q6 U3 A
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
: X2 I5 i' ~1 M( m0 f. J' n Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
- t4 v+ |; Y6 ^2 B3 S Selection::Response res;& Z; s: e: O- j: E
Features::Feature * getFeature = NULL;7 f5 L. m+ C7 v9 o" g
res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);
# Z$ x" F' H* V$ E L! ^ x6 l if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)9 B- L0 o4 y3 ?
{
" U1 Y# P1 m' r8 h- x8 P7 ?- D: t // get the information
/ Z4 p T$ `8 L! r) l& O getFeature = dynamic_cast<Features::Feature *>(object);
1 C: B- X; J. f- R, J+ g/ B, y# B o2 R* W4 b* a
theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");
7 @" L/ W' N1 l) y6 g0 F1 W- f7 F' C* l8 F. }8 h
if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))
8 ~* W% {' j. w2 w. |8 N$ z2 z {, j& ^$ q# j$ e6 r2 |5 {
Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);( ^: ^, w9 _6 |( n
std::vector<Expression *> exp = getSphere->GetExpressions();. m: o3 {$ H- L! B# A) ~" D
ss << exp.size() <<endl;" k D( ?3 ]" K' [: H! C
theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );
2 a7 ?* O/ B- z- g0 `9 b for(unsigned int i =0 ; i< exp.size();i++)
7 _9 J; f5 A6 k$ t @% o {
& I! y) |' G$ J) M: e7 J0 q theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");
8 | l7 r3 S9 {7 E }
+ M% L' A) Y, x, u4 H Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");
/ D) X1 p1 }" G* T5 r exp[0]->SetRightHandSide("400");0 V/ x1 u+ E9 _1 P$ f
theSession->UpdateManager()->DoUpdate(undomark);
$ x! r" y9 D- C5 `) }( y9 r; s) c. [4 |" Q theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");5 d- F5 z7 ]! d4 t1 Z
}" c. E0 \' G8 ~
}4 r# Q( f: a* S6 l. o+ n
0 S' e6 _: z9 {6 d( r3 z+ ^* o, i& _: f8 n
|
|