|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
+ q* Q: N' b0 ?. w6 _
2 c4 i' z+ y2 C- Y& @7 x
5 C& Q C+ B3 j1 f- _创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!3 l* J" D( U, B3 K4 s
) d* W# a$ V" P. |& `% V
Session *theSession = Session::GetSession();
- E5 i' }5 u9 w9 k( T UI *theUI = UI ::GetUI();% M, t5 i- x' p; I9 i$ t5 r" F' x
Part *workPart (theSession->Parts()->Work());
. A2 R$ ?' A, P) e7 }4 y* u- ~$ x8 K$ h9 f5 _2 @
// initialize the select
( ?3 Q: z* Q6 T% o5 B$ {% a std::vector <Selection::MaskTriple> masks(1);& F( p7 j$ E3 T/ t, g/ j
Selection::MaskTriple mask;# }$ V% y5 I0 m2 x' S% `
mask.Type=UF_feature_type;
+ O9 k: j4 l* i! U mask.Subtype =0;
8 ]5 T( q0 S. \% V) e* r mask.SolidBodySubtype=0;/ B* S) D6 F |7 M" C
masks.push_back(mask);' P: [$ _9 q& z
//masks[0] = {{UF_feature_type,0,0}};
$ |$ J1 Y6 {* p8 w* h TaggedObject *object;4 m0 u% p C+ g
std::stringstream ss;. u! d' w! a8 l
Point3d cursor;
# o3 k+ |, F- D k& H. E5 u% k Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;3 e0 K8 H$ u- x! A' ~
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
4 d3 Q8 @/ Q7 o' Q5 Z9 _( l Selection::Response res;
* L2 l# m, O, Q/ a" s Features::Feature * getFeature = NULL;
( N7 x2 b3 F L( Z, a+ { res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);. V" u8 G- d# @4 H. Y3 \
if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)$ d& F' y, O# y
{( a! l' C& ]; m, \
// get the information
0 c! q6 K2 U, k) A getFeature = dynamic_cast<Features::Feature *>(object);
) u9 Z- V! l9 ?4 w, F+ w) [: w4 g0 D& F
theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");- q7 ]2 K' c7 h e& F
J0 m, i; p& d; z if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))0 V( r/ V) e' A- W% ~
{
+ C* t! w/ q e: B3 E+ L' P: V: N Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);% G, | G3 w) i
std::vector<Expression *> exp = getSphere->GetExpressions();
. r0 ~- g0 Y x% u5 K7 N" K ss << exp.size() <<endl;3 G \( x s0 e6 g7 i2 c- D
theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );
" |8 |# c0 B+ N3 n: J) D- x for(unsigned int i =0 ; i< exp.size();i++), d6 a. b( Y) n O+ Q8 e% Y; L
{
+ a5 s% }+ S/ z0 } theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");
. {7 q; p; G9 l6 |6 H# i0 { }
W6 b1 p9 ]4 } Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");
' P+ ~2 G. q! `$ U, T exp[0]->SetRightHandSide("400");
& y! p& ~6 o$ x theSession->UpdateManager()->DoUpdate(undomark); e2 f* j0 ?2 ^% @1 f' k
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");& }0 D8 @$ w4 D$ P# G
}% {3 Y& b' E5 H7 @/ e$ f
}% i" k# J) E7 I4 b7 Y
; `9 I) N7 h; M1 a, l9 n/ D/ ?1 `: [# ?* z3 c* U
|
|