|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
% I4 t/ ^3 K4 K$ B0 j; L3 t$ b. aDimension* plmhome::select_a_dimension()9 n V* l) R% W3 l3 j; _: _
{+ ^ g6 x' w/ `7 x; ^! u9 F* d
// ask user to select a label. P3 q# r3 b, a
UI *ui = UI::GetUI(); p) f/ F9 \6 s r9 l
Selection *sm = ui->SelectionManager();% ]% }3 i* E3 k
NXMessageBox *mb = ui->NXMessageBox(); // as of NX5$ n5 t" ]- l# ]3 s
. [! ^8 W/ ^ d, j& w
NXString message("Select Dimension:");
& X/ @) H, h' A3 Z d2 \7 X( [% Q1 S NXString title("Select Dimension");5 V8 x. _. N7 A+ x# y ?3 `; l% ]2 h
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;( O( h2 G+ s. b! B/ k& p+ m
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;6 g0 j& [! s4 m; E5 c$ k
bool include_features = 0;
( |' @/ x) m9 y6 H/ l bool keep_highlighted = 0;
- ?$ B' D) A& }3 x4 |/ w% n! k5 C
// Define the mask triple(s): B! l( m0 J, ]/ G( g- c
std::vector<Selection::MaskTriple> mask(1);
0 u5 D$ C# y4 v3 |* G( s; R/ E mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );' {8 a' U) X( z% B6 v
Point3d cursor;
% h! i; C. K! x; c0 ]+ ^; X& Y TaggedObject *object;6 B, H( I: D7 x' V& R
. K& O3 k0 ?' Q$ h // Select objects using filter defined by mask triples
( g" F+ q6 ]( w$ m: f* F Selection::Response res = sm->SelectTaggedObject(
' D9 @, s% M7 g, i! E. T# q" e u message, title, scope, action, include_features,
" w( r8 Y4 g& n) b, L' _1 y keep_highlighted, mask, &object, &cursor );7 k% }+ n+ H" T3 z
$ w4 g5 f' S4 }9 O
if( res == Selection::ResponseObjectSelected )
' O8 e- v0 K7 S$ A# O# X, K8 y {4 G. P4 ~! |. o5 f
Annotations::Dimension *theDim;
( Y* H! F- }- E$ s, n; C
0 k0 p( v8 a3 J0 Y0 r // this doesn't work and 'note' will be a zero pointer, see PR-1850850) ~/ ?% b; l' J. W8 U& T* ^4 l! w
//note = dynamic_cast<Annotations::PmiNote *>(object);
. G P- N& M- c8 j2 D1 c
5 ^! J+ n7 S4 Q& q- I8 J // this works as a workaround1 U/ @8 B1 [0 S
theDim = (Annotations::Dimension *)(object);
y+ T; `. e& l, O5 t* H return theDim;
I; [( K+ g4 j: H8 H4 q' ` }* p: h0 k0 v* I
/ Q7 y' j! z) G' Z4 F; x: x- P
return 0;
/ i) d f: g( f) n6 o& S- s) H}. m( [! A$ P- f/ ~0 w7 k. l
2 d+ Z+ p8 l( k0 o8 x- w0 B$ ?8 t
+ e$ d- L: j5 ?2 q5 b K7 N: u6 t% z
# R+ T2 O9 p. i4 ]$ g' r' q
void plmhome::do_it()! w+ V: e+ T$ [% A+ `' Q( ]/ _
{: t% H* F* Q7 X. O% n3 B
workPart = theSession->Parts()->Work();$ @7 S5 d. h5 Q* s+ W2 }8 D
Part *displayPart = theSession->Parts()->Display();
Y7 L3 I y0 C a stringstream out;; g( D8 y5 F$ ^3 X' q% V
Dimension *theDim = 0;! ]" \% s) x0 ?3 _. k
% {; e* ~5 `7 T) W l# q% t NXString tolTypeStrings[] =
' a( ]3 R$ T B9 X+ x {( m7 `( B4 R; D! B
"ToleranceTypeNone",+ T/ p3 L) v8 Z0 o- O; ?* Q) I$ x0 _; {
"ToleranceTypeLimitOneLine",/ l1 O2 T* d2 S2 d9 ~( B
"ToleranceTypeLimitTwoLines",
3 j& Q' {2 ]) y "ToleranceTypeBilateralOneLine",- k7 }- D U1 l$ k f
"ToleranceTypeBilateralTwoLines",
2 t: R% f0 |7 I* U "ToleranceTypeUnilateralAbove",. ^" ?$ o6 R" l# O* v+ O# m. Q
"ToleranceTypeUnilateralBelow",4 G/ \) N, ]% C4 k: h
"ToleranceTypeBasic",
" R: f0 X- d% b; n7 g$ l "ToleranceTypeReference",+ I" x8 z) o' U/ D5 Z: V
"ToleranceTypeLimitLargerFirst",
% {$ Y7 E) m- b" a/ t "ToleranceTypeLimitLargerBelow",
( @& ^' V; T3 g5 x s "ToleranceTypeLimitsAndFits",* ?4 { Y) o, v, I
"ToleranceTypeNotToScale",+ H8 \9 }! W \- i6 v
"ToleranceTypeDiameterReference",) B$ y) h$ w8 S9 {- U/ {- Z8 {( R+ [1 _
"ToleranceTypeBasicNotToScale" 2 S% O( f* E6 [; p4 l4 ?# x( k
};, z' ^( ~# k4 y
' W# p; \9 O. f+ {2 k while( (theDim=select_a_dimension()) != 0 )! Z/ P- B0 z% A0 D0 Z! V' H# ? b
{
: A3 e5 X5 V( H, u4 Z5 L& N) k+ j out.str(""); out.clear();1 k9 J0 W; K+ v7 x6 G# l: q$ n
if(! lw->IsOpen() ) lw->Open();) x1 k, X1 d1 c% I. F V7 n3 A
, F4 P$ v: z2 b8 X. e, x: Z out << "Selected Object: " << theDim->Tag() << endl;' L+ k0 }% @, r6 F! m3 A
2 a. ]4 H' X* r& {' S0 H8 [; p std::vector<NXString> mainTextLines; g% {: t6 s' U( Y& m
std::vector<NXString> dualTextLines;
# j; Q& J. }; C. Z( A) t+ d; r theDim->GetDimensionText(mainTextLines, dualTextLines);& ?7 | H0 N9 w* M1 Z
for( int ii=0; ii<mainTextLines.size(); ii++), H" `+ ^9 O! X
out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
4 [6 o" l& T M for( int ii=0; ii<dualTextLines.size(); ii++)) [% c' R [ D: @7 i( e
out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;) z0 G" v: A G4 [; H* s
! x5 O, z# k9 |$ @! c1 D7 K
bool refFlag = theDim->ReferenceDimensionFlag();2 G* ~4 W/ q9 P: P z( D
out << " ReferenceDimensionFlag: " << refFlag << endl;/ W" M: l9 F& f. K4 h; t
, I# A$ L) Z! o- U' @* E& T; R/ T1 _
int tolType = (int) theDim->ToleranceType();
4 c8 o$ |2 P. d1 ~# W+ C5 H out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;
9 [/ R/ q" l5 Z
4 }4 {6 D7 X6 p! M6 x- L# I# s ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);
1 Y+ k0 n Z# V+ j1 Z- ^ std::vector<TexTComponent*> textComps = theData->GetTextComponents();
9 x/ d5 G7 w2 J, P2 q, u3 N9 M for( int ii=0; ii<textComps.size(); ii++)
$ C) j1 v2 i2 J4 ^ H5 f1 Z {" Q3 r1 s- Z+ C/ S0 M& l
std::vector<NXString> compText = textComps[ii]->GetText();: Q+ J) g% G2 h; h& e% X
for( int jj=0; jj<compText.size(); jj++ )0 v T5 v7 F/ |6 f, L, f
out << " Component Text: " << compText[jj].GetText() << endl;
5 q9 G% p6 _1 T- s# Y R. Z8 ^6 e }! c i7 Z% z; R% c6 x4 A6 v
$ [+ N( l- \1 R! N5 K. m2 }6 j
int subtype;; K/ j5 \' }( a L
double origin[3];9 [' ?- c( a0 x2 m+ F
UF_DRF_dim_info_t *info;
9 }6 s0 ]. f, X* M( v) o UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));
0 N7 E6 M6 K7 d0 X" P for (int ii = 0; ii<info->num_text; ii++)
. T5 }, h- Q. ` if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)9 `7 A4 @2 k. ]
for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)# ^4 b: W7 H& f
out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;) L# x0 n7 b2 T* s! Q- i
UF_CALL(UF_DRF_free_dimension(&info));7 t/ |& X3 G* s9 @
" z1 ?% ]* v% `8 }3 l* Q* q$ a
lw->WriteLine(out.str().c_str());9 H! l6 s$ f5 A
# ]% t$ C+ _5 }# e
} // while+ g f7 o1 v0 ?, L0 E/ S
}
+ b% R! D4 b" Q& G. X4 a _ |
|