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

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

[复制链接]

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

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

admin 楼主

2015-8-22 12:47:05

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

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

x
) q3 d, T" O) d  i
Dimension* plmhome::select_a_dimension()
. }* `& b( H* ~# l  Q- P{
' n. \3 P- A7 d  Y; M8 t% D5 g    // ask user to select a label# f: A- ?6 p2 U9 I
    UI *ui = UI::GetUI();7 M9 ^" b5 q( q# a0 D4 _( E
    Selection *sm = ui->SelectionManager();6 Y. t  Q2 \" z& U% @3 a' D$ j) `
    NXMessageBox *mb = ui->NXMessageBox(); // as of NX5
& B8 L: @) k( u3 }2 W. p: a' a: p4 c8 k9 g
    NXString message("Select Dimension:");
1 z* a" x4 \+ x4 J7 C, B: V- h9 a    NXString title("Select Dimension");
4 o/ V0 s5 m2 {2 G3 D" X) P9 n    Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
5 |: }4 Q; Y* X; f. G3 H    Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
9 L3 w9 Y" _, V! j    bool include_features = 0;& |0 Y9 T/ L6 N4 q/ E( @4 |
    bool keep_highlighted = 0;
7 r2 b  a  _* W0 }% d! ~
7 h: M. Y0 f2 \. r7 @4 L& {) ?% y    // Define the mask triple(s)5 g" V* @! d- K/ l; ?  A
    std::vector<Selection::MaskTriple> mask(1);
; r6 U1 |1 w% t: ~# D* K1 d5 W7 U    mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );+ z+ t8 p2 m& y, ^2 X
    Point3d cursor;
