|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
【PLM之家-NX9.0二次开发实例视频】8 Open C++ 对象选择功能# h7 F8 `1 l" z4 w* o U7 v! l
, g( }0 n8 C* _" b
) n+ x( U- [5 _内容:使用NXOpen 创建一个单选feature的功能,并输出选择feature的名称和类型!" s% X+ R8 i; E5 }
目的:熟悉使用Selection类功能!
9 T+ b2 U2 A0 n4 R2 H) g2 ^
8 Open C++ 对象选择功能
" l# Q3 u+ E( {4 v% p) c1 |+ ]0 K- d& O0 t3 H- L
, V+ ~3 L* t n0 M
3 X) g, g# n b
; J# O5 W* @$ p( b5 B1 c9 r9 S Session *theSession = Session::GetSession();; h. q2 j4 t1 b/ A. l
UI *theUI = UI::GetUI();# X: H2 H7 D+ c! B+ g
// selection feature0 p- s. ~2 }5 o6 a
char *message = "select a feature";
3 w+ P2 w* E# L3 Z3 e char *title = "single select ";5 i7 ]2 g e, f# \
Selection::SelectionScope scope = Selection::SelectionScopeWorkPart;3 w4 N9 c2 F. X& J1 Z
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
/ Q0 y' h; J1 A4 ] std::vector< NXOpen::Selection::MaskTriple > maskTriple(1);' F( r" Y" V6 m
Selection::MaskTriple mask1;
# e3 t j# ~% x: j4 | mask1.Type =UF_feature_type;' l1 O( m. ]9 c# ]& U8 U
mask1.Subtype = UF_feature_subtype;
7 I' K6 y: R8 n: q3 I) U0 z4 b mask1.SolidBodySubtype = 0;$ Z+ K& S3 E1 @: \& l( p2 P1 H
maskTriple.push_back(mask1);' G5 u" b' ^( {' l
TaggedObject *object;
2 U1 @1 @, _- R9 j( v# C* ]3 V Point3d cursor;
) D K3 @4 N' j1 q Selection::Response res;; s9 r; q$ q9 T# Z& T. Z: \/ d
res = theUI->SelectionManager()->SelectTaggedObject(message,title,scope,action,true,false,maskTriple,&object,&cursor);% g; U6 L! [' s# {
if(Selection::ResponseObjectSelected == res)) ?$ }! [9 n e% V( ]' S
{
5 C7 P* S7 T/ b Features::Feature *selectedFeature = dynamic_cast<Features::Feature*>(object);& F" J9 y' x! ]8 ]" L4 m& z
theSession->ListingWindow()->Open();
' C0 F c9 E1 M2 T6 U theSession->ListingWindow()->WriteLine("the slected feature name is:\n");, F/ \- W9 L) J0 p3 d# b0 I$ Q: D! @
theSession->ListingWindow()->WriteLine(selectedFeature->GetFeatureName());
8 G# ^6 K: }4 u" v theSession->ListingWindow()->WriteLine("the slected feature Type is:\n");
0 h* i, s/ @% _, m theSession->ListingWindow()->WriteLine(selectedFeature->FeatureType());
0 `3 @3 K# [$ X) q theSession->ListingWindow()->Close(); }6 q" p9 ~( v1 a5 l; k7 H% z
5 ]: v" r! {" u5 X9 N
1 L) ^3 f( s- W2 i
* H+ ~& p& c8 e6 e' i; y+ \ |
|