|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
【PLM之家-NX9.0二次开发实例视频】8 Open C++ 对象选择功能0 k# W/ m9 I2 C- y# a' h
! L( \+ m+ N8 Z9 C
" J3 t1 P3 k! Z) o9 v, x* ?9 M# A内容:使用NXOpen 创建一个单选feature的功能,并输出选择feature的名称和类型!
5 v8 Z/ D4 _4 ], G7 [' @/ d目的:熟悉使用Selection类功能! k5 @: c9 Z8 e+ `/ w0 y, _
8 Open C++ 对象选择功能
1 S8 b6 \$ ~* H: n$ m% \2 t
/ P& g7 p: n& d. p
3 W# o/ v9 H7 J6 g
: C' ?1 {9 X) f) C
- m# u6 t6 }6 p: r. g3 i
Session *theSession = Session::GetSession();# G$ R( F& x6 h7 s# W3 I$ H
UI *theUI = UI::GetUI();
2 Y: B! i* d# b8 J* i4 Q- } // selection feature( i. M9 \7 j1 F6 i
char *message = "select a feature";; \# g! f( M0 L# x
char *title = "single select ";+ c Q5 x5 D! O/ L
Selection::SelectionScope scope = Selection::SelectionScopeWorkPart;+ [6 R# ]+ V8 p/ S$ Y: H
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;' _2 J/ B0 j: \* Q6 H8 V
std::vector< NXOpen::Selection::MaskTriple > maskTriple(1);& R4 k, f$ [2 z- ~3 o
Selection::MaskTriple mask1;
# ?' O1 t8 T O5 D, t& K6 x% T4 _ mask1.Type =UF_feature_type;
% Z0 N! f$ X/ ~6 O$ ?2 E mask1.Subtype = UF_feature_subtype;1 y) m- o5 H3 ?/ j2 m. [
mask1.SolidBodySubtype = 0;- f) n7 {& t7 d- r% g& a
maskTriple.push_back(mask1);5 i! j& F- u$ F" X
TaggedObject *object;
9 L8 Z$ D u/ I; s7 f- e Point3d cursor;+ W2 u! \- U, b3 d0 X ?) Z
Selection::Response res;
8 {& i. J" I0 A. O! u/ R res = theUI->SelectionManager()->SelectTaggedObject(message,title,scope,action,true,false,maskTriple,&object,&cursor);; K% w/ T1 k: D; b& I: g3 ], S
if(Selection::ResponseObjectSelected == res)5 D2 c6 X' J& F
{ V. r( V- @ G( D4 ?
Features::Feature *selectedFeature = dynamic_cast<Features::Feature*>(object);5 `5 `& N w' @/ |& g9 L7 X/ J
theSession->ListingWindow()->Open();
2 m% z% ?% U V9 l' i) ^ theSession->ListingWindow()->WriteLine("the slected feature name is:\n");$ a: R/ d1 c% |: H9 f. t M* N
theSession->ListingWindow()->WriteLine(selectedFeature->GetFeatureName());
9 R8 x- j F8 {' l. X theSession->ListingWindow()->WriteLine("the slected feature Type is:\n");
7 Z, R) n1 A/ ?6 A, P' b theSession->ListingWindow()->WriteLine(selectedFeature->FeatureType());
9 y1 v! n$ ?- f0 K theSession->ListingWindow()->Close(); }
1 Q5 K5 j( \ j, m
s* |+ N2 B: Q6 a5 l t# m' z: m3 L7 H1 P3 t" Q0 k/ `) G+ k9 p
6 R7 G, ?4 ?+ F: g5 r; ~) p8 M
|
|