PLM之家精品课程培训

PLM之家精品课程培训

联系电话:18301858168   |   QQ咨询:939801026
NX二次开发培训

NX二次开发培训

UFUN/NXOpen C++和实战案例

适合初级入门或想深入了解二次开发的工程师,本培训结合ufun,NXOpen C++,大量的实例及官方内部的开发技术。
公众号二维码

关注公众号

点击扫描二维码免费在线高清教程

课程详情
Catia二次开发培训

Catia二次开发培训

市场需求大,掌握核心技术前景广阔

Catia二次开发的市场需求大,人才稀缺。掌握开发技能潜力巨大,随着经验积累将在汽车、航空等领域有所作为。
B站二维码

在线原创B站视频

点击关注工业软件传道士主页

课程详情
Teamcenter培训

Teamcenter培训

全方位培训,从基础应用到高级开发全覆盖

涵盖用户应用基础培训、管理员基础培训、管理员高级培训及二次开发培训等全方位内容,由多年经验讲师打造。
QQ群二维码

加入同行交流

点击扫描二维码加入QQ群

课程详情
×

PLM之家plmhome公众号

课程涵盖: PLM之家所有原创视频

×

关注B站视频

所有高清视频一览无余,全部在线播放学习

×

加入PLM之家QQ群

同行交流,疑问解答,更多互助

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

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

[复制链接]

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

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

admin 楼主

2015-8-22 12:47:05

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

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

x

0 Q6 c/ G! D4 @. ^Dimension* plmhome::select_a_dimension()# F) F: i, J8 G2 s+ s) P6 M! K9 u
{  y, i$ O6 ?2 H/ [$ n  ]1 ]
    // ask user to select a label% q5 Y6 \+ n* u
    UI *ui = UI::GetUI();
, n& m) l* ?! }- G; K, T/ M4 C; I    Selection *sm = ui->SelectionManager();: X1 K+ t: q( A0 f; z
    NXMessageBox *mb = ui->NXMessageBox(); // as of NX5* {8 W7 p8 q) K2 d/ Y* B
8 H2 k: F4 u) _6 u# e/ f  n
    NXString message("Select Dimension:");
  e& R) k3 \8 x# C/ Q    NXString title("Select Dimension");, G# v( b# r) |% @, ]
    Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;' Q# \, O5 n4 x
    Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;1 D, z. [: V+ H0 m3 `& y$ X+ s
    bool include_features = 0;$ S5 M) J/ F+ C
    bool keep_highlighted = 0;9 t- g# q  E1 z4 K$ m2 D
# Q% }0 o7 X2 g' f. ~- {$ M% `
    // Define the mask triple(s)
6 N* F5 j) X# g' A0 N    std::vector<Selection::MaskTriple> mask(1);  n# M9 h! Q2 D- w
    mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );
" W4 a" f2 c5 I8 D3 t! N    Point3d cursor;2 _$ e9 p' |9 t: ]$ N6 Q3 L2 {
    TaggedObject *object;
" l) v5 j8 M+ q# V' D6 M+ Z5 S6 B3 X5 X; _
    // Select objects using filter defined by mask triples
$ ]" |9 w: V$ s7 L* T. F    Selection::Response res = sm->SelectTaggedObject(  v0 z2 j. W) y3 ?9 R( L/ D
        message, title, scope, action, include_features,% _/ z2 w9 ]& M; M* n# s( Q
            keep_highlighted, mask, &object, &cursor );) n. }% e! h0 p- u2 E# n0 U( S
4 I" T8 Z! F: c4 ?
    if( res == Selection::ResponseObjectSelected )( [  E. j- i3 w  Z9 H9 b+ h
    {& Y, V: o; d' K/ c# H+ ?
        Annotations::Dimension *theDim;$ Y) @3 _( a' I! ?1 j  t. s0 a) e

6 @, F; ?$ @5 p9 A- l% s        // this doesn't work and 'note' will be a zero pointer, see PR-1850850
2 O8 Y# u7 V: w0 D; ]8 s7 a        //note = dynamic_cast<Annotations::PmiNote *>(object);' d2 i. Y( B0 h9 h

$ U/ p' c: p' q8 c* k$ ]        // this works as a workaround
8 ?' J% j7 p& o0 P' G        theDim = (Annotations::Dimension *)(object);3 Y$ @) |" c: V4 v7 Z
        return theDim;
& T1 H2 h! A5 f+ q    }
, \- W8 U" E9 y8 v2 @. m
8 a3 M6 @& N3 q; V+ K  X    return 0;
4 L5 ?, @/ e* @7 l}
6 x- j. b* `  e2 g* ?" [  l3 M2 V0 e" [7 N+ Z% s  H& l

: J0 H4 ~, D9 _& q
0 i+ y7 e& m# s1 c0 ^3 ~0 R6 `
  @, l) t2 l/ n) v9 Nvoid plmhome::do_it()
