|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
8 t+ [1 i( l9 B
Dimension* plmhome::select_a_dimension()& N1 m! g# ?1 l' Y
{
7 P' B& i8 w) t8 z U- p$ | // ask user to select a label
( i! Z9 w; ~+ j8 I/ W3 ? UI *ui = UI::GetUI();. R# @ H$ ?3 b( O7 t1 a
Selection *sm = ui->SelectionManager();2 _0 Z% `& b8 o2 F4 U6 `
NXMessageBox *mb = ui->NXMessageBox(); // as of NX5& E: l) W6 ^- }/ D" x4 [0 O
+ G" v& W3 h+ a1 ]0 a4 |, @
NXString message("Select Dimension:");# u3 Y. I: ^" |7 O0 d3 L) H3 x$ v
NXString title("Select Dimension");4 M: g" [/ H5 ~/ z/ Y4 O' `% d
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
9 P5 Z) R% g5 X% T Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;- j* g# H- H( L& {( v, z4 @' _
bool include_features = 0;# i9 @3 W5 b# w& C# }
bool keep_highlighted = 0;
- J. l- X- J) P# e4 ]0 B, `6 D+ W9 C# ~$ G: g0 O5 B3 r0 @3 r! |. [
// Define the mask triple(s)
+ N; t% |( G( G* q std::vector<Selection::MaskTriple> mask(1);
5 S- h2 |+ ~( C: J$ N* T mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );, N7 P7 m ^0 ^/ F2 P
Point3d cursor;- B, n/ B2 A, f8 s/ d8 E5 ^: s
TaggedObject *object;; d$ K! ^+ x% F2 M
' u; D1 U% F0 M3 Q2 u // Select objects using filter defined by mask triples2 d* k7 _ _$ y5 c4 x3 o
Selection::Response res = sm->SelectTaggedObject(
; z# N7 K- k6 H9 I message, title, scope, action, include_features,
, D( ^' Z' a1 f; f% [ keep_highlighted, mask, &object, &cursor );
3 f/ s0 ~2 b% k4 X, L
/ l9 t& d; P* v W: c+ V5 M; | if( res == Selection::ResponseObjectSelected )
8 Z: e+ @1 B' N& I% x5 [- ?8 [ {
: |- @6 X/ w9 C Annotations::Dimension *theDim;7 }& ], A& \3 ]! w: v
7 ] S# Y1 M, E // this doesn't work and 'note' will be a zero pointer, see PR-1850850
1 j) q) E: t. y //note = dynamic_cast<Annotations::PmiNote *>(object);
0 D7 v" e) v) l1 x6 y
5 J( [" M' R7 u! V6 J$ l // this works as a workaround
" w+ H- h- I- @! \+ e: ^5 x2 ?3 q theDim = (Annotations::Dimension *)(object);
- N3 y) A; b, i9 {1 j return theDim;, D/ T3 V! O1 E, f
}
- r8 v" w u( |/ p0 c ]
9 l% S6 J# J* G' R- h, z return 0;' d% ^5 P; E5 Z: q8 A0 ` u3 }5 h, s' `8 y6 U
}; Z. J: w1 K4 T1 e% h; o
+ O5 V4 q5 I: U. f# o: t/ A" d
* H5 n% ]9 {& b+ j3 ?( P1 M# @- S S; z4 j$ x
2 Y4 k( |4 N; Nvoid plmhome::do_it()
2 t) f$ b2 ^8 R {1 S{
; c; v4 v" [4 y( d+ D4 L# p$ B workPart = theSession->Parts()->Work();% \& ?3 v% P, h* Q. c0 H
Part *displayPart = theSession->Parts()->Display();
7 }- ~/ \* E) z- R, C stringstream out;
/ e1 k% l6 g; i! S/ y" i Dimension *theDim = 0;
% N9 }$ Y* Q' s; j# H6 O8 `% I
( C* b a, p* S& q; { e NXString tolTypeStrings[] =
7 R- s% X" t$ R {2 s( F9 f; o* F, s, \
"ToleranceTypeNone",2 G# h' }! l+ h6 y% h' c: b8 H
"ToleranceTypeLimitOneLine",/ F2 t7 {* p, f1 q6 b
"ToleranceTypeLimitTwoLines",+ _' n% q6 {8 ]5 G
"ToleranceTypeBilateralOneLine",
0 N x; X$ l1 I2 L2 U; E8 m "ToleranceTypeBilateralTwoLines",* @6 v% z1 b- r" u. w
"ToleranceTypeUnilateralAbove",
- d5 e3 |2 b9 [% x. ?% P "ToleranceTypeUnilateralBelow",
1 ~ Q+ D; w$ g! ^5 D7 T "ToleranceTypeBasic",3 ~& s4 z* `4 w# P" N
"ToleranceTypeReference",! Q) @" f; Y! F+ x2 f8 Q; _
"ToleranceTypeLimitLargerFirst"," Y9 i5 G# S( W
"ToleranceTypeLimitLargerBelow",
9 [" b6 `& M0 A "ToleranceTypeLimitsAndFits",. x( ^: S- C7 H2 {
"ToleranceTypeNotToScale",
* f" Y5 [5 n+ k1 Z* r4 L2 K "ToleranceTypeDiameterReference",
1 i/ M8 ?; S. S1 U+ W "ToleranceTypeBasicNotToScale" " X4 O! e+ X* z+ x" q9 L6 }" Y
};
7 o7 _- ~9 z/ |6 a; }) w7 K" J6 a
while( (theDim=select_a_dimension()) != 0 )# s, Q1 C7 S3 v2 b# ]
{
$ N, m$ Z2 R& {% M. O& P out.str(""); out.clear();( U) y2 i- p7 N/ }1 Z* S2 H9 S' V
if(! lw->IsOpen() ) lw->Open();$ `+ t, k8 P4 g
) s: a: x9 L( O" W out << "Selected Object: " << theDim->Tag() << endl;! Z L C* s8 w$ ]! z3 l
8 c7 F7 z2 l! O
std::vector<NXString> mainTextLines; ; t% B& X+ A1 |, I
std::vector<NXString> dualTextLines;
8 O0 _) k9 Y' A0 _: l; u# t theDim->GetDimensionText(mainTextLines, dualTextLines);
! P" O, J8 T9 E# t for( int ii=0; ii<mainTextLines.size(); ii++)
' J: K. R/ ~- v# L7 T5 C& P out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
' ^& r. d* N! }; U8 K( B4 f for( int ii=0; ii<dualTextLines.size(); ii++)
7 U8 T1 f# `" ~7 b( P; V) S( Q out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;
7 k9 m+ M/ Z9 f6 b; T8 V# r& m( e1 V% z6 m' p
bool refFlag = theDim->ReferenceDimensionFlag();
3 {5 y0 K- ^* N: E+ c* @" L V out << " ReferenceDimensionFlag: " << refFlag << endl;
$ N; U2 a; t# G
) y6 D8 w. W1 F! Y int tolType = (int) theDim->ToleranceType();
* f- p- S' B+ Q, T' ]# R( v out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;
$ Z G! y& n% m
4 H3 ^2 t3 Q$ d' M ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);
7 s, h, s1 a, V- x std::vector<TexTComponent*> textComps = theData->GetTextComponents();8 L3 U# v# _3 ?. `4 F8 _- m- m; p
for( int ii=0; ii<textComps.size(); ii++)
e- Y, E( w) G/ A5 F0 Q( d+ a {5 z1 {* ^2 _" R b' T. M
std::vector<NXString> compText = textComps[ii]->GetText();4 X7 K5 m4 B9 N/ `+ Z
for( int jj=0; jj<compText.size(); jj++ )) U& e/ r" ~1 t
out << " Component Text: " << compText[jj].GetText() << endl;
$ C% S( {7 M) a: r }4 {/ H1 d! d2 U( G
D7 l7 ^- g' _1 z0 s int subtype;
8 k/ R3 f0 ^3 F5 H) ]4 _' B double origin[3]; b' r$ B+ J2 {, \" m+ o! |8 S
UF_DRF_dim_info_t *info;
3 P" O8 k6 W$ Z! o5 l, Y4 t/ h UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));+ Q% b; v7 b% B
for (int ii = 0; ii<info->num_text; ii++)% R/ y; g5 l* N0 Y4 {
if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)
, Q; @' X3 O [- ]: J for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)
# f- v# f; d9 q out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
$ E6 j6 `" X. R5 ]& @" b$ W UF_CALL(UF_DRF_free_dimension(&info));
! p, _' t {2 |5 v
* k1 e( Z9 D, D* ~" F lw->WriteLine(out.str().c_str());
- o( e/ {; U2 a$ u% @
, W H% B$ _8 |3 B) Z } // while) O6 a; m e. J. B* S2 j
}/ f/ M; A& C8 ~# I& k
|
|