PLM之家PLMHome-工业软件践行者

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

[复制链接]

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

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

admin 楼主

2015-8-22 12:47:05

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

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

x

) p9 E. w- D; u! s8 d+ i% RDimension* plmhome::select_a_dimension()% n9 d; D/ U) f! b( q
{! h, \0 i8 n0 R8 @4 y# v6 b
    // ask user to select a label
- ~8 ~: _$ j, G6 G6 |4 s    UI *ui = UI::GetUI();
0 S: K0 N9 P, H) C/ P% V2 V    Selection *sm = ui->SelectionManager();% o$ j! w7 g, b$ r2 w$ v
    NXMessageBox *mb = ui->NXMessageBox(); // as of NX5
; w- w% B0 X: y% F6 V0 {5 S2 R4 C
    NXString message("Select Dimension:");
& `$ U: x, ?% B* r1 ~    NXString title("Select Dimension");: \" l8 W2 k/ r5 H
    Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
6 a7 U+ a" q, u0 Q    Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
; E; b  O' y3 s0 x0 j# E    bool include_features = 0;
2 R! ^; `6 w/ Y0 t+ ]8 J    bool keep_highlighted = 0;6 d% v' M& P; A, E' M# a
2 E' H3 @* ^* K
    // Define the mask triple(s)
' y: _) S, i; e& X, G. z    std::vector<Selection::MaskTriple> mask(1);
5 V4 ?& l* C5 K1 x7 N- i+ m    mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );# Z1 b4 E, ?2 f5 J0 ~# V0 E
    Point3d cursor;
9 ^3 {* P# T; r# N% X3 }- t+ K1 ?    TaggedObject *object;: s8 }' X' C" x" G3 a, o- h/ X

3 l) N# ^: ?( r2 x- G: W) }    // Select objects using filter defined by mask triples/ k( I" E. j, |6 I
    Selection::Response res = sm->SelectTaggedObject(
- w- I6 E1 y; d1 Q" |        message, title, scope, action, include_features,- A/ ]7 f$ \( w) ^0 |2 C. l. b
            keep_highlighted, mask, &object, &cursor );$ ^4 q; Y" K1 T4 q  G

1 [7 G1 N. R9 v    if( res == Selection::ResponseObjectSelected )) [! H+ B9 Y( T% S' a- ~, g3 a/ q
    {
! M  i* M% S, l6 W        Annotations::Dimension *theDim;
4 q4 n! U( m& ?' R, E5 p' u3 H5 G8 w
, f6 h0 {: U! o) m: u        // this doesn't work and 'note' will be a zero pointer, see PR-1850850
8 m% I( Q' k/ Q- \9 j- P- t        //note = dynamic_cast<Annotations::PmiNote *>(object);
+ `! H0 [9 q2 N9 j1 s# \. N2 W4 Y! E6 ~: L5 J
        // this works as a workaround  W1 H1 f  ?, [* _
        theDim = (Annotations::Dimension *)(object);
4 o& M, K8 U; O( C! k% N( E  y% M        return theDim;
; Z! c( Q5 z- K4 r' z4 I    }
! |* m) G+ ?, f3 L
- E* `6 I) t! D& Z    return 0;
+ t! J1 }7 x" v5 {, X  q}% c& p2 \8 {: p; g; j+ ~% D

: J/ c/ o& b1 n# y2 K
! _8 \: ?; V; l! J$ j2 Y
0 ~9 ]9 _/ e  g
$ h: N+ z+ u& w2 p; [- X4 G5 ?void plmhome::do_it()
. N7 L) o- [$ X% h. \4 @1 l8 X{
% n) U; |9 r$ H' Z5 K    workPart = theSession->Parts()->Work();
+ p' ?" V% N8 v) m8 g* Q    Part *displayPart = theSession->Parts()->Display();
. z6 b0 @  o' ]' B) P. U! _& G    stringstream out;
; ?5 S9 ~- q8 b* ^9 g7 x    Dimension *theDim = 0;
1 P: p5 N; \& @: [8 A2 I* A2 ~9 ^/ E& R  M# H$ h% u
    NXString tolTypeStrings[] = + }" _! r1 }7 Y" s( x
    {
1 _* V* V3 s/ M7 M* C        "ToleranceTypeNone",
5 a6 m4 I2 U- }3 b# R        "ToleranceTypeLimitOneLine",
) ~* p: e' Q. U9 v# k) d  m        "ToleranceTypeLimitTwoLines",6 L1 l. i1 h* a0 ^1 V  i
        "ToleranceTypeBilateralOneLine",0 P) ]$ k) X/ p- q/ [
        "ToleranceTypeBilateralTwoLines",
8 F# e  q& ]% ]6 l5 d        "ToleranceTypeUnilateralAbove"," E4 W7 U* }" Z1 T+ ~
        "ToleranceTypeUnilateralBelow",; A, t4 c1 Z1 U3 ?# h& Z
        "ToleranceTypeBasic",
/ q$ s2 `  V) B- J! Y" ]% r' c        "ToleranceTypeReference",+ c3 ^" ]2 @2 M4 F
        "ToleranceTypeLimitLargerFirst",6 j& d! l( E' `% ]4 N4 V
        "ToleranceTypeLimitLargerBelow",8 L$ h8 o' ~4 H8 n$ ]8 g: \9 i. f
        "ToleranceTypeLimitsAndFits",8 K1 F( @' k7 y* c
        "ToleranceTypeNotToScale",  W8 y) g7 M, y3 H3 T3 f5 I0 H- |
        "ToleranceTypeDiameterReference",- `  W, ~3 d2 s3 |0 A
        "ToleranceTypeBasicNotToScale" ! g, ^# t2 T. ]1 t* n2 e
    };1 A5 O/ H& q" i) R$ |" s

. B; f* d  \1 }  C) n7 \    while( (theDim=select_a_dimension()) != 0 )
& B' @" G1 l. G1 k; _( L    {6 M( F7 H0 }1 L% b5 j
        out.str(""); out.clear();9 g: X( b( B6 O
        if(! lw->IsOpen() ) lw->Open();
2 J4 C" z# I% f/ j) k( E
; J6 n, y  m4 ^        out << "Selected Object: " << theDim->Tag() << endl;; U( {- @- X' w; Q
7 C% u8 X$ n2 ?0 u& ]% b
        std::vector<NXString> mainTextLines; & ~( r$ l: x' T9 T7 a4 Q! [# z  y
        std::vector<NXString> dualTextLines;
# D: i! \% d- s, q        theDim->GetDimensionText(mainTextLines, dualTextLines);
+ `. b1 O8 Z7 n! }/ z+ A        for( int ii=0; ii<mainTextLines.size(); ii++)
8 }& d) D' b+ }            out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
3 N8 I% s5 q# E- I3 G& Y, G2 A        for( int ii=0; ii<dualTextLines.size(); ii++)& H# K# m  Y; ^- f
            out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;7 o% r& y% A- _$ P* @: l7 U& }
