|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
% ^' C$ P7 O+ [" U! u6 b$ J
% ^$ Q6 x# ~7 I2 T- [3 s* v7 T8 Y
创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!, j" R4 i( `' U- @
& }6 g) e% F9 ASession *theSession = Session::GetSession(); y- ?- X9 k j$ E2 S
UI *theUI = UI ::GetUI();; m9 V9 q! V( |: w o) B/ d
Part *workPart (theSession->Parts()->Work());
( N/ R+ x8 A3 q/ n( D' n( r8 t; }0 A+ v: j/ z
// initialize the select
m* c! y) ^" ?$ z, y std::vector <Selection::MaskTriple> masks(1);
( G3 a4 a3 m0 ^' }% C Selection::MaskTriple mask;7 p! Z, ~9 K# I, s8 t/ W1 Y
mask.Type=UF_feature_type;
! R, F4 G, {5 K& c mask.Subtype =0;
8 }# P& N1 I2 E" e6 L8 x, b8 w- y mask.SolidBodySubtype=0;
# G) k; I8 f% s8 W masks.push_back(mask);# R5 k( \* f7 C6 k4 y
//masks[0] = {{UF_feature_type,0,0}};0 W/ j) x- l3 C8 }. e
TaggedObject *object;& B* r/ o5 W4 {- T% N0 k M" P
std::stringstream ss;
0 v' f# N, z# ^1 q5 ] Point3d cursor;3 Z, C, [8 d+ e3 R" ?# i( f7 |
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;; T6 @' s( } L/ l- J( I+ V/ k4 F8 P |2 V
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
6 C) ?5 X- l6 v Selection::Response res;
: C, b& l6 q2 f; V2 d3 W+ e Features::Feature * getFeature = NULL;
9 @# |2 v4 b. o( f$ b7 R res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);
( l, ]9 C& @) [ if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)
! S% U0 n8 \. b1 @1 D# q# r {4 _4 X' A7 _! E- d) S
// get the information) k: n# b a! U9 V
getFeature = dynamic_cast<Features::Feature *>(object);
3 }0 I9 `9 I. h7 v" e G- k5 s. w
theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");
0 f" V4 L+ a) y$ g2 _ q$ `0 Q; M# ]( k6 {' _ X* Y" S$ `0 ]
if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE")); C/ o) _2 ^7 w5 p! {8 _3 O5 t9 P
{, a0 v" D1 O/ E2 c
Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);8 s- w8 h& y, M3 A
std::vector<Expression *> exp = getSphere->GetExpressions();* U0 }! |. T2 E2 t( R* a1 q# S
ss << exp.size() <<endl;: v0 ]6 Y$ \% G; p6 _
theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );
7 O Z9 T* R' { U for(unsigned int i =0 ; i< exp.size();i++)) v9 Q6 g, d& F. u
{
+ ]; h, @& d' Q theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");2 k1 E6 \1 Z+ }0 v7 ^4 r# ]
}# @! @1 \& Y" j# q- o
Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");
- y' i% X8 @+ G1 ] exp[0]->SetRightHandSide("400");6 [" n7 M0 s6 m: B7 F
theSession->UpdateManager()->DoUpdate(undomark);
% _5 E2 W/ v, u( O: z theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");
1 B( U! X( W: J7 d- @# z }
! T7 b" @6 i9 @ F3 x }
) T% W' H( N0 T! z3 @1 ?' ]! d8 {! U! E Z; h
4 k+ k4 Q! H( o2 f" }# Y. ~% G8 ^ |
|