|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
# k% I0 U, ?( i
" n3 j8 A; k: U
: l4 H7 z9 _; g创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!$ R- C v! l5 c. U" @
4 {; z% A% p) SSession *theSession = Session::GetSession();
8 l- _" G. y% ]4 O& W. |0 K UI *theUI = UI ::GetUI();, [: a2 H' }( H$ c8 D* B/ H: A8 j, u
Part *workPart (theSession->Parts()->Work());7 }% t! z- f8 C4 N- n; i( l
/ M- C9 V2 Y7 P# f! D# }+ l0 W
// initialize the select
. p2 A1 ?% M' L" U0 t std::vector <Selection::MaskTriple> masks(1);
+ L7 G& d% c) _6 o, F Selection::MaskTriple mask;
; b, x# K3 ~+ z4 H mask.Type=UF_feature_type;3 `7 b" R3 ]' |
mask.Subtype =0;, |$ r5 P8 Q8 a
mask.SolidBodySubtype=0;
7 [+ e8 Q7 h; d z masks.push_back(mask);2 ]7 D! V' U& I( Q
//masks[0] = {{UF_feature_type,0,0}};
9 J/ B N+ A! Y/ l( ^7 W4 [# R- J: V7 d TaggedObject *object;
3 h+ d5 y1 a" G! F# d std::stringstream ss;9 q0 w# d% |; w! h
Point3d cursor;
/ X; e- `- D4 a& a3 t$ ?3 s4 y w Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
! } U( Y4 Z# s6 V Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
( k/ _ E1 k2 W) \. o* @0 j/ Z Selection::Response res;3 _% j5 R* w, g/ a3 M
Features::Feature * getFeature = NULL;
1 w$ Y' a* }' B# h' T- r res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);/ a% W: \4 V5 p( ~* M
if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)/ j8 k$ a- X3 b/ s$ B- ^. b) K7 L
{
" l8 j/ k4 H2 ]5 c6 F // get the information3 K7 D( n2 t7 `
getFeature = dynamic_cast<Features::Feature *>(object);
1 n1 X( I% W# ]4 g8 B" a2 t# ^- S$ U e' U. l0 C" }7 ]
theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");
2 v# U+ T2 y2 M) k( a& K$ V
6 x1 k- T V& s! i if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))9 x5 I2 V& P6 i" f" [% I( E j, {. o
{
4 d+ I. F F7 V5 }9 d3 v% u6 P7 F Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);4 u. L' W0 q, N ]1 ?
std::vector<Expression *> exp = getSphere->GetExpressions();4 z" i6 F# s$ p4 ?
ss << exp.size() <<endl;/ w1 x1 B0 ^6 @7 n) h
theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );7 q a! {8 ]" v" z `2 @
for(unsigned int i =0 ; i< exp.size();i++)
0 {8 _9 j! r# k0 v- V { 6 x& p$ g8 L% }6 |3 z/ F( I% W
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");$ G: s4 P& J( X
}
& I! o4 o" h! l& o5 N7 W# ? Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");
7 Q* x( w( g7 e7 c0 c$ ^ exp[0]->SetRightHandSide("400");. C& ]6 N e4 {' O
theSession->UpdateManager()->DoUpdate(undomark);2 t7 w8 {' ?: [) @9 ]
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");
% I0 j; U1 \/ P: c }
7 Y1 e' b, F5 ]# I2 t# O }
* k0 w5 X8 ?6 U9 Y
5 t$ `2 e0 g" b1 R; o K* ]5 K. [% h9 T A! s
|
|