|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
g* k% ?' a9 @" C8 S: ]5 t
Dimension* plmhome::select_a_dimension()% a1 m- C! H5 g" m: t( ? f# r
{
) \( R- q2 i& d3 [! V2 t: ]/ _! e+ O // ask user to select a label
6 I0 [( I/ q4 G p% [9 E, A' j' k UI *ui = UI::GetUI();7 W) [$ J" G( t9 M9 V, Z
Selection *sm = ui->SelectionManager();8 G. E4 a- m- v
NXMessageBox *mb = ui->NXMessageBox(); // as of NX5( |& t# A$ e3 a# k1 s# m. Y
& E) o& S; N- h4 V9 e NXString message("Select Dimension:");( Q; H' [# J2 e- i
NXString title("Select Dimension");6 P9 T# @: d+ j* q' H. r6 V: @
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
* B: k1 x0 f8 g% F% r2 Z Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
3 l* H5 s" b& G! z2 A+ X bool include_features = 0;
6 I2 @* Z* A0 q. ^ bool keep_highlighted = 0;
& z/ w$ j( m0 T/ _5 X# N7 H+ ^ r; r% w: z
// Define the mask triple(s)
! b) p+ P3 k. t% c$ p# ] std::vector<Selection::MaskTriple> mask(1);1 t3 G; k! X& ?( {7 v! x
mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );. O. H _) J2 H/ \. B
Point3d cursor;
$ l$ z: `* r" t* Z ~ TaggedObject *object;
8 i2 r1 _5 [5 k5 V6 M* b) Q* W
( C2 e: f" T: H6 e9 d" U+ K // Select objects using filter defined by mask triples
5 v9 y. l; K* u& W6 a Selection::Response res = sm->SelectTaggedObject(
# O3 \# Y/ k3 D* f9 D7 r message, title, scope, action, include_features,& _- S- [% o6 \5 E) k* y
keep_highlighted, mask, &object, &cursor );
. z& Q2 q7 A* T) x% [9 T2 q1 P3 M- ~" x- k! o" B: r' y4 K
if( res == Selection::ResponseObjectSelected ): M+ X. X' ~3 H$ Q2 I; H
{5 e. e) J+ ?' r! }
Annotations::Dimension *theDim;# c- ^: r; c# ?, n5 Q2 B- W
/ G: l7 O2 ~0 j* l9 W
// this doesn't work and 'note' will be a zero pointer, see PR-1850850
' d" `% o) ?+ N+ d2 ^ //note = dynamic_cast<Annotations::PmiNote *>(object);
/ h* W, {$ }( T; [4 @; W+ S
; Q% x. |" q/ U! O D& w // this works as a workaround
. U$ N* I" t4 @6 F. ~0 G) U$ J theDim = (Annotations::Dimension *)(object);
# V7 c! x8 ], \: e% N6 J" s return theDim;
' [4 h% w& ~% }0 Q. F6 ? }5 {! J5 ?5 x0 @4 C7 X
9 @/ [" K/ w) @6 }- D return 0;
3 @4 ~. [: b7 T3 ^% d% W6 i" F8 u3 _}4 N) ?4 H- Q5 K8 v) ^6 z
" O! K* X n% B$ D( E, B
& Q v8 X! s9 H9 f$ i( U }, h
. n+ S# J& B/ a; l9 A! s# L ?
' ]7 a1 H1 @! [, ?2 F& y8 bvoid plmhome::do_it()& R/ K; I: O* w7 m. N" O
{1 T2 Y2 k9 D3 t% i; `" c* W% g( `
workPart = theSession->Parts()->Work();
2 |, l" j* k# n. H) a. W Part *displayPart = theSession->Parts()->Display();, n1 B" b4 g$ c; u, Z l! X
stringstream out;: z Q$ R T2 s' ^
Dimension *theDim = 0;
1 M% M. {' U! i6 d
7 P& y; {0 Z7 b) b5 H& p NXString tolTypeStrings[] =
. f9 w2 J. n( [ J {/ _+ f9 ]' s. }. d* @4 s
"ToleranceTypeNone",+ v& h; a( `* x- s0 k, t. y
"ToleranceTypeLimitOneLine",
! [) ]7 d# G, E# a; o "ToleranceTypeLimitTwoLines"," z5 V+ r7 z6 t* ?. I
"ToleranceTypeBilateralOneLine",+ E+ \& A& Y; O) ?1 |; U
"ToleranceTypeBilateralTwoLines",
+ q3 @: M0 H. K "ToleranceTypeUnilateralAbove",
' m: \9 P( _9 a1 o$ A- N1 p6 u" l "ToleranceTypeUnilateralBelow",
. `" n: r% q H9 @& l "ToleranceTypeBasic",
. d4 g2 b3 H! E8 j "ToleranceTypeReference",( w# ?: I+ e# q4 n
"ToleranceTypeLimitLargerFirst",# M; l/ U6 w g. s. w
"ToleranceTypeLimitLargerBelow",8 j% e2 }3 s2 G0 }
"ToleranceTypeLimitsAndFits",
6 q1 C: \1 v8 m8 z: O "ToleranceTypeNotToScale", v9 W+ F, k7 J+ M
"ToleranceTypeDiameterReference",: T) j3 K9 r) n- P0 N4 ^& F
"ToleranceTypeBasicNotToScale"
! b% ]' r% i, Z8 m }; H r4 g( U( \
r1 M9 U# m! l" T" K: _4 v; I
while( (theDim=select_a_dimension()) != 0 )# X& W% X+ p- D3 X
{4 ?: W, b6 r8 I( n" g4 B$ Z
out.str(""); out.clear();' s9 u" B. D" s+ M6 n( X
if(! lw->IsOpen() ) lw->Open();! f( t |% G; e# i7 j
3 P9 y0 k3 C: V- d e4 F4 p
out << "Selected Object: " << theDim->Tag() << endl;
& S9 |& S/ \# ?' n( z# l
" O: C2 x; l! t9 b6 y8 p std::vector<NXString> mainTextLines;
+ y' Y n& o+ J0 s; |! l std::vector<NXString> dualTextLines; 6 }$ g) O5 N9 C, O6 X- F
theDim->GetDimensionText(mainTextLines, dualTextLines);
8 U; p6 T3 w' v8 [: Z" } for( int ii=0; ii<mainTextLines.size(); ii++)& n5 r) e3 G& |! U$ J
out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;* Y7 Q0 x0 _& s8 [4 L, \
for( int ii=0; ii<dualTextLines.size(); ii++). c- N- s5 R9 T5 T* m1 c
out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;: h0 ~2 m8 k( Y' l% U
% `4 }) ?9 [0 t. ^7 E( ?9 V% T bool refFlag = theDim->ReferenceDimensionFlag();
8 r6 {) Q6 D' J out << " ReferenceDimensionFlag: " << refFlag << endl;! _7 t$ U0 J9 R1 J- k
9 ~% D! R1 L" Y! x7 F- S6 T
int tolType = (int) theDim->ToleranceType();
6 u/ F+ N) Z4 ~3 `: h out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;, T7 F% m: O+ \0 W$ S
% k( V2 M, y: U
ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);8 V4 `$ H+ y1 e8 n7 ?; n
std::vector<TexTComponent*> textComps = theData->GetTextComponents();3 ~! [# o9 x& i, T) s6 \. L& t& A
for( int ii=0; ii<textComps.size(); ii++)9 ~1 l5 d$ V/ \# I
{1 Y' J1 Q5 G* y& s. D( X: w; g# i
std::vector<NXString> compText = textComps[ii]->GetText();( f5 h; a" |4 F: V5 E- u' j; H2 A+ O
for( int jj=0; jj<compText.size(); jj++ ): L4 ?. r) {" z4 p# M
out << " Component Text: " << compText[jj].GetText() << endl;& z" K- f9 a, }* [. \) P1 g
}
( v0 O; x9 o1 q4 E
, `9 Y4 V8 y0 D( _6 n int subtype;
+ t1 K) ?) T7 J! e" D; w2 u double origin[3];
F: m2 ~+ ~+ U" a T6 h d UF_DRF_dim_info_t *info;
& E2 G! |5 n' ]+ v. @ UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));
9 A- }% _# a4 _2 ^ for (int ii = 0; ii<info->num_text; ii++)
# Q$ K* A8 @9 v+ Q! _' h if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)5 z y, _) J& T) ]( g
for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)+ }9 ~7 z. I8 F1 X; y
out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
# V# o; ~* s$ a- Y. M# q UF_CALL(UF_DRF_free_dimension(&info));
3 R7 K. ?2 ^! o# m
1 z9 e7 n$ ?: D) C8 g/ T3 y2 q5 k" e lw->WriteLine(out.str().c_str());( s3 u+ \8 K3 w1 p2 {! @0 ?
0 w; E* e4 F. M1 b J0 N
} // while8 b) C) D0 r! u+ K1 E
}
6 I! N6 i0 I; l8 ~ |
|