PLM之家精品课程培训,联系电话:18301858168 QQ: 939801026

  • NX二次开培训

    NX二次开培训

    适合初级入门或想深入了解二次开发的工程师,本培训结合ufun,NXOpen C++,大量的实例及官方内部的开发技术对于老鸟也值得借鉴!.

    NX CAM二次开发培训报名 NX二次开发基础培训报名
  • PLM之家Catia CAA二次开发培训

    Catia二次开发培训

    Catia二次开发的市场大,这方面开发人才少,难度大。所以只要你掌握了开发,那么潜力巨大,随着时间的积累,你必将有所用武之地!

  • PLM之Teamcenter最佳学习方案

    Teamcenter培训

    用户应用基础培训,管理员基础培训,管理员高级培训,二次开发培训应有尽有,只要你感兴趣肯学习,专业多年经验大师级打造!

  • PLM之Tecnomatix制造领域培训

    Tecnomatix培训

    想了解制造领域数字化吗?想了解工厂,生产线设计吗?数字化双胞胎,工业4.0吗?我们的课程虚位以待!

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

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

[复制链接]

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

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

admin 楼主

2015-8-22 12:47:05

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

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

x

# k6 }+ }: P2 t  j$ J7 o+ O7 RDimension* plmhome::select_a_dimension()
$ _- Y$ J5 y% f- _) w{
& \+ C0 @1 {2 v2 q9 d    // ask user to select a label
7 j, b* G1 x- W& t    UI *ui = UI::GetUI();
, e  E( C3 M# {# C/ a. p( j7 p    Selection *sm = ui->SelectionManager();
) a& l9 m4 Q% }$ h4 ]. Z    NXMessageBox *mb = ui->NXMessageBox(); // as of NX5
  W  _) j3 W* E2 r( e4 _
9 r5 r* w, {9 |+ e/ K5 R6 Y1 M    NXString message("Select Dimension:");
& [9 Q0 A* K2 N6 }; g% N    NXString title("Select Dimension");9 q  b8 t2 [3 i3 o
    Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
# n/ Z* r2 W7 h2 q" I, z- s    Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;# R( @# f) D0 J- {  w8 p  _
    bool include_features = 0;
- p6 [" s/ w% [* A/ {3 A    bool keep_highlighted = 0;
$ U  ~; S( w6 S9 l9 H, p9 z- U) }( Q6 |
    // Define the mask triple(s)
& T1 V) _: B- S' ^1 l/ ]+ x/ E, V. p    std::vector<Selection::MaskTriple> mask(1);
0 \, _5 p" N* [    mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );4 x' ]0 d/ j2 J0 k) h
    Point3d cursor;0 L. O1 G4 @; f) K
    TaggedObject *object;
% v! P+ f+ |8 A" A/ W
+ N8 ?  h( O9 t    // Select objects using filter defined by mask triples
$ N, f( o3 A( O+ ~+ L) m3 g" g1 u    Selection::Response res = sm->SelectTaggedObject(8 o% L) v3 B! J& a
        message, title, scope, action, include_features,
6 v" N/ ~, z5 w! J/ j' E            keep_highlighted, mask, &object, &cursor );# }( A4 l9 h$ p, y

; f! s  b9 y) j$ }4 C$ O    if( res == Selection::ResponseObjectSelected )+ Z: Q& B1 t: S& \- X+ A- y
    {" z& a. z5 n3 `" }& C
        Annotations::Dimension *theDim;
9 g7 v. V" |% o7 _9 x- O7 _9 S  V% @: J' O! m4 t
        // this doesn't work and 'note' will be a zero pointer, see PR-1850850( B2 f3 A7 W/ n4 a9 T0 o0 Y
        //note = dynamic_cast<Annotations::PmiNote *>(object);
1 P6 Y( ~2 r+ y! O% P$ K" E4 l9 U& {: i% B, F, Q6 W; `3 c
        // this works as a workaround  K% G! I7 D6 a0 @: d
        theDim = (Annotations::Dimension *)(object);
6 A* X) b7 q/ M        return theDim;0 R' H( ~2 q: j- Q: t( C
    }
4 X8 U: \( o) M; o/ o" r+ B
7 [7 I2 V3 v) M+ _1 G% v* D2 s    return 0;
/ v- Z2 H/ T$ W5 T# n0 m}2 V8 G2 R9 ]9 B) r# Y5 l1 B
6 ]  A2 ?* Y7 i) Z! F+ V! T/ [
7 h7 L2 C( T. |2 P

2 B$ v; y+ ~, z8 s0 d
& ^6 b, v$ ]0 \- ivoid plmhome::do_it()' g3 ], V8 v- z9 h
{
- N) n$ J! x- U; G1 B7 r8 I    workPart = theSession->Parts()->Work();
/ F4 {) w, U; ^    Part *displayPart = theSession->Parts()->Display();
# {/ x" Y3 h% j, M; F* J, S    stringstream out;
4 ~+ K- F8 X" S+ i1 I7 H, H    Dimension *theDim = 0;
" a! @, p; w) u# v. {
  W/ S8 f3 ]& X7 R; k% s& F' {    NXString tolTypeStrings[] = + g8 O- {0 a& d2 [- \
    {
