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

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

[复制链接]

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

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

admin 楼主

2015-8-22 12:47:05

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

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

x

& M( ]  Z( \- ]  MDimension* plmhome::select_a_dimension()
: Z$ M4 V, r  f$ ~{7 }0 D8 E6 n7 P" `8 E
    // ask user to select a label
5 d% r( K- _( R8 |' o, w    UI *ui = UI::GetUI();% |- l) k0 z9 ?2 S- x" }
    Selection *sm = ui->SelectionManager();
: |1 H/ B% {' [5 v+ n" ~, A    NXMessageBox *mb = ui->NXMessageBox(); // as of NX5
) v! R1 ]2 d& E- L
: T  [/ h1 w/ x, D* j; D# Q$ A    NXString message("Select Dimension:");
7 O) c  J2 v! ~! U. q1 p& F    NXString title("Select Dimension");
: q; q2 a! p8 o! \# r, Q    Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
+ j8 g) b$ t* q5 Q' u    Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
: Z4 U& X4 P; V! G  `3 q- B% P; g0 z    bool include_features = 0;
) x% e! k+ ^: f) ~* U, b4 c% I    bool keep_highlighted = 0;/ V) {4 h* k9 P& G% H* ?
7 |& c. r; e+ G+ U" C, ]2 ?
    // Define the mask triple(s)
" V% u: J1 a$ X0 v: k5 s    std::vector<Selection::MaskTriple> mask(1);$ N0 Q4 z+ Y2 V7 u+ v
    mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );+ M; u7 Y* T/ X6 a: C
    Point3d cursor;+ P% X1 g  c# }8 m% p% b
    TaggedObject *object;& `, T: N* i5 X; l* i

! H1 ~% w, Z) M4 }9 _8 I1 n+ V    // Select objects using filter defined by mask triples
4 o# h4 F5 B1 h$ g" K! B7 u    Selection::Response res = sm->SelectTaggedObject(" m( F4 o& c' T0 a/ }/ a6 ~& |9 |% l
        message, title, scope, action, include_features,0 v1 ~* L4 U# D7 ~. b; ?  m
            keep_highlighted, mask, &object, &cursor );. w0 Z* R' B) S4 q6 m

3 n+ R" C' L# }* q/ n7 d! Y( D    if( res == Selection::ResponseObjectSelected )
' D, J1 e) L/ t) K    {
7 y& v0 I& a* ?$ a- f        Annotations::Dimension *theDim;
6 p! Z' e& a2 o; N2 H2 m- s4 `" N7 f; F% U( m% ?
        // this doesn't work and 'note' will be a zero pointer, see PR-1850850% \% ~$ o: @' ^3 k  N
        //note = dynamic_cast<Annotations::PmiNote *>(object);* t0 I  X& L: |% r1 q$ I

: F4 N+ Q7 j8 L. E/ G+ f4 @! K        // this works as a workaround7 D' F8 f, i& E
        theDim = (Annotations::Dimension *)(object);
