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

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

[复制链接]

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

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

admin 楼主

2015-8-22 12:47:05

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

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

x

2 R) [1 E3 ]) T' }Dimension* plmhome::select_a_dimension()8 P6 T, H$ ^0 [/ J+ P3 r
{. \1 f5 y. F( B" J+ L4 B
    // ask user to select a label
% J2 k% V8 K- \' |9 b0 g    UI *ui = UI::GetUI();* `! t( U8 V3 P
    Selection *sm = ui->SelectionManager();
5 I% J0 ]6 O  J1 L$ O    NXMessageBox *mb = ui->NXMessageBox(); // as of NX5
$ z5 z9 G2 Q- z5 J! a9 z
$ g- u; M  v% L6 ?    NXString message("Select Dimension:");' f4 T0 h9 l5 L6 P
    NXString title("Select Dimension");
; j% v3 G: }7 [8 K    Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
0 B, g1 v/ N0 y( @6 [0 {  M    Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;0 Z7 g+ ?9 B5 @! E! f5 }: a8 N
    bool include_features = 0;$ W9 m% f( r& _. s
    bool keep_highlighted = 0;9 A: @* q6 ?4 D1 F, y# p) H, I8 P5 B

7 @- {1 H8 D+ j- K( r# w) i    // Define the mask triple(s)
- K4 Z2 l. n- u% F0 ]    std::vector<Selection::MaskTriple> mask(1);1 }" w" I2 J6 F6 Z/ m
    mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );7 S+ ]9 L; |7 @2 B
    Point3d cursor;" A! z: A( C6 t2 e; [7 t% X0 {
    TaggedObject *object;7 x& k+ T, k5 K0 z, A. X5 y. o' _, H

5 ], }. p+ t! p% K/ p; S6 r    // Select objects using filter defined by mask triples9 |: A$ ]! R; X; k% d& B6 b
    Selection::Response res = sm->SelectTaggedObject(, P+ A4 @( a, f) Z+ a
        message, title, scope, action, include_features,5 C, t  V3 F+ v7 J! X( K
            keep_highlighted, mask, &object, &cursor );; l* ^) N! m9 x. b1 j: ~* [* R& q) S9 V

