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 3236 0

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

admin 楼主

2015-8-22 12:47:05

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

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

x
7 S/ z0 `; ?7 H
Dimension* plmhome::select_a_dimension()/ k" h4 M2 t) l1 P! ]; g4 W
{
* {* b, v6 I/ o" u. {9 T3 `( t- G    // ask user to select a label
8 ~8 l( t7 r& W' ?2 }    UI *ui = UI::GetUI();( k- f+ N+ H1 O* H
    Selection *sm = ui->SelectionManager();
7 a8 l0 W, @0 Z4 }( N    NXMessageBox *mb = ui->NXMessageBox(); // as of NX5
8 s3 ?; w$ {" P! G. ]6 j  [# K* d9 J* o; Z
    NXString message("Select Dimension:");( }% z3 o: e( P5 a- S( L) Y4 ^
    NXString title("Select Dimension");
8 Z  Z" @8 v, c4 d) |$ i    Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;" J' V! _: M* d3 b: j
    Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;7 i# R: u; R, X) Y( Z8 Y1 w1 {
    bool include_features = 0;
$ s  {3 Z+ U' Q0 D; y2 f+ ?    bool keep_highlighted = 0;
% J  ^: P9 H' X- O% I" `$ g$ e( \3 I1 S& B1 s2 E
    // Define the mask triple(s)
- s+ v/ C8 w. S, A    std::vector<Selection::MaskTriple> mask(1);
1 i: H8 ^5 T  h4 @" F! C    mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );
* r: O9 M- [  c( b- f    Point3d cursor;- y* D. R3 u/ a& c) G
    TaggedObject *object;
. g$ H3 @+ W; \( M0 x* c8 S* A
6 J8 g/ V! m! F5 B% i+ q* e    // Select objects using filter defined by mask triples- q; K- ~. a- B
    Selection::Response res = sm->SelectTaggedObject(9 s3 |* ?/ E+ u" A
        message, title, scope, action, include_features,
' D4 U  t. f: i& z            keep_highlighted, mask, &object, &cursor );
$ v, s  p2 O4 r  z2 |, O7 C2 I/ H! g# ]8 l" Q
    if( res == Selection::ResponseObjectSelected ); H; j# A5 W7 H. [
    {& g6 p5 E; @# k: v
        Annotations::Dimension *theDim;/ d! O5 H* w: c0 ]4 l( |

. y8 F, I2 O! Y4 n8 P9 I/ v$ u        // this doesn't work and 'note' will be a zero pointer, see PR-1850850% W# Z8 ~, J: F# N$ s( n" D- O
        //note = dynamic_cast<Annotations::PmiNote *>(object);
2 N/ x( v  b$ O5 ]& S
8 n7 b1 n+ D+ r        // this works as a workaround
$ _) e/ I( j& s0 x0 L# r$ ?1 W3 p        theDim = (Annotations::Dimension *)(object);
9 Y- h: ]4 f2 C        return theDim;
. S, b/ o" ~1 h& I& d: d  ?* ]    }8 m$ n; a6 q4 I. E" \, b, G- [

7 K2 `' ~# S  {! k+ O    return 0;
1 K' Q# ]) X3 D* @( X/ I* U}
, @' x. R. s+ [$ W9 D5 I
/ d# s7 t- ]; l# b- Q
: U: ?% L' j8 a2 c9 g  y. K& \; T) r" `8 ?, E" _: T5 }7 O

  y# m4 o3 H- _7 cvoid plmhome::do_it()
, X6 T9 [- ^$ k5 [! k( f{/ _' `/ B. P! o2 x6 p$ B
    workPart = theSession->Parts()->Work();
0 p8 T' G6 d; T- x4 g1 c    Part *displayPart = theSession->Parts()->Display();$ v5 G' r; l9 J/ J) M: _. @" D5 A
    stringstream out;
8 y: E  {# z$ K/ W$ P2 C    Dimension *theDim = 0;7 S9 f' Q4 s$ }

# t% q. d2 }1 \    NXString tolTypeStrings[] = ) ~9 _  N5 W" f
    {# Y0 v. k* `% W/ w# ~
        "ToleranceTypeNone",: M$ x- Z8 ]8 z6 E5 Z! r
        "ToleranceTypeLimitOneLine",! [( c! W& s: g* O
        "ToleranceTypeLimitTwoLines",
, V0 J, w, r" k( x" T        "ToleranceTypeBilateralOneLine",6 p  S0 E' u6 M4 u1 Q+ p" @
        "ToleranceTypeBilateralTwoLines",' f. {/ t% K: P8 n
        "ToleranceTypeUnilateralAbove"," |: u5 S8 B/ O
        "ToleranceTypeUnilateralBelow",
4 Y# e3 |. h4 D$ q        "ToleranceTypeBasic",
7 ^* A5 w4 H% {7 N" i        "ToleranceTypeReference",
2 }) S5 q7 f; d2 T+ Y        "ToleranceTypeLimitLargerFirst"," R" C$ o3 q/ N% g8 t
        "ToleranceTypeLimitLargerBelow",
2 L9 `! K9 `( J, |        "ToleranceTypeLimitsAndFits",
5 T  c' e; |% y' \! T        "ToleranceTypeNotToScale",
7 O) A6 \) D( S- d9 ]4 ?        "ToleranceTypeDiameterReference",
9 `4 J6 A1 H$ C3 m* f% C4 ^        "ToleranceTypeBasicNotToScale" + I; U. U7 V! T' f, @9 N
    };# a' ?$ {: R2 {5 `( r1 e

8 Y. Q# P1 s, U8 D7 H% }: R* V6 J    while( (theDim=select_a_dimension()) != 0 )
$ H1 L6 x- t0 I& ?+ }, K$ f4 I" F7 Y    {5 g( J$ m, C+ G3 X6 D! @5 s- {4 _" c
        out.str(""); out.clear();
" b1 y; r/ n- i. ^3 m        if(! lw->IsOpen() ) lw->Open();
+ `  ?8 U) k( E' r; P' M, k  ]$ I1 ~0 r0 l9 T
        out << "Selected Object: " << theDim->Tag() << endl;
/ C* `. B' g6 ?5 S# a. ?: G* ?) N8 ]" q/ E* q. z7 p5 ?+ m* B4 {
        std::vector<NXString> mainTextLines; % y) i' y# I6 g8 l: c* X
        std::vector<NXString> dualTextLines; : _' h! b3 b8 Q4 I( o" C" K
        theDim->GetDimensionText(mainTextLines, dualTextLines);
! ]9 h) o$ O6 |4 k        for( int ii=0; ii<mainTextLines.size(); ii++)$ C0 C+ t; {# r' G: f+ c9 Y. G7 V
            out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
% b- X6 l/ E7 A) }9 h8 O        for( int ii=0; ii<dualTextLines.size(); ii++)
% h* s: `  M1 ~( m; A# _            out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;
: A% Y5 S# |: V* l, X& p5 M0 F* T
! ^- L; M. e6 [9 k5 i6 E& i        bool refFlag = theDim->ReferenceDimensionFlag();) Z( c& ~( q# V% H; d
        out << " ReferenceDimensionFlag: " << refFlag << endl;$ O  b4 x6 @" O
1 D. Q4 }# u* \- ]6 i& p
        int tolType = (int) theDim->ToleranceType();
% U) T! {8 L8 N9 x6 j# R( G% W        out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;
$ t9 }, P& z% {  t3 b+ }# R" B
6 U0 v2 T0 {1 M' u1 V        ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);
2 C* @$ ]( C+ }$ Z8 Q6 w0 {        std::vector<TexTComponent*> textComps = theData->GetTextComponents();3 A$ L, H) Q4 s0 M7 L
        for( int ii=0; ii<textComps.size(); ii++)
( \. b' k: C. R        {. |! f1 [# T+ `2 _" ~
            std::vector<NXString> compText = textComps[ii]->GetText();
. j! W: q9 x5 M0 x7 K            for( int jj=0; jj<compText.size(); jj++ )
- ^- p6 {, X5 ?3 g                out << " Component Text: " << compText[jj].GetText() << endl;
2 n; X) H3 Y6 d) P9 k        }! E4 L8 g% y* ^9 w

. c( j! L/ B3 R# P1 i) @, [! [        int subtype;! M0 i3 Y3 z" c/ W
        double origin[3];
  M6 S4 m/ @4 x) S+ P* j- T& @  g  e        UF_DRF_dim_info_t *info;! [& i1 e$ I5 ?, c1 I9 L
        UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));" c) q/ y1 `- K- K
        for (int ii = 0; ii<info->num_text; ii++)0 n5 A) h* ]# C# _* `
            if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)% f2 ?: d' D* U5 I  G
                for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)
3 `# |* R) e' C- Z/ S" x/ p                    out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
- \, j0 J5 D5 e1 t. a& x8 W        UF_CALL(UF_DRF_free_dimension(&info));- T" Q5 R4 Y8 r5 h/ v

) x2 u9 O2 f; e: b" t- J        lw->WriteLine(out.str().c_str());0 P# ^5 U8 G6 Q& z0 j1 N8 o2 e
" R4 l+ V: q% A
    } // while' x' P; {3 z# t( B! u2 v* M( Z8 k3 u
}
3 O3 g$ h/ `( Z. s- }% ~: l
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了