|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
9 X$ F! N2 F% w. ]9 KDimension* plmhome::select_a_dimension()5 w5 F, T- _& S
{+ {# [3 X: T8 d$ p% o- a2 B
// ask user to select a label8 z4 G- _( V+ O' }7 [5 p% y/ d
UI *ui = UI::GetUI();1 W$ H- ?; m! R4 m' D6 ?
Selection *sm = ui->SelectionManager();
`9 ]5 C" B I1 A. Z! i' K* f' l NXMessageBox *mb = ui->NXMessageBox(); // as of NX5
O2 \2 R7 G5 w
$ {; |+ ?6 L9 g6 H8 h% q NXString message("Select Dimension:");* U7 K1 I( X; g" ^2 C
NXString title("Select Dimension");
3 f; n5 _" a/ Z$ m; X/ A Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;/ ~4 A: }! J9 K. Z
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
. o1 J7 W$ }$ k9 U, H bool include_features = 0;& P5 U; F" m# S
bool keep_highlighted = 0;9 k! f4 |; R* k Y3 I4 {
0 f; g% @" L& c! ^3 ^ // Define the mask triple(s)6 m/ W3 r! j5 V2 ^9 |, E& [
std::vector<Selection::MaskTriple> mask(1);
; |! M4 P- z' v+ ^ mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );
# x3 j5 v! g9 G. A! U* \& _ Point3d cursor;: H1 t( _ j% Y2 a7 [, F8 v8 X
TaggedObject *object;! h" b t, z2 O* H: _6 Z
" ]7 O1 j( H1 X; s8 J% v
// Select objects using filter defined by mask triples
% C4 e4 J! t7 S1 }# D Selection::Response res = sm->SelectTaggedObject(
! N) a8 z7 u1 m2 r message, title, scope, action, include_features,9 w2 k6 [* [- [! e
keep_highlighted, mask, &object, &cursor );: q- x. g1 z9 i+ a1 r8 y" s2 S
`* C5 P% i; b; T8 a
if( res == Selection::ResponseObjectSelected ) i& s3 d! E- ` p9 [ v
{1 G H& R8 W) ^$ B# F& j
Annotations::Dimension *theDim;; w* r, v9 t" X" O& J; `
3 ?, ~; @, X/ ?( d/ ` // this doesn't work and 'note' will be a zero pointer, see PR-1850850
$ Y5 G6 P& J9 @, H3 C- U# X* E //note = dynamic_cast<Annotations::PmiNote *>(object);
; O, K! p |! K- X9 r4 ~8 q, J) E# x# o9 V4 j/ B) \
// this works as a workaround+ f8 D) M2 g, ?- Q7 n
theDim = (Annotations::Dimension *)(object);! A6 { S$ I/ t; Y: ]( ^
return theDim;
7 k$ C1 R, C7 \. B* O+ p }: y% l8 S8 }2 q+ X; U
: S u. t/ P0 u+ h% d$ @ return 0;* Q% Y. U8 t) E; i( u2 E; a% H
}
* c7 Q8 g1 B2 g% j% H: J0 E' Y
. a% d4 k8 r$ w0 [# x# h
& @' T7 G! U, n+ ]* f! I
* n4 f2 F- t8 _0 A2 s: ~void plmhome::do_it()
3 O7 A9 {5 U+ [+ x( y9 l{4 F" S( v9 `8 o1 E4 k- h5 X7 G; J
workPart = theSession->Parts()->Work();
! f& f; G( v, [6 R Part *displayPart = theSession->Parts()->Display();( ]; h% Q* i& V- G
stringstream out;
- u! O# U5 F3 O0 _+ c) _3 F Dimension *theDim = 0;
! j z5 ^. D0 l* o* V5 v1 W' U: C c' i. X) K; v2 o( J
NXString tolTypeStrings[] =
! C u$ h0 X: O {& D- K, P. q1 D
"ToleranceTypeNone",! U1 h4 p: p: L8 ^+ U% q
"ToleranceTypeLimitOneLine",( P3 A, `6 {2 N6 U
"ToleranceTypeLimitTwoLines",
, J; p' O; L* `) H( C8 w1 X0 p) V "ToleranceTypeBilateralOneLine",
& z" M5 r9 h: m. c8 f1 a "ToleranceTypeBilateralTwoLines",- ~' s' h; v- e }; h: r
"ToleranceTypeUnilateralAbove",* ~. ]0 u7 B3 ^1 n, N3 ]9 I' D4 x" B
"ToleranceTypeUnilateralBelow",
; [: B! R3 G/ A8 C. X: U" g* x "ToleranceTypeBasic",& j) p" R4 q, I6 Z4 e! W
"ToleranceTypeReference",, \3 z6 ^; E6 P U, l
"ToleranceTypeLimitLargerFirst", u# A/ \5 V# j0 T5 j y& z. E% G
"ToleranceTypeLimitLargerBelow",5 [: U. B% R; }0 ]0 H$ ~
"ToleranceTypeLimitsAndFits",+ ?% g$ L- A$ c0 {
"ToleranceTypeNotToScale",
+ _4 {5 L ~. W) b- g8 ` "ToleranceTypeDiameterReference",
0 z7 @7 m7 t8 [( M4 L% i: ? "ToleranceTypeBasicNotToScale"
' ~" }8 X' V Y) F8 s };* [5 b* w7 h7 K2 w5 w
) s3 f. V% `% V1 z& }
while( (theDim=select_a_dimension()) != 0 )
6 v6 m' W6 k; A2 G6 v {
1 t+ \) m0 }8 @$ n1 b7 B! _% ~ out.str(""); out.clear();* k% g6 l3 ~( ?
if(! lw->IsOpen() ) lw->Open();) c' Y- g6 j5 m& z9 T+ e7 ^6 }- S
7 R' {0 ~- {) W, O6 O" S0 L: z
out << "Selected Object: " << theDim->Tag() << endl;
8 n9 f8 _7 Y! i7 _6 g* R7 f# ^* |
std::vector<NXString> mainTextLines;
+ \6 b& z: M$ X' J0 j0 F: q std::vector<NXString> dualTextLines; 2 I) A+ }$ d% Y# p# M
theDim->GetDimensionText(mainTextLines, dualTextLines);9 p, S3 ]$ p* w! Q, e( p
for( int ii=0; ii<mainTextLines.size(); ii++)1 v( l" Z: R h! @( \6 m9 ^' ~
out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;1 q* P9 G5 o, N7 ?: j* j0 T
for( int ii=0; ii<dualTextLines.size(); ii++)
9 p3 o K8 W5 |! F/ s- y out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;! V% Q7 Q9 {- }5 e# Z, P
* O& l5 x2 B- N, W# l bool refFlag = theDim->ReferenceDimensionFlag();
5 N: k3 R8 i$ _ out << " ReferenceDimensionFlag: " << refFlag << endl;
, J+ n' p4 B, i& U1 E
. q5 U: x2 L: d N' z4 X int tolType = (int) theDim->ToleranceType();' p. P* c) N. T8 ?$ L. M
out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;$ F3 B J9 W6 u/ r& W" X2 U
" \6 q+ u9 R) G
ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim); V& ?' ~0 z; g# j9 V3 W
std::vector<TexTComponent*> textComps = theData->GetTextComponents();
: Y/ S$ Y2 N& U1 D9 `% Y' u, t8 O for( int ii=0; ii<textComps.size(); ii++)
' a% t5 _; y' q. S. |; h5 v {5 w6 K! f( T6 w# B
std::vector<NXString> compText = textComps[ii]->GetText();+ s* E& t. [5 E8 W! O" j
for( int jj=0; jj<compText.size(); jj++ )& l, B- Y$ s3 W
out << " Component Text: " << compText[jj].GetText() << endl;! i6 {! |* y+ s! Y0 P z2 ~0 ]. |
}" N) m/ I. w8 ?* s c
8 _4 ^2 F, `' z" J7 I
int subtype;* B4 m$ n( g# k9 \% ~! v+ \% c
double origin[3];
c$ @1 X1 x6 ^4 v$ Z/ \: ~1 k1 A UF_DRF_dim_info_t *info;$ m! W3 e+ K1 c8 o) Y4 S+ l' ?
UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));3 T2 h! i* o5 s9 r! R
for (int ii = 0; ii<info->num_text; ii++)
% S- M' z7 G' {/ O5 i5 R$ T if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)- N+ C5 i1 k9 \# l
for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)
2 D$ _: G9 ]! {2 o) T8 ` out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
/ J) ~ b7 v) f* L0 |( m1 k UF_CALL(UF_DRF_free_dimension(&info));
. b/ P q! }! R% g
" E5 G; x4 @ p9 d' t6 w ~1 u lw->WriteLine(out.str().c_str());! K0 _8 S. T" g, S
" Z2 ?, H$ s3 {8 S5 A' T1 P
} // while
3 P# E' _# E' D" t6 Z" E1 G}6 S, s+ e* b6 c g: ^
|
|