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

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

admin 楼主

2015-8-22 12:47:05

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

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

x
1 W/ S( j2 e- T3 X3 K' a: o1 v; n
Dimension* plmhome::select_a_dimension()
, ^6 Z' C+ v2 P{
' U- y0 p/ P2 P$ t    // ask user to select a label- m. G  R$ M/ Z! E
    UI *ui = UI::GetUI();
% Y$ p2 r$ |% B- N/ W' l9 ]( A    Selection *sm = ui->SelectionManager();
8 C; P8 a7 L/ g& Y6 E/ w& Y    NXMessageBox *mb = ui->NXMessageBox(); // as of NX5
9 ], S# w7 H  Y/ p- p5 u$ _0 N& V6 ^/ W' u8 |$ r
    NXString message("Select Dimension:");  x  f" J4 c6 J, E, ~( j
    NXString title("Select Dimension");
$ {8 ~' X5 s( R6 N/ r" E    Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
. X- ]( Q( K2 O    Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
, X& T/ w, ]) @" v+ J# `& |" Y    bool include_features = 0;1 O* J9 B" T' N/ t( @
    bool keep_highlighted = 0;2 t, K8 u; O1 u* @0 l$ ~3 L
+ j' J0 W" q8 B! p- S
    // Define the mask triple(s)2 f% M7 }9 s3 ^. }: m1 G4 D
    std::vector<Selection::MaskTriple> mask(1);2 K3 L: Q5 ]& K; ]
    mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );
4 j/ h0 i* D& R) e" b" `    Point3d cursor;1 T  O" @; C' [5 j4 B  i
    TaggedObject *object;/ ^/ |9 W5 A7 ]* b0 \" W

! g+ W: B; d# Y    // Select objects using filter defined by mask triples- U9 x8 x+ Y2 G( `
    Selection::Response res = sm->SelectTaggedObject(
! I0 l  H6 o' g9 t; x: r! O/ h' W        message, title, scope, action, include_features,
9 V% V9 w& Y: |2 X* T- d            keep_highlighted, mask, &object, &cursor );
0 _9 ?0 x/ u5 l& N4 f  ^5 g. ~+ o! f/ g6 K$ h9 i5 G2 h. r+ B
    if( res == Selection::ResponseObjectSelected ), \0 R) Y0 z$ z6 F
    {/ `" D1 O# g2 |) ?5 \2 C
        Annotations::Dimension *theDim;
8 G5 n& [# a4 G  w) r) I% F( I0 ^# c3 |# a6 _' U1 E
        // this doesn't work and 'note' will be a zero pointer, see PR-1850850' C8 l" y1 j7 w+ [/ k
        //note = dynamic_cast<Annotations::PmiNote *>(object);
+ @! G2 x4 I/ q* Q
) P; z# ~# `! R        // this works as a workaround
2 o7 w$ j/ N! T        theDim = (Annotations::Dimension *)(object);( f) y2 E8 Z+ q1 D4 l1 B1 m
        return theDim;  l' O1 E4 U1 @9 E) F1 \, F
    }
  T$ T( F( A! P
. W- L& \8 Q9 N1 {) `& K    return 0;
& B, H4 v0 X  p+ x}. J& l, A( @- h( i7 P) }3 R9 v6 B

1 s% U8 x7 S7 n/ J; X9 G' U; t1 e( R* L& o4 t0 ~

  M" M& i' e) U4 c- r7 @$ k! Z- k. g- R6 l" U& B
void plmhome::do_it()  ~3 u) z' b+ ~  o. b
{  h: @3 |0 V2 _" [) l
    workPart = theSession->Parts()->Work();0 F# ~" S& J" m' @# ^9 u& r# f
    Part *displayPart = theSession->Parts()->Display();! w" z9 z! _% s  r1 @- m; ]6 c
    stringstream out;
* V; Q, B: Z, N: ^1 i    Dimension *theDim = 0;
' e: X1 m  r; P: j7 n
4 `/ k* n8 t" \- w" i7 v    NXString tolTypeStrings[] =
2 Q  l! p9 v9 [- A. w4 J    {
( S! C* l  C0 P2 Y: V  ?* y        "ToleranceTypeNone",
( [" D  J" ~* |/ s8 M5 Q$ p- l7 x6 X        "ToleranceTypeLimitOneLine",3 t4 ]' Z# M7 L2 a7 ~- f+ X
        "ToleranceTypeLimitTwoLines",
, p$ b/ r7 \: E9 X; O) z) s( T        "ToleranceTypeBilateralOneLine",
$ q$ O! f7 d: Y, k* M' ]; V9 b        "ToleranceTypeBilateralTwoLines",# m- v/ o3 ^- c: u# H6 i; t5 _
        "ToleranceTypeUnilateralAbove",) o/ w# f! [, x1 k/ n5 `4 g
        "ToleranceTypeUnilateralBelow",* ?1 P- ~! o. t2 _( H0 B  S5 m& }
        "ToleranceTypeBasic",0 q$ L$ ~1 x3 L# a. \
        "ToleranceTypeReference",1 |& e$ ~) |$ h. a6 j# k1 n6 @
        "ToleranceTypeLimitLargerFirst",7 y% {0 S+ z$ W" Z6 z
        "ToleranceTypeLimitLargerBelow",& T. ]* B3 p1 O- H
        "ToleranceTypeLimitsAndFits",
2 V/ }+ m1 R$ q) K9 @3 H6 T        "ToleranceTypeNotToScale",
, Z1 _, V. q+ R1 H7 m        "ToleranceTypeDiameterReference",& q2 _) @: V) @9 O: S
        "ToleranceTypeBasicNotToScale" $ [+ J6 m. |/ y/ F9 I
    };
