PLM之家精品课程培训,联系电话:18301858168 QQ: 939801026

  • NX二次开培训

    NX二次开培训

    适合初级入门或想深入了解二次开发的工程师,本培训结合ufun,NXOpen C++,大量的实例及官方内部的开发技术对于老鸟也值得借鉴!.

    NX CAM二次开发培训报名 NX二次开发基础培训报名
  • PLM之家Catia CAA二次开发培训

    Catia二次开发培训

    Catia二次开发的市场大,这方面开发人才少,难度大。所以只要你掌握了开发,那么潜力巨大,随着时间的积累,你必将有所用武之地!

  • PLM之Teamcenter最佳学习方案

    Teamcenter培训

    用户应用基础培训,管理员基础培训,管理员高级培训,二次开发培训应有尽有,只要你感兴趣肯学习,专业多年经验大师级打造!

  • PLM之Tecnomatix制造领域培训

    Tecnomatix培训

    想了解制造领域数字化吗?想了解工厂,生产线设计吗?数字化双胞胎,工业4.0吗?我们的课程虚位以待!

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

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

[复制链接]

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

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

admin 楼主

2015-8-22 12:47:05

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

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

x
+ b; |1 y2 ^3 r9 T  ^' n, `8 V
Dimension* plmhome::select_a_dimension()
0 _8 F9 X' r# I& l2 k; w+ S{( Q0 W0 `' Y! \% h3 \
    // ask user to select a label
" x/ Z/ Z) j) i3 ~1 p# r6 B+ I9 F    UI *ui = UI::GetUI();
9 J, S) _4 U/ n  Y: @    Selection *sm = ui->SelectionManager();
2 G. @" o# |- r9 I/ Y+ D5 w8 X    NXMessageBox *mb = ui->NXMessageBox(); // as of NX5
# h1 b: b: V! W
9 r3 u* j- |1 \0 Z    NXString message("Select Dimension:");  X9 W$ r2 \& o: P1 j
    NXString title("Select Dimension");