: a0 j! f+ ^& K( k1 C8 {3 A{
5 ~% c  H0 ?1 P: x3 h) X' F    workPart = theSession->Parts()->Work();
+ p) m( s) U* {: g% V    Part *displayPart = theSession->Parts()->Display();
6 n9 J" t- p) r. w5 J  N5 s& ^    stringstream out;
' ~' R4 j& T  d2 s- z    Dimension *theDim = 0;
. I7 M& z" s. ?8 S
& ?; O/ l4 c& p/ ?# z' D    NXString tolTypeStrings[] =
5 q. v! `$ o0 b, @! T! A! E    {
  _4 M$ b% F1 t+ s* h        "ToleranceTypeNone",6 {' f% \5 z. f2 c& S* ?
        "ToleranceTypeLimitOneLine"," `! b& _1 D1 F: u
        "ToleranceTypeLimitTwoLines",
  V: t5 _/ g- U" H        "ToleranceTypeBilateralOneLine",7 W# U) k0 y) {& v8 Q* Y
        "ToleranceTypeBilateralTwoLines",3 C1 D% W+ ~, A$ W1 y; g
        "ToleranceTypeUnilateralAbove",% Z. h5 _# D% @
        "ToleranceTypeUnilateralBelow",! W, J4 C; B. }3 |# G0 E) S1 l
        "ToleranceTypeBasic",
0 d4 h3 o7 p9 \5 f: Z* A# B        "ToleranceTypeReference",0 ~# Y& m; s/ s9 Q4 N5 B# Z' }
        "ToleranceTypeLimitLargerFirst",
/ ~7 |  f" I$ d1 O        "ToleranceTypeLimitLargerBelow",
$ k* s% g2 K; _" {! }; J" c        "ToleranceTypeLimitsAndFits",
. Y4 C; z. W( F' P2 F. Y        "ToleranceTypeNotToScale",
) b% T! ]- k& M& h        "ToleranceTypeDiameterReference",
" N/ j+ @$ W/ H( G0 b        "ToleranceTypeBasicNotToScale" ' A! M9 `! m" x1 V5 m
    };
7 D6 i* H) S+ @9 M5 f: G
9 t* P" M5 y2 w( h6 n- [    while( (theDim=select_a_dimension()) != 0 )! J# J9 P" g7 L; j. w8 s6 r' ^% z* |
    {
6 G0 j. W6 w! u        out.str(""); out.clear();
/ x3 F+ @' S6 _. n        if(! lw->IsOpen() ) lw->Open();
9 n3 q  R/ _& p
' s& d0 R7 r' M+ `& d( z$ ?        out << "Selected Object: " << theDim->Tag() << endl;
7 e; ]$ U5 ?0 v; K' M. I  m  h" B# u3 y$ i: B
        std::vector<NXString> mainTextLines;
; m, z. v2 z2 ~* ~' J        std::vector<NXString> dualTextLines;
! l  Y6 ]0 b; ~1 a3 h& [/ S( p. O, a        theDim->GetDimensionText(mainTextLines, dualTextLines);$ D6 m: h. V* e* }; S- i+ M
        for( int ii=0; ii<mainTextLines.size(); ii++)
. \7 o! z3 Y! H* e* t            out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
7 d( x: {/ m& @  D8 \# ^0 `        for( int ii=0; ii<dualTextLines.size(); ii++)
: A. |( P, _9 \9 @3 o            out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;
7 i2 {1 Y  c, T' Z' P! |3 _+ J+ _5 [5 N8 s) p% O
        bool refFlag = theDim->ReferenceDimensionFlag();
5 o& I" W1 |1 h' {2 v1 x5 B/ g  f0 W        out << " ReferenceDimensionFlag: " << refFlag << endl;
3 w& n5 _+ {% U5 K+ N& G. M+ S" X# s0 r2 r# j6 K' P
        int tolType = (int) theDim->ToleranceType();: O5 ~# `4 N8 P: j
        out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;
# W% B/ A. k$ Y- O. b. X$ V- L% F+ H- H& B- a' A9 }6 K; w
        ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);
7 ?1 C' B1 T. u! \  H        std::vector<TexTComponent*> textComps = theData->GetTextComponents();
- C+ b# ^2 i, t' k6 p1 y; n        for( int ii=0; ii<textComps.size(); ii++)
5 F0 \( {6 I) U+ A        {1 P4 M' N* L8 O/ L# U
            std::vector<NXString> compText = textComps[ii]->GetText();, S! U& M: K( G2 [
            for( int jj=0; jj<compText.size(); jj++ )2 }9 o6 w5 d0 L3 ]% V
                out << " Component Text: " << compText[jj].GetText() << endl;
: Y/ J9 d: _6 g* K8 M. Q# B! r, s        }2 y7 y6 ?$ U7 M+ f0 N5 B
+ g: P' M& P( c; U  X9 n3 J
        int subtype;
' `* x, Z3 W# b% s4 {  l# `3 l        double origin[3];
+ U( U; D) D; f6 R% ]- y        UF_DRF_dim_info_t *info;6 S9 O- D" L) ^6 B  `  F3 T) O8 {
        UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));
+ w( P6 j; e& `, u        for (int ii = 0; ii<info->num_text; ii++)
6 f; y" y8 H+ I8 X            if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)7 x3 Z  p" l% O" L! i
                for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)
3 u0 ?% b5 `- o6 h% d+ v( i                    out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
( |2 f/ f) |0 w( h' ^* X        UF_CALL(UF_DRF_free_dimension(&info));
5 X( h/ @% m% w7 }9 b" a/ f) @0 o3 N8 \' N" K  W7 @
        lw->WriteLine(out.str().c_str());' f7 @& q+ g, u$ ^* {3 M

9 B/ j) Y: E- w. ~9 v    } // while
4 H4 y) k$ Q  D6 I6 l}
3 ^+ N% G  D% r- O( E# u" f* z) c2 z
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了