PLM之家PLMHome-国产软件践行者

[二次开发源码] NX二次开发源码分享:报告选择尺寸的相关信息

[复制链接]

2015-8-22 12:47:05 3383 0

admin 发表于 2015-8-22 12:47:05 |阅读模式

admin 楼主

2015-8-22 12:47:05

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

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

x

4 m' g9 k; S6 RDimension* plmhome::select_a_dimension()
; c+ X& ]0 J& |; y5 }! r{
! \0 k7 c- G, w$ o' \/ i/ }4 J    // ask user to select a label
" q. L+ F, q' |6 l# S- Z" `' `" n( Z    UI *ui = UI::GetUI();8 r" v& |2 A. k
    Selection *sm = ui->SelectionManager();
$ @# c  W/ h: ^, h' D. U    NXMessageBox *mb = ui->NXMessageBox(); // as of NX5
, }/ s: y( T6 @' R( h
5 ?) |6 P" @5 z    NXString message("Select Dimension:");- N  m( \0 g, X$ g( O
    NXString title("Select Dimension");
# \; P5 I2 K7 [1 b2 S8 a) V    Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;. f- d% N8 A, R9 {( g
    Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
7 O6 p, E6 z; D' ^7 u7 A! W3 d    bool include_features = 0;) m( w8 w0 A2 y. |& ]! V. \
    bool keep_highlighted = 0;
$ n, P9 o: Y: s& @6 I( }$ R0 k: Q! P
* ~/ L8 a8 i, {- Y9 y" g    // Define the mask triple(s)0 r4 I3 m$ \* |+ N1 |
    std::vector<Selection::MaskTriple> mask(1);
$ i* H+ y" I5 ]4 u    mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );3 y2 c( K) c1 B7 h4 k  Q7 V  q
    Point3d cursor;7 D) \- R; P; g; i0 ?  E3 L; \
    TaggedObject *object;; U. Q9 x$ m# {  }8 Y4 U* N7 ^

0 T: `+ o) n" C    // Select objects using filter defined by mask triples
% D  {, S, u. b    Selection::Response res = sm->SelectTaggedObject(9 R+ N2 h" O: r3 N/ ]! S  ?2 L
        message, title, scope, action, include_features,! `4 L; L" K4 J% F2 V
            keep_highlighted, mask, &object, &cursor );
) C' a# j/ W" p* `4 z  T1 [5 s& r2 l# f! \
    if( res == Selection::ResponseObjectSelected )5 e# H; O0 y$ K
    {
1 u) N: Z* d6 S( h: P6 z        Annotations::Dimension *theDim;
9 Q/ [0 ~. O) u2 o7 q4 u' F5 {' m6 I: N- |4 V
        // this doesn't work and 'note' will be a zero pointer, see PR-1850850
2 R" P: \& x  g( X% _        //note = dynamic_cast<Annotations::PmiNote *>(object);3 Q0 a" u; t) R3 w  R

$ n1 ^) g0 U3 d: N8 o# R. w* |        // this works as a workaround2 o2 z9 s  [1 k8 Q+ y7 A: W+ [& n
        theDim = (Annotations::Dimension *)(object);2 A$ y, R1 H+ ~: O! Q$ ~) g# d" e/ g# n
        return theDim;
- V- I7 k) q7 C$ b  i; d7 F& Y( c    }
; ?6 q. P# b6 l- p" L. ^3 j. @2 k' f3 }: W( Q5 x- I( h3 T1 ~
    return 0;
! T; o/ ]: r+ Y2 V+ O. O2 M8 k}; ]! D# F8 D  F# t: q8 G* x1 _: o

" y4 W0 g0 Z6 \1 p# g$ F& s! ^1 R. {3 Z7 M
, x1 W* Y9 D0 O

; F4 T* T, ~# F8 ^5 @void plmhome::do_it()
! Y, c, _; A5 ~. o' \# m/ I3 X{" |9 b# T/ a; l0 Z/ ^. b4 r9 q
    workPart = theSession->Parts()->Work();
, Z' \8 C- S3 i# D& N6 r" x    Part *displayPart = theSession->Parts()->Display();6 j- ]- e3 }1 f) `) q9 _  g9 P
    stringstream out;
