|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
+ q. C4 }) {$ V! Y$ g7 Z
^& i) w' O" J: X% W( }: T; a& F! j' w0 y# {1 I
创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!; c' n C5 @- o a
' K( a' J5 ?- s' I4 X* W
Session *theSession = Session::GetSession();
2 M. P6 f3 g; L$ C UI *theUI = UI ::GetUI();6 Y6 j4 D6 U( Y+ R2 `, `4 i2 P. u
Part *workPart (theSession->Parts()->Work());: m% c! N, h* z% y4 @8 K0 p
- C. J& T" T; x
// initialize the select
$ g f( S) x/ r+ |6 O: ~ std::vector <Selection::MaskTriple> masks(1);
, I+ ^- n! \' L, O( R' e8 \ Selection::MaskTriple mask;5 ~: F% w4 a0 Z
mask.Type=UF_feature_type;# [/ S$ z' l6 l/ J4 g6 v
mask.Subtype =0;
6 r. `; E$ K7 A% Y$ y/ m/ X3 g mask.SolidBodySubtype=0;$ _- ]4 N& F) t5 c
masks.push_back(mask); u9 t) o3 h% P
//masks[0] = {{UF_feature_type,0,0}};
+ W3 ~+ ^$ e* K2 L TaggedObject *object;
9 a. l! ?; P& [/ W2 V std::stringstream ss;, t, R, W. l. C8 P4 G) u& o( A
Point3d cursor;! \* B% X, R1 p0 N/ a0 x) C
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
0 p. A8 r- f; M8 m Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;, |- V' i& L/ Q
Selection::Response res;" y* U/ J/ I1 ?6 z
Features::Feature * getFeature = NULL;
5 h- l5 \$ n0 h3 i7 c! ? res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);
3 }( h: L, Q/ t' |' B2 s if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)
% e. ~) V' W3 l6 O {2 b' B+ A- s. }# R. l5 j
// get the information
' v; |0 }; V5 O! X4 E6 F getFeature = dynamic_cast<Features::Feature *>(object);+ N' }" b3 n3 ~) k7 `/ P
8 Y, n' l/ B! u V/ |# k9 G8 L1 j
theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");7 M6 t0 `+ i! v- g
6 _* G6 s# _/ ], P) r if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))
# ^. X3 {& b$ Q0 t3 \ {
. ?1 x3 W! Z+ Q- v9 u Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);8 d' {" `% B6 A) |7 H" r
std::vector<Expression *> exp = getSphere->GetExpressions();! y' x" A6 ^( ^) w2 c* }) Y
ss << exp.size() <<endl;5 p! N5 Y1 ~! M0 s8 V
theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );: Q+ m. Q4 T# _/ @2 C' X
for(unsigned int i =0 ; i< exp.size();i++)
+ V w7 [3 u" h+ ^ T { . G+ x& ]% J- @7 G5 l8 _7 V; g
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");& @9 Q) [/ s9 B% S# J3 J5 C
}
9 W! k5 r9 z: ]3 D J, O Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");
" l) v& i8 q+ q exp[0]->SetRightHandSide("400");
, T9 y4 R; k; v e* M0 E' L theSession->UpdateManager()->DoUpdate(undomark);
5 ~7 V" `# T, G3 G: H! l- g v/ W theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");. Q" Q; E" o8 B( z
}: i9 G; F5 q6 |
}
9 p4 e# H/ J5 V' ~% t; }9 v4 h$ j/ A7 i7 y
! [4 I) p' y! W' [& a W2 B
|
|