|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
9 }$ A, s# ^' |0 T6 i9 v0 d: D/ O$ J- O& n/ C1 v! f+ U
5 H# A$ P, t p1 i
创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!% h, G: W. S3 |
9 f0 ?( \9 s4 k6 ]' t' m3 K: tSession *theSession = Session::GetSession();
! @# R" D) X" g; k4 k$ t* A UI *theUI = UI ::GetUI();
- |% q1 R; f0 L: ?+ u Part *workPart (theSession->Parts()->Work());& ^! ~4 a$ @; N. V; t0 n$ m
/ g \/ j; e; A$ X
// initialize the select
3 M3 S4 P1 X! S+ [/ L% e std::vector <Selection::MaskTriple> masks(1);) e! b+ E& z7 f
Selection::MaskTriple mask;' v% o& j0 m( _
mask.Type=UF_feature_type;
j7 x+ y" I: P$ D B2 F' a mask.Subtype =0;: e+ M7 I0 w( M$ l/ a
mask.SolidBodySubtype=0;0 l% [% d: g! b" n
masks.push_back(mask);
- p2 S5 N& \5 b& Z7 m( X8 m //masks[0] = {{UF_feature_type,0,0}};( u( F; M9 o4 K3 m5 b' B
TaggedObject *object;
1 H0 r# {1 I( W& W" [( O1 D std::stringstream ss;! J2 `* f8 s1 ` k: R4 P/ W
Point3d cursor;
* g5 J+ b3 Y6 D& I4 r! |, W4 c Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
$ f6 }- y' b' [" x Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;7 D7 D# j5 m( d% g: L. y) C; {/ M
Selection::Response res;9 {* X9 U6 P: m$ L6 c5 C, v7 A
Features::Feature * getFeature = NULL;: e& y" t4 H3 B. \' D3 @
res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);: `+ K3 y* n: l3 U
if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)
% d1 T& o0 P% k( I; J! G {' p$ }1 [* t) ^. s- B$ o1 U
// get the information$ M- l; g8 S% s8 m* I6 d. p
getFeature = dynamic_cast<Features::Feature *>(object);' g* l9 {" c8 F; P: N8 Z6 ?
( F6 V, A, b$ B' _
theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");" |* C; q! [4 I9 \
7 i: [% e- E$ c/ K
if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))
+ G* v2 j4 @. N5 { {
' K" G3 i0 i" e4 E E; H: w0 M Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);1 q* I! l! k3 M3 x1 a7 d
std::vector<Expression *> exp = getSphere->GetExpressions();
0 o9 Q' N7 @2 S4 g0 Z; p/ X ss << exp.size() <<endl;1 G5 Q# l- R5 c% m$ R* }
theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );' l* a4 y' O, \( u/ c# K0 ~5 i
for(unsigned int i =0 ; i< exp.size();i++)
n0 D7 H! F2 U4 @* v) Y { & R6 H: I& q% g; Y; I
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");# O$ k8 R0 N1 Z3 S
}
7 t' ~3 H4 V7 d# B. v0 B' K Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");9 R9 j- C9 {5 J3 O; p5 Z7 s- S' J6 u
exp[0]->SetRightHandSide("400");
" s8 Y+ `3 w+ R$ g# H9 ^; i theSession->UpdateManager()->DoUpdate(undomark);# w8 h. x8 w3 Q: M$ X, h
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");
+ ?) m' x1 E# x' w5 u$ N3 i$ f }1 ^4 K% B4 d \7 D
}. [. e) |3 g9 {" L+ [3 M& q
- p1 u, X& w* Q7 W/ c" D
1 c5 w" W. X0 P1 z; a0 g* i" c
|
|