|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
: v) \( m7 | j' ], ^
8 R5 ~& i, ^/ R% Y- x3 ^8 u6 Z5 I) D
* V, Q$ R: t9 _$ t创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!
2 _- Y- P( f9 ~" H$ p0 u
3 W/ Z6 c7 b/ h0 CSession *theSession = Session::GetSession();
6 k3 k5 t% W9 l6 k UI *theUI = UI ::GetUI();9 R- _9 x3 r: z5 i) V( [! a
Part *workPart (theSession->Parts()->Work());( l- N& t7 P0 s, P& G
: i! r& i+ r q% b
// initialize the select
- E3 [: t: W1 `1 ` std::vector <Selection::MaskTriple> masks(1);& K1 V8 v! R1 ^" N" s
Selection::MaskTriple mask;
' s. J( R9 m/ \5 B3 h' G* ` mask.Type=UF_feature_type;8 V6 U5 t: o6 M4 R
mask.Subtype =0;% W7 q) R$ i( i3 ^- D0 Z$ B
mask.SolidBodySubtype=0;; H9 @- G) t/ H
masks.push_back(mask);
5 ~1 N2 c6 o, P2 Z+ n) i m( ` //masks[0] = {{UF_feature_type,0,0}};0 e- v1 P( l8 g" r" ^# u
TaggedObject *object;" E) |4 g/ U1 `
std::stringstream ss;
( C* l! e2 f7 X1 p) z: } Point3d cursor;+ c. j5 A! a. H# o* o: F
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;* J1 `3 f( }5 C' J- N4 |; s
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;3 g# q9 q' o) s S
Selection::Response res; r0 x9 e, f2 ]
Features::Feature * getFeature = NULL;2 _( b' l: {; ^% t, J: |0 |
res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);- s, Q" G5 {6 y# y) T: L
if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)) B: s' m) j& _+ y$ a M& ]
{
, O+ S0 ^/ G* O' `/ O // get the information
0 W) Z+ s2 G4 ^5 h& ] getFeature = dynamic_cast<Features::Feature *>(object); y" Y, `9 X# j
$ _3 k1 Q" {% W theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");: |2 V u* d8 r' B5 h
3 _+ a8 A; L/ S+ _ z0 G J: Q
if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))
+ W9 k% i6 n# |9 u3 f o* X4 x {
& Q# W) B4 a! R! t* f/ i Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);9 f! \6 z$ ~- L' r& j) t; o; K
std::vector<Expression *> exp = getSphere->GetExpressions();
8 R1 t1 q( j' u$ i) D0 A* H ss << exp.size() <<endl;( m6 }1 I4 C/ U- R
theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );
% o0 ~: }# \; y1 |& F for(unsigned int i =0 ; i< exp.size();i++)( t. k6 @" d( ~5 G x2 V$ G
{ ' Y, j7 j6 [" D8 y" l3 z! F
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n"); e* m* t2 Y7 o; U$ q7 @$ f
}
3 `/ d# _, T, r$ a3 n Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");
/ L- G( K& R$ j exp[0]->SetRightHandSide("400");* E$ e F( Q* I0 K: l
theSession->UpdateManager()->DoUpdate(undomark);! I, Y" U: L a3 g; M- n# ?
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");7 C0 x R/ v9 ?; [/ v
}
9 k! J. K" p' Y) d }
5 I4 v. X% n7 `& H
2 E/ h; h& B) H' j I4 J/ f' J# w8 p, Z, C' |6 P
|
|