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

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

admin 楼主

2015-8-22 12:47:05

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

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

x
9 R3 K  p6 D7 \7 t, N" ?$ U5 ^
Dimension* plmhome::select_a_dimension()
/ h& z* |% c! C3 E{
* ^4 {) U9 h) _# ~* H    // ask user to select a label1 g* n" K; F* ]3 x0 A; t
    UI *ui = UI::GetUI();
$ q0 t9 x8 Z% B% U    Selection *sm = ui->SelectionManager();
* o( m9 l7 l+ {! X+ T0 h5 {& Z    NXMessageBox *mb = ui->NXMessageBox(); // as of NX5
  \# k* Q% M( S1 d0 b$ i0 ?' O" n! _" d6 j9 M
    NXString message("Select Dimension:");( v& ~( I5 y/ B2 A' d; M
    NXString title("Select Dimension");' b; L* O* a) c
    Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;8 _0 g' F( T% W4 [3 H" F: Q; }
    Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
$ \5 r# u" R2 M' d  ]' n    bool include_features = 0;
1 ^  w: Q3 A- M& h2 L    bool keep_highlighted = 0;
$ q7 A' @" J5 }5 z
/ r6 ]  k- M5 G/ r! I( G! t    // Define the mask triple(s)
$ h& F' t5 d. i  f% Y% G  I    std::vector<Selection::MaskTriple> mask(1);; B( X8 T. A+ T% p, C! E5 g8 Y6 a
    mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );- g( v. L4 v5 B3 ?- x$ K- F
    Point3d cursor;
  i3 X1 w2 M4 m    TaggedObject *object;
5 m- P) y! c4 s4 x, ^$ W* A' y
5 B9 D6 b6 z# n4 W# o    // Select objects using filter defined by mask triples
* `9 K' [# J% l1 C* R    Selection::Response res = sm->SelectTaggedObject(, X# Y$ r4 T; y2 [8 W) i1 }0 ~
        message, title, scope, action, include_features,4 D2 {9 G' V$ @$ P; H
            keep_highlighted, mask, &object, &cursor );
& m) I+ q1 \" O2 U# F
  M) _5 }9 N' q" M8 h4 B! X    if( res == Selection::ResponseObjectSelected )
9 n8 X; e# g. [( v3 T7 q$ W& `8 K    {
5 t* v9 R  |% t- w0 ]        Annotations::Dimension *theDim;, p2 T' V, ?' G7 S
0 l6 ]8 {: c! F2 _0 K! Q
        // this doesn't work and 'note' will be a zero pointer, see PR-18508504 J  o- n: E+ P4 S# \/ q) H
        //note = dynamic_cast<Annotations::PmiNote *>(object);
; y" M. }: L( u, E) z' e" D- i3 D- j1 b1 r1 z
        // this works as a workaround
0 h: s& O2 o$ G# x        theDim = (Annotations::Dimension *)(object);: @( x0 x$ t$ Z- m: D
        return theDim;
. G  m2 }8 N, ?& A) E: Y    }" y# b6 g1 X, X# @$ \

: E! _' d# n+ f8 B9 n    return 0;2 w& h0 k9 u+ Y5 W. \& Q/ J
}) k6 `( B0 j- _* Q
4 H3 t( v/ u3 ?1 e) }3 u2 u; V6 Q

: n7 i8 m) {( c& L/ f; [7 L- W8 Y0 S! U; \6 @) ^% j! J$ R( Q( l
$ W5 {- c- `5 k2 M8 I
void plmhome::do_it()7 w+ K2 b( A: m0 @; u
{
% {8 [' n, j" e6 Q: t4 X    workPart = theSession->Parts()->Work();  ^/ g  h% Y7 ~. G3 u- B3 ~
    Part *displayPart = theSession->Parts()->Display();
3 O; z# k- C0 ]4 e% _" ?( e5 v    stringstream out;' o: F' q, @, g) V4 g1 O6 F
    Dimension *theDim = 0;- T- U. F: X4 Y$ f1 m: \# a, G2 e

8 G6 A( A3 O9 X- V    NXString tolTypeStrings[] =
- }2 \$ u; {: Q8 s    {
8 \/ q: a/ W4 V) f6 g: U$ [6 E/ b4 H        "ToleranceTypeNone",' \# z8 Z$ e% B% ^, }0 S  w: m
        "ToleranceTypeLimitOneLine",# }5 K2 ]  N' a- S
        "ToleranceTypeLimitTwoLines",! J1 ]( a$ O! }' x
        "ToleranceTypeBilateralOneLine",$ [; l/ A( `2 d3 _# `/ S
        "ToleranceTypeBilateralTwoLines",
( u5 D- |7 L# R6 \1 P        "ToleranceTypeUnilateralAbove",$ H2 X7 v$ I! d# o* E; c! w
        "ToleranceTypeUnilateralBelow",8 M6 Z# y' [' e
        "ToleranceTypeBasic",! j5 }" g% m. Q, e9 V
        "ToleranceTypeReference",8 Q% N& h: _: b- ~4 \
        "ToleranceTypeLimitLargerFirst",& C! I' z, J6 [' j: S
        "ToleranceTypeLimitLargerBelow",* t) I6 F, C# K% E0 L
        "ToleranceTypeLimitsAndFits",
6 b. G; n3 S3 ~        "ToleranceTypeNotToScale",
# p0 z4 t; b9 |) v1 y        "ToleranceTypeDiameterReference",* K9 D- @7 j: U% g+ U0 p
        "ToleranceTypeBasicNotToScale"
0 t, y! s4 `2 o- Y    };
4 K- d# w  Q# h1 Y9 \
. I/ e' E2 Q$ O    while( (theDim=select_a_dimension()) != 0 )) u$ N$ ~/ M$ h1 x. G9 O: t
    {
4 N0 M: }' }! X/ G  D' }        out.str(""); out.clear();
! O; k5 c* \8 w2 g  K- _        if(! lw->IsOpen() ) lw->Open();
8 u  d) P5 v" l( Y- W. _7 T; p
2 G6 I. o, |' U( Y8 ~        out << "Selected Object: " << theDim->Tag() << endl;' A3 M4 T( ]  b8 h* ^: t
4 |, y4 n' `6 L% x6 B. {4 q
        std::vector<NXString> mainTextLines;
5 K' v0 \; B0 ^3 ]; u        std::vector<NXString> dualTextLines;
) b. {$ u7 g- B; Q        theDim->GetDimensionText(mainTextLines, dualTextLines);
+ h. _4 @  K  p- O        for( int ii=0; ii<mainTextLines.size(); ii++)! \: g9 B: m+ ?! B# A
            out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;7 `3 r1 G3 O8 {1 K8 W. m6 X
        for( int ii=0; ii<dualTextLines.size(); ii++)
6 ~* S) _6 v7 p& c            out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;9 Q$ d7 P: a5 a4 H0 E; {- h
% i" X0 F; w1 l; F. N5 u5 C1 M1 m
        bool refFlag = theDim->ReferenceDimensionFlag();# L% T1 ]6 I: z* |) D  W/ d
        out << " ReferenceDimensionFlag: " << refFlag << endl;, {& @4 E4 {- ~& k! u

. e- O# h% o  h& R4 ^3 S. z7 k        int tolType = (int) theDim->ToleranceType();
' [8 ~& A0 ?: S1 @. T* i        out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;
7 d! u! }& ~' [5 K$ O% }. a  k) D5 p3 _! f$ \
        ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);
8 Z) K) R  u+ C% D# p9 F& v        std::vector<TexTComponent*> textComps = theData->GetTextComponents();
# P6 F+ I2 p' X( _        for( int ii=0; ii<textComps.size(); ii++)% c: ]! I" w: ~1 C' }' d1 Z: O  R
        {6 X6 E  s" u2 ]: h% L
            std::vector<NXString> compText = textComps[ii]->GetText();% d# O# w" j; E4 n! [
            for( int jj=0; jj<compText.size(); jj++ )
0 Q$ x9 V( S2 P5 w) s; T                out << " Component Text: " << compText[jj].GetText() << endl;
# C/ `: ^( b) K3 }8 Z- E& X        }
+ T" S) s. h& b2 q  z: D5 C; [  u, S
        int subtype;
' I+ g+ D. K, p( ]        double origin[3];
, l  ^, {' C( r* C/ b3 @        UF_DRF_dim_info_t *info;
4 J( ^' b! `* }5 y* r& Z        UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));
. M( [& K' q9 S& ?4 P        for (int ii = 0; ii<info->num_text; ii++)2 a8 K7 `* Q: Z% J9 s- Q0 ?+ H: u
            if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)
; \- N% O* b3 ^                for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)1 H8 [1 o( |. z" Q2 E8 L' y# q0 ?
                    out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;; R. Z" H8 P$ g
        UF_CALL(UF_DRF_free_dimension(&info));% ]7 f$ e- E. g7 |

) @. z. j! q8 D4 R0 Z        lw->WriteLine(out.str().c_str());$ \/ ?! k0 y7 v8 S# y
# z! P" G2 U8 p9 v
    } // while& I6 _/ Y' f" T' w
}
2 l% G( u8 }# l% |' f
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了