2 f$ M7 c( P4 J; Y" `; l+ u    Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;5 r. K. v" k* u( Z
    Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
! E1 Y3 N3 b1 K9 C/ ^9 G    bool include_features = 0;: K) d1 F  z; f. {  u# h, f
    bool keep_highlighted = 0;8 T/ J% a* \, x$ Q

- Y( P- f' w5 R    // Define the mask triple(s), K  `. U+ [) D6 f( _" N
    std::vector<Selection::MaskTriple> mask(1);- p* I* [5 T+ r9 Z
    mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );& `- y- F/ Q: G: F4 T7 I
    Point3d cursor;, {* n- `# l/ N7 j! l
    TaggedObject *object;
4 n8 k" ]% K, Q8 Q! A) p  ]5 F4 v, Q. }; [- B- h
    // Select objects using filter defined by mask triples1 z) L7 H" H8 C5 O
    Selection::Response res = sm->SelectTaggedObject(
9 j0 g! o% l4 o+ g2 E( t        message, title, scope, action, include_features,
3 I5 y% u( Y3 g# Z* l. w  ?            keep_highlighted, mask, &object, &cursor );
2 W5 ~4 M3 ^' t( b7 h( s2 Q* [5 C- ^! f1 o2 d4 l
    if( res == Selection::ResponseObjectSelected )
8 B. [& i4 J! A9 _/ [9 u    {
/ ?( T9 ~! [9 A        Annotations::Dimension *theDim;
& ~+ Y8 z; }  l/ C" ~
& ?8 ^, H6 l6 N1 k. A  V        // this doesn't work and 'note' will be a zero pointer, see PR-1850850' {4 i! r. n- _! r5 N4 V% ^
        //note = dynamic_cast<Annotations::PmiNote *>(object);7 w" v9 t& Q3 i( L1 }0 j7 S

# z" F; E3 G8 X4 R5 m; X$ H* @- |        // this works as a workaround1 Z/ M" m" v0 D9 I  i0 [
        theDim = (Annotations::Dimension *)(object);5 L  h5 }/ m0 g- L& l  d, J% K
        return theDim;" z$ t0 f) K5 O! u1 F5 W- X5 ^* E
    }8 N7 D5 r& [  E
3 O$ q, P& N7 H) h0 @& Z
    return 0;
4 g5 ^4 P7 T9 ^% F- L}
3 v6 ^' _7 E9 ^; p/ M) K  I2 l
8 Z7 U, V0 d- t& q: R, E4 P- j8 w/ H3 R' n

2 t9 M6 {: f. y' a0 W
/ i) ^) `  G* m! W5 A" W: Rvoid plmhome::do_it()
8 c9 g2 ^6 M3 X, F1 v. H{; h6 Y1 f$ M$ z5 u/ }
    workPart = theSession->Parts()->Work();
. p* n/ O0 m3 H) @7 y% o    Part *displayPart = theSession->Parts()->Display();: g# ]/ e. h' T" z
    stringstream out;
: e  V; V. E) d( D9 l    Dimension *theDim = 0;9 S' J# U* @# R& J! @1 Z3 ^

) v2 }9 y! k$ @0 L& m1 }/ M    NXString tolTypeStrings[] =
. J6 y& H7 c/ K+ j: Y4 ?7 U3 g    {& \) _& x5 N, _* ~) L$ W3 ^
        "ToleranceTypeNone",3 x7 [4 P5 h% N2 V5 `$ K
        "ToleranceTypeLimitOneLine",
0 K6 a; q3 l, J$ _/ Y        "ToleranceTypeLimitTwoLines",
& L6 G3 L1 o8 \" r3 N0 [        "ToleranceTypeBilateralOneLine",9 ~7 C# @5 [0 N9 [) {/ V% N" d& {
        "ToleranceTypeBilateralTwoLines",
6 D& Q' w. v  C; W  _        "ToleranceTypeUnilateralAbove",
; a' u- ?0 L' ~4 n; k/ w( Z' L        "ToleranceTypeUnilateralBelow",, j& W( g* h8 L" m
        "ToleranceTypeBasic",
( \! l* u5 |/ W* P        "ToleranceTypeReference",; N& @& v: F7 e7 V
        "ToleranceTypeLimitLargerFirst",5 f  ]4 Y6 a( |; J  d: Z, ~* _0 n
        "ToleranceTypeLimitLargerBelow",
9 ^( a. P6 I3 e) X% `5 s        "ToleranceTypeLimitsAndFits",, F0 l& }! ], F* `6 c
        "ToleranceTypeNotToScale",) Q. \' i( U4 V  \* F+ X& P
        "ToleranceTypeDiameterReference",
3 b1 C! G) T- t: P( J: A# b        "ToleranceTypeBasicNotToScale"
8 f, `0 X, b$ }/ K. U    };
& s" S5 U. k5 R, X/ s% E3 S# f# S* U- b: u- x& }7 a
    while( (theDim=select_a_dimension()) != 0 )! S2 k' a# m5 Q' L- x) f1 S
    {
0 g" e) z4 G- T5 b        out.str(""); out.clear();
# t) D8 e$ h& [5 j" a        if(! lw->IsOpen() ) lw->Open();: G& w! A3 ^/ {0 s
! W* o7 w( |, ?3 N3 `
        out << "Selected Object: " << theDim->Tag() << endl;- s- ^! I* u8 V+ w+ n5 R9 o' V, x; e
- M5 B) b0 ]) X1 h- [6 w
        std::vector<NXString> mainTextLines; 0 @2 I. I. J5 f% T( U0 m2 m
        std::vector<NXString> dualTextLines;
# T. ~4 u' O5 w        theDim->GetDimensionText(mainTextLines, dualTextLines);
$ O7 [7 U6 i# E5 R7 |( o        for( int ii=0; ii<mainTextLines.size(); ii++)
; {+ i5 e5 `' p- U% Y            out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
6 `. D" S# z* j  |$ Q        for( int ii=0; ii<dualTextLines.size(); ii++)  j) j2 |, q! a  e
            out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;( N* T$ g! \: T, a+ S) S0 Y

4 V5 h; Q0 C3 \$ F9 a, m' V  a) K        bool refFlag = theDim->ReferenceDimensionFlag();
: G- P  N2 V1 G        out << " ReferenceDimensionFlag: " << refFlag << endl;; P0 a% j- w1 Q; [* q  ?: Q8 c
+ Z6 }6 A: ^" O4 I  x5 @- o
        int tolType = (int) theDim->ToleranceType();
4 c  V* Z% f6 c& Z2 J" d        out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;  g7 }- m( `* }' D

$ c& C' e* q" F6 G        ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);
( \* [6 K. d: m9 z0 F7 ^        std::vector<TexTComponent*> textComps = theData->GetTextComponents();
1 f% u6 Y2 M$ I7 f        for( int ii=0; ii<textComps.size(); ii++). q0 \: j8 E7 ?# [5 X
        {
8 I. C1 U! |' K' j6 g4 f8 ~( \( n: h            std::vector<NXString> compText = textComps[ii]->GetText();2 U* l! Y; V( S/ d
            for( int jj=0; jj<compText.size(); jj++ )
" [! O9 I# P+ D5 `% N. x! q                out << " Component Text: " << compText[jj].GetText() << endl;
" X% O: T) F3 {: Q        }
+ y$ _5 x. @8 P2 j
- K1 Z( w# N/ u, `4 a! R        int subtype;
7 R: }) O9 @* I& i( D, ]        double origin[3];
- b9 s. `3 I7 [3 I8 H1 G6 c        UF_DRF_dim_info_t *info;) S0 r/ z8 y) b" p5 W! G
        UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));3 d5 l+ J, H% Y& p0 C: |
        for (int ii = 0; ii<info->num_text; ii++)
2 V5 q  {+ U0 m6 w% r            if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)
; t3 e; L/ M1 @* Q0 ~* ]0 k$ a                for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)* ]) m4 n% `& a' ~$ s" U0 z2 @
                    out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;: ~1 j4 |+ ?. U$ j6 h
        UF_CALL(UF_DRF_free_dimension(&info));
- X2 z; f7 t- P+ I0 g. |* f# Q
2 ^8 {* l; m2 a        lw->WriteLine(out.str().c_str());9 z! V+ F* Y. J7 I  X+ q1 Z( x3 I# R
# k+ x+ g/ M8 w# l* h2 X1 x
    } // while5 m# H  D" R4 X" x/ R% L0 S/ ]
}' [: ~  R; C: Q2 _) K" B
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了