|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
/ \1 z2 y: D. H! w, m
* ?$ V! W! y: |, B$ l
! \: x5 {0 v+ |# Q4 y创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!7 e# B2 _5 l8 n0 }
1 \# K, J0 K4 J1 N6 OSession *theSession = Session::GetSession();
+ B7 e+ |( K6 h C q- s UI *theUI = UI ::GetUI();
& Q7 c% v- v; Q0 h Part *workPart (theSession->Parts()->Work());2 Q& f% L; q) n) x: Y& C7 T
3 |. c% N: ^2 m; T* z& I1 ^ // initialize the select 4 T6 z4 x- l, r/ j
std::vector <Selection::MaskTriple> masks(1);5 k) l/ F- n2 \4 ]! Z( u: [1 d
Selection::MaskTriple mask;, P: \. X- H7 B; I: x
mask.Type=UF_feature_type;( i- ]- {: m2 T& a
mask.Subtype =0;4 ^' h7 X/ Q8 X
mask.SolidBodySubtype=0;
8 w2 p2 r+ y' z5 l; c1 z4 f, y% D; R masks.push_back(mask);8 t7 K1 {' V, N) i2 U- j, k
//masks[0] = {{UF_feature_type,0,0}};& l+ E4 @5 O4 ]) L* z" ]) D
TaggedObject *object;0 B, w* U7 G4 U9 n& j0 g+ m
std::stringstream ss;" }* \9 q4 E% [
Point3d cursor;% G5 s8 z$ N/ G' e" {
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
, l. g x: U( x$ [: y8 T Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;* O7 J# d: f2 Q: x5 G3 {
Selection::Response res;$ i& M. |0 E& Z2 x2 L( ~5 V3 P; V4 q
Features::Feature * getFeature = NULL;" V8 Y& E5 y% @' L, Y& O2 W; Y
res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);
' x, x4 _/ F+ G7 _! R4 E, c if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)
" v8 w/ P7 d5 ` {
; C- I7 l' z/ Y0 {1 q" u7 `7 C! b3 T // get the information
. }( x6 ^& B; s: z6 K- ` u | getFeature = dynamic_cast<Features::Feature *>(object);' L+ e$ D% f; w
- y! I" O. H! l0 ^6 ]1 t8 X0 `
theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");( b, H$ b/ X) r" h6 {0 J
0 K3 |! m( t: w) I9 ]! { if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE")), f+ P7 w6 V8 w' }
{
# `: j' A! G) u$ y" G. } Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);
2 _4 u/ ?- }1 V std::vector<Expression *> exp = getSphere->GetExpressions();
$ F4 d" j% T! ^" R" k% |$ \( w ss << exp.size() <<endl;
- C' z8 p) v8 s- i. ~, x' l$ M theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );1 z$ C I0 |) q3 ] `9 w/ u
for(unsigned int i =0 ; i< exp.size();i++)$ \- N+ c% }5 D* s$ V
{ : o9 g9 @. d m. X
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");8 I c7 n" U8 s
}
0 E7 d2 T1 W% {4 W3 z0 i1 W2 \ Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");
4 Q! U: ], d0 _+ e( e$ N exp[0]->SetRightHandSide("400");
) ?' F6 n* r; A" k" z3 S* O4 Y theSession->UpdateManager()->DoUpdate(undomark);2 b) g7 o& L; N6 Q$ _6 g
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");4 {! V/ S3 u8 z' [ n/ W+ \+ I
}( Y( D/ P( i/ o/ [ V) p
}
3 a ~* b B( I" t) h
4 [% N* e6 M* B3 n/ `& _; { r" L9 T* Z* ^. j. }
|
|