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

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

[复制链接]

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

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

admin 楼主

2015-8-22 12:47:05

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

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

x
: Z" ?! H; b, e9 E3 X. K; K3 y
Dimension* plmhome::select_a_dimension()
" w& z5 t$ ^8 W9 m2 p! i{
2 P" b2 x/ K! y( |* D4 J    // ask user to select a label
2 V* w) T3 i( l0 U    UI *ui = UI::GetUI();7 W2 s# b$ H' h# X& |3 ?) J, _  |
    Selection *sm = ui->SelectionManager();4 E  _/ C7 r" F3 B0 t- ~9 O6 s# `
    NXMessageBox *mb = ui->NXMessageBox(); // as of NX5
; w4 Q  W; U# G0 ~0 @- z
6 G( @+ m& o$ |6 S, S4 D    NXString message("Select Dimension:");% Z: A* a9 I/ [$ |9 q6 ~0 x
    NXString title("Select Dimension");
: `: l- L( c7 v7 {- a    Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
0 a2 w& Q" G9 X. g    Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
5 Q7 \9 t  z9 W    bool include_features = 0;
0 Y0 B9 R- u$ d- r7 F5 f    bool keep_highlighted = 0;
" ^" T" b6 g- H  J& {
* d) u! w# [; ]/ k    // Define the mask triple(s)$ ]1 z4 M$ }! ]8 t" s. |) D; Q* F
    std::vector<Selection::MaskTriple> mask(1);3 _% W$ Y# s3 }
    mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );
- Y/ `" G" B$ S; N4 @: D    Point3d cursor;
! {+ o  c. a: C    TaggedObject *object;
& N: s- K. H% u! Q! o+ h4 S
' I8 A; @( g+ @2 x8 J    // Select objects using filter defined by mask triples
! u! }5 u5 m% l9 V( ^    Selection::Response res = sm->SelectTaggedObject(2 S' {8 m$ P  P4 {
        message, title, scope, action, include_features,
- g$ [1 [& G( I1 K            keep_highlighted, mask, &object, &cursor );! @# d  K  R2 D; H! n

, k4 c: @1 P# ^! n+ {( A    if( res == Selection::ResponseObjectSelected )
( k, H+ T! Y. h# f, `- I; C# j    {
; s) N7 X: F  Z; C( V+ c0 y7 c8 i        Annotations::Dimension *theDim;
2 l5 ^% I  L5 \. S5 Q  ~
: F" z& G$ Q- t9 S! I- a        // this doesn't work and 'note' will be a zero pointer, see PR-1850850
) ^& Y% t. K5 M9 E: b+ Q9 H" m9 Z        //note = dynamic_cast<Annotations::PmiNote *>(object);5 v9 N* a! j" }0 n+ k! N9 m
0 O, Q5 ~3 D, l, R4 T6 F
        // this works as a workaround) c& q$ m  P- [, ^8 Y$ G7 s- w
        theDim = (Annotations::Dimension *)(object);
' \& Y2 m2 i  p- ?0 H( c  q" ?        return theDim;; ?4 X9 x3 c6 T$ R' R7 D
    }5 p5 F) F5 ~0 m+ O
3 K) m; j* x4 S9 w; r
    return 0;
4 U0 K0 @! N8 M/ u: p}
! Z7 H8 Z. M* M1 V) P: d. c" W! I; ?) a( M
0 p, D2 J6 ~# u+ C
( M& X$ V; A) X* F5 S4 m5 \

0 l9 {, C# Z; ~( q( Ivoid plmhome::do_it()( h8 u% S/ c/ \5 Y6 P
{
9 ^2 h; N8 }* G. f    workPart = theSession->Parts()->Work();6 e/ M+ _# c7 J
    Part *displayPart = theSession->Parts()->Display();, T' H6 X8 s) c9 ]* m8 {7 {
    stringstream out;
- ^. I3 Q" l7 S    Dimension *theDim = 0;8 {  Y' p% w; L$ C. w" n
* C$ b' I! w$ r- L9 E
    NXString tolTypeStrings[] = 5 i3 N6 Q7 L( S5 J
    {- I+ Z" ]! d2 S9 p4 i+ H
        "ToleranceTypeNone",
* }8 M% f9 V; f7 X8 l        "ToleranceTypeLimitOneLine",: k3 Y3 l) d" U# r( n1 F3 C/ }
        "ToleranceTypeLimitTwoLines",
4 A2 A1 ?+ ]' n- n5 y5 O2 U& A- _' ~        "ToleranceTypeBilateralOneLine",
7 N. l1 k/ f8 q! V. \4 ~        "ToleranceTypeBilateralTwoLines",; m  v) c% f' x; ~; n
        "ToleranceTypeUnilateralAbove",
