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

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

[复制链接]

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

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

admin 楼主

2015-8-22 12:47:05

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

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

x
5 U; w- E; ]* \4 O1 C
Dimension* plmhome::select_a_dimension()) V9 R) |1 M  x0 O
{4 ]; k( W* A/ v" C0 N
    // ask user to select a label
4 `* P+ G7 e; k; V# x, o    UI *ui = UI::GetUI();
% g8 q* U3 h' [* Z0 x% i    Selection *sm = ui->SelectionManager();
( [4 E/ l4 o! Q    NXMessageBox *mb = ui->NXMessageBox(); // as of NX5
' k& n9 n( _2 T% e0 \( R# h2 V, K, n$ J6 I8 w4 K
    NXString message("Select Dimension:");5 l2 a8 O# m. b4 |  k+ J1 r2 [6 G
    NXString title("Select Dimension");8 y: s2 A  }6 l  M" s
    Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;, B1 a0 v! @( W" W$ E/ K; a: q
    Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;3 ?2 Z( y( x5 r" u! D8 d
    bool include_features = 0;! ]' [% x9 j3 ~' r# T
    bool keep_highlighted = 0;- b- K( P& p0 X

5 U* O8 ]% Y9 T" P% Z    // Define the mask triple(s)& [$ A* Y- p: `( g& ~' B8 T
    std::vector<Selection::MaskTriple> mask(1);8 b! _2 G4 ^: [9 ~+ r! i0 C3 u  i
    mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );
( R# I5 e  |8 s* ]  V    Point3d cursor;- A' K! k; g( I9 F
    TaggedObject *object;% _- C1 P2 c1 M
8 o4 q( ]- x: }" r  P
    // Select objects using filter defined by mask triples
. q% ^6 b4 P+ O    Selection::Response res = sm->SelectTaggedObject(
9 ]" B/ V2 t% }1 a1 _+ z; N        message, title, scope, action, include_features,
/ X: q: W; ?; e  u7 c' p. c' {1 a            keep_highlighted, mask, &object, &cursor );$ Y2 B6 [- b5 O* [# j; P6 z# S1 E
  [5 P+ g/ r. `) Z4 R
    if( res == Selection::ResponseObjectSelected )
* l* H# y7 y+ O: a) O3 F3 y    {8 `# m, P' l" m
        Annotations::Dimension *theDim;
3 h- G6 @" R$ h1 {9 T4 e! e
  S4 O1 J" \2 Y5 j0 X- K6 X  c5 H        // this doesn't work and 'note' will be a zero pointer, see PR-1850850; w  L& o9 S; D7 Z  I8 @/ F1 z2 y. {
        //note = dynamic_cast<Annotations::PmiNote *>(object);
4 T1 K$ q' }+ ^; d9 T( B" L; F0 \! e" Q4 P; a
        // this works as a workaround( |* F9 U5 h" D  o9 B+ M3 R. l
        theDim = (Annotations::Dimension *)(object);5 b, ~' R: n. w6 W  }; c* ^
        return theDim;
5 e5 b2 E+ w& U! z! U* e    }
; N8 L2 Z) k' N, Y2 o1 T- q% b: L- v
    return 0;# T; t7 n, x+ Q& v+ ]8 \
}& Z! e9 ~& y; o9 p& G! Y
( D! L3 F8 O' i. m& L. R2 a

9 F: \5 V3 m# Y7 T  `5 s4 s, M+ k+ p
. e7 j% l1 Y, `7 n
void plmhome::do_it()
( V8 K1 {- n. H  z{
$ |1 Y+ m; F8 x: @% s' Q7 a: ?  {5 m: k    workPart = theSession->Parts()->Work();
+ j+ d7 B9 m. B    Part *displayPart = theSession->Parts()->Display();& j+ F& R; y( `( _
    stringstream out;, W. t" H' M$ C4 e  V6 s7 j5 I. R
    Dimension *theDim = 0;2 |3 m. {5 q4 q$ t4 C1 Y! {: |
1 G4 y3 n9 W. k2 V, Y% r
    NXString tolTypeStrings[] = 1 M6 m* n) Q" ^4 w
    {0 u* |6 u# J' r: A
        "ToleranceTypeNone",
( q1 B6 H) m9 m! b% v        "ToleranceTypeLimitOneLine",
$ Z. V0 t7 z$ q" @0 T! I  }3 s5 e        "ToleranceTypeLimitTwoLines",5 M" a: D1 `5 K& Y; n
        "ToleranceTypeBilateralOneLine",: b, q$ v) ]2 E+ b  x6 z. S- U- S
        "ToleranceTypeBilateralTwoLines",- z. a. l2 X1 K& A4 L
        "ToleranceTypeUnilateralAbove",2 Z( K9 t( N  N( }& A5 V, ]
        "ToleranceTypeUnilateralBelow",! e# G: a1 K9 `% R
        "ToleranceTypeBasic",
# p: r/ p- X+ X5 v! I3 W* E9 S        "ToleranceTypeReference",
! T! e, r6 U( ?        "ToleranceTypeLimitLargerFirst",( Y7 n9 Q( \0 x+ w# ^
        "ToleranceTypeLimitLargerBelow",$ |3 e! u8 u! q- q4 D$ s
        "ToleranceTypeLimitsAndFits",
; p4 i( a6 g/ Z. Y        "ToleranceTypeNotToScale",
+ n' f( M( m, {, p8 N: o        "ToleranceTypeDiameterReference",- X' j# @2 H$ L2 a% j6 ]& W7 N
        "ToleranceTypeBasicNotToScale" 9 B9 _& m* U/ m; X; D2 O
    };
; b" N" o: M- F6 ?' R0 |
! i, N' O; {$ K: M  Y4 c6 P    while( (theDim=select_a_dimension()) != 0 )6 m' q8 a. ]# @* E/ ^# L6 Y
    {
- `( E5 }( y: j2 A- o3 m8 ^% O        out.str(""); out.clear();% m4 _: z4 [" r8 E
        if(! lw->IsOpen() ) lw->Open();
  O8 M* u2 B/ k$ r7 e8 i: N# Z- B3 E! ]) E! E
        out << "Selected Object: " << theDim->Tag() << endl;6 q. H! h( q! @
8 i, y4 G+ V9 c: h9 J
        std::vector<NXString> mainTextLines; - }  j$ U& X2 I7 e  }
        std::vector<NXString> dualTextLines; , H/ V$ @( P$ @: H7 U. k
        theDim->GetDimensionText(mainTextLines, dualTextLines);
- t9 A, [$ ?9 C* S7 y; z        for( int ii=0; ii<mainTextLines.size(); ii++)% A# A9 v$ j: _& p, Y4 u2 \
            out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;& a' X# _. r4 D0 f9 Q& I7 A
        for( int ii=0; ii<dualTextLines.size(); ii++)" b/ a+ r: X5 A& p( h. ?8 Y$ Y
            out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;
  F1 ~9 T" l9 D/ _$ N7 Y9 u7 q' G8 r- x2 t# G
        bool refFlag = theDim->ReferenceDimensionFlag();' {. p9 b& [- c! }( u& e
        out << " ReferenceDimensionFlag: " << refFlag << endl;
7 R7 P, w! _  \1 W8 ^3 j
. `( U* x& }, f2 x# g+ l        int tolType = (int) theDim->ToleranceType();* W% i; L. B2 X& h
        out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;- }9 U9 y' h3 I, S1 Y6 w/ i% G
- R' O7 v5 e, H- [) i1 n
        ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);8 U7 N4 o, e; M) o
        std::vector<TexTComponent*> textComps = theData->GetTextComponents();$ ^8 |. S' O0 `/ U
        for( int ii=0; ii<textComps.size(); ii++); O8 V' L" D1 g6 J4 ?4 l3 C
        {
4 g9 M; Z, F; x6 y' U3 w' P# J. T            std::vector<NXString> compText = textComps[ii]->GetText();& Q# L! d; X2 E/ g  c; b0 z
            for( int jj=0; jj<compText.size(); jj++ )% F4 Y/ r+ E4 ?& C+ T
                out << " Component Text: " << compText[jj].GetText() << endl;
1 e% P# L/ F! j" H) q        }% D5 z2 ~. K* B+ y! n" s; d! r

# J4 ?, F% a/ K+ ], q7 s/ o        int subtype;
3 t2 h# C3 @, U7 |" @  v1 W        double origin[3];
0 e& E! p; l3 I6 g        UF_DRF_dim_info_t *info;
& \- K4 Z* m+ d. P' W        UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));
. S, u8 Q; x) p/ K; j! e        for (int ii = 0; ii<info->num_text; ii++)8 G7 q3 D8 e* y5 O  z, Q
            if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)
* J. K" V1 B) M9 y                for (int jj = 0; jj < info->text_info[ii].num_lines; jj++). d+ I2 M: J$ P
                    out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;/ f2 [! w" t7 F" Z" ]7 A) `
        UF_CALL(UF_DRF_free_dimension(&info));
% V4 @. K# F" k+ J
7 A6 K. |8 k, r% ]4 _7 u        lw->WriteLine(out.str().c_str());' U: @# X$ e2 _. k8 ?4 G. i

) i9 J0 X& R3 f! A6 v: D$ X% c    } // while
* s3 M8 s! |% w9 r}1 R; o9 K  S$ Z5 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二次开发专题模块培训报名开始啦

    我知道了