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

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

admin 楼主

2015-8-22 12:47:05

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

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

x

% I4 t/ ^3 K4 K$ B0 j; L3 t$ b. aDimension* plmhome::select_a_dimension()9 n  V* l) R% W3 l3 j; _: _
{+ ^  g6 x' w/ `7 x; ^! u9 F* d
    // ask user to select a label. P3 q# r3 b, a
    UI *ui = UI::GetUI();  p) f/ F9 \6 s  r9 l
    Selection *sm = ui->SelectionManager();% ]% }3 i* E3 k
    NXMessageBox *mb = ui->NXMessageBox(); // as of NX5$ n5 t" ]- l# ]3 s
. [! ^8 W/ ^  d, j& w
    NXString message("Select Dimension:");
& X/ @) H, h' A3 Z  d2 \7 X( [% Q1 S    NXString title("Select Dimension");5 V8 x. _. N7 A+ x# y  ?3 `; l% ]2 h
    Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;( O( h2 G+ s. b! B/ k& p+ m
    Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;6 g0 j& [! s4 m; E5 c$ k
    bool include_features = 0;
( |' @/ x) m9 y6 H/ l    bool keep_highlighted = 0;
- ?$ B' D) A& }3 x4 |/ w% n! k5 C
    // Define the mask triple(s): B! l( m0 J, ]/ G( g- c
    std::vector<Selection::MaskTriple> mask(1);
0 u5 D$ C# y4 v3 |* G( s; R/ E    mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );' {8 a' U) X( z% B6 v
    Point3d cursor;
% h! i; C. K! x; c0 ]+ ^; X& Y    TaggedObject *object;6 B, H( I: D7 x' V& R

. K& O3 k0 ?' Q$ h    // Select objects using filter defined by mask triples
( g" F+ q6 ]( w$ m: f* F    Selection::Response res = sm->SelectTaggedObject(
' D9 @, s% M7 g, i! E. T# q" e  u        message, title, scope, action, include_features,
" w( r8 Y4 g& n) b, L' _1 y            keep_highlighted, mask, &object, &cursor );7 k% }+ n+ H" T3 z
$ w4 g5 f' S4 }9 O
    if( res == Selection::ResponseObjectSelected )
' O8 e- v0 K7 S$ A# O# X, K8 y    {4 G. P4 ~! |. o5 f
        Annotations::Dimension *theDim;
( Y* H! F- }- E$ s, n; C
0 k0 p( v8 a3 J0 Y0 r        // this doesn't work and 'note' will be a zero pointer, see PR-1850850) ~/ ?% b; l' J. W8 U& T* ^4 l! w
        //note = dynamic_cast<Annotations::PmiNote *>(object);
. G  P- N& M- c8 j2 D1 c
5 ^! J+ n7 S4 Q& q- I8 J        // this works as a workaround1 U/ @8 B1 [0 S
        theDim = (Annotations::Dimension *)(object);
  y+ T; `. e& l, O5 t* H        return theDim;
  I; [( K+ g4 j: H8 H4 q' `    }* p: h0 k0 v* I
/ Q7 y' j! z) G' Z4 F; x: x- P
    return 0;
/ i) d  f: g( f) n6 o& S- s) H}. m( [! A$ P- f/ ~0 w7 k. l

2 d+ Z+ p8 l( k0 o8 x- w0 B$ ?8 t
+ e$ d- L: j5 ?2 q5 b  K7 N: u6 t% z
# R+ T2 O9 p. i4 ]$ g' r' q
void plmhome::do_it()! w+ V: e+ T$ [% A+ `' Q( ]/ _
{: t% H* F* Q7 X. O% n3 B
    workPart = theSession->Parts()->Work();$ @7 S5 d. h5 Q* s+ W2 }8 D
    Part *displayPart = theSession->Parts()->Display();
  Y7 L3 I  y0 C  a    stringstream out;; g( D8 y5 F$ ^3 X' q% V
    Dimension *theDim = 0;! ]" \% s) x0 ?3 _. k

% {; e* ~5 `7 T) W  l# q% t    NXString tolTypeStrings[] =
' a( ]3 R$ T  B9 X+ x    {( m7 `( B4 R; D! B
        "ToleranceTypeNone",+ T/ p3 L) v8 Z0 o- O; ?* Q) I$ x0 _; {
        "ToleranceTypeLimitOneLine",/ l1 O2 T* d2 S2 d9 ~( B
        "ToleranceTypeLimitTwoLines",
3 j& Q' {2 ]) y        "ToleranceTypeBilateralOneLine",- k7 }- D  U1 l$ k  f
        "ToleranceTypeBilateralTwoLines",
2 t: R% f0 |7 I* U        "ToleranceTypeUnilateralAbove",. ^" ?$ o6 R" l# O* v+ O# m. Q
        "ToleranceTypeUnilateralBelow",4 G/ \) N, ]% C4 k: h
        "ToleranceTypeBasic",
" R: f0 X- d% b; n7 g$ l        "ToleranceTypeReference",+ I" x8 z) o' U/ D5 Z: V
        "ToleranceTypeLimitLargerFirst",
% {$ Y7 E) m- b" a/ t        "ToleranceTypeLimitLargerBelow",
( @& ^' V; T3 g5 x  s        "ToleranceTypeLimitsAndFits",* ?4 {  Y) o, v, I
        "ToleranceTypeNotToScale",+ H8 \9 }! W  \- i6 v
        "ToleranceTypeDiameterReference",) B$ y) h$ w8 S9 {- U/ {- Z8 {( R+ [1 _
        "ToleranceTypeBasicNotToScale" 2 S% O( f* E6 [; p4 l4 ?# x( k
    };, z' ^( ~# k4 y

' W# p; \9 O. f+ {2 k    while( (theDim=select_a_dimension()) != 0 )! Z/ P- B0 z% A0 D0 Z! V' H# ?  b
    {
: A3 e5 X5 V( H, u4 Z5 L& N) k+ j        out.str(""); out.clear();1 k9 J0 W; K+ v7 x6 G# l: q$ n
        if(! lw->IsOpen() ) lw->Open();) x1 k, X1 d1 c% I. F  V7 n3 A

, F4 P$ v: z2 b8 X. e, x: Z        out << "Selected Object: " << theDim->Tag() << endl;' L+ k0 }% @, r6 F! m3 A

2 a. ]4 H' X* r& {' S0 H8 [; p        std::vector<NXString> mainTextLines;   g% {: t6 s' U( Y& m
        std::vector<NXString> dualTextLines;
# j; Q& J. }; C. Z( A) t+ d; r        theDim->GetDimensionText(mainTextLines, dualTextLines);& ?7 |  H0 N9 w* M1 Z
        for( int ii=0; ii<mainTextLines.size(); ii++), H" `+ ^9 O! X
            out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
4 [6 o" l& T  M        for( int ii=0; ii<dualTextLines.size(); ii++)) [% c' R  [  D: @7 i( e
            out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;) z0 G" v: A  G4 [; H* s
! x5 O, z# k9 |$ @! c1 D7 K
        bool refFlag = theDim->ReferenceDimensionFlag();2 G* ~4 W/ q9 P: P  z( D
        out << " ReferenceDimensionFlag: " << refFlag << endl;/ W" M: l9 F& f. K4 h; t
, I# A$ L) Z! o- U' @* E& T; R/ T1 _
        int tolType = (int) theDim->ToleranceType();
4 c8 o$ |2 P. d1 ~# W+ C5 H        out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;
9 [/ R/ q" l5 Z
4 }4 {6 D7 X6 p! M6 x- L# I# s        ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);
1 Y+ k0 n  Z# V+ j1 Z- ^        std::vector<TexTComponent*> textComps = theData->GetTextComponents();
9 x/ d5 G7 w2 J, P2 q, u3 N9 M        for( int ii=0; ii<textComps.size(); ii++)
$ C) j1 v2 i2 J4 ^  H5 f1 Z        {" Q3 r1 s- Z+ C/ S0 M& l
            std::vector<NXString> compText = textComps[ii]->GetText();: Q+ J) g% G2 h; h& e% X
            for( int jj=0; jj<compText.size(); jj++ )0 v  T5 v7 F/ |6 f, L, f
                out << " Component Text: " << compText[jj].GetText() << endl;
5 q9 G% p6 _1 T- s# Y  R. Z8 ^6 e        }! c  i7 Z% z; R% c6 x4 A6 v
$ [+ N( l- \1 R! N5 K. m2 }6 j
        int subtype;; K/ j5 \' }( a  L
        double origin[3];9 [' ?- c( a0 x2 m+ F
        UF_DRF_dim_info_t *info;
9 }6 s0 ]. f, X* M( v) o        UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));
0 N7 E6 M6 K7 d0 X" P        for (int ii = 0; ii<info->num_text; ii++)
. T5 }, h- Q. `            if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)9 `7 A4 @2 k. ]
                for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)# ^4 b: W7 H& f
                    out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;) L# x0 n7 b2 T* s! Q- i
        UF_CALL(UF_DRF_free_dimension(&info));7 t/ |& X3 G* s9 @
" z1 ?% ]* v% `8 }3 l* Q* q$ a
        lw->WriteLine(out.str().c_str());9 H! l6 s$ f5 A
# ]% t$ C+ _5 }# e
    } // while+ g  f7 o1 v0 ?, L0 E/ S
}
+ b% R! D4 b" Q& G. X4 a  _
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了