+ e; V* [2 j6 i4 T/ n% a+ m" \        "ToleranceTypeNone",
. b# n& Z- Y4 E        "ToleranceTypeLimitOneLine",
3 E( N3 d' e5 [8 l* J        "ToleranceTypeLimitTwoLines",
0 U& o) B8 c$ n. S, G# W8 m" i. {, D3 D        "ToleranceTypeBilateralOneLine",6 S! ~  G' P0 j0 P2 t2 B/ I
        "ToleranceTypeBilateralTwoLines"," F' g6 r& }- P+ e, D& M4 ~
        "ToleranceTypeUnilateralAbove",
- \- e* A/ j5 I7 m        "ToleranceTypeUnilateralBelow",4 a' N" H4 e" R4 [1 |  \8 Z1 S
        "ToleranceTypeBasic",
1 W4 K& R7 Q* T4 G' i) N        "ToleranceTypeReference",
# l' U* q% @, z6 I- m) j$ h+ _        "ToleranceTypeLimitLargerFirst",. e- W" o/ V% T- ~& m- Y  H
        "ToleranceTypeLimitLargerBelow",3 i) E2 Q* g2 t2 N  B2 m
        "ToleranceTypeLimitsAndFits",. _' ^2 z* x6 l3 ]0 V- T- u
        "ToleranceTypeNotToScale",% t, w: z6 P7 R2 h4 k4 u. l
        "ToleranceTypeDiameterReference",
' n7 O8 L  W* U0 y, j( i5 Y5 _8 F        "ToleranceTypeBasicNotToScale" ) o( h5 u6 Y; J( j
    };5 @) w# \0 u' o. T1 y
, i9 A1 ?- G9 m" m, V
    while( (theDim=select_a_dimension()) != 0 )
- y0 B) i+ ]9 f/ K6 Z8 O/ C* f" d    {
7 N9 H, Z- |* q: A+ a9 r' z% }) b+ T        out.str(""); out.clear();. Y, E- G, A) G% q5 n' Z
        if(! lw->IsOpen() ) lw->Open();& c% `6 `- \$ \4 k( |, ~& J
; E' i& T) w5 Z  K
        out << "Selected Object: " << theDim->Tag() << endl;$ `: m* L$ z+ A3 R1 k  T8 l
6 A- N* L# C/ q8 g$ x
        std::vector<NXString> mainTextLines; 1 X$ v2 T4 u; F  b# }$ }: H* Z
        std::vector<NXString> dualTextLines;
" X: ^+ [' S+ u        theDim->GetDimensionText(mainTextLines, dualTextLines);
. Y3 n( Z& d0 R: g& R        for( int ii=0; ii<mainTextLines.size(); ii++)
6 c8 F6 @6 L' g' q% J& t. a            out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
$ y- G4 w( o  n- O4 {9 o        for( int ii=0; ii<dualTextLines.size(); ii++)
7 X: ?. x  r- A            out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;  l9 h& P; w8 _3 F

" ~3 f6 T: t& s+ M! h        bool refFlag = theDim->ReferenceDimensionFlag();
, B: W/ T9 W; y- A        out << " ReferenceDimensionFlag: " << refFlag << endl;  t' t1 u: Z6 E8 _- [
3 L6 }( h. l: _& h' y) b1 W; y
        int tolType = (int) theDim->ToleranceType();
  _5 Q- t/ ~/ r        out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;
- w7 j$ o+ k$ x) Q4 A/ Y+ n
3 Q" w& R/ T. e        ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);
, H  ~& k/ t1 r8 ^        std::vector<TexTComponent*> textComps = theData->GetTextComponents();
9 ]5 t' ~' K3 N) t) k        for( int ii=0; ii<textComps.size(); ii++)
6 e7 z0 p, h. [  g- F! P% ?1 f( M        {
. C& G+ f  A* @* {; v            std::vector<NXString> compText = textComps[ii]->GetText();
' h: [2 x+ U4 m5 m7 u4 ?            for( int jj=0; jj<compText.size(); jj++ )
- c5 I$ `% ~8 _3 m& o3 q8 a+ P                out << " Component Text: " << compText[jj].GetText() << endl;0 s' n$ F5 g9 g5 N2 Y
        }9 `; m0 F2 t4 C! [8 y! f7 w) K
% X4 \! n, a/ `( E
        int subtype;
6 X3 _0 C4 p- v        double origin[3];
" k8 U0 r  x( h. }1 e        UF_DRF_dim_info_t *info;
0 n* T* u- G' _  ?7 [: G1 V        UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));
, H# v' V/ P/ v/ c' i! S+ E) t        for (int ii = 0; ii<info->num_text; ii++)
: x6 |- ~4 Y1 U% v% @+ x            if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)0 S; a" m  A5 h! l; i6 g9 l
                for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)
7 z8 p' `% }" p* w                    out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
( s1 w! B  ^: j' ]( }- o  Z        UF_CALL(UF_DRF_free_dimension(&info));- c& N! O/ u2 s

% D% H2 C+ _) \+ S        lw->WriteLine(out.str().c_str());
$ x2 j: m2 C, _
+ C, m* O1 s3 `2 ^7 i" C    } // while
) r. n9 i* U- u: z2 f6 a}
# X0 K4 k( P) a9 o% ~
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了