|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
J0 h: q* l; @ y
5 o* b7 i+ `: W+ m% ?3 U
3 E% k$ r9 Z z创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!" O% d- y O- V# }* c c
; R2 R3 A% d3 _% _% K+ S e' cSession *theSession = Session::GetSession();7 C' `% F+ x6 q* `5 k
UI *theUI = UI ::GetUI();& f; m9 W8 b f" ^0 z$ Y' `
Part *workPart (theSession->Parts()->Work());$ g: U: N2 s; j( ?9 I
9 a, z! U/ W8 r/ f x // initialize the select 8 a# U+ ^( ?2 k$ s
std::vector <Selection::MaskTriple> masks(1);) r8 k( l8 _+ M) R- P2 t
Selection::MaskTriple mask;1 _ h: ?- q9 j9 m2 q& Y; I* I
mask.Type=UF_feature_type;" A) T) V0 r- T% o5 B S- _& A
mask.Subtype =0;/ C- B* g, p7 r( f% y, H
mask.SolidBodySubtype=0;& _$ D J$ F# o5 w' x/ S9 |4 \
masks.push_back(mask);
4 U: J- z/ q7 K4 L //masks[0] = {{UF_feature_type,0,0}};
( `2 j1 y$ b8 _, B$ y0 r; b TaggedObject *object;5 @- z, |, K' N' {6 M
std::stringstream ss;, Q3 \: N! K) f, _7 J
Point3d cursor;: q$ Q$ Q; T$ I' a+ H
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;9 O! N; y& N! L9 s5 [) R, Y
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;# r: E5 }; h: ~2 V$ g
Selection::Response res;- t. S2 v/ n x5 c7 i1 q0 T3 y
Features::Feature * getFeature = NULL;( d' [9 S' Z. m
res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);
# D; [$ ]5 o9 a m/ y if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)
* T; W1 v, h3 f/ f4 z* {+ ] {
9 e+ w$ B0 j; Y, @0 Y; r( c! g // get the information9 F( i9 Y9 q5 G% \$ Q5 p- r- M
getFeature = dynamic_cast<Features::Feature *>(object);3 _8 _% K! S% j0 W
! z+ z9 E- g- O, Z theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");- o9 Q# H& [8 U" `
2 i7 j+ }0 ?% O4 ~ if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))! `6 ]5 P- t2 a+ Z' d9 K, Q: [* v
{+ L/ a* j! W* n
Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);3 t4 j9 e. e6 F' H/ g
std::vector<Expression *> exp = getSphere->GetExpressions();, l) l+ b; e7 r
ss << exp.size() <<endl;
! O7 z, Y g4 w" j$ b: K theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );- B$ G# z$ h8 k" [( [7 v
for(unsigned int i =0 ; i< exp.size();i++)
& M7 ~/ D* u& l3 Z2 w3 I# C$ z { 2 M5 z3 v1 Y) H0 K7 z- c) r+ M
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");
0 g) y; C1 ^; U" ]9 y6 g: w }
# o( I! n. G2 m* N+ ^2 W Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");, T; u4 u( e! E% v& z) m- ?
exp[0]->SetRightHandSide("400");
" R- q+ I* I& K/ ]) { @3 J theSession->UpdateManager()->DoUpdate(undomark);
' e5 G% P# ^! {" {0 l theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");
/ E) R2 f/ H# z: L }( a, L6 U; T5 |1 I+ a
}6 u/ ~( b) U ?3 h/ X
! L t( f* U! V! ?( l
" O+ N9 m& \ W) d |
|