|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
5 e# ?* A; q2 a+ n3 N2 W3 i q' t. p, E9 z# K- X5 L
9 Z/ o3 F5 B4 Q* D# Y
创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!% l" n6 k r: y% f
7 D+ a. @* u' L) n+ E
Session *theSession = Session::GetSession();
, K0 f! o0 S6 U" s2 A3 I) y UI *theUI = UI ::GetUI();$ [& _+ v7 B' c
Part *workPart (theSession->Parts()->Work());
3 O5 E, r. f/ ^6 Z3 x0 w/ ~8 m0 U! a) _* Y4 N) _% @. R
// initialize the select
) L. r* o C0 c9 Q( R( R std::vector <Selection::MaskTriple> masks(1);
, s9 C7 z1 D$ }$ j Selection::MaskTriple mask;
5 O! a ]2 z1 ^1 E/ y) O" R+ O1 { mask.Type=UF_feature_type;
9 u* u9 f4 L/ X9 t' W( H6 @ mask.Subtype =0;6 _7 r. |! b0 J! |. B$ A4 \
mask.SolidBodySubtype=0;
7 ^9 B: g# {0 w9 e) }, c6 K6 r1 } masks.push_back(mask);, f2 B# X2 j4 i0 S* H- A
//masks[0] = {{UF_feature_type,0,0}};) e8 q( T$ [9 d$ S/ _# J* W. G
TaggedObject *object;
" f7 P, _" t) o9 Y( B! c+ `3 f std::stringstream ss;
" G4 T- ^8 K9 |6 G) r Point3d cursor;
( r5 q7 @, K! Z& O6 l3 ]) {1 e Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;# Z! b3 |3 a% @; c: Q8 ^# K+ N
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;( p$ h! }5 I R. j8 Y
Selection::Response res;
3 \+ i( f, V3 ]; R5 |4 Z Features::Feature * getFeature = NULL;( ~3 ]; b" {! D' h0 y9 d$ n4 a
res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);9 x2 F+ a. d6 Z6 T! m8 |- g
if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)' W* F Y! E7 S5 K; l9 y; V* ]
{
|3 q2 b9 ?' c9 } // get the information
( F4 x( k3 ]4 E' X getFeature = dynamic_cast<Features::Feature *>(object);3 N$ l3 j$ F3 v
$ H: z k) E; Z, q theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");+ f3 V5 J; c6 m% M
. R7 [, d; T I9 x if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))
0 _$ J+ N7 B' e% M+ W. S9 T {
" @& V% n. u! j' ? Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);
! p5 i6 D" @, j6 p" E std::vector<Expression *> exp = getSphere->GetExpressions();
7 J* I6 i, {( S( b: ` ss << exp.size() <<endl;! M2 v L' u; G
theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );0 _4 q6 H5 B3 M$ S/ \8 A3 X% H7 A7 y
for(unsigned int i =0 ; i< exp.size();i++)
: q$ J. w* K7 r5 u- [; V {
) r9 k2 `5 q h* o3 t0 p& Q theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");' u- N4 r% G2 j+ `) y4 a5 n
}
4 u' |* K# K7 D( h1 P9 M$ l Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");6 |3 P9 ~* S7 i. x
exp[0]->SetRightHandSide("400");
; z! T7 t2 |& m0 q7 m) o theSession->UpdateManager()->DoUpdate(undomark);
, t! a+ a ^4 _, q1 E theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");
8 Y! M- e |* O* Q. T }: K& `- P: C2 f
}/ |0 A4 Y. m+ z! c2 ^$ `
9 D' T" `' s% ]) u ]; E0 o, S$ s/ [9 e9 |4 d9 l8 n6 M3 @$ l
|
|