+ T+ a" S% P7 U0 O! p) v0 u        "ToleranceTypeUnilateralBelow",8 O/ H! S. V: {. b6 a
        "ToleranceTypeBasic",% e# r2 e) p% |1 _
        "ToleranceTypeReference",
  }. \2 H5 ]: u1 e9 n        "ToleranceTypeLimitLargerFirst",7 o" w; x2 M1 }8 F
        "ToleranceTypeLimitLargerBelow",
3 ~* t, w8 q: ?& {/ C        "ToleranceTypeLimitsAndFits",1 i4 j* k& J3 E. V
        "ToleranceTypeNotToScale",, o8 W7 L* ~. ~% [
        "ToleranceTypeDiameterReference",
: u0 ^) Y3 T; e3 Z6 H        "ToleranceTypeBasicNotToScale" 1 A# _' {' l( @- Z
    };
+ h5 ?; _7 v0 ~1 Q
8 p1 U; }8 q8 u, R( S: T    while( (theDim=select_a_dimension()) != 0 )
7 h8 y- \# e" h' M: G6 G1 Q    {
$ Y6 @! t: ~6 y# e& a" P* ^3 {        out.str(""); out.clear();! t! n7 \! @& u' G# x- j( \
        if(! lw->IsOpen() ) lw->Open();7 P4 Q8 \/ P) g) ?% L- V

' \6 H) b. ]9 w" i        out << "Selected Object: " << theDim->Tag() << endl;
+ T# Y: X: t. F+ B0 `; [$ U* r4 [% X, {* a
        std::vector<NXString> mainTextLines; * J0 }* e! Z$ }) i2 U  |. d
        std::vector<NXString> dualTextLines; : ]) n: H$ {# Y: b, e! K6 E& ~
        theDim->GetDimensionText(mainTextLines, dualTextLines);
3 F: E6 Z) \1 _( C        for( int ii=0; ii<mainTextLines.size(); ii++)
' E% i  q6 P( N" }' T            out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;/ y$ F$ x* ]# L
        for( int ii=0; ii<dualTextLines.size(); ii++)
. T* ?% M. e3 v8 C1 G% X            out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;$ z; [! p# ~! Y% [9 _" w
# b( Y  c' v6 D( m
        bool refFlag = theDim->ReferenceDimensionFlag();
0 m# n/ U, C& X        out << " ReferenceDimensionFlag: " << refFlag << endl;  ^4 V0 J+ D' h& V8 P+ }  F; J: x7 y
. ]/ Q  \9 z. g8 y
        int tolType = (int) theDim->ToleranceType();) c# q) W3 v9 |( q) m1 [" ?
        out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;8 C: Y6 N% |& R; r9 K9 d5 y1 q
$ l, h9 u3 C1 E  S* l% |5 v. k
        ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);' p+ e8 V; s! z  B7 }: L1 ~
        std::vector<TexTComponent*> textComps = theData->GetTextComponents();2 v, Q0 {; [1 O
        for( int ii=0; ii<textComps.size(); ii++)9 e6 Z9 s2 Y/ f; i' ?! y
        {) t6 h* X9 w. ]1 K
            std::vector<NXString> compText = textComps[ii]->GetText();0 Z9 _  N/ t* V1 L: @  z
            for( int jj=0; jj<compText.size(); jj++ )! U  L  t* P% f' D6 K0 y
                out << " Component Text: " << compText[jj].GetText() << endl;7 w/ q4 ?7 Q$ @. \! W0 V  J6 f
        }
; @9 q, B7 l6 U0 Y; n7 b7 T+ g! ~# U5 z6 ~+ ?
        int subtype;
% w0 a( y; q$ y/ q/ N! a" R        double origin[3];
( V* }1 ^" ~0 d' M! i1 |" y1 I        UF_DRF_dim_info_t *info;9 N3 l' g' B$ N! I( R# w7 q
        UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));8 O0 W& y8 w  |5 N6 k$ I6 l& Z
        for (int ii = 0; ii<info->num_text; ii++); e/ ?' x; I4 g
            if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)) [# A2 `- o& j0 z" [) ~4 O
                for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)- U6 |9 ~/ Q. }3 C/ e
                    out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;% L  b- d2 [6 G  L
        UF_CALL(UF_DRF_free_dimension(&info));. u8 ?7 g$ B* X! T( E, V. L
1 j$ D+ Q$ M) ^5 t4 `
        lw->WriteLine(out.str().c_str());
% |$ m4 o8 p5 |5 _, M7 w! k4 K8 `( R1 x0 F5 [
    } // while$ C+ O" j; x3 H& Z/ |
}
; l. D0 o- T1 f- ]* U  N
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了