|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
b( s M9 T4 H* x' V2 o/ ?
% j, X7 a e" j- L) A6 q
: r1 M6 q! w6 d创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!
, x2 d0 x, f* a, b# K0 X8 w1 m; v* m5 k' J
Session *theSession = Session::GetSession();
5 Z; t, y$ v3 m UI *theUI = UI ::GetUI();
8 \. y' g h3 f Part *workPart (theSession->Parts()->Work());
- U( P8 j: V# E! @5 k. f0 M, @0 |9 {) D k* u0 q1 i
// initialize the select
. f4 g" e& W4 P, ]. x std::vector <Selection::MaskTriple> masks(1);/ p% i9 M% H) P5 L
Selection::MaskTriple mask;
1 x; H0 M7 _& }* L# C! L* U Q: H mask.Type=UF_feature_type;& F0 F& }8 H% Q# Y
mask.Subtype =0;9 l$ s5 d7 G( O- v
mask.SolidBodySubtype=0;
. v9 V8 E/ t; z! b9 z# S masks.push_back(mask);* ~) ]! Z4 C8 H
//masks[0] = {{UF_feature_type,0,0}};
8 _- _/ H) K0 M( x/ M" U7 f, R TaggedObject *object;
: `+ q- C1 B+ t std::stringstream ss;
G* v0 e$ Z) h+ U9 ~1 D1 y Point3d cursor;
. \' b/ O. k! F, H2 {3 `( K6 `3 M Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;) G% w5 t6 I. N/ ] t2 p' n: g* j
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;5 G5 P L4 {2 W: b7 u
Selection::Response res;& v0 C$ D! x$ {2 w/ ~6 }
Features::Feature * getFeature = NULL;
2 v z" P% b. D- L y' r res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);
' \6 z9 V F P if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)+ _6 }% b5 E) S
{
. c P, z' j7 f! U // get the information
/ R+ h a1 K, a; ~. J$ n, g. K. r; U getFeature = dynamic_cast<Features::Feature *>(object);. ~) q& b/ Q8 g9 `
; ^; @# {9 e7 W3 Q) |' | e
theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n"); L; u, D4 }% c2 \: h8 P8 D7 B
' F9 s, P" A& v, K' }- [( X1 e) z
if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))! n4 J3 F% Q' Z3 d8 S, D0 _. y, `
{
n, m. I/ U X. k2 S3 o& f" W Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);
3 g1 W" v+ V. ]$ K9 N6 ~+ v std::vector<Expression *> exp = getSphere->GetExpressions();5 |; |; q d2 h( M& P
ss << exp.size() <<endl;
4 R6 i/ Y( L# X; ]4 z: ^- x theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );
- m9 j& |* X9 J9 {% d! ~. V for(unsigned int i =0 ; i< exp.size();i++)
1 a$ N) z3 I$ p: o- x- F { ) Y# v* I4 z5 k' K7 ?8 T
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");
9 Z0 M5 f5 ]+ Q7 N. h }
* Y5 ^7 x) p2 ?$ K& X2 I Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");
, f ^9 K, s: x$ _ exp[0]->SetRightHandSide("400");# N5 `0 C6 c- H( l Q9 @$ ^
theSession->UpdateManager()->DoUpdate(undomark);
1 @( j0 N/ N# z ] theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");
6 Q$ A' b6 G1 f7 U }
' _- c# Q! v5 C( ^9 y }
3 Q4 P# N! G P) G9 o1 ~. p- Y+ l/ N5 C
: K2 l, c- M, }: p7 v |
|