|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
% s# x- ]5 j! i
# B4 \$ A( [, O M% a; _1 e+ M
. Y/ c; E) ]! {- q' E创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!
7 @% X) b3 B1 {. Q# i- D) U
& J4 _% b" G4 E/ J! ]" m8 FSession *theSession = Session::GetSession();
& a) C: R- A( G0 c) R" O UI *theUI = UI ::GetUI();1 ? _6 u9 O J6 Q8 ^$ x5 ~
Part *workPart (theSession->Parts()->Work());
* L# ^. S) e0 a8 _) j" o6 m
8 ~7 B3 q% l1 s1 n- P2 u. F // initialize the select 5 ?: J" K( s& J# F) w
std::vector <Selection::MaskTriple> masks(1);0 \/ V# _- l9 M+ [( ?: j
Selection::MaskTriple mask;# k' U& o! v1 U6 J
mask.Type=UF_feature_type;- T" Y3 l2 x4 p2 x& \' w
mask.Subtype =0;7 B; U8 z5 I3 ~0 S8 Y$ @, ] B
mask.SolidBodySubtype=0;
, k; B) H# v" c1 b. g* I8 d7 i masks.push_back(mask);$ a* ? \% p7 t8 h1 `9 Q
//masks[0] = {{UF_feature_type,0,0}};! I0 |) e, N& t1 w+ \ i# P
TaggedObject *object;
* z, E4 f9 w; w1 N4 O- g9 i std::stringstream ss;
2 g! \: i8 ~ o2 _" J* [ Point3d cursor;
3 {4 v: g [. ^7 f6 _ Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
& C2 X: J7 Z# ?" [9 i# p# [" e Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;7 K" |! i' g* s* Z6 w2 l, ?5 ^
Selection::Response res;
) w+ k1 l$ T, s2 Q# k. q. a- b" o$ u- ` Features::Feature * getFeature = NULL;
1 L. B: r4 V/ u res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);
/ p5 C3 N, \7 D2 }5 i3 P6 @ if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)
* f; D, k( f- T6 ]' M {
# S8 O' E1 Z. U9 V$ ?/ P // get the information: I% Z/ Z1 X* }0 z
getFeature = dynamic_cast<Features::Feature *>(object);
" r7 M# c' \# V# G9 h& P( B: m3 H2 M Y$ y+ B3 W2 a
theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");* S9 N' g$ _: @& z5 A8 W4 Y
r7 [) ~! `7 l2 c5 c
if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))- y- `- ^ y& v( ]0 ~1 [
{% Y. i: q5 H' ]. F$ ~( z+ d+ E
Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);
, ^- l7 }, A$ K5 R std::vector<Expression *> exp = getSphere->GetExpressions();
' O- E" A. ^& o- o* Q ss << exp.size() <<endl;
6 T' ~1 p) E! G; Q: l" g- ] theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );2 J( s: D) e; F% l8 T
for(unsigned int i =0 ; i< exp.size();i++)+ _9 R( \6 X3 x
{
/ v& z* B1 P- k |4 S/ U3 m theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");) u( K8 |0 F+ g% r. d) z
}
- X o! K$ M/ W+ c Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");
. f7 W: M4 Y9 G" n& K exp[0]->SetRightHandSide("400");
9 h1 g/ j( m' l, b theSession->UpdateManager()->DoUpdate(undomark);
6 l" ?/ ?/ _& z; [ } theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");
' ~7 G% u1 L* `; S } H4 ?! N, q8 N6 f$ c
}
8 S2 n. }) Q5 A& P9 a7 f* \! I. O* Y1 E
: K+ s1 Y# u+ ]6 y0 g% d V: ?
|
|