|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
8 ]: E6 f. u! E2 _# [/ g, J- B9 K; ^; v0 h Z
! M z- C# X$ d; t% [( B+ [6 L! a创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!
3 K) y& @' O1 I" D
, c- {' z% B2 B6 e9 \! Z1 m( PSession *theSession = Session::GetSession();
$ h. O+ i" @ M z% I q: v UI *theUI = UI ::GetUI();3 X) J2 J" x& n M& N
Part *workPart (theSession->Parts()->Work());! Y& N) I6 @6 s3 i% o; W
( h0 S; B7 @. G: F
// initialize the select ! H J6 ]/ P) q1 U* c3 i
std::vector <Selection::MaskTriple> masks(1);
6 y/ v6 L4 G7 |- T& g) l, \ Selection::MaskTriple mask;
/ Q1 R7 k& G1 {# A mask.Type=UF_feature_type;
+ S" z; n3 w* N mask.Subtype =0;% f( J* Q! _. o* `, _3 N# n; r" v
mask.SolidBodySubtype=0;
0 c. K2 q1 J4 j" c9 H masks.push_back(mask);, o- h$ R: u1 ~. N2 f
//masks[0] = {{UF_feature_type,0,0}};
6 C) O$ f4 G" o( Q- S7 G, {9 {9 J TaggedObject *object;4 f$ g# }; N W2 E s4 F2 u; T
std::stringstream ss;
6 \. `) F! ?" I3 W Point3d cursor;
& s9 a9 y3 T* y: i8 y3 y$ | Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;! U8 C% c7 d' _8 f P( l
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;5 @" M+ B, K2 u
Selection::Response res;
% J9 J! a! A/ a5 Q Features::Feature * getFeature = NULL;
' c( `3 D5 l; Q4 b# s `3 W! t h) X res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor); I! {9 g) \9 w, ~" E) y
if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)9 C" C$ d# v' P6 o1 p& S# F; {
{# D' a- e2 I7 K$ X, C( L
// get the information
7 I4 x0 B8 I+ m' O; K& M getFeature = dynamic_cast<Features::Feature *>(object);2 R9 d$ J: F, X% I9 l
( K- f# O8 [" }3 V% J& D, S$ r theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");# D! `. S( W/ f4 ]9 x, r& i
! Z3 I1 U0 T d0 b7 L9 c if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))
; W, Q- {2 ]; f0 t {
0 |% m8 g* u9 o$ V0 Z: P. I Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);5 Y7 n+ P1 _# k% {6 D: o: f
std::vector<Expression *> exp = getSphere->GetExpressions();
" ]7 a9 z1 a8 C, i( t$ S1 U( V ss << exp.size() <<endl;
8 {, J% y3 |- r2 ?3 {$ j theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );
- t0 }1 {( b9 P( P. O for(unsigned int i =0 ; i< exp.size();i++)0 p3 T) G! L) `
{ 8 } b/ v0 x* t' M
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");( ~- n) y2 b: B$ q' R. A5 l8 ]+ y
}
; j+ W/ ]" f0 q Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");5 n9 V8 ~' @& h7 I1 D: ^
exp[0]->SetRightHandSide("400");) O+ \" g0 b4 ~# ?+ B& [* }/ o
theSession->UpdateManager()->DoUpdate(undomark);
: `8 b4 w. X3 t/ i% u- v- G theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");
. Q+ A6 H# X- }) Z ~* [ }2 p' D8 G* ~, B( r$ e3 m) y6 }! }
}
( u; M d- W; Z9 P4 t9 P
4 @/ O; @3 a2 R. X; X3 \6 _6 l1 y
|
|