|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
2 @# i3 ~3 T$ s% U5 H, w( P0 R- p
; D( a/ @+ Y% r' h8 X" G
q! q* _* y. p9 C/ z( c创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!% x. T8 x; p- |7 \6 S$ G, h
4 n* O* {/ L! U- M
Session *theSession = Session::GetSession();4 S, X4 {9 {" U3 x- ? J
UI *theUI = UI ::GetUI();
0 |: F7 F. Y1 }. p Part *workPart (theSession->Parts()->Work());
# V/ H: v) p) n R3 S9 i
$ G6 M; Y: @. E* h) v // initialize the select 4 k3 {* o7 i& Z, L- @, M4 s: ?
std::vector <Selection::MaskTriple> masks(1);
+ R6 Z: y f: @( j Selection::MaskTriple mask;! Y6 B: z% r- X( o
mask.Type=UF_feature_type;
% P2 [0 V/ N3 Z( W6 P* A mask.Subtype =0;& t) d( `3 [ D6 E) y" {3 H0 y
mask.SolidBodySubtype=0;: \) t6 w/ A3 F
masks.push_back(mask);
2 G* k% x* f R8 W! c( ]6 o //masks[0] = {{UF_feature_type,0,0}};
% x8 {9 G2 N3 W# \4 q: { TaggedObject *object;7 r1 `3 V% t: ]7 Q
std::stringstream ss;. t0 ~6 P6 C2 `- c, M# M d
Point3d cursor;; n" Y/ T5 c9 U: N5 A
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;' L3 w8 U& E# y# z0 ^/ W
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
% L! T' N) u M( j n1 B$ \ Selection::Response res;
1 ?, S" x% I/ R) r9 n5 F5 T$ z Features::Feature * getFeature = NULL;
k$ o' G T+ U0 C% {* k res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);
; F1 o1 _* I$ i6 J. c9 }4 g# | if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName); Z7 s2 T& q7 {: I6 ?- `; d
{
7 ]9 O4 w( v3 R! c. K, B& \ // get the information
+ V# }# M' w! b" n& S$ q+ P getFeature = dynamic_cast<Features::Feature *>(object);
2 d0 l) F b1 r% i Y
: z5 v; y4 Q6 x) u6 T theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");5 s' A* d, s# f( Z
9 } I$ b7 \# @4 h( `" p& w, `4 Y
if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))
. f! {2 G4 S, W7 ] {' V' i- M0 J) L. X
Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);: P4 P& K. J9 {: @. D; q# E+ V( b
std::vector<Expression *> exp = getSphere->GetExpressions();
5 e! F2 d3 k4 b- M7 v9 c/ [ ss << exp.size() <<endl;" c5 W3 O; [3 A1 U+ o! X
theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );% z+ B3 k2 i! p0 e$ I6 l6 ?
for(unsigned int i =0 ; i< exp.size();i++)
3 W+ ]- h- ]/ q3 c { + Y+ Q( M2 S$ d4 p# q
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");- ]" G- {' W2 w/ \) N8 X
}, `! E# N# F2 M% Y5 b) V( t
Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");" x) U0 K+ X. ?
exp[0]->SetRightHandSide("400");
# s- u0 l( L/ D4 Z theSession->UpdateManager()->DoUpdate(undomark);
; U% l1 w+ T% g2 J7 N& `% { theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");6 T. n9 t( Q! ~9 P" c$ Z
}
6 h5 V1 Q6 m, L7 x8 z% ?. d D }
) n9 N2 ~, [3 `/ z7 j" ?6 m: b* y& z' l. O' N1 V
; E' D, w" r/ j$ d: k0 E
|
|