PLM之家精品课程培训

PLM之家精品课程培训

联系电话:18301858168   |   QQ咨询:939801026
NX二次开发培训

NX二次开发培训

UFUN/NXOpen C++和实战案例

适合初级入门或想深入了解二次开发的工程师,本培训结合ufun,NXOpen C++,大量的实例及官方内部的开发技术。
公众号二维码

关注公众号

点击扫描二维码免费在线高清教程

课程详情
Catia二次开发培训

Catia二次开发培训

市场需求大,掌握核心技术前景广阔

Catia二次开发的市场需求大,人才稀缺。掌握开发技能潜力巨大,随着经验积累将在汽车、航空等领域有所作为。
B站二维码

在线原创B站视频

点击关注工业软件传道士主页

课程详情
Teamcenter培训

Teamcenter培训

全方位培训,从基础应用到高级开发全覆盖

涵盖用户应用基础培训、管理员基础培训、管理员高级培训及二次开发培训等全方位内容,由多年经验讲师打造。
QQ群二维码

加入同行交流

点击扫描二维码加入QQ群

课程详情
×

PLM之家plmhome公众号

课程涵盖: PLM之家所有原创视频

×

关注B站视频

所有高清视频一览无余,全部在线播放学习

×

加入PLM之家QQ群

同行交流,疑问解答,更多互助

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

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

[复制链接]

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

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

admin 楼主

2015-8-22 12:47:05

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

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

