|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
! ]8 ~$ Q L; ~; b, l% `& D- |: a+ t3 c3 u" l- O
3 w* V9 J: H# f3 O" I8 v+ L
创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!9 U9 h- P s& u
+ D4 }6 y0 ]. _, M) ?' |Session *theSession = Session::GetSession();
. R; N7 }5 C/ e- d UI *theUI = UI ::GetUI();
' N9 Y! j" M# j: U3 D, w" ]. Z Part *workPart (theSession->Parts()->Work());( C; e: N* I: l {5 X5 B% U2 C
. I/ U/ c# V# x: P% ^ // initialize the select
( }" Q: }7 I+ L& K std::vector <Selection::MaskTriple> masks(1);
% K8 v1 ^1 s" `/ u! ^8 `$ ` Selection::MaskTriple mask;
, u }5 D0 x' M+ t4 x mask.Type=UF_feature_type;* L r* T; E G2 ^ q! f! h9 f
mask.Subtype =0;) J) |. X3 S X5 q2 }1 A$ k
mask.SolidBodySubtype=0;
& q' K8 x. K3 @" C$ x. ^8 j masks.push_back(mask);
0 _, Y; ^7 V1 | //masks[0] = {{UF_feature_type,0,0}};
% s |; d6 Q4 @( {$ l TaggedObject *object;
) Q" x! E- h2 S std::stringstream ss;
0 R9 X3 u% v, w' x Point3d cursor;
6 B- ^4 E5 }' g' P+ K Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
" z4 k# `3 e0 ?) O0 a9 i9 q8 T q7 S Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
; V- b: n4 J* G: I Selection::Response res;
~& r; |- u6 }9 l0 ` Features::Feature * getFeature = NULL;
9 e) T% G: R* m& r res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);8 h. C5 U* n! |) _: v- T- Z1 d
if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName); F7 ^, D8 [% I D
{
9 W, {) q2 {" W+ i5 l+ A Q // get the information' p* z9 A8 W' ]* m; R" h
getFeature = dynamic_cast<Features::Feature *>(object);
G1 b" }2 M9 t2 b7 S- c0 ^
6 n7 c1 }3 _% l7 Z. g theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");
5 R9 p& r) k! i# H* @) V9 f/ W: N1 p e; _% o* [6 C
if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))5 u8 w' C4 K. m2 M9 W/ L
{2 I- Q' t8 n0 [1 `$ J, d3 @
Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);
% Y8 `* ?+ C G" H7 f+ ^ std::vector<Expression *> exp = getSphere->GetExpressions();5 W2 P$ C: I% P: c2 t8 u' A* N
ss << exp.size() <<endl;
# t a/ k, p, E8 d! J9 ? theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );9 U: l7 q0 X! Y: f) z" J
for(unsigned int i =0 ; i< exp.size();i++)
6 Z( x" B! W' a: |. { { ! \; x6 L$ u3 Z3 }) ~9 M! B
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");
, B- [5 e4 }( b, b* `2 D }
" L5 a9 z( t- W2 }( z/ q( C Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");6 y" N$ r8 N: d* W8 }# o
exp[0]->SetRightHandSide("400");
* ?) q$ G+ ^; L& J' j7 N theSession->UpdateManager()->DoUpdate(undomark);& T( E+ L, g5 {( i1 ]
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");
$ d% A$ I" P4 S( t2 S2 I' } } @% o8 h3 ^- e4 \8 X2 S
}
5 a& h4 y5 g* h# B9 @
5 a) a! @. v) ~; P8 }8 S0 ` q+ l# C" B! i7 y1 m8 N
|
|