|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
b, n% o! H* E7 `" A' o# r3 q' z
# M9 e/ n6 h! ~1 A
创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!8 U! F0 \$ Z& g' {
; t/ B- k: v3 `# \8 \. d" E3 K* Z
Session *theSession = Session::GetSession();
5 K. f2 v4 _1 d" ~* W UI *theUI = UI ::GetUI();
/ R' s1 }5 p/ j, s5 f `. v0 i Part *workPart (theSession->Parts()->Work());
1 k8 t/ j& V4 m+ f$ D9 o% o# v: M; B. ?
// initialize the select ! o5 _ Q) s% \2 i* f" i# M
std::vector <Selection::MaskTriple> masks(1);
2 _2 z3 S* j9 |- F0 S. h Selection::MaskTriple mask;9 N4 Y$ i, S/ V# r8 J
mask.Type=UF_feature_type;
! m3 G# X7 [8 J$ O4 |& f* ]3 g mask.Subtype =0;8 }. @% k5 m( h/ ]
mask.SolidBodySubtype=0;
/ J- J; Y |% g) j masks.push_back(mask);9 V. |! q; D3 p$ c/ Z$ }
//masks[0] = {{UF_feature_type,0,0}};+ i+ S+ m2 x. i, ?6 h$ @+ R& a
TaggedObject *object;( c" e+ \4 C$ w/ y# o
std::stringstream ss;
2 P# k2 Q( Y8 F/ @) W Point3d cursor;5 B$ r3 `4 N( N* w8 ]
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;9 N6 f8 h4 @1 n0 V% Z+ _
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;5 e# Q! m z9 {
Selection::Response res;- Q p- s+ [7 J& g; }( a$ e
Features::Feature * getFeature = NULL;* r" p0 P6 }( [; H
res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);- `" M, p" }- c8 |# H% _5 s* k9 d
if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)
& a ]6 _) M7 Y2 S0 Y# ?$ | {$ d3 Q$ g2 E) j, Q! k( n
// get the information% l, l+ g2 ^2 |% z1 }# p, Z
getFeature = dynamic_cast<Features::Feature *>(object);
$ {8 w; P3 {3 z- e4 x9 z1 m( E
8 H! y& F2 z3 U' K theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");3 K4 v2 {" ?2 a0 ?+ F
7 l/ t6 q+ V! [ I& s if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))
! @0 Z) u3 z7 `/ u; }9 J {
! X' ]* s+ |/ E# u) S Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);
- H* K- f, F: f# D8 i std::vector<Expression *> exp = getSphere->GetExpressions();; {. I& o0 e1 C) B) a
ss << exp.size() <<endl;- n- ~) s, g' v# i0 L
theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );0 b$ L+ @6 Y ~# o2 B$ Z2 F
for(unsigned int i =0 ; i< exp.size();i++)
: w/ f; q5 b, }0 A, Y6 G5 c- r {
, a5 D* x* O) {; e2 f8 H- Z8 h, q theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");
& m5 b6 R9 U# P! |& e }) ], o V9 \7 u z0 U0 Z k |" b
Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");" U. t1 i1 J" _9 `- {
exp[0]->SetRightHandSide("400");
7 r; a$ x) Y3 q2 O4 T( Y- b2 } theSession->UpdateManager()->DoUpdate(undomark);0 \0 N. e3 Y+ i8 f9 _2 j1 @( _
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");+ c" Y2 l4 b; R, Q& C+ b6 A; i1 k
}9 q2 h L9 U- ?8 ~& e2 t
}
/ ^, M( R9 t9 L+ a) g! c$ V, u. N5 }; k2 Z# Z2 A) M1 V7 l/ C
9 `* e) |/ G8 J+ l7 ^; u |
|