7 A# \" k# v, e% M) f; w9 B& a6 V# r6 M4 z9 @# L% i$ M
    while( (theDim=select_a_dimension()) != 0 )
# }$ l0 \5 e7 ?& g    {
  ?2 a* A0 u; ]7 b. e        out.str(""); out.clear();
3 E. }: R- S. T5 S; b9 t        if(! lw->IsOpen() ) lw->Open();& e  P( R8 E3 n, _

+ `% N6 u1 C" R        out << "Selected Object: " << theDim->Tag() << endl;# M9 y5 Z5 H5 j: r

/ {1 k0 U+ u2 Y6 U, L        std::vector<NXString> mainTextLines; - A# c; G+ n& Z1 ^! j
        std::vector<NXString> dualTextLines;
2 W: S) l  U0 H* T- @9 \  j        theDim->GetDimensionText(mainTextLines, dualTextLines);
& J& a* r8 l+ r. @- h. b, m& O        for( int ii=0; ii<mainTextLines.size(); ii++)% q& I( T( k; y' |$ V0 Y
            out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
9 Q" o, u( O& R: T, E        for( int ii=0; ii<dualTextLines.size(); ii++)8 w! g" m6 Z0 A; Z
            out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;4 V5 U  e- N* z% O7 A5 H, E
3 `) m$ N5 I* R5 A7 o
        bool refFlag = theDim->ReferenceDimensionFlag();( R& c8 @& P" i
        out << " ReferenceDimensionFlag: " << refFlag << endl;
  c/ M3 `' T8 y2 C0 y6 u
2 c+ Z% H* r! o5 b  _) K! \- e        int tolType = (int) theDim->ToleranceType();, {- F1 K" d2 q/ j+ _
        out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;
6 E- e  h* Y" N2 j2 p- R
3 K8 ?  D2 p/ S# J! X        ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);# I- m% Z2 e; ?6 [7 {$ f
        std::vector<TexTComponent*> textComps = theData->GetTextComponents();
0 [( @8 u4 V% w+ a        for( int ii=0; ii<textComps.size(); ii++)  H( [# o% H' ?! x
        {
; t/ b9 {7 k' S! T0 i            std::vector<NXString> compText = textComps[ii]->GetText();" \' e, y) q9 E: g/ t2 o
            for( int jj=0; jj<compText.size(); jj++ )
2 H6 ^+ |! Z* F6 K                out << " Component Text: " << compText[jj].GetText() << endl;
9 y& x( a7 E  I, q        }
1 n5 R/ N6 p2 h) z" f/ a
! v' a5 |; B& S# C) T0 G        int subtype;
1 H. ]* x# {- t" k2 R        double origin[3];
  J# ^& n5 N5 h8 _        UF_DRF_dim_info_t *info;
- [: f# e& U* i        UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));
% o; Z+ V/ I. p9 p# [' I' x        for (int ii = 0; ii<info->num_text; ii++)
0 e: z8 h9 `/ ?8 H9 G' u* |            if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)
- v. n2 ]+ A8 b& E) o+ h                for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)
6 ~2 U2 h4 r4 g7 {                    out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
4 C3 c- E/ D( H) q' m        UF_CALL(UF_DRF_free_dimension(&info));: i  e8 f& Q, L6 ]! x& N. q

$ I4 d% c6 {1 E; p: l        lw->WriteLine(out.str().c_str());3 u% m$ u3 H, K2 ]7 q! ~* E$ ?2 m

, g" a2 v, j- n& V" Q/ K    } // while9 _  X$ p! j- j# U) Q9 ~& W
}
. g* a/ \6 D$ v2 o- G
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了