8 X) v  [" C$ m0 u* t0 ~/ t        return theDim;
3 J+ l! a7 U" n    }9 c* E5 I7 f0 @' ]2 p* i
+ a9 Q2 u4 Q% r
    return 0;
! |. Y8 Y7 L" E+ A7 N2 @}' V9 \3 o$ H& y9 Q4 C) y
* i1 Y; ^* q) ^- }( D  t& t; q

/ n1 s0 K4 j9 s& U% x# }; _# X5 r0 j$ I4 I: q

6 z7 k; n$ o: yvoid plmhome::do_it()) I6 H( B3 B- W/ x& S# x
{
' _* v  I, F1 K7 \$ x5 A    workPart = theSession->Parts()->Work();/ m3 s/ M5 c3 H5 [, T
    Part *displayPart = theSession->Parts()->Display();
- B# g+ |7 D# L* p) ?! H7 L3 I9 h    stringstream out;
8 G0 S, W& t# Q5 M    Dimension *theDim = 0;: \1 T+ C* A6 _( f  X+ }

8 J9 U7 l$ N1 U: E    NXString tolTypeStrings[] = ( z5 \! f2 j3 D& z4 _( a! J
    {
& K# h8 E( L$ b2 q        "ToleranceTypeNone",9 v3 G  x7 N( \+ ~! C/ F8 P
        "ToleranceTypeLimitOneLine",# U6 U( x( }8 A5 O/ Z! I' b
        "ToleranceTypeLimitTwoLines",
# g+ `6 o; U9 ?; }' d4 `- T        "ToleranceTypeBilateralOneLine",
# y& E' F% o; c: ~- L1 E        "ToleranceTypeBilateralTwoLines",8 |8 a0 w& s$ ~) F$ g, F8 N2 B$ G
        "ToleranceTypeUnilateralAbove",
( ^( n2 J( D: n  ~. s7 Q        "ToleranceTypeUnilateralBelow",2 G) G8 U7 |5 A6 J/ Z% n9 [
        "ToleranceTypeBasic",
4 S8 T5 A/ S3 E5 \" a' V& m        "ToleranceTypeReference",; O, ^5 H, _8 O1 S# Q
        "ToleranceTypeLimitLargerFirst",, D1 a/ J+ l' u) I
        "ToleranceTypeLimitLargerBelow",
; y4 n" Y# w5 K5 @/ Y        "ToleranceTypeLimitsAndFits",
$ d# {, J* h1 _( k        "ToleranceTypeNotToScale",7 Z  r. y4 o% d  E0 h1 S8 Z8 }$ R
        "ToleranceTypeDiameterReference",
0 J/ n7 G$ Z2 Y/ v: R        "ToleranceTypeBasicNotToScale" ) k( ^& _0 y& f0 C" w% R! C
    };
; n9 q. ?8 C, `! a  {% \
; |5 J8 i0 O1 U) U- g) }    while( (theDim=select_a_dimension()) != 0 )
- B9 X" R6 y( X3 n    {
( m, _1 U8 S! A: F& s0 T7 F$ I9 p- Y        out.str(""); out.clear();: N# h5 N8 o+ c4 r* i0 E' C
        if(! lw->IsOpen() ) lw->Open();
+ ?$ [, E, {' {0 E$ N" ]
' s  ]1 g+ i; |+ W! X7 c+ z        out << "Selected Object: " << theDim->Tag() << endl;
5 {3 J. R% m6 S! X* q9 n2 s) b4 x0 C" y
        std::vector<NXString> mainTextLines;
- z" `) u9 W/ d        std::vector<NXString> dualTextLines; 5 Z3 h# C/ l) J
        theDim->GetDimensionText(mainTextLines, dualTextLines);
7 v% u/ ?4 X& e+ k. \3 p3 f        for( int ii=0; ii<mainTextLines.size(); ii++)
3 z  `4 u5 f; v3 ^# }4 c( B* b4 g            out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
4 G' o" `/ d! }2 E        for( int ii=0; ii<dualTextLines.size(); ii++)
. J! X# G6 o2 ^/ A9 X            out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;
6 {6 @$ y! H/ ^: b( u$ Y. m  K
9 _8 N( d* h& R7 c1 {! o: [        bool refFlag = theDim->ReferenceDimensionFlag();+ V4 T0 @3 [6 Y
        out << " ReferenceDimensionFlag: " << refFlag << endl;
5 u: m' V4 t* N/ Q6 l
7 ~$ f- v7 ^+ Z2 m" c. Z6 M" t        int tolType = (int) theDim->ToleranceType();$ e* O# y; J) n0 U* i$ H
        out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;
; N( ?+ }7 G# L2 F" l# d, f8 C- l, \) j) l3 n+ ^& }
        ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);+ g8 c+ A8 x1 U5 P! i
        std::vector<TexTComponent*> textComps = theData->GetTextComponents();- x- x( {7 R! z1 w) f% b/ }9 W
        for( int ii=0; ii<textComps.size(); ii++)
) g# t/ m$ a! ?1 w$ z1 W        {
2 q# T( `3 `  Q# j1 Q/ G/ J            std::vector<NXString> compText = textComps[ii]->GetText();5 y6 K1 p/ P8 K! b8 N, M1 h6 \9 F
            for( int jj=0; jj<compText.size(); jj++ )2 J$ G+ n2 B* s4 n: J
                out << " Component Text: " << compText[jj].GetText() << endl;
. A8 [; L( s/ {7 E, @        }. y$ w" E+ V( {# D3 Y; T: G
1 y& u" V  j& [( G' ~
        int subtype;
  }2 p! J# z" D/ d% G+ H        double origin[3];( v% @2 _+ E5 c) V
        UF_DRF_dim_info_t *info;$ o; e9 V2 o6 d+ A3 G8 Z
        UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));  M, `9 u: o, ]) J5 Z( n
        for (int ii = 0; ii<info->num_text; ii++)1 ?& v  m  j" c' x
            if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)6 Q$ E% b7 D! R5 ?  f4 E
                for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)
3 [4 T+ X5 J. Z. o8 @                    out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
  D' J9 {4 Q( Y& s        UF_CALL(UF_DRF_free_dimension(&info));! _- A2 @4 w3 \

1 `6 B% q) X" ?( E3 _+ G2 n: \        lw->WriteLine(out.str().c_str());/ P* A9 V7 P6 `, X* J

. Z7 x+ w  Q' J. z# Q- r$ _; ~    } // while, S) w2 O0 l4 y+ O! G) m
}
0 C. ]: |/ r3 h2 d
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了