6 \( T2 m, Y. t4 T1 @/ \
        bool refFlag = theDim->ReferenceDimensionFlag();
# g7 y, c1 ^4 v# B) }' e# n        out << " ReferenceDimensionFlag: " << refFlag << endl;5 H8 [: m' {: Z# t5 b, l7 [2 l

# L$ x0 O7 V! o  ?        int tolType = (int) theDim->ToleranceType();
/ A# V' A# s4 }1 E# X$ ]4 X        out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;6 |& k7 ~5 c4 ^7 o, c+ W( V

( l" Y# J0 J$ E0 i$ O* ~9 ^) G        ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);! Y7 V5 V2 k% e6 z' f# Q/ X
        std::vector<TexTComponent*> textComps = theData->GetTextComponents();3 N$ h' ?( y: J+ \
        for( int ii=0; ii<textComps.size(); ii++)7 E6 l9 W' O. v" h* Y
        {
- w. Y5 x' K0 v9 W% J! {            std::vector<NXString> compText = textComps[ii]->GetText();$ ]5 [3 [  r; R& _# x/ r/ c
            for( int jj=0; jj<compText.size(); jj++ )# Z; S2 h0 h6 k! R; o* q  E  k9 m
                out << " Component Text: " << compText[jj].GetText() << endl;
/ N* i) q8 `4 d7 V8 S2 {! g' N: d, _        }& Y- M+ n( I( I& k" ]# \

7 S$ j( Y8 U* [" ~        int subtype;
' {! i0 v  A0 ]* l        double origin[3];
5 ?( B! U" x5 C& b: i4 q        UF_DRF_dim_info_t *info;
) o; `  D& s9 U- v2 R        UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));9 N( y9 \8 @/ q4 K! C) ]! ?. h
        for (int ii = 0; ii<info->num_text; ii++)3 @6 s" @* ~7 Y( @( g
            if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)+ x0 c3 C0 h' X) F# e: }0 w: F
                for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)0 o% U/ T# X% \2 {2 i3 V8 ]
                    out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
- \0 n1 p, X, D3 w+ F& \4 M* f, C8 @        UF_CALL(UF_DRF_free_dimension(&info));
# s! P2 e7 g5 K+ j
# _0 a) X; \$ {# B. S        lw->WriteLine(out.str().c_str());3 E. s' P4 o8 E3 w
/ P6 v, L4 ~* K" L) r- u) ~
    } // while" G: w6 p! m6 j: u8 |8 q
}3 V# Q- v( v  l( S0 j
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了