PLM之家PLMHome-工业软件与AI结合践行者

[二次开发源码] NX二次开发:选择方式代码大全

  [复制链接]

2015-11-13 21:09:39 5926 6

admin 发表于 2014-2-18 13:07:13 |阅读模式

admin 楼主

2014-2-18 13:07:13

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x
选择方式包括通过mask过滤,通过type选择,或者通过选择所有的对象。! {- I& b4 f# r7 g8 X6 G; S

3 L) X- |  m* M8 B/ V5 ?0 D/------------------------------------------------------------------------------
1 g# k' P- V8 }' d! B// Selection with mask
$ I  o3 ?: h( u, W! c//------------------------------------------------------------------------------: U% \0 ?( Z0 I  d5 a, L, y
TaggedObject* MyClass::select_by_mask()9 x; [! x& I6 s" N! p
{
- X$ I2 H% ~1 Z3 _- S7 YNXString message("Select an object by mask:");
% G' g! b' H+ j0 T( n, a8 a1 U; m; `NXString title("Select object");
; j$ E5 K9 D- p2 T# ySelection::SelectionScope scope = Selection::SelectionScopeUseDefault;8 _& b5 `7 l; F& z) S2 U3 a0 Q  O
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
4 Y* |; Y2 s$ @/ w- Sbool include_features = 0;8 F& R1 V! m4 l* G
bool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.( F& h; R% V  S2 T- Q& T  o" d
// Uncomment or combine the desired mask triples% u8 j5 a' x0 ^8 S7 ^" L# e
std::vector<Selection::MaskTriple> maskArray(1);
0 n- V& q& n( J, tmaskArray[0] = Selection::MaskTriple( UF_solid_type, UF_solid_body_subtype, 0 ); // Bodies  i" Q6 X5 B/ N3 A5 p5 Y
/*$ @! g+ f+ x0 Y& h0 I; _
maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_FACE); // Faces) }/ Z6 _: T2 n$ [8 q5 G
maskArray[0] = Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_EDGE); // Edges
" ~9 h4 U7 w/ P3 w( HmaskArray[0] = Selection::MaskTriple( UF_component_type, 0, 0 ); // Components: c, w7 h2 ~# G% b! W) x5 m
maskArray[0] = Selection::MaskTriple( UF_line_type, 0, 0 ); // Lines4 |9 a) {" ^2 V# S+ W! D7 E4 v
maskArray[0] = Selection::MaskTriple( UF_drafting_entity_type, 0, 0 ); // Drafting objects
. r) ^0 C$ u! T*/1 p- o% q" e; F* B$ a4 E$ V
Point3d cursor;6 ]- y+ T+ I; K: X# \
TaggedObject *object; // Select objects using filter defined by maskArray triples( w& a5 c/ |* u6 O4 B
Selection::Response res = selmgr->SelectTaggedObject(
5 B/ _9 M* r& p! E   message, title, scope, action, include_features,
% a6 p1 M( |3 r8 c1 b* ?0 X            keep_highlighted, maskArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected )
2 D5 q* u$ p& c) Y: T{
- z8 k- g0 T% }# k" l+ R  return object;1 \# o3 p3 q# E2 x0 U8 e2 Q4 C
}3 b3 {! J0 K" u8 F
return 0;
' c% A; k0 s/ e4 d}//------------------------------------------------------------------------------# X& \) g, o" c( z9 H, N
// Selection with type array
! i& `- Z( g- z" t//------------------------------------------------------------------------------
: b- o# O; f$ UTaggedObject* MyClass::select_by_type()5 _8 W. j! I+ g  m8 i
{/ u, b4 e- f! r+ [: ?; |
NXString message("Select an object by type:");
9 x  o! B# u9 J( W, P. F3 cNXString title("Select object");7 I, l# ^5 ]; {1 p5 _
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;, f/ @  s+ X- \& b- r- [* b; H
bool keep_highlighted = 0; // Define the mask triple(s), see also uf_object_types.h.
* c3 U; V2 \3 u' O& d+ z( H6 c// Uncomment or combine the desired types7 U* N8 E5 ?- n/ n* a7 K
std::vector<Selection::SelectionType> typeArray(1);
8 O" `& a) d7 m% T3 r) FtypeArray[0] = Selection::SelectionTypeAll;
3 M2 Z# J2 b: H( G9 j; z: F* b/*0 s% t$ [. U" N- f0 I( K
typeArray[0] = Selection::SelectionTypeFeatures;! C3 m, ?! D; a+ A9 P
typeArray[0] = Selection::SelectionTypeCurves;) C4 D3 j. Q7 K) W' l
typeArray[0] = Selection::SelectionTypeFaces;
- ?. r; x* t: R; V8 C! U1 FtypeArray[0] = Selection::SelectionTypeEdges;
2 G& _" @2 Y- H& G4 S) dtypeArray[0] = Selection::SelectionTypeCurvesAndEdges;- N4 i# ~) q2 S, F6 b0 p1 @
*/
8 [5 i  Q' e/ g% O. u9 }; q$ p0 c3 GPoint3d cursor;
; D: _  J4 ^$ m% _6 uTaggedObject *object; // Select objects using filter defined by type array
8 R1 r( g0 |. o$ F0 Z& PSelection::Response res = selmgr->SelectTaggedObject(
# M6 U& C+ X* I) L   message, title, scope, keep_highlighted,
) Y7 T7 T* V& f: O: }, L   typeArray, &object, &cursor ); if( res == Selection::ResponseObjectSelected ), Q' B1 i' Q, x% o
{; m7 v/ Z/ U2 J) M7 r, f- T
  return object;
