|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
0 Q6 c/ G! D4 @. ^Dimension* plmhome::select_a_dimension()# F) F: i, J8 G2 s+ s) P6 M! K9 u
{ y, i$ O6 ?2 H/ [$ n ]1 ]
// ask user to select a label% q5 Y6 \+ n* u
UI *ui = UI::GetUI();
, n& m) l* ?! }- G; K, T/ M4 C; I Selection *sm = ui->SelectionManager();: X1 K+ t: q( A0 f; z
NXMessageBox *mb = ui->NXMessageBox(); // as of NX5* {8 W7 p8 q) K2 d/ Y* B
8 H2 k: F4 u) _6 u# e/ f n
NXString message("Select Dimension:");
e& R) k3 \8 x# C/ Q NXString title("Select Dimension");, G# v( b# r) |% @, ]
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;' Q# \, O5 n4 x
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;1 D, z. [: V+ H0 m3 `& y$ X+ s
bool include_features = 0;$ S5 M) J/ F+ C
bool keep_highlighted = 0;9 t- g# q E1 z4 K$ m2 D
# Q% }0 o7 X2 g' f. ~- {$ M% `
// Define the mask triple(s)
6 N* F5 j) X# g' A0 N std::vector<Selection::MaskTriple> mask(1); n# M9 h! Q2 D- w
mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );
" W4 a" f2 c5 I8 D3 t! N Point3d cursor;2 _$ e9 p' |9 t: ]$ N6 Q3 L2 {
TaggedObject *object;
" l) v5 j8 M+ q# V' D6 M+ Z5 S6 B3 X5 X; _
// Select objects using filter defined by mask triples
$ ]" |9 w: V$ s7 L* T. F Selection::Response res = sm->SelectTaggedObject( v0 z2 j. W) y3 ?9 R( L/ D
message, title, scope, action, include_features,% _/ z2 w9 ]& M; M* n# s( Q
keep_highlighted, mask, &object, &cursor );) n. }% e! h0 p- u2 E# n0 U( S
4 I" T8 Z! F: c4 ?
if( res == Selection::ResponseObjectSelected )( [ E. j- i3 w Z9 H9 b+ h
{& Y, V: o; d' K/ c# H+ ?
Annotations::Dimension *theDim;$ Y) @3 _( a' I! ?1 j t. s0 a) e
6 @, F; ?$ @5 p9 A- l% s // this doesn't work and 'note' will be a zero pointer, see PR-1850850
2 O8 Y# u7 V: w0 D; ]8 s7 a //note = dynamic_cast<Annotations::PmiNote *>(object);' d2 i. Y( B0 h9 h
$ U/ p' c: p' q8 c* k$ ] // this works as a workaround
8 ?' J% j7 p& o0 P' G theDim = (Annotations::Dimension *)(object);3 Y$ @) |" c: V4 v7 Z
return theDim;
& T1 H2 h! A5 f+ q }
, \- W8 U" E9 y8 v2 @. m
8 a3 M6 @& N3 q; V+ K X return 0;
4 L5 ?, @/ e* @7 l}
6 x- j. b* ` e2 g* ?" [ l3 M2 V0 e" [7 N+ Z% s H& l
: J0 H4 ~, D9 _& q
0 i+ y7 e& m# s1 c0 ^3 ~0 R6 `
@, l) t2 l/ n) v9 Nvoid plmhome::do_it()
: a0 j! f+ ^& K( k1 C8 {3 A{
5 ~% c H0 ?1 P: x3 h) X' F workPart = theSession->Parts()->Work();
+ p) m( s) U* {: g% V Part *displayPart = theSession->Parts()->Display();
6 n9 J" t- p) r. w5 J N5 s& ^ stringstream out;
' ~' R4 j& T d2 s- z Dimension *theDim = 0;
. I7 M& z" s. ?8 S
& ?; O/ l4 c& p/ ?# z' D NXString tolTypeStrings[] =
5 q. v! `$ o0 b, @! T! A! E {
_4 M$ b% F1 t+ s* h "ToleranceTypeNone",6 {' f% \5 z. f2 c& S* ?
"ToleranceTypeLimitOneLine"," `! b& _1 D1 F: u
"ToleranceTypeLimitTwoLines",
V: t5 _/ g- U" H "ToleranceTypeBilateralOneLine",7 W# U) k0 y) {& v8 Q* Y
"ToleranceTypeBilateralTwoLines",3 C1 D% W+ ~, A$ W1 y; g
"ToleranceTypeUnilateralAbove",% Z. h5 _# D% @
"ToleranceTypeUnilateralBelow",! W, J4 C; B. }3 |# G0 E) S1 l
"ToleranceTypeBasic",
0 d4 h3 o7 p9 \5 f: Z* A# B "ToleranceTypeReference",0 ~# Y& m; s/ s9 Q4 N5 B# Z' }
"ToleranceTypeLimitLargerFirst",
/ ~7 | f" I$ d1 O "ToleranceTypeLimitLargerBelow",
$ k* s% g2 K; _" {! }; J" c "ToleranceTypeLimitsAndFits",
. Y4 C; z. W( F' P2 F. Y "ToleranceTypeNotToScale",
) b% T! ]- k& M& h "ToleranceTypeDiameterReference",
" N/ j+ @$ W/ H( G0 b "ToleranceTypeBasicNotToScale" ' A! M9 `! m" x1 V5 m
};
7 D6 i* H) S+ @9 M5 f: G
9 t* P" M5 y2 w( h6 n- [ while( (theDim=select_a_dimension()) != 0 )! J# J9 P" g7 L; j. w8 s6 r' ^% z* |
{
6 G0 j. W6 w! u out.str(""); out.clear();
/ x3 F+ @' S6 _. n if(! lw->IsOpen() ) lw->Open();
9 n3 q R/ _& p
' s& d0 R7 r' M+ `& d( z$ ? out << "Selected Object: " << theDim->Tag() << endl;
7 e; ]$ U5 ?0 v; K' M. I m h" B# u3 y$ i: B
std::vector<NXString> mainTextLines;
; m, z. v2 z2 ~* ~' J std::vector<NXString> dualTextLines;
! l Y6 ]0 b; ~1 a3 h& [/ S( p. O, a theDim->GetDimensionText(mainTextLines, dualTextLines);$ D6 m: h. V* e* }; S- i+ M
for( int ii=0; ii<mainTextLines.size(); ii++)
. \7 o! z3 Y! H* e* t out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
7 d( x: {/ m& @ D8 \# ^0 ` for( int ii=0; ii<dualTextLines.size(); ii++)
: A. |( P, _9 \9 @3 o out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;
7 i2 {1 Y c, T' Z' P! |3 _+ J+ _5 [5 N8 s) p% O
bool refFlag = theDim->ReferenceDimensionFlag();
5 o& I" W1 |1 h' {2 v1 x5 B/ g f0 W out << " ReferenceDimensionFlag: " << refFlag << endl;
3 w& n5 _+ {% U5 K+ N& G. M+ S" X# s0 r2 r# j6 K' P
int tolType = (int) theDim->ToleranceType();: O5 ~# `4 N8 P: j
out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;
# W% B/ A. k$ Y- O. b. X$ V- L% F+ H- H& B- a' A9 }6 K; w
ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);
7 ?1 C' B1 T. u! \ H std::vector<TexTComponent*> textComps = theData->GetTextComponents();
- C+ b# ^2 i, t' k6 p1 y; n for( int ii=0; ii<textComps.size(); ii++)
5 F0 \( {6 I) U+ A {1 P4 M' N* L8 O/ L# U
std::vector<NXString> compText = textComps[ii]->GetText();, S! U& M: K( G2 [
for( int jj=0; jj<compText.size(); jj++ )2 }9 o6 w5 d0 L3 ]% V
out << " Component Text: " << compText[jj].GetText() << endl;
: Y/ J9 d: _6 g* K8 M. Q# B! r, s }2 y7 y6 ?$ U7 M+ f0 N5 B
+ g: P' M& P( c; U X9 n3 J
int subtype;
' `* x, Z3 W# b% s4 { l# `3 l double origin[3];
+ U( U; D) D; f6 R% ]- y UF_DRF_dim_info_t *info;6 S9 O- D" L) ^6 B ` F3 T) O8 {
UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));
+ w( P6 j; e& `, u for (int ii = 0; ii<info->num_text; ii++)
6 f; y" y8 H+ I8 X if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)7 x3 Z p" l% O" L! i
for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)
3 u0 ?% b5 `- o6 h% d+ v( i out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
( |2 f/ f) |0 w( h' ^* X UF_CALL(UF_DRF_free_dimension(&info));
5 X( h/ @% m% w7 }9 b" a/ f) @0 o3 N8 \' N" K W7 @
lw->WriteLine(out.str().c_str());' f7 @& q+ g, u$ ^* {3 M
9 B/ j) Y: E- w. ~9 v } // while
4 H4 y) k$ Q D6 I6 l}
3 ^+ N% G D% r- O( E# u" f* z) c2 z |
|