|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
# b2 r. |/ z3 l0 {/ J0 A4 Z7 L- T/ [- @
# c m! F {6 K+ \3 @- I; y2 M4 T创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!/ R- N3 x1 ~+ V0 a7 W% t2 d6 x3 ]5 T
+ J2 |9 K; D, D( r9 K3 w, y
Session *theSession = Session::GetSession();: G- f% a& {3 C8 m+ H0 b: Y
UI *theUI = UI ::GetUI();* j7 z+ u2 {& N9 d1 ^& {
Part *workPart (theSession->Parts()->Work());. }3 \6 y4 T( e. d* J! F+ Y. k1 x
* I5 s1 z5 h' Q9 a1 s$ D8 u) I
// initialize the select
& w7 O2 Y n/ [0 ]; A3 U std::vector <Selection::MaskTriple> masks(1);
$ L4 G% R) C" F Selection::MaskTriple mask;
C2 }5 f" N3 q; A8 d mask.Type=UF_feature_type;
3 F: D' r; j9 [% [9 W5 i mask.Subtype =0;
. V$ C: W; d& I. A mask.SolidBodySubtype=0;
% ^" R# w6 v$ ^" @ masks.push_back(mask);, @6 ]# M9 Z9 V' [. z
//masks[0] = {{UF_feature_type,0,0}};1 Z5 N% x9 s* p% \2 z7 S6 c; L
TaggedObject *object;' ?: T. Q! _# ^* D% E
std::stringstream ss;$ F0 I& R R0 ~% g p% c& j
Point3d cursor;
; { p7 T3 | c2 O3 F2 h9 {+ [ Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
. @9 y) f9 G4 d j! g Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
/ s3 \' `& m/ W' u Z7 |9 n Selection::Response res;4 {/ @4 r# V6 c/ U4 V
Features::Feature * getFeature = NULL;
: G# d4 ?' W" O( I/ s/ R A res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);
- z8 h& {4 K- f0 d if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)7 Q( S6 n: B+ e8 ?8 I" Q
{
1 F( O9 S) j" H // get the information$ t7 k5 C+ B4 U& ^8 J) P
getFeature = dynamic_cast<Features::Feature *>(object);
% b i+ M! }/ P( R. k* O$ _) |' ^) x; N
theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");+ Y3 i+ {8 [; E5 L2 m
/ l( A* Z: b9 `
if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))
5 P: U9 t: n0 v6 K3 V& E6 t& W {
1 L' ]. |) P/ z! H Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);$ x) w0 d1 E1 i. y1 Y0 _
std::vector<Expression *> exp = getSphere->GetExpressions();
2 v8 K* Q& A7 F3 B% {2 b/ O9 D3 ? ss << exp.size() <<endl;" M6 f- [" V0 q+ t" R4 y8 q: C
theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );+ s1 ?) Y" a( P2 ^8 m
for(unsigned int i =0 ; i< exp.size();i++)
& u+ @7 V1 f6 H, [& v/ ] {
" M* Z+ b" F/ z# w; J theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");4 v5 G1 K) G9 Y7 ], e
}) y' X ~9 k8 `: N
Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");8 X; d/ X4 w: p) `
exp[0]->SetRightHandSide("400");
2 T, m* K( z! m3 i theSession->UpdateManager()->DoUpdate(undomark);
5 G0 K( e& E. b2 Y; _1 x: N5 f4 X theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");
/ K# }* h. r; @2 A5 l1 z" p }: N/ j; A! {3 }2 B' {. w
}
: {9 {, S# L8 G- j+ B
( U% N4 N, M- M k% z7 l1 ^5 C# j% i" X: _$ t
|
|