% R: T& }3 F2 I}
  Z/ P3 ~6 d% V7 X- q/ s' breturn 0;
4 `  f3 N( Z. U7 |; V( C, d6 Q# _}//------------------------------------------------------------------------------; Y, [- ^9 \& f+ ?$ w$ z
// Selection any objects
8 h" X9 a- {- i1 y3 M  L# H  |//------------------------------------------------------------------------------/ L7 l5 K. Z9 a3 y9 ~' R
std::vector< NXOpen::TaggedObject * > MyClass::select_any_objects()5 J8 R) Z4 W/ C; W$ N5 b/ Z
{% i8 F* r$ x3 C
NXString message("Select any objects:");, [, C1 G# k' Q% ^- H
NXString title("Select objects");+ ?$ W2 L2 O  o
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
* s7 |3 l6 l8 P% e" wbool include_features = 0;
: |6 ?  U: y8 X" \bool keep_highlighted = 0;  }2 g4 }1 R3 _7 c. @2 U% \
std::vector< NXOpen::TaggedObject * > objectArray; // Select any object array
6 Q4 y- x  c" C5 b8 ~  MSelection::Response res = selmgr->SelectTaggedObjects(0 S, |2 O( t- Q; s8 N' c/ ^3 L2 {
   message, title, scope, include_features, 9 V# L+ `" C+ A' x( J+ j
   keep_highlighted, objectArray ); return objectArray;1 T& B+ ~8 ?: [( [  B
}  U8 \7 J  q: k: `! }- j+ q4 e
' Q* q" |6 \; @9 N- S9 e8 k
' J# D0 m2 r: u
4 e' G. f8 L3 V5 H" ?1 }8 m
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

全部回复6

sl2651668521 发表于 2014-3-2 18:36:05

sl2651668521 沙发

2014-3-2 18:36:05

老大 为什么把你的这个代码放在这里会提示错误啊。。。新手一枚,问题幼稚,请多指教 谢谢
321.jpg
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复 支持 反对

使用道具 举报

admin 发表于 2014-3-2 19:34:19

admin 板凳

2014-3-2 19:34:19

sl2651668521 发表于 2014-3-2 10:36
) |* c& `. t# M+ }4 I老大 为什么把你的这个代码放在这里会提示错误啊。。。新手一枚,问题幼稚,请多指教 谢谢 ...
% l! S' k- {  P) ], v/ s- A7 R4 b
你抱什么错6 ]3 A9 }5 s' Q2 N4 L. }
头文件 加了么
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复 支持 反对

使用道具 举报

admin 发表于 2014-3-2 19:34:21

admin 地板

2014-3-2 19:34:21

sl2651668521 发表于 2014-3-2 10:36
; A% k( l5 i1 z; O# `* Z老大 为什么把你的这个代码放在这里会提示错误啊。。。新手一枚,问题幼稚,请多指教 谢谢 ...
. \9 G  G, o1 l) x& R' O: R& |) {
你抱什么错: s5 n2 ~2 c, m" K! i& J  {
头文件 加了么
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复 支持 反对

使用道具 举报

sl2651668521 发表于 2014-3-2 19:47:18

sl2651668521 5#

2014-3-2 19:47:18

还需要加什么头文件? 我是利用vc中ug模块建立的工程
2.jpg
1.jpg
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复 支持 反对

使用道具 举报

wyw6686 发表于 2015-11-5 14:55:45

wyw6686 6#

2015-11-5 14:55:45

老大,这个 selmgr 是个什么东西,怎么定义啊?
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复 支持 反对

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了