|
请使用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 |
|