. {" |3 z4 G% v0 a7 c8 R; ~4 }    if( res == Selection::ResponseObjectSelected )
2 L9 a7 U. I: J    {
- g$ v% Q0 M& H" Y. f        Annotations::Dimension *theDim;9 D8 k8 o3 T4 M$ _4 w+ X8 P# p

0 K) B! {. \5 u1 @# y        // this doesn't work and 'note' will be a zero pointer, see PR-1850850
6 }9 x# V6 x6 ]6 U        //note = dynamic_cast<Annotations::PmiNote *>(object);! [& q( c& l/ f. V& Q
! B8 q7 D5 _4 `1 `7 r- J2 p0 a% h
        // this works as a workaround
2 o, k7 M$ D  b2 ]% N: i        theDim = (Annotations::Dimension *)(object);
5 \$ e! g* `; ?0 m$ X        return theDim;
) u6 r# R  I9 y2 |: S    }5 ]/ i7 X* C3 E" r
: ^: z' p* x0 @# Y. @+ d4 f- K
    return 0;# M% Y" h$ D  |! h9 L% Y( ^# L/ b
}
% J. h; @, {" i) y
4 {8 {: G) J9 l4 g# K/ u
& ~/ R# j( V/ f" T
! O( [: c) x* G4 ?( l) _
7 k3 ~# T  a% w0 X+ ]. }void plmhome::do_it()
" @/ t8 _: X& B{
& z& u% {: D) x/ c' D0 I* \    workPart = theSession->Parts()->Work();
+ }" y" }. i) h' P+ m0 S    Part *displayPart = theSession->Parts()->Display();
: F% f4 D2 W# A1 r' L    stringstream out;
9 y& [7 a3 }* \7 ^. p    Dimension *theDim = 0;# Q# Y+ c7 E2 l1 |7 ^% H
' Z# V; h* [& p
    NXString tolTypeStrings[] = + ~  C2 K7 T6 o* j% [1 o
    {# P2 Z! D/ N! p, e( [2 V; r. z3 o
        "ToleranceTypeNone",
/ q0 \. Z, ^& Z3 O& j        "ToleranceTypeLimitOneLine",
( V0 [. k, O/ R/ q; A" \        "ToleranceTypeLimitTwoLines",
- `+ p7 C+ W3 n7 I7 s- e& B: I) n' t% [        "ToleranceTypeBilateralOneLine",
- A4 R$ G- L8 t5 G3 h5 N. h        "ToleranceTypeBilateralTwoLines",
; h9 o' }; A: l, n& R        "ToleranceTypeUnilateralAbove",( |, ?! Q+ i/ o) a. |) \( E
        "ToleranceTypeUnilateralBelow",( d" \# x$ {* r0 V2 [
        "ToleranceTypeBasic",4 I# B" Q& ~3 v- C: }  X
        "ToleranceTypeReference",
9 b( y# W# q7 Y( j$ F# f        "ToleranceTypeLimitLargerFirst",
( Q8 K) r; r0 l5 [- Q* Z3 z        "ToleranceTypeLimitLargerBelow",
* w7 O! D6 \+ H; R, C) R        "ToleranceTypeLimitsAndFits",4 {3 y1 y1 |8 T2 R6 R, o
        "ToleranceTypeNotToScale",
' Y8 t5 ^* v: m/ C, v8 g        "ToleranceTypeDiameterReference",) o% _, P! G( m) {& ?5 q+ l+ s$ c
        "ToleranceTypeBasicNotToScale"
; J, }  y2 Q9 y. d( p" R% M    };
9 Y/ e( F% h$ a
& [; D% O$ k1 |6 u/ y& o    while( (theDim=select_a_dimension()) != 0 )
! B: t7 m/ Y0 O5 }    {9 g' m$ S- B8 `+ c0 o# v$ Y
        out.str(""); out.clear();& ]* l  R6 X% a7 N1 T
        if(! lw->IsOpen() ) lw->Open();' Y- J3 f+ \4 S. b9 i  p

" U' v8 o$ V$ ^1 ]% e; r+ g$ x        out << "Selected Object: " << theDim->Tag() << endl;
  k7 T2 w/ S1 Z  ~% [7 a8 J0 Q; M! m' \! P2 F: x; b
        std::vector<NXString> mainTextLines;
( @3 l; T+ \$ B        std::vector<NXString> dualTextLines;
$ w$ O( M0 k2 j        theDim->GetDimensionText(mainTextLines, dualTextLines);
# R% z5 U5 k" D( }2 N: }5 Z        for( int ii=0; ii<mainTextLines.size(); ii++)
' u8 I5 a$ t: f. a/ w            out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
' f7 [8 \9 o2 j2 }& R        for( int ii=0; ii<dualTextLines.size(); ii++)
0 h; i/ e1 b- |- @7 i9 V            out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;( {/ G( z# i& |1 A0 U% I

* U/ T, Y+ t8 n- _        bool refFlag = theDim->ReferenceDimensionFlag();
+ h- P. E; w# k$ B8 W% _        out << " ReferenceDimensionFlag: " << refFlag << endl;
: G& r/ t0 J# x/ X/ ?
' k9 U6 P5 g5 K        int tolType = (int) theDim->ToleranceType();
( @% b8 J: i& O7 b) l& R; j        out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;
9 x5 w$ g" P' i+ h3 j3 ?) g# w7 d, ]6 j, c- S
        ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);
: e0 E: u9 E, p) N6 n8 H8 G        std::vector<TexTComponent*> textComps = theData->GetTextComponents();0 s  w. a9 Z& w$ n+ }6 z  j
        for( int ii=0; ii<textComps.size(); ii++)/ P9 P# L$ x6 ]2 ^: `- |
        {7 U/ _2 y/ f; D# `2 L3 {% W
            std::vector<NXString> compText = textComps[ii]->GetText();0 U" u9 y8 Q5 k7 J& z, }% ?
            for( int jj=0; jj<compText.size(); jj++ )
. u  A8 I! Y7 n6 q1 |4 y& f/ k                out << " Component Text: " << compText[jj].GetText() << endl;
4 q) o$ A/ p* j) g        }
) @0 ~& P0 |/ a) Y. X+ k6 u6 t7 z
3 [3 m& o- q* r        int subtype;
+ n) r" Z* b$ ^        double origin[3];
6 {3 D* r1 o, F" |+ M: X1 S0 Q        UF_DRF_dim_info_t *info;
6 R& U( c9 Z, k        UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));$ _% P' y/ F8 Q- ^4 E2 a
        for (int ii = 0; ii<info->num_text; ii++)
0 j' T8 e6 C& K$ H% g            if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)$ i" S& i  r: g* n" F
                for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)
: _7 B) X9 p+ H2 _* {- z7 ~                    out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
- h$ u: E% d% q$ u        UF_CALL(UF_DRF_free_dimension(&info));
# v7 H# g# {' P& p( x; L! c
! A0 I2 T3 i' W  c5 E/ A7 t. M        lw->WriteLine(out.str().c_str());; i; Q0 F1 ~' a$ {% y4 F, `

& e7 [  h$ m, Y& f    } // while1 u0 p$ F2 {4 D# z  l- @  M6 J) Y
}3 A  ]9 V: a* O+ F  y
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了