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

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

[复制链接]

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

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

admin 楼主

2015-8-22 12:47:05

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

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

x

1 [1 h" w, e9 _0 T1 [( l$ RDimension* plmhome::select_a_dimension(); r9 [$ z+ Z7 Z; L! b) r
{6 h' L# {; s) H+ h4 W& A
    // ask user to select a label# k9 V4 v8 w* a: K/ A1 i
    UI *ui = UI::GetUI();( [+ ~$ |. H1 y# O
    Selection *sm = ui->SelectionManager();5 |, a: i9 A% x; h, O& c
    NXMessageBox *mb = ui->NXMessageBox(); // as of NX5
: B- P" i" V- c/ Z/ N& F$ d: M' F. z$ R! E( x! P0 o3 [1 n; e
    NXString message("Select Dimension:");
6 F) s. F, n; d7 i    NXString title("Select Dimension");) W+ r3 B2 x1 ~- Z
    Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
  \* {1 y5 x' Q$ s9 [    Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
8 n0 B3 A$ ^: m1 P    bool include_features = 0;
  H1 |& G( Q( q" `8 l' c& q% L% P    bool keep_highlighted = 0;
2 t* S" r1 N8 ]' }& f" p1 Z( `4 t5 h
    // Define the mask triple(s)9 Z, |' ?- c6 s" j3 a1 o& c) c
    std::vector<Selection::MaskTriple> mask(1);
2 c5 u6 B7 W/ X9 R    mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );4 x# l# m# j; \( h7 H' b
    Point3d cursor;
) R( Q" V2 s, p$ n1 y    TaggedObject *object;
, f& i# L# E) l( s  l
! u& L/ R$ K5 T1 x    // Select objects using filter defined by mask triples
- ]* I( I0 _4 ?4 `6 y( A' h2 }$ r7 d- X/ P    Selection::Response res = sm->SelectTaggedObject(! h1 f; |) l; A" P
        message, title, scope, action, include_features," [9 ^/ i( s3 v, g1 g& b
            keep_highlighted, mask, &object, &cursor );
" u3 c* Q; q2 R( I- d3 e
4 ?4 C) N; R* Q% _3 T. U! |) Z; |    if( res == Selection::ResponseObjectSelected )
% _% O1 ?8 s0 e: h    {7 p; _* i! C4 `9 r4 t+ w
        Annotations::Dimension *theDim;
5 b4 V3 c( j  c7 Z2 H; }
5 A# f2 C. O6 s+ E! K        // this doesn't work and 'note' will be a zero pointer, see PR-1850850
3 C# \9 r: y& L: [+ f& ?        //note = dynamic_cast<Annotations::PmiNote *>(object);
2 j) h0 V' Y/ k
# \9 H6 i, }) T5 M  U. Y        // this works as a workaround
" s( A" ?5 D" I$ l( u3 F1 _9 R5 E        theDim = (Annotations::Dimension *)(object);- s- G3 q8 j# Q% b- [7 |
        return theDim;3 |6 B9 \% ]3 r; v% L
    }
9 N, s2 b( O! T0 x' C4 T* C
) j1 s: R! X6 W    return 0;
- d" _* t5 g  k0 L}
9 P2 W5 k5 q, O& Q. [* T/ L8 `) ~

+ B% K, |( p: I7 [7 W5 G
$ o0 i; e5 ^# W! @/ A) L0 H0 J2 L+ m6 B+ I# z7 @
void plmhome::do_it()
3 C8 o+ X5 [, d! \5 {9 H{3 z: I) i' s( U5 U
    workPart = theSession->Parts()->Work();
% e3 }- \9 j: D/ N' V) L4 k$ D    Part *displayPart = theSession->Parts()->Display();
# J" ?; l/ {- s) R( A    stringstream out;  ], C  W$ A: h. }+ M
    Dimension *theDim = 0;$ y# s1 ]' {# h9 _0 G5 W. Q# M
, E: K  T/ M3 t% i' B* J; U
    NXString tolTypeStrings[] = 8 `' z: R7 x# k5 F( n5 H
    {
2 E/ r6 h4 u$ s- w6 q        "ToleranceTypeNone",
: \8 d$ `$ \: J! n# R8 W# X        "ToleranceTypeLimitOneLine",6 y! m7 Y4 ~- ], r  U7 h7 T
        "ToleranceTypeLimitTwoLines",. Y# v+ D0 ?$ W& o1 T$ M- y
        "ToleranceTypeBilateralOneLine",
  o' U  F8 d  R5 O& Q1 T        "ToleranceTypeBilateralTwoLines",: m8 U* a. x! @. J  u
        "ToleranceTypeUnilateralAbove",' _, D+ ^" |) ~; j7 m( r& Q# F9 \! T: h( p
        "ToleranceTypeUnilateralBelow",9 ^& b' @9 j5 W2 A4 A" ]# @
        "ToleranceTypeBasic",6 q9 E5 `$ ?3 W0 g5 z
        "ToleranceTypeReference",9 D; L+ K& ?( W. y' [0 C9 P  V& ^
        "ToleranceTypeLimitLargerFirst",3 T  |+ G+ B, }* @, y7 a
        "ToleranceTypeLimitLargerBelow",/ f& v% g1 n/ }, p
        "ToleranceTypeLimitsAndFits",
% j% ?1 a  G, V. z3 i        "ToleranceTypeNotToScale",6 t  D, L( P$ m. d' E# T) Z5 F
        "ToleranceTypeDiameterReference",& Y- c3 J! Y7 }4 S* ]
        "ToleranceTypeBasicNotToScale"
& |8 Q  a% i5 ^8 p# `    };) }' ^6 K7 b/ g# n
3 y" n( G! U8 ^' [( N' F% w$ b
    while( (theDim=select_a_dimension()) != 0 )
' _; r. Z' p0 d7 q+ l    {  o/ b1 p' ^. Z; V
        out.str(""); out.clear();
8 h8 N5 V3 a1 m) @7 ^2 E        if(! lw->IsOpen() ) lw->Open();5 |! L! K( m8 z6 T
, b9 e  z: \0 P3 x+ H- K3 }8 g( P: s
        out << "Selected Object: " << theDim->Tag() << endl;1 M- n: J3 i2 `1 |5 f! z; o$ K
; N2 W! }' f- X6 _! I
        std::vector<NXString> mainTextLines; * j" @$ H, c; j! K. a0 g
        std::vector<NXString> dualTextLines;
- X1 D& P0 O' L* Y# `  A! ^$ Y* O8 }        theDim->GetDimensionText(mainTextLines, dualTextLines);
, N; h& V2 _6 H- u9 p1 ~& D  {        for( int ii=0; ii<mainTextLines.size(); ii++)) S+ ?( D0 v* O
            out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
% F+ L1 p: X$ p/ ^% l/ |( V! z        for( int ii=0; ii<dualTextLines.size(); ii++)1 Q5 ^' c+ f) G' I- W6 q" D
            out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;) ^5 \. ?, ^8 `- g) T$ l: I

6 Y0 x# q/ ?- N0 l( x( B1 U+ Q        bool refFlag = theDim->ReferenceDimensionFlag();, P) q3 I- |: X" G' D: {) J9 O7 I
        out << " ReferenceDimensionFlag: " << refFlag << endl;5 R, r! ?" L4 x0 s3 h
* N" j. z1 k* n/ f4 p
        int tolType = (int) theDim->ToleranceType();! X- [6 q3 ^$ h+ L7 o
        out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;/ |! V& I+ Z2 S/ Q( W, I! ?( `' `

& d: H  J1 j/ W6 A' q        ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);
: V8 s7 G/ e2 a! |4 ~; J6 a8 b        std::vector<TexTComponent*> textComps = theData->GetTextComponents();, }  p! `6 U' {# z0 g
        for( int ii=0; ii<textComps.size(); ii++)" U3 B9 S$ W: e- Q
        {
% O. U2 M- h- u9 h6 [            std::vector<NXString> compText = textComps[ii]->GetText();+ b5 Z1 x0 S' ^+ I5 d( x
            for( int jj=0; jj<compText.size(); jj++ )
# c5 g1 I0 Q% R9 H+ p: n                out << " Component Text: " << compText[jj].GetText() << endl;
4 ]& H# z: O- J! w' n# c        }
0 o* C& M4 e+ b* c( \
6 M5 E  ~& S" V2 V' L. c        int subtype;6 J. H' a( d2 w. C3 K" s  w
        double origin[3];
& s0 v3 l$ o- |" ]# b: P2 G        UF_DRF_dim_info_t *info;
4 [7 h$ N% i9 v0 _" G" C) g        UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));: V, w$ m  u" C2 _, H
        for (int ii = 0; ii<info->num_text; ii++)
8 ^  X) {. i5 u            if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)
" G, z( |# A8 R0 j) _# C! n3 E2 I                for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)
- X. ^2 ?2 z) v8 ]0 \                    out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;8 I% |! P$ u6 r# V
        UF_CALL(UF_DRF_free_dimension(&info));$ V; x9 _6 w$ F8 O( v8 c0 r

% `2 B, E' N; E. K        lw->WriteLine(out.str().c_str());; t* y5 `$ E! C- p" `

$ q* `( U; R  `9 P" @' N! H2 j    } // while
- @3 t& x, o4 k4 A) H) @}
! U* l- @3 S; ~' \0 w9 y& G
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了