|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
( U+ c4 _( i% h4 Y2 f+ d0 N% H0 f+ v. Y4 r4 t- m
+ e+ o3 k3 ~" d. ?* ^ u" W创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!
. ~% z& @% t* ^) R+ C/ W' Q6 y8 Z
4 g D5 B' P4 K) J wSession *theSession = Session::GetSession();! |% Y% a O7 s+ f2 ?1 U
UI *theUI = UI ::GetUI();+ N t+ n& {# X4 ]4 x
Part *workPart (theSession->Parts()->Work());3 n L6 w4 J+ v7 s) V
+ o$ U. t% p; y
// initialize the select
; i( P8 S7 c8 {* t, @7 ^ std::vector <Selection::MaskTriple> masks(1);! I J5 ~9 v# y; \( E0 D5 S# a
Selection::MaskTriple mask;! \* ^. m) D u8 R% p1 T
mask.Type=UF_feature_type;. V+ A# f" h& v2 K s+ m
mask.Subtype =0;
- h: b$ u2 O z0 `% @! h. g( ^/ {; j mask.SolidBodySubtype=0;
' F3 y: K! o, @2 I masks.push_back(mask);
5 e3 D: T8 u. E& t0 E //masks[0] = {{UF_feature_type,0,0}};
6 M; X( U D& v* m TaggedObject *object;
) K7 Z, O$ L6 G+ [+ f2 ~+ q# P! y std::stringstream ss;
0 k: y- h) ?0 w4 q+ e; u Point3d cursor;6 A, h2 o% q* ~0 h( O0 {; Y0 }
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;- E+ ]9 d$ t( N5 |0 P/ @/ w3 @ ^
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
) G9 @4 X: h; z! x8 w Selection::Response res; H$ E( k5 n6 R; O7 k( |
Features::Feature * getFeature = NULL;, X# k8 W. \% X2 r1 L4 b, x
res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);
2 P) R( U+ v3 L5 ?: L if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName) [- \* b& G! x
{/ e& b9 [& r, a& |: r' c6 r3 b, [) ^
// get the information
) {) X" D- p P& g getFeature = dynamic_cast<Features::Feature *>(object);
6 R: n, z' L. F, b3 x
: x0 z6 \7 I* O7 X theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");0 }9 h, q. _# g7 N
& \, |# k3 E8 i# F- r
if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))
, L$ }2 c# |" L {
- y2 i! v+ y+ c& E- I$ E4 c$ B0 U0 h Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);
2 v& v( F j& W% M/ x, \ std::vector<Expression *> exp = getSphere->GetExpressions();
: e, _! p" t$ T8 Q8 A4 |1 g2 ~. u ss << exp.size() <<endl;, ~& Y' f" c( s; q d3 q
theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );
3 b9 `* Y9 ?$ |1 c8 R for(unsigned int i =0 ; i< exp.size();i++)9 z+ ~' D6 w- }- z; I9 |8 ~- j
{
. n3 S" F2 M& T: C- { theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");
( B( T7 x( v$ M, X } _8 E0 [ O% C' k
Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");' [4 V: L7 c7 [! }
exp[0]->SetRightHandSide("400");
- ~1 x" D) l% Z3 X. f theSession->UpdateManager()->DoUpdate(undomark);
4 D7 j2 R$ m5 y# ]+ o theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");
! n1 B6 }9 N/ o9 P: q }
3 o& h+ q* J3 h! g, A$ @* h }
' ^ l+ ~$ U0 M1 |3 `# F
% u5 ^) e4 T+ X4 B1 \- @* h1 U
|
|