|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
. U: e0 A% o1 \. s8 I
) c+ J9 b; i& }) {7 r9 w( ~- G
2 i4 ^( J% H6 A& d创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!
5 i) ~6 ^8 |: W z* u$ f5 ^% i1 G/ d/ q6 @8 o4 Q9 ?
Session *theSession = Session::GetSession();
5 l- }5 t1 p, r& Q! W Q UI *theUI = UI ::GetUI();0 b3 I8 y& w% e
Part *workPart (theSession->Parts()->Work());
# n+ X! a) K& C! \6 c3 u) a$ B' P- n8 ], n! k# e1 u
// initialize the select
0 ^# x5 y+ E! Y/ i0 M% { std::vector <Selection::MaskTriple> masks(1);
( t S1 Z: p8 z1 O. N8 M Selection::MaskTriple mask;
- V# O+ E2 V* S2 T* r; ? mask.Type=UF_feature_type;
) |- k, Q5 h8 j1 u! {: @* w, H0 g% k mask.Subtype =0;
5 S$ R1 Q4 y, `+ ? mask.SolidBodySubtype=0;
% ~4 U( B/ F9 ~% U- r masks.push_back(mask);/ a0 f- F6 Z- W k
//masks[0] = {{UF_feature_type,0,0}};
@* S; c# @8 d TaggedObject *object;) @6 q$ P& ]) _& H( X: v
std::stringstream ss;' ]. v0 J& W- g
Point3d cursor;
! \: Q3 a- p/ F Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
3 y& w# } n( u9 X Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;2 H3 a3 J7 ~, G7 q5 G8 O+ l
Selection::Response res;
6 X+ {( |( [- O5 S Features::Feature * getFeature = NULL;5 T* @7 n- B# T, J
res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);+ o+ M7 d/ g- _" v- A
if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)
+ J( L6 x3 S# } {
7 h6 ]3 y* I- G A1 D. ^; |2 t5 [ // get the information
! d8 o" {" _1 k6 P6 P getFeature = dynamic_cast<Features::Feature *>(object);' a5 y8 _! X* P( z5 J
* x5 ^( q. c- T+ z+ i: H theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");
6 f1 C$ d' d Z7 V. ~& K2 L, ^' w }$ t% e5 @) g* i
if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))9 g2 {5 H8 S3 r; t# R( u7 M
{
* r1 }0 w- R6 q9 A) h. g Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);
0 G5 i( l/ m. e" ] std::vector<Expression *> exp = getSphere->GetExpressions();
J% t6 ]) q/ p* q% V1 I ss << exp.size() <<endl;! ]! D/ v" @% h- Y7 O: d" ~
theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );& K( w0 m/ e; A0 F5 `; B* c
for(unsigned int i =0 ; i< exp.size();i++)
# I4 Z! {( b1 r% F6 _0 G( ^ {
- X9 Y3 t f4 |+ w5 N" W) J* f theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");+ Q" P j U7 a4 F: Q& y1 G& F% X
}
* Q, N, q/ q7 p3 @$ f% f% V' A# S" C& t- [ Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");
5 U$ M8 o- r; _0 f3 D! B exp[0]->SetRightHandSide("400");+ a5 Z0 \" l/ o* m( U9 [
theSession->UpdateManager()->DoUpdate(undomark);$ K: ]2 @5 M8 \0 k2 Q
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");
, A8 X6 d, f; q+ p8 Q* ~9 b" s: g }
& ?& J& t/ n3 K0 |& i3 b2 p2 x) E }# Q5 |# X2 \2 X- T3 T. [
$ X# M+ k4 S$ V% q0 ?0 x
0 e3 x$ {+ ]( Z2 ^ |
|