x
. N$ m8 d! h4 d9 I8 l5 u0 @
Dimension* plmhome::select_a_dimension()
! @1 T+ |! q' A2 n! T4 f' u{7 M1 j$ e3 @# E4 I, {
    // ask user to select a label' H. N7 H3 w5 d/ S. ~) ^
    UI *ui = UI::GetUI();7 T* N0 l2 ?. n: ^8 X9 k
    Selection *sm = ui->SelectionManager();, ]  G& d6 s1 A, M! I1 k
    NXMessageBox *mb = ui->NXMessageBox(); // as of NX5
) F- R/ x0 s% P' W
" x4 _* c3 l& d; U+ X6 g0 }) i9 |    NXString message("Select Dimension:");
" c+ A) G5 j+ O7 Z6 @: V/ T/ v" P    NXString title("Select Dimension");" M% e6 w5 S1 h( a: T& {
    Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;  @$ H& H; \( t; O/ Y5 h; J: _) d% {2 F& _
    Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;$ M+ T& L1 I; Q0 U8 k1 o5 Y1 r
    bool include_features = 0;. ~/ {: Q0 v; t
    bool keep_highlighted = 0;8 M5 i6 x, n( B1 M5 O

6 N7 F9 M0 v0 Y) \    // Define the mask triple(s); t- f% W$ s% ~7 U; {! {. A5 [
    std::vector<Selection::MaskTriple> mask(1);
" Z# C1 Y- T6 `; |- ]" i$ M    mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );  E2 d  ~1 ?+ G8 N
    Point3d cursor;5 f: |1 ^# ]" H) v. c/ A
    TaggedObject *object;' d- d2 Y4 r7 x7 |# A/ L$ }6 n/ d
5 f8 t! o& q4 o* U' J7 Z
    // Select objects using filter defined by mask triples
% H3 [$ D3 L$ C* k- i( u    Selection::Response res = sm->SelectTaggedObject(
6 `1 j! O; F- a/ T9 \/ ?        message, title, scope, action, include_features,0 q# R  N' G7 G# ~
            keep_highlighted, mask, &object, &cursor );
2 F# o$ p) I% B2 w: V# L) r$ Y0 I! G( |, i* _# A
    if( res == Selection::ResponseObjectSelected )+ ?' y. g( e1 g& E# ]
    {
! t9 O1 r8 [3 D) J        Annotations::Dimension *theDim;
9 c9 T' y- ~  k* |" c4 K
2 W, ?7 [/ u: f0 E  J        // this doesn't work and 'note' will be a zero pointer, see PR-1850850; H4 Z6 h9 |4 @' {
        //note = dynamic_cast<Annotations::PmiNote *>(object);) W. Z3 f' H/ K: O/ r

! k/ d4 Z" f, h" j8 u        // this works as a workaround
% a7 P" u' y( `7 D  T        theDim = (Annotations::Dimension *)(object);5 m1 K/ H( V: R1 P  M
        return theDim;
, M; o3 d8 d& r0 x    }# T$ Q# y7 u) d: C. |) _

! r! A; ]: q% f4 b3 J' h4 J/ u2 R    return 0;
% ]  [8 E* Y9 _7 Z0 }}: U- j0 ^0 J7 }, S$ l) U
# V! X0 S+ L& ?: N0 x( c3 f0 H( [
2 l( ~5 s" e" F/ l& C

7 S9 N$ I  k1 {, U+ M3 H- e3 A1 g
8 }/ G  S; b$ U' h) Vvoid plmhome::do_it()- i0 B$ ~# W2 B
{5 p: N. b, l4 T: o' \( U/ ]
    workPart = theSession->Parts()->Work();- q+ H' Y0 x8 Y% |  |
    Part *displayPart = theSession->Parts()->Display();" R, b, T) r. C1 i6 G  T. m6 X
    stringstream out;6 I% R0 ^) R3 R! O' t- j; b' A
    Dimension *theDim = 0;
1 k9 O0 }7 ?0 z, H% [- v
# Y" G$ `" J: q* W    NXString tolTypeStrings[] = 0 ]% w* v9 ?. q" f0 Z4 {( Y
    {
2 m$ ^" O- i" h/ m- H* R- |        "ToleranceTypeNone",2 H9 I3 H. j2 j" W: N/ I/ @
        "ToleranceTypeLimitOneLine",
, s5 R* `6 Y( `+ q* l        "ToleranceTypeLimitTwoLines",1 R( @; v; @9 c# r( K( }
        "ToleranceTypeBilateralOneLine",
0 M, }' G$ y* Z: K, O) Y& e! k2 ]        "ToleranceTypeBilateralTwoLines",0 \3 I. B: ^. D* S" D5 `9 k& j  Q2 S
        "ToleranceTypeUnilateralAbove",
  f; h* L( O: o1 \8 a        "ToleranceTypeUnilateralBelow",7 S% t3 |- \) E3 c* \& h$ J
        "ToleranceTypeBasic",
( S, X5 j: Y* o/ J2 z        "ToleranceTypeReference",, R: z4 B. A( V
        "ToleranceTypeLimitLargerFirst",
/ m# y* j; _1 w; S1 B. @        "ToleranceTypeLimitLargerBelow",! u0 b3 ?  `2 O5 n: T- }
        "ToleranceTypeLimitsAndFits",3 u# C4 ~# ?) h1 z; b
        "ToleranceTypeNotToScale",
) b- ]% L' n9 `7 v2 q        "ToleranceTypeDiameterReference",
* R: Q' n: [0 k" R3 P        "ToleranceTypeBasicNotToScale"
! Z" N: U% ^" Q% o' [( D; o) K    };, P7 r0 y) v" d$ i& i
% F& d& Y8 {8 W5 t1 C
    while( (theDim=select_a_dimension()) != 0 )
6 `. f+ w8 j! @6 u: F6 x" O$ \    {& T  O8 k$ {* I& A0 \
        out.str(""); out.clear();4 M% W  N0 l6 a4 k! X. O2 l
        if(! lw->IsOpen() ) lw->Open();
, }- B6 a: V5 d/ J" m4 O# _0 F, }; {' U' {# z0 }  Q- f
        out << "Selected Object: " << theDim->Tag() << endl;! c: I- U0 Z0 T4 y7 N

& T; `& ]5 o! P1 K5 B! f; n* A6 j        std::vector<NXString> mainTextLines;
8 Q8 [* n1 R- a2 I3 b" {        std::vector<NXString> dualTextLines;
& a9 M: S+ z( d& \! a        theDim->GetDimensionText(mainTextLines, dualTextLines);% I/ B; O# s# Z# ]2 H
        for( int ii=0; ii<mainTextLines.size(); ii++)
: a3 v( c$ a8 S$ v  F. m. w            out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
. R% V$ @: [6 x6 f( E, R) }& s        for( int ii=0; ii<dualTextLines.size(); ii++)
& }# o& ^" b8 _9 [8 k            out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;- ^7 V2 X1 K) K6 V/ ~  F4 E
  @# ?3 e2 v, I, J! L9 E* s; c
        bool refFlag = theDim->ReferenceDimensionFlag();& e0 r& N7 S6 |+ {# b# O, {- N
        out << " ReferenceDimensionFlag: " << refFlag << endl;9 v5 ~. v7 t- ?  M3 i$ c

- k/ f* R! O& S  I+ b        int tolType = (int) theDim->ToleranceType();
) G8 a# D. I$ a1 ~- n4 q        out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;+ o1 W# }' U! h) h" q

1 K; Q. I) R$ b5 z) P        ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);
- N( K( j9 Q2 E* O# `4 y, f  |        std::vector<TexTComponent*> textComps = theData->GetTextComponents();
) I2 u9 ~0 C# [; C7 E        for( int ii=0; ii<textComps.size(); ii++)
5 Z5 C/ q% g3 ]7 y- d        {
# ]6 Z8 i% f& Q4 k; c" @5 y            std::vector<NXString> compText = textComps[ii]->GetText();
8 E/ i0 N" t: T$ M            for( int jj=0; jj<compText.size(); jj++ )- C* w5 D, [4 U  c/ ~
                out << " Component Text: " << compText[jj].GetText() << endl;+ f' O2 S% G& t, {' ?; P
        }
9 @$ h+ K' W+ l( }9 \% R6 N
- o9 y8 t3 a! v* X5 ~        int subtype;
0 p' A3 G( W0 C6 F' |6 }6 f        double origin[3];9 J6 b0 F" b9 [( {' C, ]. ~0 a6 u
        UF_DRF_dim_info_t *info;
  W' m  c# }- G8 N( h7 e. `. m        UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));. U( ~8 j$ b9 T
        for (int ii = 0; ii<info->num_text; ii++)& W" q( ^* L; \' L& {9 X
            if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)* p+ B+ ?9 X- r1 |
                for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)' ]/ D; H  f+ S) v
                    out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
5 p, o. X; W  j; r$ @' J/ u        UF_CALL(UF_DRF_free_dimension(&info));+ m" P" U1 B4 B6 e

, K0 X5 p: ~" m3 I) P$ w        lw->WriteLine(out.str().c_str());- i' t0 `7 d- I% x" y

' t3 `4 r- F* o: S* U    } // while
" u+ ~/ {# [7 M+ q. k5 p# J3 x}5 v9 |  s/ L8 |1 }
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了