|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
3 z+ O, E7 ]4 t- O; n
Dimension* plmhome::select_a_dimension()
$ p- W$ g5 C" Q9 H0 E{9 ]* B; [2 q/ G7 {* J' s* I
// ask user to select a label
1 I8 q7 N% b# e: M! ]5 @' @ V$ ^ UI *ui = UI::GetUI();
i" J5 Y8 O; }& R q+ X, w8 l1 |; G Selection *sm = ui->SelectionManager();
$ B* O8 }6 a0 W! m NXMessageBox *mb = ui->NXMessageBox(); // as of NX5
. N; ~# f4 B4 @& r5 K6 X# M$ J9 D
, r. P V" P7 v; M4 ?) D% d" o1 E% f NXString message("Select Dimension:");
$ i: X% X9 g+ z& v. n' x NXString title("Select Dimension");
' ?4 ^9 t8 o5 r9 P Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;! E% B, W! G/ y* o0 U1 ]) H2 M
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;0 D/ G4 Y* a/ m Y
bool include_features = 0;
' J5 R1 c0 h( m$ ?7 m" L. i( N bool keep_highlighted = 0;
1 r9 |) c. e1 ]! R- m0 f$ I& v, F; }. L: B" U+ a! a
// Define the mask triple(s)' M& k5 b' q8 @- \8 d8 k: b
std::vector<Selection::MaskTriple> mask(1);! t8 k! j& o! T% Z
mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );
8 f2 R% s4 X- }8 {6 ~ Point3d cursor;5 m: Q' w) b3 q9 C9 u+ h9 M
TaggedObject *object;) O) V( a# z5 [2 R( c, n
8 |2 N ]/ N7 e) T0 o+ J
// Select objects using filter defined by mask triples1 q: U0 n5 ?4 o. `% e/ C
Selection::Response res = sm->SelectTaggedObject(/ m M( K7 T n& O$ c' i$ [
message, title, scope, action, include_features,
; A' D0 V# K8 O5 b& i keep_highlighted, mask, &object, &cursor );# j; b; ]0 V7 x, z! {; U$ `
- c' D: V0 e/ P2 }+ S
if( res == Selection::ResponseObjectSelected )
; Z( w4 I% Y& }$ z# Z8 L Z {0 M/ R! s% P! ^9 `$ S" L- T8 X6 |" l
Annotations::Dimension *theDim;
9 H+ @# w8 T c8 i8 ~7 D8 L/ G; k x- f W" C4 a
// this doesn't work and 'note' will be a zero pointer, see PR-1850850
4 [# V# N9 m; ? //note = dynamic_cast<Annotations::PmiNote *>(object);
: [, p6 }3 L1 f- w/ C/ O' m
4 @9 F! ^3 r/ [- |4 C( e* i7 { // this works as a workaround( O* ?9 l1 S" }
theDim = (Annotations::Dimension *)(object);
7 q5 Y. p, ~. u4 {6 N1 s7 J return theDim;6 f; F1 U" V0 M* W3 c. k! f [ R, ?
}
& g2 h: B# b2 c* X: L
- m2 K' c) f) h3 H$ `" Y' \+ r return 0;0 _; p: D2 `0 m2 F
}
' J, Q0 X! U9 G& J+ O
& `: r5 ^ x. O2 K8 N
; H3 O X Q( D9 Q* I
% d, g5 G5 d( u, F7 B2 V4 m# S
' M8 q) ]4 F6 p8 g7 mvoid plmhome::do_it()& _* R. g/ f$ m& V
{: q7 o. {4 t( B) _5 s; K
workPart = theSession->Parts()->Work();
; T) X6 N7 l) i: A7 ~& n Part *displayPart = theSession->Parts()->Display();
* G5 f2 j3 P3 @2 S, `0 v stringstream out;( L6 g1 {& Q+ e \! x+ ]& M
Dimension *theDim = 0;
% `' C, E. C4 a( B; ?1 H& m4 ^" Z r. Y' q, d
NXString tolTypeStrings[] =
& ]4 B' X( C2 P M9 J* S. Q {
! Q+ G$ L7 c. A8 [' y* o "ToleranceTypeNone",
* l. ]: Y. G) n, o8 i- a "ToleranceTypeLimitOneLine",
1 C% ^* {; |4 [ c" f "ToleranceTypeLimitTwoLines",
2 A; g4 f5 c, {2 ?; v& h3 g "ToleranceTypeBilateralOneLine",
4 Z6 ^; L- k1 e# u) V: c6 d "ToleranceTypeBilateralTwoLines",
$ Y- \& ?4 |8 ], K4 u "ToleranceTypeUnilateralAbove",; B) h( ?" I- k3 M: G
"ToleranceTypeUnilateralBelow",
0 P- P3 Q% f1 Q" U "ToleranceTypeBasic"," L9 t, |5 ?6 g: J8 C# v0 M% @5 ~" w
"ToleranceTypeReference",
/ s* } {4 l/ {- @ P. X/ u. m. E "ToleranceTypeLimitLargerFirst",
$ H; o" [/ F: Z) O( [ "ToleranceTypeLimitLargerBelow",
: o* X/ y8 R# O "ToleranceTypeLimitsAndFits",
) v9 B' C- L$ ] "ToleranceTypeNotToScale",
. w' I9 p. E- V2 m6 X1 _ "ToleranceTypeDiameterReference",8 P7 A3 n6 }, E9 j# L5 q
"ToleranceTypeBasicNotToScale" ) s) r% ?0 Y" I" m$ y! ?. o: @
};
( T6 _' s4 |' G& H( k4 u3 D. M' o' O- K3 Q" W0 D2 J
while( (theDim=select_a_dimension()) != 0 )1 K8 T& F9 u) F
{' T) a3 k* R# R
out.str(""); out.clear();
A5 f5 M7 f9 e5 R8 U: [! j1 Q" n if(! lw->IsOpen() ) lw->Open();
. V& o5 O8 }( G1 I2 s& V& \- r$ [( Y4 m( i8 a% { G6 k
out << "Selected Object: " << theDim->Tag() << endl;6 M$ @0 C. t) a" h
! |: Q2 z/ h! @, D
std::vector<NXString> mainTextLines; 2 u8 M5 p9 u S
std::vector<NXString> dualTextLines;
! ~! L: V5 g$ Y7 d; s* A theDim->GetDimensionText(mainTextLines, dualTextLines);: V1 O* m6 t1 ?6 Z- k
for( int ii=0; ii<mainTextLines.size(); ii++)8 V7 U) K3 z& M/ b
out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
$ K7 b/ X. w1 S$ A1 g" U$ j for( int ii=0; ii<dualTextLines.size(); ii++)
; a( i- s! {% f* V out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;
& v. z, R4 j5 Z& \2 L, `2 P
% H) H4 ?8 t* ?3 T9 M" i: b# [5 Q bool refFlag = theDim->ReferenceDimensionFlag();
1 p7 e3 X K% |3 d$ ?7 T' N1 J out << " ReferenceDimensionFlag: " << refFlag << endl;+ s6 K8 g& G& T( k0 z3 f
0 y# S4 v9 E' W5 T. `% v+ w+ i |
int tolType = (int) theDim->ToleranceType();
& g @7 E, x2 u$ q2 O! ` out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;
2 g3 i) V9 M( g1 m4 u/ w3 G+ l; C/ b0 y
ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);& B/ X: h5 A/ ^% E( w9 o
std::vector<TexTComponent*> textComps = theData->GetTextComponents();
( ?4 K0 h8 v. `" n; ] for( int ii=0; ii<textComps.size(); ii++)4 a% D( O$ h6 ~6 p& U
{& L9 e2 V$ y% x: z( g9 |$ l3 c
std::vector<NXString> compText = textComps[ii]->GetText();0 ^. p3 Z. _( ^% P1 [
for( int jj=0; jj<compText.size(); jj++ )
$ x2 o& {0 m1 R out << " Component Text: " << compText[jj].GetText() << endl;
4 I+ a( i2 C9 V) A }1 A, @6 q8 D: m6 R
- ]- o) T/ ^8 K. h- ?
int subtype;
# B5 m. D$ c$ f; J3 {' k double origin[3];# a" g1 D$ l' ^6 T3 _' Z' ~7 E9 k
UF_DRF_dim_info_t *info;
: e8 h. e% s7 E/ G2 ]3 A UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));# i- n" l4 u% s$ i' S( T% }
for (int ii = 0; ii<info->num_text; ii++)
4 i' N# E5 }. @4 _6 Q, h+ v if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)
; z- c1 Q o' T: j3 Z: G4 E& l# q for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)$ b# |; J: v* E h
out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl; q# D D; J9 n1 \6 N& N0 d
UF_CALL(UF_DRF_free_dimension(&info));) i0 T9 f, J+ a6 j6 ], e
! ]7 B& p9 j' N7 m0 N, }% z
lw->WriteLine(out.str().c_str());
* Z1 z+ \! {( l3 v7 s; l) a+ Z2 k( H6 E2 o5 O& }. C# [2 x: m
} // while: v) H |3 b6 a2 ~1 _7 y
}
9 \) [7 W! j V$ @! s1 Q% } |
|