. L; _* N! o1 B    Dimension *theDim = 0;) h3 o+ c, D$ [* `- C
* R. q- w- |( _; ~; }9 a
    NXString tolTypeStrings[] =
6 o/ b: w/ r4 i( }    {
2 \5 q8 C+ g) E  J- y; z        "ToleranceTypeNone",& J4 N! y; `7 [  G
        "ToleranceTypeLimitOneLine",' k" H$ L& F- H6 t: u& {- {
        "ToleranceTypeLimitTwoLines",
) |3 g) r2 P3 l, C5 F: r        "ToleranceTypeBilateralOneLine",1 l, @3 z( I5 e8 V- E* s
        "ToleranceTypeBilateralTwoLines",3 G" ~  m- C9 W" {
        "ToleranceTypeUnilateralAbove",7 R8 G* Y9 _$ a7 z: q9 ?
        "ToleranceTypeUnilateralBelow",  @3 C3 L2 H7 W' P. D
        "ToleranceTypeBasic",
7 s- j' ?7 \7 t/ H        "ToleranceTypeReference",
4 {5 v7 C+ [! v8 ?% J        "ToleranceTypeLimitLargerFirst",' J$ t+ X  C# `  X7 R3 k7 Q
        "ToleranceTypeLimitLargerBelow",
5 D3 `' J' B' C4 c4 N2 j4 h        "ToleranceTypeLimitsAndFits",
( _' G2 m5 I6 R        "ToleranceTypeNotToScale",4 T% g3 r; K0 n" D) ?) j
        "ToleranceTypeDiameterReference",9 |3 r, }  i$ B4 C$ m+ V1 G
        "ToleranceTypeBasicNotToScale" 8 ?8 D# |" j, U8 I, R
    };
4 n! R; }+ s  T" ~! ?4 X: r! I# w$ \/ l8 |/ Q5 b* I* f
    while( (theDim=select_a_dimension()) != 0 )- U! n9 A# p$ b  ^& q3 J. \
    {% _3 ^  x9 [5 A
        out.str(""); out.clear();
' i$ [6 J" _9 V  a" O( [        if(! lw->IsOpen() ) lw->Open();1 [" N8 Z2 M, k1 w+ Z* A
% |1 P3 A2 c, X/ R
        out << "Selected Object: " << theDim->Tag() << endl;
& ]) R, s. L. S+ O) @, B* A7 l6 J9 ^( m$ L
        std::vector<NXString> mainTextLines; / B4 y: m' h( N
        std::vector<NXString> dualTextLines; 4 C5 _; p  I. ^4 f
        theDim->GetDimensionText(mainTextLines, dualTextLines);' j' d7 E, r, W6 ]" p& G% q. Z% x
        for( int ii=0; ii<mainTextLines.size(); ii++)4 w0 T, h% ~0 J
            out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
5 T' }, B9 f! K7 p  p9 U3 e        for( int ii=0; ii<dualTextLines.size(); ii++)
0 I7 u6 U; |( j. W! e( T2 T+ v. R4 ?            out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;
5 W1 [; _& |, c: i# N4 I& j% {, F( `
        bool refFlag = theDim->ReferenceDimensionFlag();5 {: C) N/ t8 o& ]9 M, g% J1 v7 [1 r
        out << " ReferenceDimensionFlag: " << refFlag << endl;1 P* A$ k" N2 H. B- S0 G
' g( p7 s: C# `2 x; v
        int tolType = (int) theDim->ToleranceType();, {* e0 {  X$ r9 v5 T, I& r
        out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;+ e( S" y1 _* M
4 K3 J/ M7 B! T: i  v6 g
        ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);' [- l9 [6 C2 b! y/ s
        std::vector<TexTComponent*> textComps = theData->GetTextComponents();
" W: j8 a+ y3 \. o! j        for( int ii=0; ii<textComps.size(); ii++)8 F7 a0 p" b! H' Y
        {
$ [  g- Z6 E+ O: d' m            std::vector<NXString> compText = textComps[ii]->GetText();
9 j+ M! g- A& G, ~" {0 B. y            for( int jj=0; jj<compText.size(); jj++ )2 O7 ~" ]9 ?* o# Z1 w. i* L. W
                out << " Component Text: " << compText[jj].GetText() << endl;6 b8 H: n: T  I8 J! u
        }
0 D; b* W6 n  B! A  I1 ]7 l7 o2 w3 X8 U5 |
        int subtype;, W2 d# r0 J. `/ ?
        double origin[3];
" x! z8 c+ e: d1 O9 ?4 g6 f; D$ y        UF_DRF_dim_info_t *info;
& e' ?; N, [. \; u: }8 t0 K        UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));
7 b) J! E6 ?  E) I  R        for (int ii = 0; ii<info->num_text; ii++)
4 w) T+ l3 W4 r/ L0 `1 J4 V% V8 h            if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT): w, P  o9 R/ `4 ^# F1 D$ T
                for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)
: T- s$ t# u" f' y# [$ K                    out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
: Q2 r  T6 }! v2 W3 r( A- Y        UF_CALL(UF_DRF_free_dimension(&info));9 X4 O8 s) r2 m- n

+ n- k0 r. `' c' Y        lw->WriteLine(out.str().c_str());
1 g0 Z3 x6 M: ?  o$ f: T+ M2 l# P
    } // while
' s; U3 A+ o& Q# P! q}" u" V% g& m/ p# B
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

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

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

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

    我知道了