|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
4 M# |- d( m& I7 N1 G( C0 p1 } T! i( T1 q v% ]8 W, \
7 F' I) S8 H" N7 o0 x创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!) j5 ^8 h+ h; [3 w7 i+ b1 j
7 B3 B7 g3 [# ?7 S/ X- M! u( W5 M
Session *theSession = Session::GetSession();
8 b% }. C/ ^$ ~$ Q UI *theUI = UI ::GetUI();
% _1 g5 W( [7 O Part *workPart (theSession->Parts()->Work());
- A" |. k( f; Z$ w6 G9 ~7 n# ~: b" Y2 H7 s
// initialize the select
% x/ Q7 S9 V6 D& p. ]2 g std::vector <Selection::MaskTriple> masks(1);' K8 f+ u0 Y0 K1 \. K
Selection::MaskTriple mask;
9 z& \9 U$ i. l" q! C, T6 E7 K$ D mask.Type=UF_feature_type;0 g1 }! T: Z: { I; w
mask.Subtype =0;4 A" q' s) B# p: | b- ?7 C- }' x
mask.SolidBodySubtype=0;2 |; a X) U5 {- U+ i- ]4 x
masks.push_back(mask);8 E) y4 [' o' o! n& j
//masks[0] = {{UF_feature_type,0,0}};5 B; V* x" m/ g" f! _+ e/ F
TaggedObject *object;7 j8 s, u7 N1 t& P% Z' l q& k3 z) a
std::stringstream ss;
$ O* e$ Z4 g, q( Q% ` Point3d cursor;; M, x$ f2 }2 n8 ]0 B* a
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
* z" P! l/ J$ M! A, `- C a Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;' w6 ^, `& z+ z: Z$ R3 v
Selection::Response res;
7 J- K" x. Q6 M Features::Feature * getFeature = NULL;/ J* G9 H9 D2 C8 b
res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);
8 r: W# Z# V! C% N if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)" j( S Z9 u, u4 _/ C
{
* y7 }, g+ L2 g6 n4 _: G) M' B // get the information7 i/ @. U* j+ W) ?+ o% p
getFeature = dynamic_cast<Features::Feature *>(object);/ N+ G/ n0 t2 S$ D
0 b+ f/ p' H8 b* l, R5 H- B4 N. @ theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");/ J- c5 e6 |* O
" T6 K6 Z/ J( g* X
if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE")), y; @* V2 O% Z/ U% ^% B
{
: r! ^' }0 `! Q Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);
) K* n' w. Y& |( i, @+ D std::vector<Expression *> exp = getSphere->GetExpressions();5 x; H( ~9 j1 [* Y8 A6 u; k* E
ss << exp.size() <<endl;- A# b1 |3 Q. a- r9 r9 B
theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );
( a/ @; s+ R) A$ a6 c for(unsigned int i =0 ; i< exp.size();i++)
8 o2 H, M: z% ~4 w# ~ { & n9 N k! i. ?- ]/ D* B
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");8 B( f6 j" _/ k/ h1 t+ [
}7 w3 l; g3 _& R6 N& i& Z; d" s' p
Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");( y6 D- x( S5 Z/ |
exp[0]->SetRightHandSide("400");1 u u' ^4 c* C0 b3 c) q1 `/ e
theSession->UpdateManager()->DoUpdate(undomark);7 s7 ^$ i1 |2 ?1 o
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");
2 c/ _# O- T! I+ W }& m* n- O+ @7 X; g: L% V' d2 p1 i! u
} Q6 M5 N$ N$ v* d% l& [3 |
9 K" @9 t; U l' X, N5 O2 y; `) K" v5 r( \* d4 }1 I1 W# ]+ [* L
|
|