|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
9 r4 c2 G, r) ? [- j" |5 L5 c3 R) T* c& @. u$ p/ K
" Z5 Z* u6 i6 d/ f创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!
1 ~/ y/ m5 H; ?1 P8 n- z, [/ z. a8 i
Session *theSession = Session::GetSession();$ Y9 |. j. K7 Q7 n
UI *theUI = UI ::GetUI();
( ]8 ]1 H% B" V& c: d Part *workPart (theSession->Parts()->Work());
" {: H0 w& g2 ~% e, Q7 j/ Y3 k" d5 L
// initialize the select 7 d9 L( h# @* F# y; h7 _
std::vector <Selection::MaskTriple> masks(1);/ x7 v c# k7 D) E, a1 [
Selection::MaskTriple mask;% v6 }! _: I" n Q
mask.Type=UF_feature_type;+ C. @' s4 z: e
mask.Subtype =0;4 X* t9 |" [+ O: x& [& S4 Z. K
mask.SolidBodySubtype=0;
4 F% d' N8 d4 u2 o$ R( I masks.push_back(mask);0 z W# E7 _4 W0 J" \& |; C
//masks[0] = {{UF_feature_type,0,0}};
2 T6 G" X7 m% d2 p C TaggedObject *object;
4 h; E2 M' C& X7 H9 R6 } std::stringstream ss;
8 s: X6 c- r' Z+ U0 k9 Y Point3d cursor;
# ~ P5 r2 R0 ? B& ~ Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;* `; M0 r* N' G8 t3 X+ F
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;/ B% A6 F* ^' M) {) o+ s; J/ {
Selection::Response res;! E+ K6 O: t2 z5 h
Features::Feature * getFeature = NULL;
; e# e ^6 L% b9 E res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);, `/ M: d7 h: P. w' m) j
if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)
- `% N7 r& T, B+ y0 B' A& \* B. Y {
0 T7 N+ t8 O9 n& {6 g% {. e2 x! o // get the information' C" I4 Y8 o% V8 y" u6 |
getFeature = dynamic_cast<Features::Feature *>(object);
8 t3 ^/ C+ v. X ^6 d' }4 b
! K9 a* d( G4 A. U# J+ Q& ] theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");
5 {8 @! F! q% w9 b9 V* Y
f; V% ~: W. O9 j if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))* ^5 L* ~' K) u
{
2 R- T6 g; {2 q+ b Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);
L4 B& A, f! l }5 A4 U2 Z1 _ std::vector<Expression *> exp = getSphere->GetExpressions();
% L2 I1 J! s, q7 |/ Y1 Y+ q ss << exp.size() <<endl;
6 G( V1 e; J- \. d6 Y% r( { theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );
1 X; f- L) o$ _3 B3 c: }' O0 d: H for(unsigned int i =0 ; i< exp.size();i++)
3 D- ~5 [( ^* R0 \7 s. E. [ { " w: v/ `& x% n/ Q
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");
$ D4 a$ O* C0 G `" ^! m& ^3 X }
' ]# \/ S' Q" I) G0 ?8 Y Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");
; j2 L$ F: z8 R5 w exp[0]->SetRightHandSide("400");
9 p2 Z0 @6 V% U$ H2 b theSession->UpdateManager()->DoUpdate(undomark);
7 |! Q* p* g$ P2 ?/ Z theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");
' I( a t% ]4 V }
; G, B$ x( \+ G/ I8 B }
7 O/ C# K. h5 z
" M& {) j$ n* ^7 Z" u/ M/ Z4 D" k* i# ` q! a& A. m( G. C+ x+ u2 j
|
|