9 B; G! I( G$ x/ V% e" F7 J7 Z    TaggedObject *object;# C6 o- I: A$ W! a7 a; A
$ R4 k; g" l$ P& W' C# S; d
    // Select objects using filter defined by mask triples, G7 O1 H0 T& i, y% N5 ]
    Selection::Response res = sm->SelectTaggedObject(
/ v6 ^" y0 N2 [9 |        message, title, scope, action, include_features,
3 M1 G" J+ x. }8 u            keep_highlighted, mask, &object, &cursor );! E* f5 F8 ~. U
% [! y5 L, S7 D5 I2 t2 w
    if( res == Selection::ResponseObjectSelected )" Q! p; o% F8 O" \4 L2 }" m
    {5 F4 `4 M$ p' w; p0 a
        Annotations::Dimension *theDim;) c  X& j  g& [: V/ P8 U* z

5 h6 B8 _  I0 m2 d1 a$ ]        // this doesn't work and 'note' will be a zero pointer, see PR-1850850
$ n' ^7 v, n& c) ]5 I: @4 m        //note = dynamic_cast<Annotations::PmiNote *>(object);) \! @: o) F2 R; P1 y; p
9 g/ B/ W4 l, X5 A
        // this works as a workaround
8 S3 Y' h9 Z$ y. E" q        theDim = (Annotations::Dimension *)(object);
2 z1 ~9 C; C2 I' x) Q  ]        return theDim;# ]! P1 g( h& u* I7 v: \. u
    }$ R8 b2 M( q+ m* j9 c

0 a& D% D% \3 f4 k, J: U5 A& B/ E    return 0;* v( k7 @: W; k
}1 o) M9 T/ F8 n7 w% D6 ^

8 v. W: j% H  M% N, ?, J, x/ ?2 @$ E

7 C& Y# F2 ]) {  l$ \& ~) B$ P
: `( z9 D1 X! C7 F# h: ivoid plmhome::do_it()
: z1 r5 r! ?" S9 G9 r{  n% b; M/ B8 V  }, h
    workPart = theSession->Parts()->Work();
- |; L% X, @* D  O    Part *displayPart = theSession->Parts()->Display();
( P& u+ y8 [+ ~/ G& d7 O    stringstream out;
4 r( D  q/ O2 S    Dimension *theDim = 0;/ x' ?  Z; }8 m6 M

' }  f$ s/ A& l$ ]8 C    NXString tolTypeStrings[] = 0 q' f3 o  a/ O, `. b
    {
  D" U( ]" t! B) g1 I; m& D2 c        "ToleranceTypeNone",
5 Z+ c, I. u6 L0 O        "ToleranceTypeLimitOneLine",
# `" ^$ {& o: t. L0 P8 R        "ToleranceTypeLimitTwoLines",
# g4 o- e1 N  S, i/ y2 n$ @5 u        "ToleranceTypeBilateralOneLine",
# L. ?1 g( E& |# c4 D        "ToleranceTypeBilateralTwoLines",
$ y1 B3 @* \1 K. n, H        "ToleranceTypeUnilateralAbove",
  J2 _/ C' H5 ?8 U. H* H8 Y/ R" J        "ToleranceTypeUnilateralBelow",6 n* c( ], R& X# e4 e
        "ToleranceTypeBasic",
& w3 f4 [$ q2 f6 D) ]        "ToleranceTypeReference",
$ C4 N8 _/ g# B        "ToleranceTypeLimitLargerFirst",
3 Q' r# X7 X; F+ y8 H- ?9 q        "ToleranceTypeLimitLargerBelow",
0 ~0 z+ H+ ~: z: T. i/ U        "ToleranceTypeLimitsAndFits",
' M# b. b; L; T9 Y& K9 Q& {        "ToleranceTypeNotToScale",
: d% ?; L, J# u- N1 N3 ]& V* F" C        "ToleranceTypeDiameterReference",+ b) r1 z! x2 t8 Q, W. q7 p
        "ToleranceTypeBasicNotToScale"
& l) K8 L. j5 \, T- m  L    };$ F$ `* ?0 ]( h3 c8 c# Q/ ]) U

% d( }, }- @) w& }/ _* j) q    while( (theDim=select_a_dimension()) != 0 )
: D' B4 e* M( `3 Q& B* {    {: P5 i' D: Y7 A) F2 _
        out.str(""); out.clear();3 P3 d8 g9 h6 S' F9 B9 u- }# R3 l, H% U
        if(! lw->IsOpen() ) lw->Open();, `$ y& C# U# Q; O0 z
/ R! p$ ]0 j! |0 j, M" ]
        out << "Selected Object: " << theDim->Tag() << endl;
" O/ S1 O9 u, @, D+ T3 e, T; X+ A6 Y& T1 A
        std::vector<NXString> mainTextLines;
" Y, t/ X3 d4 q! c: [        std::vector<NXString> dualTextLines; $ w( |8 f- q5 l* q6 x, C% m( j7 c
        theDim->GetDimensionText(mainTextLines, dualTextLines);  e& l9 g& }' Z" L
        for( int ii=0; ii<mainTextLines.size(); ii++)0 d* V4 h, g3 f- a* V! R3 {
            out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;" j) k- _" X' X9 p3 r
        for( int ii=0; ii<dualTextLines.size(); ii++)$ M; p; }: Z+ N( B8 l$ ]8 x( a
            out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;; A: K5 A5 m- j: b% t# ^

2 P$ F5 D. `7 c        bool refFlag = theDim->ReferenceDimensionFlag();
* o( A( x9 s4 V        out << " ReferenceDimensionFlag: " << refFlag << endl;6 T  D/ X8 r" f$ n
6 T. `3 i+ {5 ~; N( o& C
        int tolType = (int) theDim->ToleranceType();
& T# S, V, O% W        out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;
; Z9 r- _# X4 c5 B
$ o( }/ R5 x( b/ d2 X        ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);$ f! `1 G5 Y# s4 {; V
        std::vector<TexTComponent*> textComps = theData->GetTextComponents();9 h. s: P2 _) a: @1 l8 R2 W
        for( int ii=0; ii<textComps.size(); ii++)0 L* x% E- K/ J1 E0 w% o9 w
        {; D) \6 [2 u0 p5 B: q# k' [
            std::vector<NXString> compText = textComps[ii]->GetText();
( p4 s( j. q6 y7 J9 L) X            for( int jj=0; jj<compText.size(); jj++ )
+ I3 A0 u1 B( p0 V+ M7 [+ W                out << " Component Text: " << compText[jj].GetText() << endl;
: U8 o$ T: j. h. S4 _        }
; Y! i$ C( ?( N" V$ I: M  r3 e2 P$ M
        int subtype;
- d6 a2 C9 @/ O2 e* x        double origin[3];/ [- U$ R1 X8 F! P; T6 [
        UF_DRF_dim_info_t *info;
" w9 T8 W- w% o! }* C; ]+ k4 R        UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));
& ~: w. E" U( p2 E* ~8 J4 k# _9 q; i        for (int ii = 0; ii<info->num_text; ii++); i5 P- R3 h" t9 x8 g
            if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)( r% X6 O6 J. B' f( @$ d
                for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)
8 ?0 d5 a) I* H( o: G# _( X, j                    out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;6 B- l8 X" R6 ]; w9 m& ?; D: X
        UF_CALL(UF_DRF_free_dimension(&info));
; f: `1 F/ X0 a: }/ L' s, F" }3 Y
' |1 E/ r9 v+ U* T' Q9 t        lw->WriteLine(out.str().c_str());
, r# Y$ V& |1 i' F- O/ |# E: j7 p: J% ?0 W# Z: e, W1 c
    } // while
# b. T# U& E7 n. t: q5 U: w' @}
$ E% {$ S; H6 t5 o* q5 O
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了