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

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

admin 楼主

2015-8-22 12:47:05

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

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

x
/ e+ r8 y5 @" |, K% X5 J% \
Dimension* plmhome::select_a_dimension()
1 K) a" L: i* d7 o! E) n{4 L! C6 S% E* F( L/ e9 R8 W9 y* a
    // ask user to select a label
/ k' P6 v6 D4 w0 X    UI *ui = UI::GetUI();; N& q6 x. K$ Y! O8 C. W" s3 Q
    Selection *sm = ui->SelectionManager();; `7 P$ z0 Z( Z+ L& g; W: m
    NXMessageBox *mb = ui->NXMessageBox(); // as of NX5$ O' G7 Y3 M% s1 U

% [) u4 S% |5 P1 }) b    NXString message("Select Dimension:");
) }( P& p9 W$ Q4 t7 m    NXString title("Select Dimension");
6 F, c8 T: P" w- A" s. Y4 j    Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
0 Y" ?3 r: d- {! @5 c    Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;* D& l5 v( G( j* R1 h3 W) B& g
    bool include_features = 0;
: T  s$ Y& k0 x! S8 A$ A) I    bool keep_highlighted = 0;
/ h9 f! t1 J2 E8 K* S6 T& c% ~- l9 E! I
    // Define the mask triple(s)
& ?: k7 C6 s% }. r    std::vector<Selection::MaskTriple> mask(1);
! n4 }4 m6 ]( B- t3 w  l- N    mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );" R! T( o4 H) M9 x3 a/ J3 o: ~
    Point3d cursor;; i9 T6 \! q% I% T: ?  K7 i
    TaggedObject *object;2 N, v+ A! C, z/ H
6 T. t# a+ p, h3 f( A1 n
    // Select objects using filter defined by mask triples
* V5 D" S% V6 f: l1 ]# r) m    Selection::Response res = sm->SelectTaggedObject(
% b$ b* t7 u, e; T        message, title, scope, action, include_features,% Q$ h# O2 t, ^* t4 s
            keep_highlighted, mask, &object, &cursor );
6 I( x. O( k  N
* R" T% H9 a% Z2 ~) m7 ]; O    if( res == Selection::ResponseObjectSelected )
: Q7 p" @, S, w8 g) N    {
( q8 {- I- p/ p        Annotations::Dimension *theDim;
" `, p. M0 V; F+ {: u1 O* L; O5 H: C& V( q
        // this doesn't work and 'note' will be a zero pointer, see PR-1850850
* r. p  X0 y/ K0 e        //note = dynamic_cast<Annotations::PmiNote *>(object);9 ^6 G% j/ `& R) E2 B

0 ^4 f+ W' f/ S5 @- d        // this works as a workaround
: l9 ~- e1 l5 t# r9 s4 W, J        theDim = (Annotations::Dimension *)(object);
$ M2 z% B% |9 o2 P. Z. v        return theDim;! F. r5 n/ a" g. J7 ?7 n
    }
  k2 Z6 T( I. _2 X2 w- B! X3 o& H2 i* g. e& n! J3 v
    return 0;9 j2 c# Q4 k8 K! v! g7 r& q# {
}  r# Z  R' v  F$ e6 m& `: d
: p& U; h! ?# w

: [8 `1 W$ _; V% C9 @" Q% e' K! e% Y$ Z( @
, q# ?2 `4 g7 z5 E4 s4 S% N2 x
void plmhome::do_it(), y# V* O) h1 n
{
8 t2 Y) z6 l6 U* L' M+ Z    workPart = theSession->Parts()->Work();- X1 {* u, R' p8 t2 j3 ^# j
    Part *displayPart = theSession->Parts()->Display();7 b6 |: c  s  J5 l9 ]9 J
    stringstream out;  a" ]2 d, f( K1 Y; u
    Dimension *theDim = 0;( C5 [2 o! ?& p: ]
, U+ h! L: C5 I: b
    NXString tolTypeStrings[] = 6 N% b- c0 @3 L5 L3 f2 s. G; K
    {
; Y; F& {' N6 N- l! J2 g        "ToleranceTypeNone",7 t9 Z* J% m+ C5 N  B& \1 T
        "ToleranceTypeLimitOneLine",% X/ K4 q7 J- @, a
        "ToleranceTypeLimitTwoLines",7 x% m! w8 j; m6 d8 _4 \
        "ToleranceTypeBilateralOneLine",' \) q0 T6 i8 ~7 u
        "ToleranceTypeBilateralTwoLines",% s# x  ]5 u/ G' Y
        "ToleranceTypeUnilateralAbove",
0 R$ i+ k6 l9 @% x' a7 |        "ToleranceTypeUnilateralBelow",
$ `" D* |7 E' V& _1 r3 L/ }        "ToleranceTypeBasic",7 L4 Z( S( o( @( m/ o
        "ToleranceTypeReference",
4 y. Z3 W, \- }4 M/ F: Q        "ToleranceTypeLimitLargerFirst",& x  d6 v+ l& ~" x% L6 {
        "ToleranceTypeLimitLargerBelow",
/ Q- |2 o3 F6 K8 f( Z! }        "ToleranceTypeLimitsAndFits",
" G! T7 E5 B) U  w3 n; b        "ToleranceTypeNotToScale",
! X6 W. {& c, b4 p* t3 D        "ToleranceTypeDiameterReference",
! a& D4 V) m( _- Z0 ~        "ToleranceTypeBasicNotToScale"
- n( M0 Y) f' t    };
8 e; W1 I% y  G1 Q6 B; w/ p5 X7 u/ w
    while( (theDim=select_a_dimension()) != 0 )
4 D0 [' N/ w6 @! g& v8 D& K    {  p3 @, r3 i! [2 x) F8 I9 \
        out.str(""); out.clear();* C$ Q8 }/ {" i- e. j' z
        if(! lw->IsOpen() ) lw->Open();
2 z7 V6 h* y' G: m! ]
0 j( P0 U% _/ N( R# g/ N9 ]: v; v        out << "Selected Object: " << theDim->Tag() << endl;; _8 F/ f3 R; }- a; N+ E2 T

) E- a3 M8 [4 Q( B        std::vector<NXString> mainTextLines; 4 B. l8 e9 M& S/ P9 S
        std::vector<NXString> dualTextLines; 4 A) R1 V7 M$ y
        theDim->GetDimensionText(mainTextLines, dualTextLines);
+ ?: _  B! Q( m! j9 ?        for( int ii=0; ii<mainTextLines.size(); ii++)
& `9 N  g6 q5 g) K9 Q$ x            out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
- a2 ~- H+ z  `+ y# b3 S1 I; }        for( int ii=0; ii<dualTextLines.size(); ii++)6 n' q! g7 e- ~+ `
            out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;' k/ V2 c# }- ^4 n4 ?% D+ h5 D

: w) I4 E4 I3 D0 _9 B$ Z. \        bool refFlag = theDim->ReferenceDimensionFlag();: v; s# [: m0 i  o3 I
        out << " ReferenceDimensionFlag: " << refFlag << endl;, o! w" t3 ]3 l- o
9 f+ J9 p, C6 n4 t3 [0 v
        int tolType = (int) theDim->ToleranceType();
: k" A5 E1 ]( ^* {        out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;4 {0 X5 ]& u% ]: R
! X8 H( a9 x- r3 p5 W* y
        ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);/ }2 o' c$ \; {) ~& R+ H/ `: V1 L  a
        std::vector<TexTComponent*> textComps = theData->GetTextComponents();
. D# B$ J/ c; S( t  O' V9 I        for( int ii=0; ii<textComps.size(); ii++)
  g. i4 K4 V' C2 b( z        {- C9 x2 T7 Z2 h. j" ?& Z
            std::vector<NXString> compText = textComps[ii]->GetText();
: ^0 E  l% e( d. @            for( int jj=0; jj<compText.size(); jj++ )
4 J2 j# e7 P! G% Q  Q                out << " Component Text: " << compText[jj].GetText() << endl;6 ?9 S7 ]0 A+ {" [2 T
        }5 {+ G/ O/ ?" ^8 d. L- F

- ]5 W+ k- u; t1 R% W* G        int subtype;
4 N+ t: {  r: K: R# b) W, M        double origin[3];
4 ~% {/ @% Y! T8 M        UF_DRF_dim_info_t *info;7 i7 ~) e0 b# b6 I3 Q1 U
        UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));
0 X+ ]! t; e- Q8 ~        for (int ii = 0; ii<info->num_text; ii++)* J, p+ l; o) }  m3 t' ]: R$ `
            if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)
. E8 n7 F% N0 z' w2 j/ M                for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)
- F5 K- O) P$ O( j, S. _                    out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
+ P  O8 O7 e$ `        UF_CALL(UF_DRF_free_dimension(&info));9 A" E$ R6 o: ~

, _* K6 @  \7 k8 F; f        lw->WriteLine(out.str().c_str());
/ E' s" x  J% L. _( w( \5 a& `! ~1 k7 b  n4 }9 l- H& t/ {+ A
    } // while% e5 L. m6 Z: y* ~
}& [9 M  y% X+ o% N/ E
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了