|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
+ L" u, q9 G1 G. F6 H+ ]
Dimension* plmhome::select_a_dimension()
; | Z. s& {: L4 {+ S! b6 x% X{% k4 u& t1 L* f( J
// ask user to select a label
, v$ T y7 w( B: V/ R& l% k UI *ui = UI::GetUI();
+ U C2 I; _4 f2 N/ W8 r9 b: Y Selection *sm = ui->SelectionManager();& B( O z9 {5 N3 r
NXMessageBox *mb = ui->NXMessageBox(); // as of NX5/ G) O. c7 p: r( C2 d
* N" j( q+ U2 y9 n P/ j1 s
NXString message("Select Dimension:");
8 c& F; ?. B# X: j2 W NXString title("Select Dimension");
/ h% a, e2 V8 z& y2 D Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
( @% ]( O1 ~" l8 j Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;5 f: t; s& ^; v9 N9 H6 D# v
bool include_features = 0;
# X3 D$ k Z% D, m+ y3 E bool keep_highlighted = 0;
2 A" h2 Q) W7 B: B8 a9 g& ?* i0 A0 t% ^" W, C; |) _
// Define the mask triple(s)
' x+ B2 u6 i2 D# C' }! f) U, j3 f5 F std::vector<Selection::MaskTriple> mask(1);
1 Y6 C0 q A1 k" }( U0 _: U; ~5 ~ mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );
5 r; i$ U& k# E2 o/ ^2 w Point3d cursor;
% ]2 P+ P3 @" }* R) ^5 Y TaggedObject *object;
( ^! ^4 g+ k: }1 g6 c/ u4 J3 _8 r8 b* ?/ R1 \; V: {
// Select objects using filter defined by mask triples
9 }9 ]! W9 P4 ~! k* }- L9 f: d/ L$ X Selection::Response res = sm->SelectTaggedObject(2 P D6 e6 _& U4 }1 s4 k/ N0 t
message, title, scope, action, include_features,4 k, L! R9 v# [1 I- J
keep_highlighted, mask, &object, &cursor );
4 V( S! W1 D) B$ ]' M2 U7 ~4 d( V3 G- R
if( res == Selection::ResponseObjectSelected )
1 ~/ }, z& H' e) E9 F0 M {1 ^: R+ i/ J* ? J9 o' H; K1 p9 a
Annotations::Dimension *theDim;0 ~% C; d: d# _2 E- }) _2 C
" S" s* |8 M4 Z! u6 T, D3 C3 ?/ G
// this doesn't work and 'note' will be a zero pointer, see PR-18508503 U2 \' u. b/ V) [
//note = dynamic_cast<Annotations::PmiNote *>(object);5 X2 h% P# C' E; _4 ]1 A
/ K0 b7 e* Z. Z6 p7 ~7 B
// this works as a workaround" u+ u3 { P- T, i6 D
theDim = (Annotations::Dimension *)(object);; g& V. T; a8 z3 n: E3 X+ X* l
return theDim;
& A T |. V: M( Q! \$ Q }' J4 J4 P" {# x! W" Z% M; H5 ~
* f: |' |/ I7 |) E# a return 0;& R% E1 F; I- o) g/ v, S
}
9 y1 b3 N6 x- t6 Z
% v& m5 b" o; G: X6 D% l# Z6 O7 ^( |) g w# ~# }; a/ ?: k
, J0 S E& m. S+ s$ [0 J: E
; l8 f6 I& t+ A+ W4 P N( k: j4 }& @void plmhome::do_it()2 n1 A4 b' r4 G ~$ T' o
{* L* o. X; y% l @5 P# K; j
workPart = theSession->Parts()->Work();
! O, U1 Y! R# l1 V Part *displayPart = theSession->Parts()->Display(); o2 o3 n2 F5 G; @
stringstream out;4 z9 b# o. N: A, Y2 x* U' b! g" _* p
Dimension *theDim = 0;
( h7 x& E. Y8 j9 @7 Z8 M( b) h' q& \4 R- ^. p8 r. n, W. A
NXString tolTypeStrings[] =
" r& F6 ^; f$ y {/ n7 t1 V2 P1 g; s9 w
"ToleranceTypeNone",9 Z% \3 A" f5 d& s1 i: e& f2 |
"ToleranceTypeLimitOneLine",
3 z+ b/ K% a; I5 |4 I+ |. @* Q. P "ToleranceTypeLimitTwoLines",, T8 S* }3 {* c3 b) i
"ToleranceTypeBilateralOneLine",; b; I5 ]* \ P- K7 t7 p+ y7 N' d
"ToleranceTypeBilateralTwoLines",
4 m) _ D" K8 c+ o4 _. G) z% D "ToleranceTypeUnilateralAbove",# R4 ~# p6 R4 |2 R4 e/ R. A
"ToleranceTypeUnilateralBelow",0 ^# [4 K0 u; H+ n% s
"ToleranceTypeBasic",
1 j7 |6 A% d3 n% G* }9 [ "ToleranceTypeReference",1 B3 g, R* }( w t6 i
"ToleranceTypeLimitLargerFirst",) ]& t8 b$ @0 Q4 c; [, h- p" A
"ToleranceTypeLimitLargerBelow",! ]- V( @* Y/ O# D, S4 h# M! M, p) ^
"ToleranceTypeLimitsAndFits",
1 l( k2 n' s( B/ ^% q+ i$ M "ToleranceTypeNotToScale",
- H1 m3 f8 M- d& K' Y; I$ H. i "ToleranceTypeDiameterReference",0 E1 B0 y0 s# V# L1 q
"ToleranceTypeBasicNotToScale" . H( z8 F z' l a
};
/ [8 c0 D+ s% B5 R- T. d) k. a: x: i- Z! e
while( (theDim=select_a_dimension()) != 0 )7 V9 p- z+ e/ Y
{! r, [5 N- |% m$ y. v/ H
out.str(""); out.clear();
; k# b6 n+ ~( _* w7 i# } if(! lw->IsOpen() ) lw->Open();2 z1 h& O6 K/ X+ r
. {: U3 Z( J( c U
out << "Selected Object: " << theDim->Tag() << endl;0 l( B+ t( V$ f3 `0 {' H
/ W) b+ }2 @ j+ G% n. L+ K std::vector<NXString> mainTextLines; ' F" B: n f6 H9 H
std::vector<NXString> dualTextLines;
; D- `# I% L2 L7 D! O9 q* `5 | theDim->GetDimensionText(mainTextLines, dualTextLines);
4 L3 [4 H4 E/ b! x* c for( int ii=0; ii<mainTextLines.size(); ii++)
0 m9 q. J' P6 s" e2 K# e out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;& U8 x% F2 U- s- F* d
for( int ii=0; ii<dualTextLines.size(); ii++)3 L+ R/ l6 d* ^; h9 } f
out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;
) J! n, z9 h/ f( ^* ]9 c. @! [/ |
$ f# S, @0 L# H/ t$ a+ |7 U bool refFlag = theDim->ReferenceDimensionFlag();7 G8 n% _5 a. Z
out << " ReferenceDimensionFlag: " << refFlag << endl;# a& k: Z+ n4 T5 b! e' `$ b
x, p# N& d, b1 {; \! U' [ int tolType = (int) theDim->ToleranceType();
5 f. `& e7 z4 V+ m ]; W out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;
- Q0 T1 W* N9 p8 I: a
" v- j( H6 v1 p: O ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);+ a- M3 I; u2 [& `7 f
std::vector<TexTComponent*> textComps = theData->GetTextComponents();
9 R; N3 c& h7 t for( int ii=0; ii<textComps.size(); ii++), p" W A$ G, e! ]2 S! S; r5 g% i
{
5 A- ~8 W, {9 F6 K* T+ e std::vector<NXString> compText = textComps[ii]->GetText();; J$ V- @: ~ V9 [/ c
for( int jj=0; jj<compText.size(); jj++ )% P) W; O* G$ \. _- N
out << " Component Text: " << compText[jj].GetText() << endl;
% c9 U/ H* f: d }6 b1 S3 m3 F) f
; d8 F# a) E2 B# \3 b int subtype;5 ^8 I' m( U; A
double origin[3];1 c- ^6 J! v. D% n: ~* P. ]
UF_DRF_dim_info_t *info;
1 H# Y9 \; f( N7 @) H/ @# S5 x UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));
' \9 U4 Q6 r$ K- w* L+ q# @. T9 o9 S for (int ii = 0; ii<info->num_text; ii++)
" T* J. q, E/ s6 @3 i3 L0 Y if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)
" w- B7 {, [, ?8 P0 \7 ]" _) Q for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)
# y, M0 @$ e7 z4 C1 |6 a3 U1 B# S2 T: f out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
1 b! y; G( ]6 \$ q UF_CALL(UF_DRF_free_dimension(&info));
8 D# C/ L, O1 r3 E/ P7 {; T1 m' w5 n2 f
lw->WriteLine(out.str().c_str());$ \& G# z2 |4 Q
9 }+ E6 j- z7 H O: s
} // while
8 _, t) i# S7 A& P}% g3 l+ Q- V( V* j, C- V0 O. r
|
|