|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
3 x2 z: ?, Y' T( M
6 o ?( E e" ~7 q$ @8 b9 ]
( s4 [$ s9 P( U/ n+ a% |! Z创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!
" B3 K. U! U$ c1 V g8 i: Y0 \8 |" c$ ]" H o- I& a0 `4 l
Session *theSession = Session::GetSession();1 d0 f# v! Y3 q
UI *theUI = UI ::GetUI();
{4 R% T5 @6 P4 } Part *workPart (theSession->Parts()->Work());
* Y2 U$ z) v5 Q2 b% e/ F
2 K+ d+ @* M5 l c" Z // initialize the select
! u' M8 D) ?% G0 ~9 o std::vector <Selection::MaskTriple> masks(1);6 S% f& i/ B) u, }+ {8 t
Selection::MaskTriple mask;
# ?( f/ A6 W9 X/ g& x6 f4 r' P mask.Type=UF_feature_type;# I5 v/ k% F7 ?' `* ^ W
mask.Subtype =0;
! X$ E+ p3 d* M% Q/ \, j: P* y# b mask.SolidBodySubtype=0;
$ G/ W3 Y' y5 k! E8 D' D5 F masks.push_back(mask);+ d7 U' x* w6 ` _6 y( W2 D" c
//masks[0] = {{UF_feature_type,0,0}};
; r4 K2 l$ H; t7 K8 o* s! `: i% _ TaggedObject *object;
9 t, A1 x! c8 o/ S5 h# ` std::stringstream ss;
1 ~/ G- J- x# D) u4 j& m6 A# ?1 H Point3d cursor;
( h% H% g' y& c3 q4 a1 b3 ?# x% S Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;) J' d- s+ w$ A7 p
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;- l" {2 X6 |* C1 C$ C6 x
Selection::Response res;
+ b z/ T: k% Q9 E5 A1 R9 B& p% j Features::Feature * getFeature = NULL;
! B- Z: L- M9 @- s% e" V, [ res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);
1 H! M' ~2 O3 i) a; W( X9 [! f6 [ if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)/ X8 G& y- v' R; F+ W/ R
{
; w" c! f) Y( ]5 B/ I, F // get the information
2 ?. `) O( ^/ F. e8 S getFeature = dynamic_cast<Features::Feature *>(object);* ^; C. r% _+ w- Q3 [) D
/ l3 w$ V% s, E3 t
theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");; D p* i* }/ f r5 f
) V, i- w& q, U- h: | if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))
$ s; e' t$ u7 `, } {' L! v9 X7 J; H! w( @0 t
Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);3 C9 E2 j, k9 \, l: ~2 {) ~& @
std::vector<Expression *> exp = getSphere->GetExpressions();; A Z7 o5 z" s i* i* d4 t
ss << exp.size() <<endl;' L# S# F, B% y" {* e0 a) v
theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );' \! m/ D. p! T* R- N9 a' D8 }
for(unsigned int i =0 ; i< exp.size();i++)
7 R8 D/ o: D: v) \( b3 U {
: g' x6 a9 _- O theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");
& |' W7 \+ X7 l$ W9 P& T }
& \8 Z! _+ b3 |% G6 { Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");
' e/ o$ R& R# C [& f3 i& v/ l1 s exp[0]->SetRightHandSide("400");
3 [- h* c: N& } theSession->UpdateManager()->DoUpdate(undomark);% w2 K: W% F8 d! Y6 |
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");: N0 w. u( N# H& A. w* y9 u9 u
}
: @& N. P' ]3 e$ p+ K6 C }* O! S& D8 _ }/ e4 F. c/ U8 m
9 H5 c. M4 E! ?2 @' i" _4 t2 P6 ]6 y- a7 m, m- H; U; F$ Y4 H+ J3 ?; h3 a- w
|
|