|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
. N$ m8 d! h4 d9 I8 l5 u0 @
Dimension* plmhome::select_a_dimension()
! @1 T+ |! q' A2 n! T4 f' u{7 M1 j$ e3 @# E4 I, {
// ask user to select a label' H. N7 H3 w5 d/ S. ~) ^
UI *ui = UI::GetUI();7 T* N0 l2 ?. n: ^8 X9 k
Selection *sm = ui->SelectionManager();, ] G& d6 s1 A, M! I1 k
NXMessageBox *mb = ui->NXMessageBox(); // as of NX5
) F- R/ x0 s% P' W
" x4 _* c3 l& d; U+ X6 g0 }) i9 | NXString message("Select Dimension:");
" c+ A) G5 j+ O7 Z6 @: V/ T/ v" P NXString title("Select Dimension");" M% e6 w5 S1 h( a: T& {
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault; @$ H& H; \( t; O/ Y5 h; J: _) d% {2 F& _
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;$ M+ T& L1 I; Q0 U8 k1 o5 Y1 r
bool include_features = 0;. ~/ {: Q0 v; t
bool keep_highlighted = 0;8 M5 i6 x, n( B1 M5 O
6 N7 F9 M0 v0 Y) \ // Define the mask triple(s); t- f% W$ s% ~7 U; {! {. A5 [
std::vector<Selection::MaskTriple> mask(1);
" Z# C1 Y- T6 `; |- ]" i$ M mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 ); E2 d ~1 ?+ G8 N
Point3d cursor;5 f: |1 ^# ]" H) v. c/ A
TaggedObject *object;' d- d2 Y4 r7 x7 |# A/ L$ }6 n/ d
5 f8 t! o& q4 o* U' J7 Z
// Select objects using filter defined by mask triples
% H3 [$ D3 L$ C* k- i( u Selection::Response res = sm->SelectTaggedObject(
6 `1 j! O; F- a/ T9 \/ ? message, title, scope, action, include_features,0 q# R N' G7 G# ~
keep_highlighted, mask, &object, &cursor );
2 F# o$ p) I% B2 w: V# L) r$ Y0 I! G( |, i* _# A
if( res == Selection::ResponseObjectSelected )+ ?' y. g( e1 g& E# ]
{
! t9 O1 r8 [3 D) J Annotations::Dimension *theDim;
9 c9 T' y- ~ k* |" c4 K
2 W, ?7 [/ u: f0 E J // this doesn't work and 'note' will be a zero pointer, see PR-1850850; H4 Z6 h9 |4 @' {
//note = dynamic_cast<Annotations::PmiNote *>(object);) W. Z3 f' H/ K: O/ r
! k/ d4 Z" f, h" j8 u // this works as a workaround
% a7 P" u' y( `7 D T theDim = (Annotations::Dimension *)(object);5 m1 K/ H( V: R1 P M
return theDim;
, M; o3 d8 d& r0 x }# T$ Q# y7 u) d: C. |) _
! r! A; ]: q% f4 b3 J' h4 J/ u2 R return 0;
% ] [8 E* Y9 _7 Z0 }}: U- j0 ^0 J7 }, S$ l) U
# V! X0 S+ L& ?: N0 x( c3 f0 H( [
2 l( ~5 s" e" F/ l& C
7 S9 N$ I k1 {, U+ M3 H- e3 A1 g
8 }/ G S; b$ U' h) Vvoid plmhome::do_it()- i0 B$ ~# W2 B
{5 p: N. b, l4 T: o' \( U/ ]
workPart = theSession->Parts()->Work();- q+ H' Y0 x8 Y% | |
Part *displayPart = theSession->Parts()->Display();" R, b, T) r. C1 i6 G T. m6 X
stringstream out;6 I% R0 ^) R3 R! O' t- j; b' A
Dimension *theDim = 0;
1 k9 O0 }7 ?0 z, H% [- v
# Y" G$ `" J: q* W NXString tolTypeStrings[] = 0 ]% w* v9 ?. q" f0 Z4 {( Y
{
2 m$ ^" O- i" h/ m- H* R- | "ToleranceTypeNone",2 H9 I3 H. j2 j" W: N/ I/ @
"ToleranceTypeLimitOneLine",
, s5 R* `6 Y( `+ q* l "ToleranceTypeLimitTwoLines",1 R( @; v; @9 c# r( K( }
"ToleranceTypeBilateralOneLine",
0 M, }' G$ y* Z: K, O) Y& e! k2 ] "ToleranceTypeBilateralTwoLines",0 \3 I. B: ^. D* S" D5 `9 k& j Q2 S
"ToleranceTypeUnilateralAbove",
f; h* L( O: o1 \8 a "ToleranceTypeUnilateralBelow",7 S% t3 |- \) E3 c* \& h$ J
"ToleranceTypeBasic",
( S, X5 j: Y* o/ J2 z "ToleranceTypeReference",, R: z4 B. A( V
"ToleranceTypeLimitLargerFirst",
/ m# y* j; _1 w; S1 B. @ "ToleranceTypeLimitLargerBelow",! u0 b3 ? `2 O5 n: T- }
"ToleranceTypeLimitsAndFits",3 u# C4 ~# ?) h1 z; b
"ToleranceTypeNotToScale",
) b- ]% L' n9 `7 v2 q "ToleranceTypeDiameterReference",
* R: Q' n: [0 k" R3 P "ToleranceTypeBasicNotToScale"
! Z" N: U% ^" Q% o' [( D; o) K };, P7 r0 y) v" d$ i& i
% F& d& Y8 {8 W5 t1 C
while( (theDim=select_a_dimension()) != 0 )
6 `. f+ w8 j! @6 u: F6 x" O$ \ {& T O8 k$ {* I& A0 \
out.str(""); out.clear();4 M% W N0 l6 a4 k! X. O2 l
if(! lw->IsOpen() ) lw->Open();
, }- B6 a: V5 d/ J" m4 O# _0 F, }; {' U' {# z0 } Q- f
out << "Selected Object: " << theDim->Tag() << endl;! c: I- U0 Z0 T4 y7 N
& T; `& ]5 o! P1 K5 B! f; n* A6 j std::vector<NXString> mainTextLines;
8 Q8 [* n1 R- a2 I3 b" { std::vector<NXString> dualTextLines;
& a9 M: S+ z( d& \! a theDim->GetDimensionText(mainTextLines, dualTextLines);% I/ B; O# s# Z# ]2 H
for( int ii=0; ii<mainTextLines.size(); ii++)
: a3 v( c$ a8 S$ v F. m. w out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
. R% V$ @: [6 x6 f( E, R) }& s for( int ii=0; ii<dualTextLines.size(); ii++)
& }# o& ^" b8 _9 [8 k out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;- ^7 V2 X1 K) K6 V/ ~ F4 E
@# ?3 e2 v, I, J! L9 E* s; c
bool refFlag = theDim->ReferenceDimensionFlag();& e0 r& N7 S6 |+ {# b# O, {- N
out << " ReferenceDimensionFlag: " << refFlag << endl;9 v5 ~. v7 t- ? M3 i$ c
- k/ f* R! O& S I+ b int tolType = (int) theDim->ToleranceType();
) G8 a# D. I$ a1 ~- n4 q out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;+ o1 W# }' U! h) h" q
1 K; Q. I) R$ b5 z) P ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);
- N( K( j9 Q2 E* O# `4 y, f | std::vector<TexTComponent*> textComps = theData->GetTextComponents();
) I2 u9 ~0 C# [; C7 E for( int ii=0; ii<textComps.size(); ii++)
5 Z5 C/ q% g3 ]7 y- d {
# ]6 Z8 i% f& Q4 k; c" @5 y std::vector<NXString> compText = textComps[ii]->GetText();
8 E/ i0 N" t: T$ M for( int jj=0; jj<compText.size(); jj++ )- C* w5 D, [4 U c/ ~
out << " Component Text: " << compText[jj].GetText() << endl;+ f' O2 S% G& t, {' ?; P
}
9 @$ h+ K' W+ l( }9 \% R6 N
- o9 y8 t3 a! v* X5 ~ int subtype;
0 p' A3 G( W0 C6 F' |6 }6 f double origin[3];9 J6 b0 F" b9 [( {' C, ]. ~0 a6 u
UF_DRF_dim_info_t *info;
W' m c# }- G8 N( h7 e. `. m UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));. U( ~8 j$ b9 T
for (int ii = 0; ii<info->num_text; ii++)& W" q( ^* L; \' L& {9 X
if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)* p+ B+ ?9 X- r1 |
for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)' ]/ D; H f+ S) v
out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
5 p, o. X; W j; r$ @' J/ u UF_CALL(UF_DRF_free_dimension(&info));+ m" P" U1 B4 B6 e
, K0 X5 p: ~" m3 I) P$ w lw->WriteLine(out.str().c_str());- i' t0 `7 d- I% x" y
' t3 `4 r- F* o: S* U } // while
" u+ ~/ {# [7 M+ q. k5 p# J3 x}5 v9 | s/ L8 |1 }
|
|