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

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

admin 楼主

2015-8-22 12:47:05

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

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

x

2 {! B5 O( v$ L4 E2 p, B; h! ~Dimension* plmhome::select_a_dimension()
! E: f4 W, t* h8 R( ^# ^1 ^+ _' f1 p{" ], r; C( X+ W  }0 V
    // ask user to select a label5 S# g' U: ^1 N: e% p2 S3 c
    UI *ui = UI::GetUI();
/ `/ @7 u8 E$ q7 H6 G9 h5 b    Selection *sm = ui->SelectionManager();
# n3 }6 P  c5 G    NXMessageBox *mb = ui->NXMessageBox(); // as of NX5/ R3 U, b5 y% `1 K& x, t

/ K) S/ V" w+ k- m    NXString message("Select Dimension:");
, S* i! g# [. B  B: a, `5 l    NXString title("Select Dimension");
3 B, L6 D$ Q# _, ?    Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;. @7 v6 \5 m. _$ {
    Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
* v7 L9 b3 j  d& j  d+ S7 d1 z    bool include_features = 0;3 M9 S. s3 ]% p* u9 e# t" R
    bool keep_highlighted = 0;8 t  N5 T3 D2 v4 U  S8 f% s2 I! k
% l3 m* f5 X* ~6 z. E
    // Define the mask triple(s)
4 l' V/ {' R- E$ Z; ?; x9 L    std::vector<Selection::MaskTriple> mask(1);
3 M$ K7 W6 C8 a    mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );5 P, G$ Z0 A% ^0 z" H
    Point3d cursor;
! ~  o- C5 ~$ |    TaggedObject *object;
1 g" Q  D  G& b" F  @3 a/ I9 j0 X" b8 S
    // Select objects using filter defined by mask triples. K2 B1 \7 f$ W# U
    Selection::Response res = sm->SelectTaggedObject(9 t. y* F' _, R# P8 B
        message, title, scope, action, include_features,
/ {$ F' y9 t; |1 m            keep_highlighted, mask, &object, &cursor );
5 o0 V, o2 O$ O2 _) N# g$ {5 l3 y8 t' \+ G8 ~" p* s
    if( res == Selection::ResponseObjectSelected ): }. `- `; z9 Z( ]/ M
    {3 c) g; w* b% w1 k8 G
        Annotations::Dimension *theDim;: j& E+ n  a9 u6 _

