|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
( `2 w: D8 S: t; D* u% \; G5 ]Dimension* plmhome::select_a_dimension()/ g; P# N/ \: `2 S0 @
{
# B+ O+ c' \! j1 L6 r6 ` // ask user to select a label( }/ u( i+ z" U- K5 E
UI *ui = UI::GetUI();
: O: {- G* J; q6 Y Selection *sm = ui->SelectionManager();3 g/ k" G5 G* R( v# u* {+ t. H
NXMessageBox *mb = ui->NXMessageBox(); // as of NX52 h/ y5 i! p" L: g9 H
4 J8 D2 H- o1 B9 A( v3 C7 K
NXString message("Select Dimension:");/ h3 ?: N2 l O3 j. a5 @
NXString title("Select Dimension");9 D2 K1 T% b$ V" ]$ }1 X
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;$ W! p! v% k5 @
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
* \5 M( [7 o( q. f3 p: W bool include_features = 0;
/ X9 a. _: b+ u4 i bool keep_highlighted = 0;
, P( }0 H. o* G. W
. W& c* L3 a8 c* N$ R8 V // Define the mask triple(s)
7 S! t; X* {( w/ j! t0 L/ b0 y std::vector<Selection::MaskTriple> mask(1);
: }7 j+ x5 ^, G* a9 x S: _ ` mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );7 ?" I: c& \/ P& w
Point3d cursor;
) e# ^2 b) S$ p* g# C3 p! q TaggedObject *object;* [) C$ ^% R2 U7 z7 g
& g- z% J8 f0 [( i# ]* g, I
// Select objects using filter defined by mask triples
* K; m, Q ^& T! Q9 e Selection::Response res = sm->SelectTaggedObject(
; [& K: h" j! l& f message, title, scope, action, include_features,. i" G# F$ Z+ o* T) s
keep_highlighted, mask, &object, &cursor );7 I) |9 L/ \9 a# E
{1 Q; N! a* n$ l/ X3 z; _" A
if( res == Selection::ResponseObjectSelected )
9 O+ j% F, w2 Z+ S7 z) R [/ _ {
1 @: v0 y( D3 b6 ^ Annotations::Dimension *theDim;9 z4 @0 [, B: @4 g+ B( _
$ t5 l8 }8 ~9 M* l" }% J* T$ R4 g // this doesn't work and 'note' will be a zero pointer, see PR-1850850 P- q5 q- q5 y7 W
//note = dynamic_cast<Annotations::PmiNote *>(object);
1 e+ S" c3 `2 g/ \5 E5 J0 Q8 D+ z" ?" I, j1 s' l* A
// this works as a workaround
. h# O/ `: D1 l theDim = (Annotations::Dimension *)(object);
/ J0 k% B3 G5 P$ B return theDim;
2 h9 v$ {# c. D$ F }) {# @/ H: F+ Y# Q: k) P# `9 I
P& z& Y# U9 f1 v# E, l6 {! q! O
return 0;' r) o/ C$ u) F/ C5 k! C
}
( K* B- ^( X6 a
: F" n) Z7 j$ ]+ i' `8 ~9 J8 e! v
. m" e2 m9 L* A+ @3 Q3 N/ L: C& p0 ~, j4 P' \
9 h3 T" E& ^% A r' Mvoid plmhome::do_it()
: m$ ~! H6 R4 H( {7 N! N* v{
! o( A2 l2 w7 I; l workPart = theSession->Parts()->Work();* I* ?1 r8 b2 D5 c: u* g! S8 v. A
Part *displayPart = theSession->Parts()->Display();+ U, T+ @0 g b V( b7 O- C8 ]$ _
stringstream out;
9 t) [5 x" c+ D }9 c; @ Dimension *theDim = 0;
" M0 H6 z1 n l( l O
7 ?- ]. q9 n' f NXString tolTypeStrings[] =
3 L& ~1 p1 ^2 P {
$ y( N& U1 _4 b& l "ToleranceTypeNone",
/ T/ p" j# m6 s3 E6 M# d0 g "ToleranceTypeLimitOneLine",' I7 R V" r7 J! g/ l
"ToleranceTypeLimitTwoLines",2 r X( U! f2 f' M* s
"ToleranceTypeBilateralOneLine",4 r% T$ O- B* Q4 G _
"ToleranceTypeBilateralTwoLines",. p) S3 Q* w7 {/ }( x7 M+ [
"ToleranceTypeUnilateralAbove",
' ?' c- v. U+ d- c3 ~4 ?7 j "ToleranceTypeUnilateralBelow",5 m5 B) q/ `) h* e( s; d5 s4 u
"ToleranceTypeBasic",7 I, h% M7 |4 a$ u3 I& ]! [1 J8 Z+ W' b
"ToleranceTypeReference",
E0 C9 f- m9 K" G8 h2 i- d5 P "ToleranceTypeLimitLargerFirst",0 i- C! }: Y4 @& X" F
"ToleranceTypeLimitLargerBelow",: q+ L% S, E a& ~+ ]; A
"ToleranceTypeLimitsAndFits",0 o$ d( T: B; Q- ?# ~; V1 t
"ToleranceTypeNotToScale",
- S' P3 u4 `" [) C2 f! E "ToleranceTypeDiameterReference",: t( J% ^0 m! n# M* M H" g3 y
"ToleranceTypeBasicNotToScale" 8 Q; |9 h3 v- o* ~8 O
};
; `) i7 v, }: N/ s1 K6 }0 z: }, _* P% M
& V3 i' t0 l; u. g3 \2 x0 ^ while( (theDim=select_a_dimension()) != 0 )
: J$ R: S) S% g4 R$ n1 M! M3 \ {
- d* R5 Q1 I) ^; q5 X1 p- A% { out.str(""); out.clear();
0 r# k; Q2 n3 ^+ S7 j& j6 E if(! lw->IsOpen() ) lw->Open();
' E, K, _4 A; p0 ?
1 {. R! }2 t; ] out << "Selected Object: " << theDim->Tag() << endl;+ _: l# D* P' @& R, e: c
0 |( o( z/ c; e) K4 ^
std::vector<NXString> mainTextLines; ' W0 f* _ L" n7 a
std::vector<NXString> dualTextLines; : N' H( ^. i' v* \" ^
theDim->GetDimensionText(mainTextLines, dualTextLines);2 x4 f. R! E. l% i% }: L6 v
for( int ii=0; ii<mainTextLines.size(); ii++)
# |) A( L+ b5 @* ?0 [; p; S4 { out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;/ [% X* a8 d8 }" ~+ J: A
for( int ii=0; ii<dualTextLines.size(); ii++): l& d' ~4 z1 b. z
out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;
: m+ E' C8 s# E0 M( Z1 l8 P; K$ w5 Y2 n3 ~: O; n/ t- Z4 ^
bool refFlag = theDim->ReferenceDimensionFlag();
; V$ n+ e! v, h: r/ E% m! j% G) k out << " ReferenceDimensionFlag: " << refFlag << endl;4 Q+ ]6 \; ~: O) p
% v: F2 y- J+ Y2 e int tolType = (int) theDim->ToleranceType();# x* Q; h' A0 z2 C" ^( T& o) k
out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;
1 `, J0 N7 [; i( Z L" V" K/ K( U0 S9 ^* S- ~, n; P) r* T
ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);
6 J9 a3 T! K* [/ |6 c4 K+ Z std::vector<TexTComponent*> textComps = theData->GetTextComponents();
( l+ @6 S" U" q; s0 }% @" u4 S for( int ii=0; ii<textComps.size(); ii++)
. `9 Y1 Q+ S* P. y) S {6 u) U V# _+ K3 x1 i
std::vector<NXString> compText = textComps[ii]->GetText(); P9 a! I' B4 V4 ^: N9 S
for( int jj=0; jj<compText.size(); jj++ )1 r7 B! p: P' E0 }5 {
out << " Component Text: " << compText[jj].GetText() << endl;% [* t0 g) }0 B& }; n4 z+ B
}
" e) H' w7 N9 b8 c8 L8 _) m/ g
5 z# Q+ O& M, V9 R5 Z% G int subtype;
- S3 `# S' Q% @3 i; o! f double origin[3];# B: J- c% B- C# m7 H2 F
UF_DRF_dim_info_t *info;
* K- h: b3 {; n. Y* L4 e UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));
. |. a# B1 C! g; a: p3 l9 { for (int ii = 0; ii<info->num_text; ii++)! |- A Q* m5 \' c" \# V& ], f. S1 X
if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)
" F7 B) V- Z5 a for (int jj = 0; jj < info->text_info[ii].num_lines; jj++) ]9 N' u# L. V1 h0 j* }
out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
, A6 L/ l, b/ i7 X- p UF_CALL(UF_DRF_free_dimension(&info));
% A3 \2 Q* U/ O& C' }4 J! H8 e0 X# H; @
lw->WriteLine(out.str().c_str());
9 G' N Y: ~6 D; v
9 f: R# X! I( U. C } // while
! _: x4 g1 j/ u1 z1 O# n R( z0 d}
7 `8 h# _8 M& }) k: M& r+ C0 R |
|