; O8 S4 r) A) c2 x- S1 }        // this doesn't work and 'note' will be a zero pointer, see PR-1850850
0 M8 r% s9 b$ j4 t. P# w. O# [        //note = dynamic_cast<Annotations::PmiNote *>(object);
. R# Z7 j1 X3 G/ h& z; N+ s
5 t2 z  @6 c( N        // this works as a workaround$ h- B0 d4 L6 H$ P; C2 x
        theDim = (Annotations::Dimension *)(object);
; ~) N+ P' }1 O) c5 E: v6 h: H        return theDim;
/ K5 e2 M1 x3 m! a. s! x# P    }
: p# W! p: Y- I& W* q: M* j. e% c( M
    return 0;9 f, a3 p$ q' g( c: U. i
}2 \: O; Z% T+ T! ?5 [9 }; A# @
3 N7 D& F% _8 O/ [1 h

  x$ v3 f4 W( w. H# B' J! A" z! w4 l7 j* u! z' v! h

& g$ W8 s# t0 ~" u& x8 Avoid plmhome::do_it()
4 P; Q* w% X9 h; i4 b# M7 s{
. V+ ^6 E8 ~  J+ {! s& k# j" o    workPart = theSession->Parts()->Work();
) ?' n  p, Q! {3 K& B    Part *displayPart = theSession->Parts()->Display();
) s2 k* U9 Q2 A& s    stringstream out;' x# b  l! ~* [' S
    Dimension *theDim = 0;
" J; J2 [& L4 T) r- d$ q* S* G6 N& R8 p5 d: {( A. S
    NXString tolTypeStrings[] = ; E- V" U, G, Z( ?/ G7 S) B$ i
    {3 o6 S" t0 w/ N
        "ToleranceTypeNone",. t/ M* ~; B; b* I( d& d
        "ToleranceTypeLimitOneLine",8 q# y& M- Q3 q; O
        "ToleranceTypeLimitTwoLines",
& Q! t0 u4 W/ ?7 P        "ToleranceTypeBilateralOneLine",
  W, r, t; p( p$ _" n& E# p$ g1 ]! `; S        "ToleranceTypeBilateralTwoLines",
  Z+ ^* b% U1 ]( L1 ^3 f- s        "ToleranceTypeUnilateralAbove",
7 I* C* {$ f/ S        "ToleranceTypeUnilateralBelow",  J5 m/ W+ w' S" a, ^
        "ToleranceTypeBasic",
" z" D4 Q1 S( C3 S9 w7 f1 }4 _1 z1 g        "ToleranceTypeReference",
/ N6 j3 n. U$ v' Y        "ToleranceTypeLimitLargerFirst",! ~2 j% L! ^: j7 t2 v
        "ToleranceTypeLimitLargerBelow",
8 N7 x7 `/ b/ a! l        "ToleranceTypeLimitsAndFits",' D2 O$ B. ]' R3 X! |3 z  Q
        "ToleranceTypeNotToScale",2 _: X. f* a7 R+ m
        "ToleranceTypeDiameterReference",, {1 x2 `$ s# E3 a
        "ToleranceTypeBasicNotToScale" 4 W0 o- n& X) o
    };
6 _  l; K4 v4 h) r$ i' U+ g3 P+ ^0 J. ^! G# ?
    while( (theDim=select_a_dimension()) != 0 )
' j% d+ \- p/ b+ s    {
% [* d4 L0 Y9 l3 P        out.str(""); out.clear();
1 n7 P5 i0 d; X  q" g$ ~7 G- Y6 N        if(! lw->IsOpen() ) lw->Open();3 I+ A1 B# u: Q; y8 A3 ~

' n* c' E7 E" u1 }. x        out << "Selected Object: " << theDim->Tag() << endl;5 p4 S% G7 M& W8 X5 F

, K( e/ a1 r! S0 L4 B% Y1 a/ E3 b        std::vector<NXString> mainTextLines;
( W4 d; r+ U' b- g        std::vector<NXString> dualTextLines;
4 E- I* C/ c+ x% W2 Q! \6 }        theDim->GetDimensionText(mainTextLines, dualTextLines);# N& `0 j+ s# F2 m
        for( int ii=0; ii<mainTextLines.size(); ii++)) l7 E$ U  F) I0 D+ P2 p
            out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
, A6 v. f3 l6 X% f        for( int ii=0; ii<dualTextLines.size(); ii++)* p7 E, A( G4 |7 c- k( F) i; O
            out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;
: a* e9 V/ {) P
8 ~5 G- o2 O: Q: c, B        bool refFlag = theDim->ReferenceDimensionFlag();
! r6 t/ A) i0 |. t        out << " ReferenceDimensionFlag: " << refFlag << endl;* ~+ j) K/ `6 T) O$ v8 Q& _+ f
8 z( U* h6 E2 `! i; [6 F8 }8 M; }
        int tolType = (int) theDim->ToleranceType();: @; D  b2 q6 `1 o6 o1 e3 ?' w
        out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;. o( ~. e; q& s; ~6 }2 O

3 H/ F1 U/ p' g0 B        ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);4 N- b* U* w8 B% w3 }- {
        std::vector<TexTComponent*> textComps = theData->GetTextComponents();9 ^. z) {3 }7 Q' {" C
        for( int ii=0; ii<textComps.size(); ii++)
8 r+ k- P: U4 K! l7 I- O/ |        {2 y( a  @0 S; `- G& X2 e9 L' Q
            std::vector<NXString> compText = textComps[ii]->GetText();6 f6 `6 y0 @4 v0 b2 [
            for( int jj=0; jj<compText.size(); jj++ )
8 k. r+ D: P7 ]" x1 l0 P                out << " Component Text: " << compText[jj].GetText() << endl;7 ]7 c$ t# A" ~2 N
        }: N4 B2 r. E5 {
: [' W) O/ V' x7 `5 t
        int subtype;
  f  `* D! {  j. \% F. j! O2 F        double origin[3];
5 [) \! N3 T$ S5 @        UF_DRF_dim_info_t *info;4 w& `' P9 `3 J/ t* l
        UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));
1 Y1 h+ `3 [, b5 x9 O! Y# s        for (int ii = 0; ii<info->num_text; ii++)$ ?" Y$ h& d( l4 A4 u- ?( q4 l
            if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT): l7 {# C  X+ s5 Y( u
                for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)
; N" }3 g2 ^" I4 _' m" B                    out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;0 e9 O$ r3 B1 p. V
        UF_CALL(UF_DRF_free_dimension(&info));; F& j7 a: `0 a4 ?5 c5 e& }4 ?) g

7 m1 Q/ U9 p# m1 N: z% p        lw->WriteLine(out.str().c_str());
* U' t$ H6 k! V' T+ N( p1 G1 `% P3 s( g
    } // while
5 A2 @; t& l5 X}: I2 z) J# o8 `9 |
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了